Skip to content

Commit

Permalink
lint and change xmlDom xhtml root to document.body @danielweck need y…
Browse files Browse the repository at this point in the history
…our advice about this !
  • Loading branch information
panaC committed Dec 18, 2024
1 parent 6a7bc53 commit 69f4c91
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
9 changes: 6 additions & 3 deletions src/common/readium/annotation/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export async function convertSelectorTargetToLocatorExtended(target: IReadiumAnn
// const fragmentSelectorArray = target.selector.filter(isFragmentSelector);
// const cfiFragmentSelector = fragmentSelectorArray.find(isCFIFragmentSelector);

const root = xmlDom.body.ownerDocument.documentElement;
// TODO: @danielweck is it ok ?
const root = xmlDom.body;

const selectionInfoFound: ISelectionInfo[] = [];

Expand Down Expand Up @@ -156,6 +157,8 @@ export async function convertAnnotationStateToSelector(annotationWithCacheDoc: I
return [];
}

// TODO: @danielweck is it ok ?
const root = xmlDom.body;

const { locatorExtended } = annotation;
const { selectionInfo } = locatorExtended;
Expand All @@ -166,12 +169,12 @@ export async function convertAnnotationStateToSelector(annotationWithCacheDoc: I
debug(range);

// describeTextPosition()
const selectorTextPosition = await describeTextPosition(range, xmlDom.body);
const selectorTextPosition = await describeTextPosition(range, root);
debug("TextPositionSelector : ", selectorTextPosition);
selector.push(selectorTextPosition);

// describeTextQuote()
const selectorTextQuote = await describeTextQuote(range, xmlDom.body);
const selectorTextQuote = await describeTextQuote(range, root);
debug("TextQuoteSelector : ", selectorTextQuote);
selector.push(selectorTextQuote);

Expand Down
2 changes: 0 additions & 2 deletions src/main/redux/middleware/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ const SYNCHRONIZABLE_ACTIONS: string[] = [

annotationActions.pushToAnnotationImportQueue.ID,


// TODO: shift dispatch from one reader do not dispatch it to other reader !?! need to check this issue before merge request
annotationActions.shiftFromAnnotationImportQueue.ID,

readerActions.setTheLock.ID,
Expand Down
25 changes: 3 additions & 22 deletions src/renderer/reader/components/ReaderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1100,23 +1100,8 @@ const AnnotationList: React.FC<{ annotationUUIDFocused: string, resetAnnotationU
<Popover.Portal>
<Popover.Content collisionBoundary={popoverBoundary} avoidCollisions alignOffset={-10} align="end" hideWhenDetached sideOffset={5} className={stylesAnnotations.annotations_sorting_container} style={{ maxHeight: Math.round(window.innerHeight / 2), padding: "15px 0" }}>
<Popover.Arrow className={stylesDropDown.PopoverArrow} aria-hidden style={{ fill: "var(--color-extralight-grey)" }} />
{/* !!!! */}
{/* !!!! */}
{/* !!!! */}
{/* !!!! */}
{/* !!!! */}
{/* !!!! */}
{/* TODO: Form submission not connected !?! , is it useful to have form element here !?! */}
{/* !!!! */}
{/* !!!! */}
{/* !!!! */}
{/* !!!! */}
{/* !!!! */}
<form
<div
className={stylesAnnotations.annotationsTitle_form_container}
onSubmit={(e) => {
e.preventDefault();
}}
>
<p>{__("reader.annotations.annotationsExport.description")}</p>
<div className={stylesInputs.form_group}>
Expand All @@ -1129,7 +1114,7 @@ const AnnotationList: React.FC<{ annotationUUIDFocused: string, resetAnnotationU
className="R2_CSS_CLASS__FORCE_NO_FOCUS_OUTLINE" />
</div>
<Popover.Close aria-label={__("catalog.export")} asChild>
<button type="submit" onClick={() => {
<button onClick={() => {
const annotations = annotationListFiltered.map(([, anno]) => {
const { creator } = anno;
if (creator?.id === creatorMyself.id) {
Expand All @@ -1145,17 +1130,13 @@ const AnnotationList: React.FC<{ annotationUUIDFocused: string, resetAnnotationU
label = label.replace(/^\./, ""); // remove dot start
label = label.toLowerCase();

// TODO: dispatch an action to launch export saga routine: init/get resource, iterator on each annotations => w3cAnnotations, return IReadiumAnnotationSet
// const contents = convertAnnotationListToReadiumAnnotationSet(annotations, publicationView, title);
// downloadAnnotationJSON(contents, label);

dispatch(readerLocalActionExportAnnotationSet.build(annotations, publicationView, label));
}} className={stylesButtons.button_primary_blue}>
<SVG svg={SaveIcon} />
{__("catalog.export")}
</button>
</Popover.Close>
</form>
</div>
</Popover.Content>
</Popover.Portal>
</Popover.Root>
Expand Down

0 comments on commit 69f4c91

Please sign in to comment.