From b5bcc6d8807246b7cdf393bad36d0b888ecd6498 Mon Sep 17 00:00:00 2001 From: windingwind Date: Mon, 10 Apr 2023 18:21:17 +0800 Subject: [PATCH] init: 1.0.0a --- .gitignore | 1 - .vscode/launch.json | 38 + .vscode/toolkit.code-snippets | 45 + LICENSE | 149 +- README.md | 180 --- Template.md | 25 - TemplateDoc.md | 495 ------- TemplateUsage.md | 42 - UserGuide.md | 193 --- UserGuideCN.md | 192 --- addon/bootstrap.js | 153 ++ addon/chrome.manifest | 3 - addon/chrome/content/about.xul | 40 - addon/chrome/content/bubbleMap.html | 34 +- addon/chrome/content/export.xul | 97 -- .../icons}/favicon.png | Bin .../icons}/favicon@2x.png | Bin .../icons}/knowledge-app.png | Bin addon/chrome/content/imageViewer.html | 4 +- .../lib/css/github-markdown-light.min.css | 1 + addon/chrome/content/mindMap.html | 31 +- addon/chrome/content/overlay.xul | 107 -- addon/chrome/content/pdfPrinter.html | 58 + addon/chrome/content/preferences.xhtml | 69 + addon/chrome/content/sync.xul | 27 - .../content/{diff.html => syncDiff.html} | 2 +- addon/chrome/content/syncList.xul | 52 - addon/chrome/content/syncManager.xhtml | 120 ++ addon/chrome/content/template.xul | 66 - addon/chrome/content/templateEditor.xhtml | 201 +++ .../workspace.css => content/tooltip.css} | 0 addon/chrome/content/treeView.html | 48 +- addon/chrome/content/wizard.xul | 61 - addon/chrome/content/workspace.xul | 178 --- addon/chrome/locale/en-US/addon.properties | 110 +- addon/chrome/locale/en-US/overlay.dtd | 120 +- addon/chrome/locale/zh-CN/addon.properties | 110 +- addon/chrome/locale/zh-CN/overlay.dtd | 120 +- .../default/Knowledge4Zotero/add-link.gif | Bin 299664 -> 0 bytes .../Knowledge4Zotero/intro-workspace.png | Bin 229696 -> 0 bytes .../Knowledge4Zotero/open-knowledge.png | Bin 169754 -> 0 bytes addon/defaults/preferences/defaults.js | 26 - addon/install.rdf | 13 +- addon/manifest.json | 19 + addon/prefs.js | 26 + image/README/export.png | Bin 7014 -> 0 bytes image/README/from-annotation.png | Bin 39171 -> 0 bytes image/README/from-note.png | Bin 35824 -> 0 bytes image/README/importnoteandupdate.png | Bin 45273 -> 0 bytes image/README/insertCitation.png | Bin 97773 -> 0 bytes image/README/insertnote.png | Bin 23226 -> 0 bytes image/README/knowledge-app.png | Bin 54366 -> 0 bytes image/README/mainpage.png | Bin 29060 -> 0 bytes image/README/markdown-ob.png | Bin 779963 -> 0 bytes image/README/markdowncomment.png | Bin 51036 -> 0 bytes image/README/openpdf.png | Bin 51191 -> 0 bytes image/README/openworkspace.png | Bin 11231 -> 0 bytes image/README/outline.png | Bin 20683 -> 0 bytes image/README/preview-note.png | Bin 72442 -> 0 bytes image/README/sync.png | Bin 15039 -> 0 bytes image/README/teaser.png | Bin 448903 -> 0 bytes image/README/template.gif | Bin 811188 -> 0 bytes image/README/workspace.png | Bin 87521 -> 0 bytes package.json | 62 +- restart.js | 8 - build.js => scripts/build.js | 112 +- scripts/start.js | 25 + scripts/stop.js | 10 + scripts/zotero-cmd-default.json | 9 + src/addon.ts | 269 ++-- src/api.ts | 106 ++ src/editor/editorController.ts | 73 - src/editor/editorScript.ts | 225 --- src/editor/editorViews.ts | 1267 ----------------- src/editor/imageViewerWindow.ts | 293 ---- src/extras/docxWorker.ts | 16 + src/extras/editorScript.ts | 339 +++++ src/hooks.ts | 236 +++ src/index.ts | 42 +- src/module.ts | 15 - src/modules/convert/api.ts | 1104 ++++++++++++++ src/modules/editor/image.ts | 28 + src/modules/editor/initalize.ts | 34 + src/modules/editor/inject.ts | 65 + src/modules/editor/popup.ts | 257 ++++ src/modules/editor/toolbar.ts | 405 ++++++ src/modules/export/api.ts | 218 +++ src/modules/export/docx.ts | 68 + src/modules/export/exportWindow.ts | 227 +++ src/modules/export/freemind.ts | 90 ++ src/modules/export/markdown.ts | 60 + src/modules/export/pdf.ts | 35 + src/modules/imageViewer.ts | 293 ++++ src/modules/import/markdown.ts | 70 + src/modules/menu.ts | 81 ++ src/modules/noteLink.ts | 21 + src/modules/notify.ts | 27 + src/modules/preferenceWindow.ts | 145 ++ src/modules/reader.ts | 391 +++++ src/modules/sync/api.ts | 434 ++++++ src/modules/sync/diffWindow.ts | 141 ++ src/modules/sync/infoWindow.ts | 81 ++ src/modules/sync/managerWindow.ts | 197 +++ src/modules/template/api.ts | 165 +++ src/modules/template/controller.ts | 85 ++ src/modules/template/data.ts | 73 + src/modules/template/editorWindow.ts | 284 ++++ src/modules/template/picker.ts | 64 + src/modules/template/preview.ts | 120 ++ src/modules/userGuide.ts | 0 src/modules/workspace/content.ts | 448 ++++++ src/modules/workspace/message.ts | 85 ++ src/modules/workspace/tab.ts | 314 ++++ src/modules/workspace/window.ts | 5 + src/note/noteExportController.ts | 453 ------ src/note/noteExportWindow.ts | 105 -- src/note/noteImportController.ts | 98 -- src/note/noteParse.ts | 832 ----------- src/note/noteUtils.ts | 832 ----------- src/reader/readerViews.ts | 354 ----- src/sync/syncController.ts | 292 ---- src/sync/syncDiffWindow.ts | 162 --- src/sync/syncInfoWindow.ts | 112 -- src/sync/syncListWindow.ts | 216 --- src/sync/syncUtils.ts | 1127 --------------- src/template/templateController.ts | 286 ---- src/template/templateWindow.ts | 232 --- src/utils.ts | 44 - src/utils/annotation.ts | 244 ++++ src/utils/citation.ts | 34 + src/utils/config.ts | 165 +++ src/utils/editor.ts | 285 ++++ src/utils/hint.ts | 36 + src/utils/itemPicker.ts | 21 + src/utils/link.ts | 103 ++ src/utils/locale.ts | 23 + src/utils/note.ts | 485 +++++++ src/utils/prefs.ts | 13 + src/utils/str.ts | 80 ++ src/utils/wait.ts | 35 + src/utils/window.ts | 31 + src/utils/workspace.ts | 6 + src/wizard/wizardWindow.ts | 288 ---- src/workspace/workspaceMenu.ts | 53 - src/workspace/workspaceOutline.ts | 122 -- src/workspace/workspaceWindow.ts | 393 ----- src/zotero/events.ts | 1110 --------------- src/zotero/locale.ts | 18 - src/zotero/notifies.ts | 291 ---- src/zotero/views.ts | 426 ------ start.js | 6 - stop.js | 6 - tsconfig.json | 9 +- typing/editor.d.ts | 55 + typing/global.d.ts | 73 +- typing/note.d.ts | 34 + typing/template.ts | 4 + update-template.json | 26 + update-template.rdf | 30 + update.json | 26 + update.rdf | 14 +- zotero-cmd-default.json | 5 - 162 files changed, 10025 insertions(+), 12148 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/toolkit.code-snippets delete mode 100644 Template.md delete mode 100644 TemplateDoc.md delete mode 100644 TemplateUsage.md delete mode 100644 UserGuide.md delete mode 100644 UserGuideCN.md create mode 100644 addon/bootstrap.js delete mode 100644 addon/chrome/content/about.xul delete mode 100644 addon/chrome/content/export.xul rename addon/chrome/{skin/default/Knowledge4Zotero => content/icons}/favicon.png (100%) rename addon/chrome/{skin/default/Knowledge4Zotero => content/icons}/favicon@2x.png (100%) rename addon/chrome/{skin/default/Knowledge4Zotero => content/icons}/knowledge-app.png (100%) create mode 100644 addon/chrome/content/lib/css/github-markdown-light.min.css delete mode 100644 addon/chrome/content/overlay.xul create mode 100644 addon/chrome/content/pdfPrinter.html create mode 100644 addon/chrome/content/preferences.xhtml delete mode 100644 addon/chrome/content/sync.xul rename addon/chrome/content/{diff.html => syncDiff.html} (99%) delete mode 100644 addon/chrome/content/syncList.xul create mode 100644 addon/chrome/content/syncManager.xhtml delete mode 100644 addon/chrome/content/template.xul create mode 100644 addon/chrome/content/templateEditor.xhtml rename addon/chrome/{skin/default/Knowledge4Zotero/workspace.css => content/tooltip.css} (100%) delete mode 100644 addon/chrome/content/wizard.xul delete mode 100644 addon/chrome/content/workspace.xul delete mode 100644 addon/chrome/skin/default/Knowledge4Zotero/add-link.gif delete mode 100644 addon/chrome/skin/default/Knowledge4Zotero/intro-workspace.png delete mode 100644 addon/chrome/skin/default/Knowledge4Zotero/open-knowledge.png delete mode 100644 addon/defaults/preferences/defaults.js create mode 100644 addon/manifest.json create mode 100644 addon/prefs.js delete mode 100644 image/README/export.png delete mode 100644 image/README/from-annotation.png delete mode 100644 image/README/from-note.png delete mode 100644 image/README/importnoteandupdate.png delete mode 100644 image/README/insertCitation.png delete mode 100644 image/README/insertnote.png delete mode 100644 image/README/knowledge-app.png delete mode 100644 image/README/mainpage.png delete mode 100644 image/README/markdown-ob.png delete mode 100644 image/README/markdowncomment.png delete mode 100644 image/README/openpdf.png delete mode 100644 image/README/openworkspace.png delete mode 100644 image/README/outline.png delete mode 100644 image/README/preview-note.png delete mode 100644 image/README/sync.png delete mode 100644 image/README/teaser.png delete mode 100644 image/README/template.gif delete mode 100644 image/README/workspace.png delete mode 100644 restart.js rename build.js => scripts/build.js (69%) create mode 100644 scripts/start.js create mode 100644 scripts/stop.js create mode 100644 scripts/zotero-cmd-default.json create mode 100644 src/api.ts delete mode 100644 src/editor/editorController.ts delete mode 100644 src/editor/editorScript.ts delete mode 100644 src/editor/editorViews.ts delete mode 100644 src/editor/imageViewerWindow.ts create mode 100644 src/extras/docxWorker.ts create mode 100644 src/extras/editorScript.ts create mode 100644 src/hooks.ts delete mode 100644 src/module.ts create mode 100644 src/modules/convert/api.ts create mode 100644 src/modules/editor/image.ts create mode 100644 src/modules/editor/initalize.ts create mode 100644 src/modules/editor/inject.ts create mode 100644 src/modules/editor/popup.ts create mode 100644 src/modules/editor/toolbar.ts create mode 100644 src/modules/export/api.ts create mode 100644 src/modules/export/docx.ts create mode 100644 src/modules/export/exportWindow.ts create mode 100644 src/modules/export/freemind.ts create mode 100644 src/modules/export/markdown.ts create mode 100644 src/modules/export/pdf.ts create mode 100644 src/modules/imageViewer.ts create mode 100644 src/modules/import/markdown.ts create mode 100644 src/modules/menu.ts create mode 100644 src/modules/noteLink.ts create mode 100644 src/modules/notify.ts create mode 100644 src/modules/preferenceWindow.ts create mode 100644 src/modules/reader.ts create mode 100644 src/modules/sync/api.ts create mode 100644 src/modules/sync/diffWindow.ts create mode 100644 src/modules/sync/infoWindow.ts create mode 100644 src/modules/sync/managerWindow.ts create mode 100644 src/modules/template/api.ts create mode 100644 src/modules/template/controller.ts create mode 100644 src/modules/template/data.ts create mode 100644 src/modules/template/editorWindow.ts create mode 100644 src/modules/template/picker.ts create mode 100644 src/modules/template/preview.ts create mode 100644 src/modules/userGuide.ts create mode 100644 src/modules/workspace/content.ts create mode 100644 src/modules/workspace/message.ts create mode 100644 src/modules/workspace/tab.ts create mode 100644 src/modules/workspace/window.ts delete mode 100644 src/note/noteExportController.ts delete mode 100644 src/note/noteExportWindow.ts delete mode 100644 src/note/noteImportController.ts delete mode 100644 src/note/noteParse.ts delete mode 100644 src/note/noteUtils.ts delete mode 100644 src/reader/readerViews.ts delete mode 100644 src/sync/syncController.ts delete mode 100644 src/sync/syncDiffWindow.ts delete mode 100644 src/sync/syncInfoWindow.ts delete mode 100644 src/sync/syncListWindow.ts delete mode 100644 src/sync/syncUtils.ts delete mode 100644 src/template/templateController.ts delete mode 100644 src/template/templateWindow.ts delete mode 100644 src/utils.ts create mode 100644 src/utils/annotation.ts create mode 100644 src/utils/citation.ts create mode 100644 src/utils/config.ts create mode 100644 src/utils/editor.ts create mode 100644 src/utils/hint.ts create mode 100644 src/utils/itemPicker.ts create mode 100644 src/utils/link.ts create mode 100644 src/utils/locale.ts create mode 100644 src/utils/note.ts create mode 100644 src/utils/prefs.ts create mode 100644 src/utils/str.ts create mode 100644 src/utils/wait.ts create mode 100644 src/utils/window.ts create mode 100644 src/utils/workspace.ts delete mode 100644 src/wizard/wizardWindow.ts delete mode 100644 src/workspace/workspaceMenu.ts delete mode 100644 src/workspace/workspaceOutline.ts delete mode 100644 src/workspace/workspaceWindow.ts delete mode 100644 src/zotero/events.ts delete mode 100644 src/zotero/locale.ts delete mode 100644 src/zotero/notifies.ts delete mode 100644 src/zotero/views.ts delete mode 100644 start.js delete mode 100644 stop.js create mode 100644 typing/editor.d.ts create mode 100644 typing/note.d.ts create mode 100644 typing/template.ts create mode 100644 update-template.json create mode 100644 update-template.rdf create mode 100644 update.json delete mode 100644 zotero-cmd-default.json diff --git a/.gitignore b/.gitignore index 0be9b7b..d2d96bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ **/builds node_modules -.vscode package-lock.json zotero-cmd.json \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9be09e3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,38 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Restart-Z6", + "runtimeExecutable": "npm", + "runtimeArgs": [ + "run", + "restart-dev-z6" + ] + }, + { + "type": "node", + "request": "launch", + "name": "Restart-Z7", + "runtimeExecutable": "npm", + "runtimeArgs": [ + "run", + "restart-dev-z7" + ] + }, + { + "type": "node", + "request": "launch", + "name": "Restart in Prod Mode", + "runtimeExecutable": "npm", + "runtimeArgs": [ + "run", + "restart-prod" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/toolkit.code-snippets b/.vscode/toolkit.code-snippets new file mode 100644 index 0000000..ab0b6da --- /dev/null +++ b/.vscode/toolkit.code-snippets @@ -0,0 +1,45 @@ +{ + "appendElement - full": { + "scope": "javascript,typescript", + "prefix": "appendElement", + "body": [ + "appendElement({", + "\ttag: '${1:div}',", + "\tid: '${2:id}',", + "\tnamespace: '${3:html}',", + "\tclassList: ['${4:class}'],", + "\tstyles: {${5:style}: '$6'},", + "\tproperties: {},", + "\tattributes: {},", + "\t[{ '${7:onload}', (e: Event) => $8, ${9:false} }],", + "\tcheckExistanceParent: ${10:HTMLElement},", + "\tignoreIfExists: ${11:true},", + "\tskipIfExists: ${12:true},", + "\tremoveIfExists: ${13:true},", + "\tcustomCheck: (doc: Document, options: ElementOptions) => ${14:true},", + "\tchildren: [$15]", + "}, ${16:container});" + ] + }, + "appendElement - minimum": { + "scope": "javascript,typescript", + "prefix": "appendElement", + "body": "appendElement({ tag: '$1' }, $2);" + }, + "register Notifier": { + "scope": "javascript,typescript", + "prefix": "registerObserver", + "body": [ + "registerObserver({", + "\t notify: (", + "\t\tevent: _ZoteroTypes.Notifier.Event,", + "\t\ttype: _ZoteroTypes.Notifier.Type,", + "\t\tids: string[],", + "\t\textraData: _ZoteroTypes.anyObj", + "\t) => {", + "\t\t$0", + "\t}", + "});" + ] + } +} diff --git a/LICENSE b/LICENSE index f288702..dbbe355 100644 --- a/LICENSE +++ b/LICENSE @@ -1,23 +1,21 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble - The GNU General Public License is a free, copyleft license for -software and other kinds of works. + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to +our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. +software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you @@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. The precise terms and conditions for copying, distribution and modification follow. @@ -72,7 +60,7 @@ modification follow. 0. Definitions. - "This License" refers to version 3 of the GNU General Public License. + "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. @@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. - 13. Use with the GNU Affero General Public License. + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single +under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General +Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published +GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's +versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. @@ -635,40 +633,29 @@ the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Affero General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md index e0815a5..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,180 +0,0 @@ -# Zotero Better Notes - -![teaser](./image/README/teaser.png) - -Everything about note management. All in Zotero. - -Better Notes Handbook: [EN](https://github.com/windingwind/zotero-better-notes/wiki) | [中文 (provide translation)](https://zotero.yuque.com/staff-gkhviy/better-notes/biigg4?) - -User Guide: [EN](./UserGuide.md) | [中文](./UserGuideCN.md) - -## Introduction - -Better Notes is a plugin for [Zotero](https://zotero.org). - -It streamlines your unordered workflows of metadata analyzing, paper reading, annotating, and note-taking into a closed loop in Zotero. - -Works out of the box and is highly customizable. - -## Contents - -- [Quick start](#quick-start) -- [Install](#install) -- [Note workspace](#note-workspace) -- Connect notes with the [bi-directional links](#bi-directional-link-support) -- Automate note generation with the [note templates](#note-templates) -- [Export notes](#export) to different formats -- Integrate with 3rd-party MarkDown editors seamlessly with [note<->markdown syncing](#syncing-note-markdown) -- [Other features](#other-features) - -## Quick Start - -> See [Handbook:Quick Start](https://zotero.yuque.com/staff-gkhviy/better-notes/gw5d7v) for more details. - -New to note-taking? Install and start now! - -Already an Obsidian/Logseq/... user? Forget those complicated integration tools and keep them in sync with MarkDown files with just one click. - -## Install - -- Download the latest release (.xpi file) from the [Releases Page](https://github.com/windingwind/zotero-better-notes/releases)_Note_ If you're using Firefox as your browser, right-click the `.xpi` and select "Save As.." -- In Zotero click `Tools` in the top menu bar and then click `Addons` -- Go to the Extensions page and then click the gear icon in the top right. -- Select `Install Add-on from file`. -- Browse to where you downloaded the `.xpi` file and select it. -- Restart Zotero, by clicking `restart now` in the extensions list where the plugin is now listed. - -## Note Workspace - -> See [Handbook:Workspace](https://zotero.yuque.com/staff-gkhviy/better-notes/yul2qm) for more details. - -The workspace allows you to focus on the note, as shown in the teaser on top of the README. - -- Note outline(tree view, mindmap, and bubble map) -- Note links Preview - -## Bi-directional Link - -> See [Handbook:Bi-directional Link](https://zotero.yuque.com/staff-gkhviy/better-notes/yxpiew) for more details. - -The bi-directional link note(双链笔记) is supported. Link your notes inside Zotero with just one click. - -Export with its' linked sub-notes to Obsidian: -![Obsidian example](./image/README/markdown-ob.png) - -## Note Templates - -> See [Handbook:Note Templates](https://zotero.yuque.com/staff-gkhviy/better-notes/un54wc) for more details. - -Use customized templates to import data from items/notes! -![template](./image/README/template.gif) - -[How to Use Templates](./TemplateUsage.md) - -[How to Write Your Own Template](./TemplateDoc) - -See what templates can do and find templates contributed by the community here: [Note Templates from Community](https://github.com/windingwind/zotero-better-notes/discussions/categories/note-templates) - -## Export - -> See [Handbook:Export](https://zotero.yuque.com/staff-gkhviy/better-notes/nxlngg) for more details. - -- To new note in Zotero -- To MarkDown file(embed or link, with images) -- To MS Word document(.docx) -- To PDF document(.pdf) -- To FreeMind file(.mm) - -## Syncing: Note<->MarkDown - -> See [Handbook:Sycn](https://zotero.yuque.com/staff-gkhviy/better-notes/aid2c3) for more details. - -It's painless to Better Notes into your current workflow if you are using software like Obsidian. Keep your notes in sync with external MD files with one click. - -Click 'Auto Sync to Export Path' the first time you export your note. Do not require any third-party tools or complicated setups! - -Any modification in the note or its corresponding MarkDown file will be automatically synced. - -![syncing](./image/README/sync.png) - -## Other Features - -> See [Handbook:Other Features](https://zotero.yuque.com/staff-gkhviy/better-notes/sh4v2y) for more details. - -- Quick Note: annotation to note with one click. Support MarkDown comments. - -- Auto-insert new annotations to note. Disabled by default. -- Format MarkDown/AsciiDoc in the clipboard. -- Quick Cite: cite items in the note with the given cite format. -- Image annotation math OCR. -- Resize images (right-click on images). -- Preview images (double-click/ctrl-click on images). -- Customize link actions. -- Note editor enhancements. - - Quick switch main note. - - Copy note link. - - Import from MarkDown. - - Quick Cite. -- ... - -## Development & Contributing - -This addon is built based on the [Zotero Addon Template](https://github.com/windingwind/zotero-addon-template). - -### Build - -```shell -# A release-it command: version increase, npm run build, git push, and GitHub release -# You need to set the environment variable GITHUB_TOKEN https://github.com/settings/tokens -# release-it: https://github.com/release-it/release-it -npm run release -``` - -Alternatively, build it directly using build.js: `npm run build` - -### Debug - -1. Copy the Zotero command line config file. Modify the commands. - -```sh -cp zotero-cmd-default.json zotero-cmd.json -``` - -2. Initialize the addon development environment following this [link](https://www.zotero.org/support/dev/client_coding/plugin_development#setting_up_a_plugin_development_environment). - -3. Build the addon and restart Zotero with this npm command. - -```sh -npm run restart -``` - -You can also debug code in these ways: - -- Test code segments in Tools->Developer->Run Javascript; -- Debug output with `Zotero.debug()`. Find the outputs in Help->Debug Output Logging->View Output; -- UI debug. Zotero is built on the Firefox XUL framework. Debug XUL UI with software like [XUL Explorer](https://udn.realityripple.com/docs/Archive/Mozilla/XUL_Explorer). - > XUL Documents: - > https://www.xul.fr/tutorial/ - > http://www.xulplanet.com/ - -## Disclaimer - -Use this code under AGPL (open source required). No warranties are provided. Keep the laws of your locality in mind! - -Part of the code of this repo refers to other open-source projects within the allowed scope. - -- [zotero-pdf-translate](https://github.com/windingwind/zotero-pdf-translate) - -## My Other Zotero Addons - -- [zotero-pdf-preview](https://github.com/windingwind/zotero-pdf-preview) PDF preview for Zotero -- [zotero-pdf-translate](https://github.com/windingwind/zotero-pdf-translate) PDF translation for Zotero 6 -- [zotero-tag](https://github.com/windingwind/zotero-tag) Automatically tag items/Batch tagging - -## Sponsor Me - -I'm windingwind, an active Zotero(https://www.zotero.org) plugin developer. Devoting to making reading papers easier. - -Sponsor me to buy a cup of coffee. I spend more than 24 hours every week coding, debugging, and replying to issues in my plugin repositories. The plugins are open-source and totally free. - -If you sponsor more than $10 a month, you can list your name/logo here and have priority for feature requests/bug fixes! diff --git a/Template.md b/Template.md deleted file mode 100644 index 3ec94d9..0000000 --- a/Template.md +++ /dev/null @@ -1,25 +0,0 @@ -# Note Template - -## Introduction - -Note Template is an advanced feature that allows users insert anything into the note. - -You can easily reuse your note segments by making them a template. - -Moreover, you can use `Javascript` code to generate custom contents based on the input! - -![template](image/README/template.gif) - -## Documentations - -For new users, please see [Usage Documentation](TemplateUsage.md). It will guide you to know how to use templates. - -If you want to write your own template, you can either add a new template from an existing note, or follow this [Template Documentation](TemplateDoc.md). - -## Template Market - -See [[Documentation] Note Templates from Community](https://github.com/windingwind/zotero-better-notes/issues/85) - -Here are templates provided by other Zotero Better Notes users. Search to find one that suits your need! - -If you don't know how to make a template, it is welcomed to discuss or ask for help in a new issue. diff --git a/TemplateDoc.md b/TemplateDoc.md deleted file mode 100644 index d2327ae..0000000 --- a/TemplateDoc.md +++ /dev/null @@ -1,495 +0,0 @@ -# How to Write Your Own Template - -This documentation is like a dictionary. For beginners, see [How to Use Templates](./TemplateUsage.md). - -Use `Ctrl+F` to look up what you need and make your own template! - -## Stages - -Some type of templates(Item) support stages. - -Code wrapped inside the stage will be called at a specific time. - -For example, the `beforeloop` stage code: - -```js -// @beforeloop-begin -code; -// @beforeloop-end -``` - -| stage | calling time | -| ---------- | --------------------------------- | -| beforeloop | before entering the loop of items | -| default | loop of items | -| afterloop | after leaving the loop of items | - -In other type of templates, the default stage is called. - -## Variables - -### QuickInsert - -> variables: link: string, subNoteItem, noteItem - -### QuickBackLink - -> variables: subNoteItem, noteItem - -### QuickImport - -> variables: subNoteLines: string[], subNoteItem, noteItem - -### QuickNoteV3 - -> variables: annotationItem, topItem - -### ExportMDFileName - -> variables: noteItem - -### ExportMDFileHeader - -> variables: noteItem - -The return value must be a JSON string. - -### Text - -> variables: - - -### Item - -> beforeloop stage: items, copyNoteImage, editor, sharedObj(for temporary variables, shared by all stages) -> default stage: topItem, itemNotes, copyNoteImage, editor, sharedObj -> afterloop stage: items, copyNoteImage, editor, sharedObj - -### Note - -> Removed after v0.7.15+ - -## Formats - -### Line - -Description: Normal line. -Template Type: None. -Required Variable: None. - -```html -

