fix: initialize existing editors on plugin reload

This commit is contained in:
windingwind 2024-06-30 13:18:40 +08:00
parent c561657472
commit 7162f249fe
2 changed files with 3 additions and 2 deletions

View File

@ -19,6 +19,7 @@ export function registerEditorInstanceHook() {
},
},
);
Zotero.Notes._editorInstances.forEach(onEditorInstanceCreated);
}
async function onEditorInstanceCreated(editor: Zotero.EditorInstance) {

View File

@ -10,10 +10,10 @@ export function initEditorMenu(editor: Zotero.EditorInstance) {
const makeId = (key: string) =>
`${config.addonRef}-editor-menu-${editor.instanceID}-${key}`;
// Prevent duplicate menu items
if (editor._popup.getAttribute("bn-init") === "true") {
if (editor._popup.getAttribute("bn-init") === addon.data.uid) {
return;
}
editor._popup.setAttribute("bn-init", "true");
editor._popup.setAttribute("bn-init", addon.data.uid);
(editor._popup as XUL.Menu).addEventListener("popupshowing", (ev) => {
const menuitemID = makeId("resizeImage");
if (