From ca2d08de2738cda87533458c0437ba8fbc0a4e4c Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 18 May 2023 21:10:25 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/5066 "click-editorcontent" | "click-pdf" --- app/src/asset/index.ts | 5 ++++- app/src/protyle/wysiwyg/index.ts | 3 +++ app/src/types/index.d.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/asset/index.ts b/app/src/asset/index.ts index bbe4b54f4..e06541100 100644 --- a/app/src/asset/index.ts +++ b/app/src/asset/index.ts @@ -30,8 +30,11 @@ export class Asset extends Model { this.element = options.tab.panelElement; this.path = options.path; this.pdfId = options.page; - this.element.addEventListener("click", () => { + this.element.addEventListener("click", (event) => { setPanelFocus(this.element.parentElement.parentElement); + this.app.plugins.forEach(item => { + item.eventBus.emit("click-pdf", event); + }); }); if (typeof this.pdfId === "string") { this.getPdfId(() => { diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 84856d774..fa9b0807c 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1502,6 +1502,9 @@ export class WYSIWYG { let shiftStartElement: HTMLElement; this.element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => { + this.app.plugins.forEach(item => { + item.eventBus.emit("click-editorcontent", event); + }); hideElements(["hint", "util"], protyle); const ctrlIsPressed = event.metaKey || event.ctrlKey; /// #if !MOBILE diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 034895281..f57d75b6a 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -22,7 +22,7 @@ type TOperation = | "removeFlashcards" type TBazaarType = "templates" | "icons" | "widgets" | "themes" | "plugins" type TCardType = "doc" | "notebook" | "all" -type TEventBus = "ws-main" | "click-blockicon" +type TEventBus = "ws-main" | "click-blockicon" | "click-editorcontent" | "click-pdf" declare module "blueimp-md5"