Your Line Here

-``` - -### Heading - -Description: From h1 to h6. -Template Type: None. -Required Variable: None. - -```html -

Your Heding 1 Here

-

Your Heding 2 Here

-``` - -### Highlight - -Description: Highlight. -Template Type: None. -Required Variable: None. - -```html -

Text

-``` - -### Strong - -Description: **Strong text**. Put it in a `p`. -Template Type: None. -Required Variable: None. - -```html -Your Text -``` - -### Underline - -Description: Underline text. Put it in a `p`. -Template Type: None. -Required Variable: None. - -```html -Your Text -``` - -### Deleteline - -Description: Deleteline text. Put it in a `p`. -Template Type: None. -Required Variable: None. - -```html -Your Text -``` - -### Link - -Description: Link. Put it in a `p`. -Template Type: None. -Required Variable: None. - -```html -Link Text -``` - -### Number List - -Description: Number List. -Template Type: None. -Required Variable: None. - -```html -
    -
  1. First
  2. -
  3. Second
  4. -
  5. ...
  6. -
-``` - -### Bullet List - -Description: Bullet List. -Template Type: None. -Required Variable: None. - -```html -
    -
  • First
  • -
  • Second
  • -
  • ...
  • -
-``` - -### Sup & Sub Text - -Description: $\text{The}^{sup} \ and \ \text{the}_{sub}$ text. -Template Type: None. -Required Variable: None. - -```html -

