Skip to content

Do we need HighlightRange? #69

Closed
Closed
@gked

Description

@gked

Moving the original issue from https://github.com/dlibby-/highlight/issues/15

@Reinmar as FYI

To avoid defining a new subclass of Range, perhaps the entire API could be somehow built around the HighlightsMap.

const range = new Range();

const highlight = document.highlights.create( 'example-highlight', range, {
    priority: 1
} );

highlight.style.color = 'red';
highlight.priority = 42;

document.highlights.remove( range );

HighlightsMap#create() doing create&add at once is not the prettiest method, but maybe something along these lines could work. Having those new properties (style, priority, label) in some new interface (rather than squashed together with Range's properties) might avoid creating one giant class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions