Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Exception if an annotation has no TextQuoteSelector #58

@reckart

Description

@reckart

The quote() method throws an exception if an annotation has no TextQuoteSelector. That is probably fine, but does SelectionUtils.getExactOverlaps have to use the quote really?

Screenshot 2022-01-01 at 00 35 51

/**
 * Util function that checks if the given selection is an exact overlap to any
 * existing annotations, and returns them, if so
 */
export const getExactOverlaps = (newAnnotation, selectedSpans) => {
  // All existing annotations at this point
  const existingAnnotations = [];

  selectedSpans.forEach(span => {
    const enclosingAnnotationSpan = span.closest('.r6o-annotation');
    const enclosingAnnotation = enclosingAnnotationSpan?.annotation;

    if (enclosingAnnotation && !existingAnnotations.includes(enclosingAnnotation))
      existingAnnotations.push(enclosingAnnotation);
  });

  if (existingAnnotations.length > 0)
    return existingAnnotations.filter(anno => {
      const isSameAnchor = anno.anchor == newAnnotation.anchor;
      const isSameQuote = anno.quote == newAnnotation.quote; // <<<< HERE
      return isSameAnchor && isSameQuote;
    });
  else
    return [];
};

This happens when trying to select text which has already been annotated.

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