Thesupand thesub text

-``` - -### Block Quote - -Description: - -> Block Quote - -Template Type: None. -Required Variable: None. - -```html -
-

Text

-
-``` - -### Monospaced - -Description: `Monospaced` -Template Type: None. -Required Variable: None. - -```html -
Text
-``` - -### Table - -Description: -| Table | Column1 | Column2 | -| ---- | ---- | ---- | -| 00 | 01 | 02 | -| 10 | 11 | 12 | - -Template Type: None. -Required Variable: None. - -```html - - - - - - - - - - - - - - - - -
-

Table

-
Column1Column2
000102
101112
-``` - -## General Fields - -### Current Date - -Description: Current Date. -Required Variable: None. - -```js -

${new Date().toLocaleDateString()}

-``` - -### Tags - -Description: `item.getTags()` returns tags in list. Usually use `tags.includes("YourTag") ? do sth : do sth else`. -Required Variable: any item/note/annotation. - -```js -

${topItem.getTags()}

-``` - -## Note Fields - -### Note Title - -Description: Note Title. First line of note. -Template Type: Note. -Required Variable: noteItem/subNoteItem. - -```js -

${noteItem.getNoteTitle()}

-``` - -### Note Content - -Description: Note Content. -Template Type: Note. -Required Variable: noteItem/subNoteItem. - -```js -

