mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-29 03:36:10 +01:00
This commit is contained in:
parent
6d45b15ee3
commit
b5004ef48f
2 changed files with 31 additions and 0 deletions
|
|
@ -131,6 +131,25 @@ export const initAnno = (file: string, element: HTMLElement, annoId: string, pdf
|
|||
element.addEventListener("click", (event) => {
|
||||
let processed = false;
|
||||
let target = event.target as HTMLElement;
|
||||
if (typeof event.detail === "string") {
|
||||
window.siyuan.storage[Constants.LOCAL_PDFTHEME].annoColor = event.detail === "0" ?
|
||||
(window.siyuan.storage[Constants.LOCAL_PDFTHEME].annoColor || "var(--b3-pdf-background1)")
|
||||
: `var(--b3-pdf-background${event.detail})`;
|
||||
setStorageVal(Constants.LOCAL_PDFTHEME, window.siyuan.storage[Constants.LOCAL_PDFTHEME]);
|
||||
const coords = getHightlightCoordsByRange(pdf, window.siyuan.storage[Constants.LOCAL_PDFTHEME].annoColor);
|
||||
if (coords) {
|
||||
coords.forEach((item, index) => {
|
||||
const newElement = showHighlight(item, pdf);
|
||||
if (index === 0) {
|
||||
rectElement = newElement;
|
||||
copyAnno(`${pdf.appConfig.file.replace(location.origin, "").substr(1)}/${rectElement.getAttribute("data-node-id")}`,
|
||||
pdf.appConfig.file.replace(location.origin, "").substr(8).replace(/-\d{14}-\w{7}.pdf$/, ""));
|
||||
}
|
||||
});
|
||||
}
|
||||
hideToolbar(element);
|
||||
return;
|
||||
}
|
||||
while (target && !target.classList.contains("pdf__outer")) {
|
||||
const type = target.getAttribute("data-type");
|
||||
if (target.classList.contains("color__square")) {
|
||||
|
|
|
|||
|
|
@ -3194,6 +3194,18 @@ function webViewerKeyDown(evt) {
|
|||
return
|
||||
}
|
||||
|
||||
if (!evt.repeat && cmd !== 1 && cmd !== 2 && cmd !== 4 && cmd !== 8 &&
|
||||
[48, 49, 50, 51, 52, 53, 54, 55].includes(evt.keyCode) &&
|
||||
getSelection().rangeCount > 0 &&
|
||||
!pdfInstance.appConfig.toolbar.rectAnno.classList.contains('toggled')) {
|
||||
const range = getSelection().getRangeAt(0);
|
||||
if (range.toString() !== "" && hasClosestByClassName(range.commonAncestorContainer, "pdfViewer")) {
|
||||
pdfInstance.appConfig.appContainer.dispatchEvent(new CustomEvent("click", {detail: (evt.keyCode - 48).toString()}));
|
||||
evt.preventDefault()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// First, handle the key bindings that are independent whether an input
|
||||
// control is selected or not.
|
||||
if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue