npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

annotorious-tahqiq

v1.3.0

Published

A custom Annotorious editor/view plugin

Downloads

84

Readme

annotorious-tahqiq

annotorious-tahqiq is a custom annotation editor implemented as a plugin for Annotorious. It is being developed as part of the Princeton Geniza Project (https://github.com/Princeton-CDH/geniza) to support transcription editing and management with IIIF/W3C annotation.

The name taḥqīq (tah-KEEK) comes from the Arabic for text edition.

tahqiq-demo

Requirements

  • Node.JS v16.x
  • NPM v8.x
  • Annotorious
  • An annotation store supported by an Annotorious plugin

This project uses Volta to pin Node and NPM versions.

Usage

Installation

This plugin can be installed with NPM:

npm install --save annotorious-tahqiq

or to install a specific version number:

npm install --save [email protected]

Then, to use alongside Annotorious and a storage plugin:

import {
  TranscriptionEditor,
  AnnotationServerStorage,
} from "annotorious-tahqiq";

// Initialize Annotorious with your settings
const client = Annotorious(annotoriousSettings);

// Initialize annotorious-tahqiq storage plugin
const storageSettings = {
    annotationEndpoint,   // Endpoint of the annotation store
    target,               // Target for annotations (typically, a IIIF canvas)
    manifest,             // IIIF manifest that target is a part of
    csrf_token,           // CSRF token for communication with annotation store
    secondaryMotivation,  // Optional secondary motivation for annotations
                          // (primary is "sc:supplementing"). If supplied, will also
                          // attempt to filter annotation endpoint on this motivation.
    sourceUri,            // Optional "dc:source" URI attribute for annotations
    lineMode,             // Boolean to enable "line mode", which allows grouping
                          // and editing of line-level annotations with the
                          // "textGranularity" property
};
const storagePlugin = AnnotationServerStorage(client, storageSettings);

// Locate an empty HTML element that the editor will be placed into
const annotationContainer = document.getElementById("annotation");

// And an empty HTML fieldset element that toolbar tools will be placed into.
// Currently, the provided tools are rectangle and polygon image annotation drawing tools.
const toolbarContainer = document.getElementById("tahqiq-toolbar");

// Your TinyMCE editor API key (optional, can be omitted for testing purposes)
const tinyApiKey = "1234567890";

// Initalize annotorious-tahqiq editor
new TranscriptionEditor(
    client,
    storagePlugin,
    annotationContainer,
    toolbarContainer,
    tinyApiKey,
    textDirection, // one of the two strings "rtl" or "ltr"; sets text direction
                   // of the TinyMCE editor 
);

Styling

This plugin exposes the following CSS classes that can be used to style its elements:

  • Annotation blocks
    • .tahqiq-block-display: Container div containing an annotation label and body
    • .tahqiq-block-editor: Container div when in edit mode
    • .tahqiq-label-display: h3 elements for block labels
    • .tahqiq-label-editor: Editable h3 elements for block labels
    • .tahqiq-body-display: div element displaying the content of an annotation body
    • .tahqiq-body-editor: div element containing the TinyMCE editor for editing an annotation body
    • .tahqiq-line-group: div element grouping multiple line-level annotations
    • .tahqiq-line-group-label: h3 element labeling a group of multiple line-level annotations
  • Buttons and inputs
    • .tahqiq-button: All buttons (save, delete, cancel)
    • .tahqiq-save-button: Save button
    • .tahqiq-delete-button: Delete button
    • .tahqiq-cancel-button: Cancel button
    • .tahqiq-tool: All tool label elements
    • .rectangle-tool, .polygon-tool: Individual label elements for tools
    • .active-tool: The currently active tool's label element
  • Drag and drop
    • .tahqiq-drag-targetable: Annotation container receives this class when the user begins dragging another annotation (i.e. this annotation container is "targetable")
    • .tahqiq-drag-target: Annotation container receives this class when the user hovers a dragged annotation over it (i.e. this annotation container is "targeted")
    • .tahqiq-drop-zone: When running multiple instances of Tahqiq on the same page, this div will appear on an instance that has no annotations when the user begins dragging an annotation from another instance
    • .tahqiq-loading: To compensate for network request timing, this class is added to all annotation containers after a drag and drop is completed, and removed when the network requests are finished

Events

This plugin also raises custom events to report errors and other messages.

  • tahqiq-alert: A CustomEvent with a detail object containing message, status, and target. message is an info, success, or error message; status is one of "info", "success", or "error"; and target is the target set in the settings for the storage plugin.
  • tahqiq-cancel: A CustomEvent informing the consuming application that a cancellation has occurred.

Development

Getting started

To start developing on this project, first install the dependencies with NPM:

npm install

Then you can start editing TypeScript code. When you have made changes, you can rebuild the package by running:

npm run build

This will place transpiled and minified JavaScript (via webpack) into the /dist directory.

To use your modified code in other projects locally, after running the build script, install with NPM in your other projects by pointing it to the project root directory:

npm install --save /path/to/annotorious-tahqiq/

Then, follow the remaining steps in the Usage section.

Organization

This project is written in TypeScript, and organized according to the following scheme:

  • /src contains the source code of the repository
    • /src/elements contains custom HTML elements
    • /src/types contains type definitions used in the TypeScript code
    • /src/index.ts is the entrypoint for the TypeScript code
  • /tests contains Jest unit tests, and should mirror the structure of /src
  • /dist contains the build outputs and should not be directly modified
    • /dist/index.js is the entrypoint for the built JavaScipt code

Code style and linting

This project uses ESLint to manage code style and enforce consistency.

If you are using VSCode, you will need to install the ESLint extension. Then, your editor should pick up the settings from .vscode/settings.json, which specify that ESLint will auto-fix any style errors on saving a file.

You may also use the following scripts to check for and fix linter errors:

npm run lint
npm run lint:fix

Testing

This project uses Jest for unit tests, stored in the /tests directory. Tests can be run with the following command:

npm test