From 2f31c7db066abfa7ceee86d8d577ced861641de7 Mon Sep 17 00:00:00 2001 From: xiangyu <3170102889@zju.edu.cn> Date: Sun, 8 May 2022 23:33:01 +0800 Subject: [PATCH] fix: add annotation to note bug --- src/events.ts | 5 ++++- src/views.ts | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/events.ts b/src/events.ts index 2b1348c..42a376a 100644 --- a/src/events.ts +++ b/src/events.ts @@ -681,7 +681,10 @@ class AddonEvents extends AddonBase { const noteEditor = _window.document.getElementById("zotero-note-editor"); t = 0; - while (!noteEditor.getCurrentInstance() && t < 500) { + while ( + (!noteEditor.getCurrentInstance || !noteEditor.getCurrentInstance()) && + t < 500 + ) { t += 1; await Zotero.Promise.delay(10); } diff --git a/src/views.ts b/src/views.ts index 3a03cdc..f7b33af 100644 --- a/src/views.ts +++ b/src/views.ts @@ -298,6 +298,7 @@ class AddonViews extends AddonBase { } moreButton.setAttribute("knowledgeinit", "true"); const addAnnotationNoteButton = _document.createElement("div"); + addAnnotationNoteButton.setAttribute("style", "margin: 5px;"); addAnnotationNoteButton.innerHTML = this.editorIcon["addAnnotationNote"]; let annotationWrapper = moreButton; @@ -367,10 +368,13 @@ class AddonViews extends AddonBase { e.preventDefault(); }); addAnnotationNoteButton.addEventListener("mouseover", (e: XULEvent) => { - e.target.setAttribute("style", "background: #F0F0F0;"); + addAnnotationNoteButton.setAttribute( + "style", + "background: #F0F0F0; margin: 5px;" + ); }); addAnnotationNoteButton.addEventListener("mouseout", (e: XULEvent) => { - e.target.removeAttribute("style"); + addAnnotationNoteButton.setAttribute("style", "margin: 5px;"); }); moreButton.before(addAnnotationNoteButton); updateCount += 1;