Merge 935aed5fb34b5dd03672f8fe27eafd2facb681b8 into 520363b350648ea066b4bd6b3d5697398a7e4096
This commit is contained in:
commit
bfa3aeb35d
@ -111,7 +111,7 @@ const defaultOptions = {
|
|||||||
},
|
},
|
||||||
supportsCaretBrowsingMode: {
|
supportsCaretBrowsingMode: {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
value: false,
|
value: true,
|
||||||
kind: OptionKind.BROWSER,
|
kind: OptionKind.BROWSER,
|
||||||
},
|
},
|
||||||
supportsDocumentFonts: {
|
supportsDocumentFonts: {
|
||||||
|
|||||||
@ -182,16 +182,47 @@ class PDFFindBar {
|
|||||||
this.findField.focus();
|
this.findField.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
async close() {
|
||||||
if (!this.opened) {
|
if (!this.opened) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ele = document.querySelector(".highlight");
|
||||||
|
if (ele) {
|
||||||
|
ele.parentElement.setAttribute("id", "find-element");
|
||||||
|
}
|
||||||
|
const idxFindElement = ele
|
||||||
|
? ele.parentNode.innerHTML.indexOf(ele.outerHTML)
|
||||||
|
: null;
|
||||||
|
|
||||||
this.#resizeObserver.disconnect();
|
this.#resizeObserver.disconnect();
|
||||||
|
|
||||||
this.opened = false;
|
this.opened = false;
|
||||||
toggleExpandedBtn(this.toggleButton, false, this.bar);
|
toggleExpandedBtn(this.toggleButton, false, this.bar);
|
||||||
|
|
||||||
this.eventBus.dispatch("findbarclose", { source: this });
|
await this.eventBus.dispatch("findbarclose", { source: this });
|
||||||
|
|
||||||
|
// apply the cursor position for the caret mode
|
||||||
|
if (ele) {
|
||||||
|
const range = document.createRange();
|
||||||
|
const selection = document.getSelection();
|
||||||
|
|
||||||
|
const findElement = document.getElementById("find-element");
|
||||||
|
const walker = document.createTreeWalker(
|
||||||
|
findElement,
|
||||||
|
NodeFilter.SHOW_TEXT
|
||||||
|
);
|
||||||
|
const findElementChild = walker.firstChild();
|
||||||
|
|
||||||
|
if (findElementChild) {
|
||||||
|
range.setStart(findElementChild, idxFindElement);
|
||||||
|
range.setEnd(findElementChild, idxFindElement);
|
||||||
|
range.collapse(true);
|
||||||
|
selection.removeAllRanges();
|
||||||
|
selection.addRange(range);
|
||||||
|
findElement.removeAttribute("id");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user