1.0.8 • Published 10 months ago

evt-text-annotations v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

EVT - Text Annotator

License NPM Package NPM version NPM monthly downloads NPM total downloads This library was created to provide Digital Scholarly Editions users, and specifically EVT-based DSEs, with an easy way to add their own annotations to the edition texts. It is based on the standard W3C - Web Annotation Data Model and it has been developed using the following libraries: ​

Installation

​ Installation is performed via npm, use this command: npm install evt-text-annotator

API Documentation

​ The library exposes two APIs: createAnnotation and getAnnotation. ​

createAnnotation(root, range, note)

​ This API takes three values ​​as input: (root, range, note).

  • root identifies the HTML element generated by the text selection made by the user. ​
  • range identifies the range that is generated when the user selects the text. ​
  • note identifies the note that the user wants to insert within the selection. ​ The return of this API is an Object conform to W3C - Web Annotation Data Model containing the text of the note. ​​

getAnnotation(anno)

​ This API takes only one value ​​(anno) as input.

  • anno identifies the object that is generated using the createAnnotation API. ​ The return of this API is a Range. ​

Usage

​ A simple example of use of the library: ​

import {annotator}  from "evt-text-annotator";
​
const range = selection.getRangeAt(0); // Range
const root = range.commonAncestorContainer.parentElement; // HTMLElement
const note = "my note" // input String
// create annotation from text selection
const anno = annotator.createAnnotation(root, range, note); // Annotation
// get a Range form an annotation 
const range_anno = annotator.getAnnotation(anno); // Range

​ ​

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

3 years ago