Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] export annotation set [Round 2] #2704

Merged
merged 37 commits into from
Jan 31, 2025
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
403a942
update readium annotation set model [skip ci]
panaC Dec 11, 2024
bf63fe5
annotation import FIFO queue from main to reader process
panaC Dec 12, 2024
0429d08
update json schema selector
panaC Dec 12, 2024
fff4963
apache-annotator
panaC Dec 13, 2024
6fed198
lint and revert unused addAnnotationToReaderPublicatrion action previ…
panaC Dec 13, 2024
effd92e
fix seachCachePublicationResources from search to ReaderRootState at …
panaC Dec 13, 2024
c06ae34
lint and type fixes on the third-party apache-annotator lib
panaC Dec 13, 2024
05e582d
[skip ci]
panaC Dec 13, 2024
c993d56
set resourceCache to a dedicated file
panaC Dec 16, 2024
e4268a0
apache-annotator remove .js extension and fix type linting
panaC Dec 16, 2024
0304776
export annotation [skip ci]
panaC Dec 16, 2024
1c85520
import annotation
panaC Dec 16, 2024
cef265c
add textQuote in import process [skip ci]
panaC Dec 16, 2024
e6990c0
Merge branch 'develop' into feat/export-annotation-2
panaC Dec 17, 2024
87bdedc
add reader lock protection for importAnnotationSet function
panaC Dec 17, 2024
4245dc7
fix: add actionAcrossRenderer to dispatch action from renderer to
panaC Dec 18, 2024
c284410
fixes importQueue shift first elem immutability
panaC Dec 18, 2024
6a7bc53
remove unused addAnnotationToReaderPublication action
panaC Dec 18, 2024
69f4c91
lint and change xmlDom xhtml root to document.body @danielweck need …
panaC Dec 18, 2024
cd89bf0
when annotation import add locatorExtended.locations info (rangeInfo and
panaC Dec 18, 2024
a3fa129
Merge branch 'develop' into feat/export-annotation-2
danielweck Dec 20, 2024
7cf31fa
fix: add cssSelector and progressionSelector, and apply it to
panaC Dec 20, 2024
7738eab
fix: old annotation imported from updated annotation, now update the …
panaC Dec 30, 2024
b3a39cd
fix: import dialog labels
panaC Dec 30, 2024
c9184f7
fixes en/fr i18n annotation dialog
panaC Dec 30, 2024
8e9bb59
up: origin label annotation import modal
panaC Dec 30, 2024
c4b4516
Merge branch 'develop' into feat/export-annotation-2
danielweck Dec 30, 2024
29d0b52
Merge branch 'develop' into feat/export-annotation-2
danielweck Dec 30, 2024
8271ae4
Merge branch 'develop' into feat/export-annotation-2
danielweck Jan 8, 2025
a1de16a
Merge branch 'develop' into feat/export-annotation-2
danielweck Jan 29, 2025
fee85e7
fix: guard against undefined/null TextQuoteSelector during annotation…
danielweck Jan 29, 2025
71874f3
removed range normalisation as this can modify the original text boun…
danielweck Jan 29, 2025
d4a413f
added code comments about DOM Range document order (start/end points)…
danielweck Jan 29, 2025
ea00f54
[skip ci] added code comments about DOM Range document order contract
danielweck Jan 29, 2025
8aa456b
Merge branch 'develop' into feat/export-annotation-2
danielweck Jan 30, 2025
72132fd
Merge branch 'develop' into feat/export-annotation-2
danielweck Jan 31, 2025
3abeaf0
English localisation improvements
danielweck Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: guard against undefined/null TextQuoteSelector during annotation…
… import (LCP protected EPUB?), also added DOM Range normalisation prior to convertRange() to guard against ranges created outside the navigator
danielweck committed Jan 29, 2025
commit fee85e7c5f2c24a41d8301a60af86d75fea335fc
20 changes: 12 additions & 8 deletions src/common/readium/annotation/converter.ts
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ import { ISelectionInfo } from "@r2-navigator-js/electron/common/selection";
const debug = debug_("readium-desktop:common:readium:annotation:converter");

export async function convertSelectorTargetToLocatorExtended(target: IReadiumAnnotation["target"], cacheDoc: ICacheDocument): Promise<MiniLocatorExtended | undefined> {

const xmlDom = getDocumentFromICacheDocument(cacheDoc);
if (!xmlDom) {
return undefined;
@@ -50,7 +50,7 @@ export async function convertSelectorTargetToLocatorExtended(target: IReadiumAnn
}[selector.type];

if (!innerCreateMatcher) {

// no matcher for this selector
debug("no matcher for this selector:", selector.type);
return undefined;
@@ -72,19 +72,19 @@ export async function convertSelectorTargetToLocatorExtended(target: IReadiumAnn

ranges.push(range);
};
{
if (textQuoteSelector) {
const matchAll = createMatcher(textQuoteSelector);
for await (const rangeOrElement of matchAll(root)) {
pushToRangeArray(rangeOrElement);
}
}
}
{
if (textPositionSelector) {
const matchAll = createMatcher(textPositionSelector);
for await (const rangeOrElement of matchAll(root)) {
pushToRangeArray(rangeOrElement);
}
}
{
if (cssSelector) {
const matchAll = createMatcher(cssSelector);
for await (const rangeOrElement of matchAll(root)) {
pushToRangeArray(rangeOrElement);
@@ -98,7 +98,11 @@ export async function convertSelectorTargetToLocatorExtended(target: IReadiumAnn

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

for (const range of ranges) {
for (const r of ranges) {
const range = normalizeRange(r);
if (range.collapsed) {
debug("RANGE COLLAPSED AFTER NORMALISE, skipping...");
}
const tuple = convertRange(range, (element) => finder(element, xmlDom, {root}), () => "", () => "");
if (tuple && tuple.length === 2) {
convertedRangeArray.push(tuple);
@@ -230,7 +234,7 @@ export async function convertAnnotationStateToSelector(annotationWithCacheDoc: I
debug("ProgressionSelector : ", progressionSelector);
selector.push(progressionSelector);

// Next TODO: CFI !?!
// Next TODO: CFI !?!

return selector;
}