${noteItem.getNote()}

-``` - -### Note Link - -Description: Note Link. -Template Type: Note. -Required Variable: noteItem/subNoteItem. - -```js -

- - ${noteItem.key} - -

-``` - -## Item Fields - -### Title - -Description: Item title. -Template Type: Item. -Required Variable: topItem. - -```js -

${topItem.getField("title")}

-``` - -### Publisher/Journal - -Description: Publisher/Journal. -Template Type: Item. -Required Variable: topItem. - -```js -

- $ - {(() => { - if (topItem.itemType === "conferencePaper") { - return; - topItem.getField("conferenceName") || - topItem.getField("proceedingsTitle"); - } - if (topItem.itemType === "journalArticle") - return topItem.getField("publicationTitle"); - if (topItem.itemType === "report") return topItem.getField("institution"); - return topItem.getField("publicationTitle"); - })()} -

-``` - -### Authors - -Description: Authors. -Template Type: Item. -Required Variable: topItem. - -```js -

- $ - {topItem - .getCreators() - .map((v) => v.firstName + " " + v.lastName) - .join("; ")} -

-``` - -### Pub. date - -Description: Pub. date. -Template Type: Item. -Required Variable: topItem. - -```js -

${topItem.getField("date")}

-``` - -### Pub. date - -Description: Publication date/time. -Template Type: Item. -Required Variable: topItem. - -```js -

