fix: editor link popup button order

fix: #929
This commit is contained in:
windingwind 2024-04-09 22:43:18 +08:00
parent 35db16186e
commit d1b109e043

View File

@ -11,6 +11,7 @@ import {
} from "../../utils/editor";
import { getNoteLink, getNoteLinkParams } from "../../utils/link";
import { getString } from "../../utils/locale";
import { waitUtilAsync } from "../../utils/wait";
export function initEditorPopup(editor: Zotero.EditorInstance) {
const ob = new (ztoolkit.getGlobal("MutationObserver"))((muts) => {
@ -143,9 +144,13 @@ async function updateEditorLinkPopup(editor: Zotero.EditorInstance) {
],
});
_window.document
.querySelector(".link-popup")
?.append(insertButton, updateButton, openButton);
const linkPopup = _window.document.querySelector(".link-popup");
if (!linkPopup) {
return;
}
// Ensure the builtin buttons are appended
await waitUtilAsync(() => linkPopup.querySelectorAll("button").length >= 2);
linkPopup?.append(insertButton, updateButton, openButton);
} else {
Array.from(_window.document.querySelectorAll(".link-popup-extra")).forEach(
(elem) => elem.remove(),