mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 00:38:49 +01:00
This commit is contained in:
parent
83128d2fd8
commit
b181529269
3 changed files with 38 additions and 12 deletions
|
|
@ -96,7 +96,7 @@ export const initAnno = (file: string, element: HTMLElement, annoId: string, pdf
|
|||
newHeight = y - newTop;
|
||||
}
|
||||
rectResizeElement.setAttribute("style",
|
||||
`top:${newTop}px;height:${newHeight}px;left:${newLeft}px;width:${newWidth}px;`);
|
||||
`top:${newTop}px;height:${newHeight}px;left:${newLeft}px;width:${newWidth}px;background-color:${moveEvent.altKey?"var(--b3-pdf-background1)":""}`);
|
||||
};
|
||||
documentSelf.onmouseup = () => {
|
||||
documentSelf.onmousemove = null;
|
||||
|
|
@ -145,7 +145,8 @@ export const initAnno = (file: string, element: HTMLElement, annoId: string, pdf
|
|||
if (pdfConfig.mainContainer.lastElementChild.classList.contains("fn__none")) {
|
||||
coords = getHightlightCoordsByRange(pdf, color);
|
||||
} else {
|
||||
coords = getHightlightCoordsByRect(pdf, color, pdfConfig.mainContainer.lastElementChild);
|
||||
coords = getHightlightCoordsByRect(pdf, color, pdfConfig.mainContainer.lastElementChild,
|
||||
pdfConfig.mainContainer.lastElementChild.style.backgroundColor ? "text" : "border");
|
||||
pdfConfig.mainContainer.lastElementChild.classList.add("fn__none");
|
||||
}
|
||||
if (coords) {
|
||||
|
|
@ -400,7 +401,7 @@ const getHightlightCoordsByRange = (pdf: any, color: string) => {
|
|||
return results;
|
||||
};
|
||||
|
||||
const getHightlightCoordsByRect = (pdf: any, color: string, rectResizeElement: HTMLElement) => {
|
||||
const getHightlightCoordsByRect = (pdf: any, color: string, rectResizeElement: HTMLElement, type:string) => {
|
||||
const rect = rectResizeElement.getBoundingClientRect();
|
||||
|
||||
const startPageElement = hasClosestByClassName(document.elementFromPoint(rect.left, rect.top - 1), "page");
|
||||
|
|
@ -437,7 +438,7 @@ const getHightlightCoordsByRect = (pdf: any, color: string, rectResizeElement: H
|
|||
id,
|
||||
color,
|
||||
content,
|
||||
type: "border",
|
||||
type,
|
||||
mode: "rect",
|
||||
}];
|
||||
|
||||
|
|
@ -465,7 +466,7 @@ const getHightlightCoordsByRect = (pdf: any, color: string, rectResizeElement: H
|
|||
id,
|
||||
color,
|
||||
content,
|
||||
type: "border",
|
||||
type,
|
||||
mode: "rect",
|
||||
});
|
||||
}
|
||||
|
|
@ -475,7 +476,7 @@ const getHightlightCoordsByRect = (pdf: any, color: string, rectResizeElement: H
|
|||
pages,
|
||||
content,
|
||||
color,
|
||||
type: "border",
|
||||
type,
|
||||
mode: "rect",
|
||||
});
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {webViewerLoad} from "./pdf/viewer";
|
|||
import {webViewerPageNumberChanged} from "./pdf/app";
|
||||
/// #endif
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {setStorageVal} from "../protyle/util/compatibility";
|
||||
import {setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
|
||||
|
||||
export class Asset extends Model {
|
||||
public path: string;
|
||||
|
|
@ -241,7 +241,7 @@ export class Asset extends Model {
|
|||
<button id="viewFind" class="toolbarButton b3-tooltips b3-tooltips__s" tabindex="12" aria-expanded="false" aria-controls="findbar" aria-label="${window.siyuan.languages.search}">
|
||||
<svg><use xlink:href="#iconSearch"></use></svg>
|
||||
</button>
|
||||
<button id="rectAnno" class="toolbarButton b3-tooltips b3-tooltips__s" tabindex="12" aria-expanded="false" aria-controls="findbar" aria-label="${window.siyuan.languages.rectAnnotation}">
|
||||
<button id="rectAnno" class="toolbarButton b3-tooltips b3-tooltips__s" tabindex="12" aria-expanded="false" aria-controls="findbar" aria-label="${window.siyuan.languages.rectAnnotation} ${updateHotkeyTip("⌘/⌥")}">
|
||||
<svg><use xlink:href="#iconTopLeft"></use></svg>
|
||||
</button>
|
||||
<button class="toolbarButton pageUp b3-tooltips b3-tooltips__s" aria-label="${window.siyuan.languages.previousLabel}" id="previous" tabindex="13">
|
||||
|
|
|
|||
|
|
@ -1304,7 +1304,8 @@ class PDFViewerApplication {
|
|||
this._initializeAutoPrint(pdfDocument, openActionPromise)
|
||||
},
|
||||
reason => {
|
||||
this._documentError(window.siyuan.languages.loadingError, {message: reason?.message})
|
||||
this._documentError(window.siyuan.languages.loadingError,
|
||||
{message: reason?.message})
|
||||
},
|
||||
)
|
||||
|
||||
|
|
@ -1619,7 +1620,7 @@ class PDFViewerApplication {
|
|||
}
|
||||
}
|
||||
annotationStorage.onResetModified = () => {
|
||||
// NOTE window.removeEventListener('beforeunload', beforeUnload)
|
||||
// NOTE window.removeEventListener('beforeunload', beforeUnload)
|
||||
|
||||
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
||||
delete this._annotationStorageModified
|
||||
|
|
@ -1940,6 +1941,7 @@ class PDFViewerApplication {
|
|||
})
|
||||
window.addEventListener('click', webViewerClick)
|
||||
window.addEventListener('keydown', webViewerKeyDown)
|
||||
window.addEventListener('keyup', webViewerKeyUp)
|
||||
window.addEventListener('resize', _boundEvents.windowResize)
|
||||
window.addEventListener('hashchange', _boundEvents.windowHashChange)
|
||||
window.addEventListener('beforeprint', _boundEvents.windowBeforePrint)
|
||||
|
|
@ -2021,6 +2023,7 @@ class PDFViewerApplication {
|
|||
})
|
||||
window.removeEventListener('click', webViewerClick)
|
||||
window.removeEventListener('keydown', webViewerKeyDown)
|
||||
window.removeEventListener('keyup', webViewerKeyUp)
|
||||
window.removeEventListener('resize', _boundEvents.windowResize)
|
||||
window.removeEventListener('hashchange', _boundEvents.windowHashChange)
|
||||
window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint)
|
||||
|
|
@ -2221,7 +2224,8 @@ function webViewerInitialized (pdf) {
|
|||
|
||||
if (!pdf.supportsFullscreen) {
|
||||
// NOTE
|
||||
appConfig.secondaryToolbar.presentationModeButton?.classList.add('fn__hidden')
|
||||
appConfig.secondaryToolbar.presentationModeButton?.classList.add(
|
||||
'fn__hidden')
|
||||
}
|
||||
|
||||
if (pdf.supportsIntegratedFind) {
|
||||
|
|
@ -2433,7 +2437,8 @@ function webViewerSpreadModeChanged (evt) {
|
|||
if (!pdfInstance) {
|
||||
return
|
||||
}
|
||||
if (pdfInstance.isInitialViewSet && !pdfInstance.pdfViewer.isInPresentationMode) {
|
||||
if (pdfInstance.isInitialViewSet &&
|
||||
!pdfInstance.pdfViewer.isInPresentationMode) {
|
||||
// Only update the storage when the document has been loaded *and* rendered.
|
||||
pdfInstance.store?.set('spreadMode', evt.mode).catch(() => {
|
||||
// Unable to write to storage.
|
||||
|
|
@ -2949,6 +2954,20 @@ function webViewerClick (evt) {
|
|||
}
|
||||
|
||||
// NOTE
|
||||
function webViewerKeyUp (evt) {
|
||||
const pdfInstance = getPdfInstance(evt.target)
|
||||
if (!pdfInstance || pdfInstance.overlayManager.active) {
|
||||
return
|
||||
}
|
||||
if (pdfInstance.overlayManager.active) {
|
||||
return
|
||||
}
|
||||
if (pdfInstance.appConfig.toolbar.rectAnno.classList.contains('toggled')) {
|
||||
pdfInstance.appConfig.toolbar.rectAnno.dispatchEvent(
|
||||
new MouseEvent('click'))
|
||||
}
|
||||
}
|
||||
|
||||
function webViewerKeyDown (evt) {
|
||||
const pdfInstance = getPdfInstance(evt.target)
|
||||
if (!pdfInstance || pdfInstance.overlayManager.active) {
|
||||
|
|
@ -2968,6 +2987,12 @@ function webViewerKeyDown (evt) {
|
|||
(evt.shiftKey ? 4 : 0) |
|
||||
(evt.metaKey ? 8 : 0)
|
||||
|
||||
if ((cmd === 8 || cmd === 1 || cmd === 2) &&
|
||||
!pdfInstance.appConfig.toolbar.rectAnno.classList.contains('toggled')) {
|
||||
pdfInstance.appConfig.toolbar.rectAnno.dispatchEvent(
|
||||
new MouseEvent('click'))
|
||||
}
|
||||
|
||||
// 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