${topItem.getField("date")}

-``` - -### DOI - -Description: DOI. -Template Type: Item. -Required Variable: topItem. - -```js -

- - ${topItem.getField("DOI")} - -

-``` - -### URL - -Description: URL. -Template Type: Item. -Required Variable: topItem. - -```js -

- ${topItem.getField("url")} -

-``` - -### CitationKey - -Description: CitationKey. -Template Type: Item. -Required Variable: topItem. - -```js -

${topItem.citationKey ? topItem.citationKey : ""}

-``` - -### PDF Link - -Description: URL. -Template Type: Item. -Required Variable: topItem. - -```js -

- $ - {((topItem) => { - const getPDFLink = (_item) => { - let libraryID = _item.libraryID; - let library = Zotero.Libraries.get(libraryID); - let itemKey = _item.key; - let itemLink = ""; - if (library.libraryType === "user") { - itemLink = `zotero://open-pdf/library/items/${itemKey}`; - } else if (library.libraryType === "group") { - itemLink = `zotero://open-pdf/groups/${library.id}/items/${itemKey}`; - } - return `${_item.getFilename()}`; - }; - return Zotero.Items.get(topItem.getAttachments()) - .filter((i) => i.isPDFAttachment()) - .map((i) => getPDFLink(i)) - .join("\n"); - })(topItem)} -

