Skip to content

Commit

Permalink
fix(annotations): when importing notes, the selector can potentially …
Browse files Browse the repository at this point in the history
…cause a DOM Range to encapsulate an Element, must normalise to snap on text nodes (revert of my incorrect fix in PR #2704 )
  • Loading branch information
danielweck committed Feb 1, 2025
1 parent fa643e5 commit b91ebc3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/common/readium/annotation/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ICacheDocument } from "readium-desktop/common/redux/states/renderer/res
import { getDocumentFromICacheDocument } from "readium-desktop/utils/xmlDom";
import { createCssSelectorMatcher, createTextPositionSelectorMatcher, createTextQuoteSelectorMatcher, describeTextPosition, describeTextQuote } from "readium-desktop/third_party/apache-annotator/dom";
import { makeRefinable } from "readium-desktop/third_party/apache-annotator/selector";
import { convertRange, convertRangeInfo } from "@r2-navigator-js/electron/renderer/webview/selection";
import { convertRange, convertRangeInfo, normalizeRange } from "@r2-navigator-js/electron/renderer/webview/selection";
import { MiniLocatorExtended } from "readium-desktop/common/redux/states/locatorInitialState";
import { uniqueCssSelector as finder } from "@r2-navigator-js/electron/renderer/common/cssselector2-3";
import { ISelectionInfo } from "@r2-navigator-js/electron/common/selection";
Expand Down Expand Up @@ -98,8 +98,8 @@ export async function convertSelectorTargetToLocatorExtended(target: IReadiumAnn

const convertedRangeArray: ReturnType<typeof convertRange>[] = [];

for (const range of ranges) {
// const range = normalizeRange(r);
for (const r of ranges) {
const range = normalizeRange(r);
if (range.collapsed) {
debug("RANGE COLLAPSED :( skipping...");
continue;
Expand Down

0 comments on commit b91ebc3

Please sign in to comment.