diff --git a/src/modules/annotations.ts b/src/modules/annotations.ts index ffa1c437..28d13307 100644 --- a/src/modules/annotations.ts +++ b/src/modules/annotations.ts @@ -1,19 +1,19 @@ import { TagElementProps } from "zotero-plugin-toolkit/dist/tools/ui"; import { config } from "../../package.json"; +import { getPref } from "../utils/prefs"; import { - sortByFixedTag2Length, groupBy, groupByResult, - memFixedTags, - uniqueBy, + groupByResultIncludeFixedTags, + memAllTagsDB, memFixedColor, + memFixedTags, + memRelateTags, + sortByFixedTag2Length, sortByLength, str2RegExp, + uniqueBy, } from "../utils/zzlb"; -import { getPref } from "../utils/prefs"; -import { groupByResultIncludeFixedTags } from "../utils/zzlb"; -import { memAllTagsDB } from "../utils/zzlb"; -import { memRelateTags } from "../utils/zzlb"; function register() { // if (!getPref("enable")) return; // ztoolkit.UI.basicOptions.log.disableZLog = true; diff --git a/src/modules/annotationsToNote.ts b/src/modules/annotationsToNote.ts index 8549b320..a91a5e4a 100644 --- a/src/modules/annotationsToNote.ts +++ b/src/modules/annotationsToNote.ts @@ -1,19 +1,18 @@ -import { config } from "../../package.json"; import { ProgressWindowHelper } from "zotero-plugin-toolkit/dist/helpers/progressWindow"; import { MenuitemOptions } from "zotero-plugin-toolkit/dist/managers/menu"; +import { TagElementProps } from "zotero-plugin-toolkit/dist/tools/ui"; +import { config } from "../../package.json"; import { - groupBy, - uniqueBy, - promiseAllWithProgress, - sortByFixedTag2Length, getChildCollections, + groupBy, memFixedColor, + promiseAllWithProgress, setProperty, - memAllTagsDB, + sortByFixedTag2Length, + str2RegExp, + toggleProperty, + uniqueBy, } from "../utils/zzlb"; -import { TagElementProps } from "zotero-plugin-toolkit/dist/tools/ui"; -import { toggleProperty } from "../utils/zzlb"; -import { str2RegExp } from "../utils/zzlb"; let popupWin: ProgressWindowHelper | undefined = undefined; let popupTime = -1; @@ -391,39 +390,9 @@ async function createChooseTagsDiv(doc: Document, isCollection: boolean) { }, ], }; + const children = [tagsDiv, actionDiv]; - const div = ztoolkit.UI.appendElement( - { - tag: "div", - styles: { - padding: "20px", - position: "fixed", - left: "100px", - top: "100px", - zIndex: "9999", - width: "calc(100% - 200px)", - maxHeight: "400px", - overflowY: "scroll", - display: "flex", - background: "#a99", - flexWrap: "wrap", - flexDirection: "column", - }, - children: [tagsDiv, actionDiv], - listeners: [ - { - type: "click", - listener: (ev) => { - ev.stopPropagation(); - const target = ev.target as HTMLElement; - // target.remove(); - return false; - }, - }, - ], - }, - doc.querySelector("body,div")!, - ); + const div = createTopDiv(children, doc); createTags(); return div; @@ -467,6 +436,30 @@ async function createChooseTagsDiv(doc: Document, isCollection: boolean) { } } +function createTopDiv(children: TagElementProps[], doc: Document) { + return ztoolkit.UI.appendElement( + { + tag: "div", + styles: { + padding: "20px", + position: "fixed", + left: "100px", + top: "100px", + zIndex: "9999", + width: "calc(100% - 200px)", + maxHeight: "400px", + overflowY: "scroll", + display: "flex", + background: "#a99", + flexWrap: "wrap", + flexDirection: "column", + }, + children: children, + }, + doc.querySelector("body,div")!, + ); +} + async function saveNote(targetNoteItem: Zotero.Item, txt: string) { await Zotero.BetterNotes.api.note.insert(targetNoteItem, txt, -1); // const editor= await Zotero.BetterNotes.api.editor.getEditorInstance(targetNoteItem.id)