-``` - -### Item Notes - -Description: Walk all sub notes under an item. You can add your code inside the loop. -Template Type: Item. -Required Variable: topItem. - -```js -${itemNotes.map((noteItem)=>{ - // process each item note - const noteLine = `
- ${noteItem.getNote()} -
`; - copyNoteImage(noteItem); - return noteLine; -}).join("\n")} -``` - -### About Item Fields - -The `noteItem` and `topItem` is a Zotero Item object. The general data can be accessed using the `getField()` method. - -For example: `topItem.getField('title')` will return the title of the `topItem`. - -```ts -// Get Item Fields -getField: (void)=>string; - -// Get Authors -getCreators: (void)=>{ - fieldMode: number, - firstName: string, // may be empty - lastName: string, - creatorTypeID: number, - }[]; -``` - -Find available fields of the selected item with the code below: - -```js -const item = ZoteroPane.getSelectedItems().shift(); -const usedFields = item.getUsedFields(); -Zotero.ItemFields.getAll() - .filter((e) => usedFields.indexOf(e.id) >= 0) - .map((e) => e.name); -``` - -The result is like this (depending on the item you select): - -```JSON -[ - "0": "title" - "1": "date" - "2": "language" - "3": "shortTitle" - "4": "libraryCatalog" - "5": "url" - "6": "accessDate" - "7": "pages" - "8": "conferenceName" -] -``` - -or see https://aurimasv.github.io/z2csl/typeMap.xml for the detailed Zotero fields documentation. diff --git a/TemplateUsage.md b/TemplateUsage.md deleted file mode 100644 index ade9484..0000000 --- a/TemplateUsage.md +++ /dev/null @@ -1,42 +0,0 @@ -# How to Use Templates - -This documentation is for beginners. - -If you want to customize your own template, see [How to Write Your Own Template](./TemplateDoc.md). Post an issue if you need help. - -You can find templates under the Workspace Tab/Window->Edit: -![image](https://user-images.githubusercontent.com/33902321/169189492-ab27b5ef-d6b2-4e4b-9035-2c11a91d53a1.png) - -## Add a template - -Click the _Edit Templates_ to open the editor. -![image](https://user-images.githubusercontent.com/33902321/169189605-e450702c-2336-463f-b157-600a198d987c.png) - -Create a blank template, or from a note. Here are example templates for the test: - -Copy The Name & template text to a new template and save it! - -**Template Name must include one of these keywords:** - -### Custom Templates - -These templates can have different names. The keyword must be incluede in the template name. - -- Text: indicate it's a normal template -- Item: indicate it's an item template. Must select items before inserting - -### System Templates - -Only the template with specific name will be called. - -- QuickInsert: Called when inserting a note link to main note. -- QuickBackLink: Called when inserting a note link to main note. The template will be inserted to the end of the sub-note and point to the main note by default. -- QuickImport: Called when importing a sub-note to main note. -- QuickNoteV3: Called when creating a note from an annotation. - > QuickNote is deprecated since v0.6.25 -- ExportMDFileName: Called when exporting notes to markdown in batch/linked notes to markdown mode. The rendered template will be file name. -- ExportMDFileHeader: Called when exporting notes to markdown in batch/linked notes to markdown mode. The rendered template will be YAML header. - -## Template Examples - -Welcome to share & contribute your template! See [Templates From Community](https://github.com/windingwind/zotero-better-notes/discussions/categories/note-templates) for more templates. diff --git a/UserGuide.md b/UserGuide.md deleted file mode 100644 index af7a0e9..0000000 --- a/UserGuide.md +++ /dev/null @@ -1,193 +0,0 @@ -# Zotero Better Notes User Guide: Workflow - -Welcome to **Zotero Better Notes** ! - -This note helps you quickly learn how to use this addon in 3 min! - -Let's start now. - -## 1 What is Knowledge - -Knowledge is an extension of Zotero's built-in note function. - -Zotero's note is much like a markdown/rich-text editor. You can edit the format with the tools above⬆️. - -### 1.1 Workspace Window - -The knowledge workspace window contains an outline area(left side⬅️), the main note area, and the preview area(right side➡️). - -![workspace](./image/README/workspace.png) - -Open workspace by clicking the 'Open Workspace' line above the 'My Library' line in Zotero main window. - -![Open workspace](./image/README/openworkspace.png) - -Alternatively, open it with the '🏠home' button on the top-left of note editors. - -![main page](./image/README/mainpage.png) - -### 1.2 Main note - -This addon uses a Zotero note item as the main note. It will show up on the main area of the workspace window. - -All links will be added to the main note. - -Set a note as the main note in the right-click popup menu. - -### 1.3 Workspace Menu - -**File menu**: - -- Create new main note(Ctrl/Cmd+N) -- Open main note(Ctrl/Cmd+O) -- Import notes(Ctrl/Cmd+I) -- Export notes(Ctrl/Cmd+E) -- Close workspace window(Ctrl/Cmd+W) - -**Edit menu**: - -- Insert heading -- Decrease selected heading level(Tab) -- Increase selected heading level(Shift+Tab) - -**View menu**: - -- Outline Views - -**Help menu**: - -- Open user guide - -## 2 Gather Ideas to Main Note - -### 2.1 From Note - -Select a note outside the workspace window(in Zotero items view or PDF viewer), you may realize a button with the addon's icon on the top of the note editor toolbar. - -Click it, the current note link will be inserted into the main note's cursor position; - -Select a heading, and the note's link will be inserted into the end of this heading. - -![insert-link-from-note](./image/README/from-note.png) - -> **💡 Try it now!** -> -> Open a PDF and open/create a note(in the right side bar of PDF viewer). Add a link below. - -### 2.2 From Annotation (including highlight and picture) - -You can find a button with the addon's icon on every annotation(in the left sidebar of PDF viewer). - -![insert-link-from-annotation](./image/README/from-annotation.png) - -Click it, and a new note containing this annotation will be created under the PDF item. Annotation tags are copied to the new note. -You can then add its link to the main note in the note editor. - -> **💡 Try it now!** -> -> Open a PDF and open/create an annotation(in the left sidebar of PDF viewer). - -### 2.3 Import Existing Notes - -You can import notes into the main note. - -- In workspace window, File -> Import Notes; -- Select notes and confirm. - -Notes' links will be appended to the end of the main note. - -## 3 Check Linked Notes in Workspace Window - -### 3.1 View Linked Notes - -Suppose you have added a lot of links to the main note. Now, it's time to view what you've got. - -Go back to the workspace window. - -Open a note link, the linked note will show up in the preview area(right side➡️). - -![preview-link](./image/README/preview-note.png) - -> **💡 Try it now!** -> -> Open a note link. - -### 3.2 View Linked Note's PDF - -Click the '📄PDF' button on the top-left of the preview area. - -![openpdf](./image/README/openpdf.png) - -> **💡 Try it now!** -> -> Open a linked note's PDF. - -### 3.3 Insert Citation - -Click the "Insert Citation" button in the middle of the preview area. - -![insertCitation](./image/README/insertCitation.png) - -Currently, the quick copy format must be a citation format, otherwise, this function will not work. See Edit->Preferences->Export in Zotero main window. - -### 3.4 Import Linked Note - -Import the selected linked note's context to the main note by clicking the 'import note' button in the link popup. - -![importnoteandupdate](./image/README/importnoteandupdate.png) - -Example: - -![insertnote](./image/README/insertnote.png) - -> **💡 Try it now!** -> -> Import one linked note. - -### 3.5 Update Note Link Text - -Update the link text in main note by clicking the 'update link text' button in the link popup. - -> **💡 Try it now!** -> -> Modify the first line of a linked note in the preview area. Then update its link text in the main note. - -## 4 Outline Mode - -Switch the outline mode with the '📊mode' button on the bottom of the outline area. - -![outline](./image/README/outline.png) - -> **💡 Try it now!** -> -> Try different outline modes. - -## 5 Export - -Click the '⬆️export' button on the top-right of the main note area. Choose a format to export, i.e. MarkDown. - -![export](./image/README/export.png) - -If you are using MS Word/OneNote, export to clipboard and paste there. - -> **💡 Try it now!** -> -> Export this main note! - -## 6 Start a New Job - -After the export, you may want to start a new job with a new empty main note. - -Create a note and right-click to set it as the main note, or just create a new main note. - -Open different main note in workspace window->File->Open Main Note. - -> **✨ Hint** -> -> Create a new collection and save all main notes there is the best way to manage them. -> -> The user guide should have done this for you. - -Congratulations! - -You can select a new main note and start working with **Zotero Better Notes** now. Have fun! diff --git a/UserGuideCN.md b/UserGuideCN.md deleted file mode 100644 index 01a6e2d..0000000 --- a/UserGuideCN.md +++ /dev/null @@ -1,192 +0,0 @@ -# Zotero Better Notes 用户指引:工作流 - -欢迎使用 **Zotero Better Notes** ! - -本笔记帮助您在 3 分钟内快速学习如何使用此插件! - -现在开始吧。 - -## 1 认识 Knowledge - -Knowledge 是 Zotero 内置 note 功能的扩展。 - -Zotero 的 note 很像一个标记/富文本编辑器。您可以使用上方工具编辑格式 ⬆️。 - -### 1.1 工作区窗口 - -知识工作区窗口包含一个大纲区域(左侧 ⬅️),主笔记区域和预览区域(右侧 ➡️)。 - -![workspace](./image/README/workspace.png) - -在 Zotero 主窗口中单击“我的文库”上方的“Open Workspace”来打开工作区。 - -![Open workspace](./image/README/openworkspace.png) - -或者,用笔记编辑器左上角的“🏠 主页”按钮。 - -![main page](./image/README/mainpage.png) - -### 1.2 主笔记 - -这个插件使用某一个 Zotero note 作为主笔记。它将显示在工作区窗口的主笔记区域。 - -所有链接都将添加到主笔记中。 - -从右键菜单中设置当前一个笔记为主笔记: - -### 1.3 工作区菜单栏 - -**文件菜单**: - -- 创建新的主笔记(Ctrl/Cmd+N) -- 打开主笔记(Ctrl/Cmd+O) -- 导入笔记(Ctrl/Cmd+I) -- 导出笔记(Ctrl/Cmd+E) -- 关闭(Ctrl/Cmd+W) - -**编辑菜单**: - -- 插入标题 -- 降低标题层级 -- 提升标题层级 - -**查看菜单**: - -- 大纲视图 - -**帮助菜单**: - -- 打开用户指引 - -## 2 在主笔记中收集想法 - -### 2.1 从 Note - -在工作区窗口外选择一个 note(在 Zotero 条目视图或 PDF 阅读器中),您会在笔记编辑器工具栏顶部看到一个带有本插件图标的按钮。 - -点击它,当前笔记的链接将插入主笔记的光标位置; - -选择一个标题层级,笔记的链接将插入该标题的末尾。 - -![insert-link-from-note](./image/README/from-note.png) - -> **💡 尝试一下!** -> -> 打开 PDF 并打开/创建笔记(在 PDF 阅读器的右侧栏中)。用上面的方法在这条主笔记添加一个链接。 - -### 2.2 从 Annotation(高亮批注和图片) - -你可以在每个批注上找到一个带有插件图标的按钮(在 PDF 阅读器的左侧栏中)。 - -![insert-link-from-annotation](./image/README/from-annotation.png) - -单击它,PDF条目下将创建一个带有此批注的新笔记。批注的标签将会复制到新的笔记。 - -然后可以在打开的笔记编辑器中将该笔记链接添加到主笔记。 - -> **💡 尝试一下!** -> -> 打开 PDF 并打开/创建批注高亮(在 PDF 阅读器的左侧栏中)。用上面的方法在这条主笔记添加一个链接。 - -### 2.3 从功能区导入笔记 - -支持从现有的多个笔记批量导入到主笔记中。 - -- 在工作区窗口菜单栏文件->导入笔记; -- 选择多个笔记并确认。 - -## 3 查看工作区窗口中的链接笔记 - -### 3.1 查看链接笔记 - -假设你已经在主笔记添加了很多的链接。现在,是时候看看你的结果了。 - -返回工作区窗口。 - -打开笔记链接,链接的笔记将显示在预览区域(右侧 ➡️)。 - -![preview-link](./image/README/preview-note.png) - -> **💡 尝试一下!** -> -> 在工作区窗口打开一个笔记链接。 - -### 3.2 查看链接笔记的 PDF - -在上一步打开的预览笔记中,点击预览区左上角的“📄PDF”按钮。 - -![openpdf](./image/README/openpdf.png) - -> **💡 尝试一下!** -> -> 打开一个链接笔记的 PDF。 - -### 3.3 插入当前子笔记父条目文献的引用格式 - -在上一步打开的预览笔记中,点击预览区中间的“插入引用”按钮。 - -![insertCitation](./image/README/insertCitation.png) - -目前,快速复制格式需要设置为citation format,否则该功能无法正常工作。可在Zotero主窗口的编辑->首选项->导出中设置。 - -### 3.4 插入链接的子笔记 - -点击链接弹窗中的'import note'来插入选择的笔记内容。 - -![importnoteandupdate](./image/README/importnoteandupdate.png) - -插入之后: - -![insertnote](./image/README/insertnote.png) - -> **💡 尝试一下!** -> -> 插入一个链接的笔记 - -### 3.5 更新链接文本 - -点击链接弹窗中的'update link text'来更新选择的笔记链接文本。 - -> **💡 尝试一下!** -> -> 在预览区域中编辑某个链接笔记的第一行文本,然后在主笔记区域更新它的链接文本。 - -## 4 大纲视图 - -点击大纲区域左下角的 ‘📊 大纲模式‘ 按钮 来切换大纲视图模式。 - -![outline](./image/README/outline.png) - -> **💡 尝试一下!** -> -> 尝试不同的大纲模式(思维导图) - -## 5 导出 - -点击主笔记区域右上角的“⬆️ 导出”按钮,或者工作区窗口菜单的文件->导出主笔记。选择要导出的格式,比如 MarkDown。 - -![export](./image/README/export.png) - -如果您使用的是 MS Word/OneNote,请导出到剪贴板并粘贴到那里。 - -> **💡 尝试一下!** -> -> 导出这个主笔记! - -## 6 开始新的任务 - -导出后,您可能希望使用新的空主笔记开始新任务。 - -创建一个笔记,然后在右键菜单中将其设置为主笔记;或者直接创建一个新的主笔记。 - -使用工作区窗口菜单的文件->打开主笔记以切换不同的主笔记。 - -> **✨ 提示** -> -> 创建一个新的文件夹并在其中专门保存所有的主笔记——这是管理主笔记的最佳方法。 -> -> 用户指引应该已经为您做到了这一点。 - -恭喜! - -你现在可以选择或新建一个主笔记,然后开始使用 **Zotero Better Notes**了。用的开心! diff --git a/addon/bootstrap.js b/addon/bootstrap.js new file mode 100644 index 0000000..0bd4aa2 --- /dev/null +++ b/addon/bootstrap.js @@ -0,0 +1,153 @@ +/** + * Most of this code is from Zotero team's official Make It Red example[1] + * or the Zotero 7 documentation[2]. + * [1] https://github.com/zotero/make-it-red + * [2] https://www.zotero.org/support/dev/zotero_7_for_developers + */ + +if (typeof Zotero == "undefined") { + var Zotero; +} + +var chromeHandle; + +// In Zotero 6, bootstrap methods are called before Zotero is initialized, and using include.js +// to get the Zotero XPCOM service would risk breaking Zotero startup. Instead, wait for the main +// Zotero window to open and get the Zotero object from there. +// +// In Zotero 7, bootstrap methods are not called until Zotero is initialized, and the 'Zotero' is +// automatically made available. +async function waitForZotero() { + if (typeof Zotero != "undefined") { + await Zotero.initializationPromise; + } + + var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); + var windows = Services.wm.getEnumerator("navigator:browser"); + var found = false; + while (windows.hasMoreElements()) { + let win = windows.getNext(); + if (win.Zotero) { + Zotero = win.Zotero; + found = true; + break; + } + } + if (!found) { + await new Promise((resolve) => { + var listener = { + onOpenWindow: function (aWindow) { + // Wait for the window to finish loading + let domWindow = aWindow + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow); + domWindow.addEventListener( + "load", + function () { + domWindow.removeEventListener("load", arguments.callee, false); + if (domWindow.Zotero) { + Services.wm.removeListener(listener); + Zotero = domWindow.Zotero; + resolve(); + } + }, + false + ); + }, + }; + Services.wm.addListener(listener); + }); + } + await Zotero.initializationPromise; +} + +function install(data, reason) {} + +async function startup({ id, version, resourceURI, rootURI }, reason) { + await waitForZotero(); + + // String 'rootURI' introduced in Zotero 7 + if (!rootURI) { + rootURI = resourceURI.spec; + } + + if (Zotero.platformMajorVersion >= 102) { + var aomStartup = Components.classes[ + "@mozilla.org/addons/addon-manager-startup;1" + ].getService(Components.interfaces.amIAddonManagerStartup); + var manifestURI = Services.io.newURI(rootURI + "manifest.json"); + chromeHandle = aomStartup.registerChrome(manifestURI, [ + ["content", "__addonRef__", rootURI + "chrome/content/"], + ["locale", "__addonRef__", "en-US", rootURI + "chrome/locale/en-US/"], + ["locale", "__addonRef__", "zh-CN", rootURI + "chrome/locale/zh-CN/"], + ]); + } else { + setDefaultPrefs(rootURI); + } + + /** + * Global variables for plugin code. + * The `_globalThis` is the global root variable of the plugin sandbox environment + * and all child variables assigned to it is globally accessible. + * See `src/index.ts` for details. + */ + const ctx = { + rootURI, + document: Zotero.getMainWindow().document, + }; + ctx._globalThis = ctx; + + Services.scriptloader.loadSubScript( + `${rootURI}/chrome/content/scripts/index.js`, + ctx + ); +} + +function shutdown({ id, version, resourceURI, rootURI }, reason) { + if (reason === APP_SHUTDOWN) { + return; + } + if (typeof Zotero === "undefined") { + Zotero = Components.classes["@zotero.org/Zotero;1"].getService( + Components.interfaces.nsISupports + ).wrappedJSObject; + } + Zotero.__addonInstance__.hooks.onShutdown(); + + Cc["@mozilla.org/intl/stringbundle;1"] + .getService(Components.interfaces.nsIStringBundleService) + .flushBundles(); + + Cu.unload(`${rootURI}/chrome/content/scripts/index.js`); + + if (chromeHandle) { + chromeHandle.destruct(); + chromeHandle = null; + } +} + +function uninstall(data, reason) {} + +// Loads default preferences from defaults/preferences/prefs.js in Zotero 6 +function setDefaultPrefs(rootURI) { + var branch = Services.prefs.getDefaultBranch(""); + var obj = { + pref(pref, value) { + switch (typeof value) { + case "boolean": + branch.setBoolPref(pref, value); + break; + case "string": + branch.setStringPref(pref, value); + break; + case "number": + branch.setIntPref(pref, value); + break; + default: + Zotero.logError(`Invalid type '${typeof value}' for pref '${pref}'`); + } + }, + }; + Zotero.getMainWindow().console.log(rootURI + "prefs.js"); + Services.scriptloader.loadSubScript(rootURI + "prefs.js", obj); +} diff --git a/addon/chrome.manifest b/addon/chrome.manifest index 3533a05..713e1b0 100644 --- a/addon/chrome.manifest +++ b/addon/chrome.manifest @@ -1,6 +1,3 @@ content __addonRef__ chrome/content/ -skin __addonRef__ default chrome/skin/default/__addonRef__/ locale __addonRef__ en-US chrome/locale/en-US/ locale __addonRef__ zh-CN chrome/locale/zh-CN/ - -overlay chrome://zotero/content/zoteroPane.xul chrome://__addonRef__/content/overlay.xul diff --git a/addon/chrome/content/about.xul b/addon/chrome/content/about.xul deleted file mode 100644 index 9044d92..0000000 --- a/addon/chrome/content/about.xul +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - %AboutDTD; - - %knowledgeDTD; -]> - - - + + +
+

Print to PDF

+

Waiting for data...

+
+ + diff --git a/addon/chrome/content/preferences.xhtml b/addon/chrome/content/preferences.xhtml new file mode 100644 index 0000000..06506b2 --- /dev/null +++ b/addon/chrome/content/preferences.xhtml @@ -0,0 +1,69 @@ + + + + + &zotero.__addonRef__.pref.workspace.expandLevel.label; + + + + + + + &zotero.__addonRef__.pref.sync.period.label; + + + + + + + + + + + + + + + + + + + + diff --git a/addon/chrome/content/sync.xul b/addon/chrome/content/sync.xul deleted file mode 100644 index 19a4b2c..0000000 --- a/addon/chrome/content/sync.xul +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - %ZoteroDTD; - - %knowledgeDTD; -]> - - - + + + +
+
+
+
+
+ + + diff --git a/addon/chrome/content/template.xul b/addon/chrome/content/template.xul deleted file mode 100644 index 445e872..0000000 --- a/addon/chrome/content/template.xul +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - %globalDTD; - - %standaloneDTD; - - %zoteroDTD; - - %knowledgeDTD; -]> - - - + + + + +
+
+
+
+
+
+
+ templateEditor.templateName +
+ +
+
+ +
+
+
+
+
+ templateEditor.previewContainer +
+
+
+
+
+ + + diff --git a/addon/chrome/skin/default/Knowledge4Zotero/workspace.css b/addon/chrome/content/tooltip.css similarity index 100% rename from addon/chrome/skin/default/Knowledge4Zotero/workspace.css rename to addon/chrome/content/tooltip.css diff --git a/addon/chrome/content/treeView.html b/addon/chrome/content/treeView.html index 30c927a..f4750e3 100644 --- a/addon/chrome/content/treeView.html +++ b/addon/chrome/content/treeView.html @@ -84,7 +84,7 @@ items, expandNodesRecursive: false, dataStructure: "plain", - height: $("window").height() - 100, + height: $("window").height(), displayExpr: "name", noDataText: "Outline is Empty", onItemClick: jumpNode, @@ -127,7 +127,7 @@ e.dropInsideItem && toNode !== null && // !toNode.itemData.isDirectory && - toNode.itemData.rank === 7 + toNode.itemData.level === 7 ) { return; } @@ -160,7 +160,11 @@ } function getTreeView() { - return $("#treeview").dxTreeView("instance"); + try { + return $("#treeview").dxTreeView("instance"); + } catch { + return undefined; + } } function calculateToIndex(e) { @@ -267,22 +271,44 @@ window.parent.postMessage({ type: "getMindMapData" }, "*"); } - function setData(nodes) { + function walkNode(node, callback) { + if (!node) { + return; + } + callback(node); + node.children.forEach((child) => walkNode(child, callback)); + } + + function setData(nodes, expandLevel) { console.log(nodes); + const tree = getTreeView(); + const expandedStatus = {}; + if (tree) { + const rootNodes = tree.getNodes(); + console.log(tree, rootNodes); + rootNodes.forEach((root) => { + walkNode(root, (node) => { + expandedStatus[node.itemData.name] = node.itemData.expanded; + }); + }); + } + console.log(expandedStatus); const treeData = []; nodes.map((node) => { treeData.push({ id: String(node.model.id), name: node.model.name, - rank: node.model.rank, - icon: node.model.rank === 7 ? noteIcon : undefined, + level: node.model.level, + icon: node.model.level === 7 ? noteIcon : undefined, lineIndex: node.model.lineIndex, endIndex: node.model.endIndex, isDirectory: node.children.length > 0, expanded: - node.children.filter((n) => n.model.rank < 7).length !== 0, + node.model.name in expandedStatus + ? expandedStatus[node.model.name] + : node.model.level < expandLevel, parentId: - node.model.rank > 1 ? String(node.parent.model.id) : undefined, + node.model.level > 1 ? String(node.parent.model.id) : undefined, }); }); $(() => { @@ -296,7 +322,7 @@ if (itemData.noteLink) { window.parent.postMessage( { - type: "jumpNote", + type: "openNote", link: itemData.noteLink, id: parseInt(itemData.id), }, @@ -308,6 +334,7 @@ type: "jumpNode", lineIndex: itemData.lineIndex, id: parseInt(itemData.id), + workspaceType: window.workspaceType || "tab", }, "*" ); @@ -317,7 +344,8 @@ function handler(e) { console.log(e); if (e.data.type === "setMindMapData") { - setData(e.data.nodes); + setData(e.data.nodes, e.data.expandLevel); + window.workspaceType = e.data.workspaceType; } } diff --git a/addon/chrome/content/wizard.xul b/addon/chrome/content/wizard.xul deleted file mode 100644 index a6063f6..0000000 --- a/addon/chrome/content/wizard.xul +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - %ZoteroDTD; - - %knowledgeDTD; -]> - - - - \ No newline at end of file diff --git a/addon/chrome/content/workspace.xul b/addon/chrome/content/workspace.xul deleted file mode 100644 index cd22b24..0000000 --- a/addon/chrome/content/workspace.xul +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - - - - - %globalDTD; - - %standaloneDTD; - - %editMenuOverlayDTD; - - %zoteroDTD; - - %knowledgeDTD; -]> - - - -