Skip to content

linalgo/annotate

Repository files navigation

annotate-core

Installation

npm i @linalgo/annotate-core

How to use

import { Annotator } from './annotators/annotator';

document.addEventListener('selectionchange', function () {
  let selection = window.getSelection();
  range = selection.getRangeAt(0);
});

function highlight(range: Range) {
  const annotation = annotator.createAnnotation(range, 'test', 'test', document.URL, 'test');
  annotator.showAnnotation(annotation);
  console.log(JSON.stringify(annotation));
}

let range: Range;
const annotator = new Annotator(document, 'mark');
let btn = document.getElementById('button');
btn.addEventListener('click', (e: Event) => highlight(range));

About

Library for W3C annotations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published