@dokieli/web-annotation - v1.0.1
    Preparing search index...

    @dokieli/web-annotation - v1.0.1

    dokieli Web Annotation

    W3C Web Annotation implementation for creating, parsing, and serializing Web Annotations in JSON-LD, with support for HTML+RDFa embedding and DOM-based annotation application.

    npm install @dokieli/web-annotation
    

    or

    yarn install @dokieli/web-annotation
    
    import { createAnnotation, serializeAnnotationToJSONLD, serializeAnnotationToHTML } from '@dokieli/web-annotation';

    const annotation = createAnnotation({
    motivatedBy: 'oa:commenting',
    body: { value: 'A note.' },
    target: { source: 'https://example.org/', selector: { type: 'TextQuoteSelector', exact: 'annotated text' } }
    });

    const jsonld = serializeAnnotationToJSONLD(annotation);
    const html = serializeAnnotationToHTML(annotation);

    See API Reference and Examples.

    • Parsing and serializing annotations in JSON-LD and HTML+RDFa.
    • Support for selectors and states.
    • Restoring the selection object from a stored selector.
    • Marking the annotated text (the target) in the DOM.

    The data in JSON-LD this library emits conforms to the W3C Web Annotation Data Model, validated against the official w3c/web-annotation-tests suite (its MUST assertions). Run the checks with yarn test:conformance.

    See the Contributing Guide for development setup, tests, and commit conventions.

    Help the project grow by sponsoring it on Open Collective or reach out to us.