From b181529269a3d63595b3aaf12cf3f1ff2ebb624a Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 24 Jan 2023 17:16:54 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/3318 --- app/src/asset/anno.ts | 13 +++++++------ app/src/asset/index.ts | 4 ++-- app/src/asset/pdf/app.js | 33 +++++++++++++++++++++++++++++---- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/app/src/asset/anno.ts b/app/src/asset/anno.ts index 8b601d745..9424c639b 100644 --- a/app/src/asset/anno.ts +++ b/app/src/asset/anno.ts @@ -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; diff --git a/app/src/asset/index.ts b/app/src/asset/index.ts index 1d322403f..8fd03525c 100644 --- a/app/src/asset/index.ts +++ b/app/src/asset/index.ts @@ -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 { -