add: open parent attachment from editor

This commit is contained in:
windingwind 2023-04-12 21:15:26 +08:00
parent afe46c8e39
commit 2ca70f9909
3 changed files with 15 additions and 1 deletions

View File

@ -85,4 +85,5 @@ editor.toolbar.settings.openWorkspace=Open Note Workspace
editor.toolbar.settings.setWorkspace=Set as Workspace Note
editor.toolbar.settings.insertTemplate=Insert Template to Cursor Line
editor.toolbar.settings.copyLink=Copy Note Link
editor.toolbar.settings.openParent=Open Attachment
editor.toolbar.export.title=Export Note...

View File

@ -85,4 +85,5 @@ editor.toolbar.settings.openWorkspace=打开笔记工作区
editor.toolbar.settings.setWorkspace=设为工作区笔记
editor.toolbar.settings.insertTemplate=插入模板到光标行
editor.toolbar.settings.copyLink=复制笔记链接
editor.toolbar.settings.openParent=打开附件
editor.toolbar.export.title=导出笔记...

View File

@ -28,7 +28,7 @@ export async function initEditorToolbar(editor: Zotero.EditorInstance) {
(e) => {}
);
settingsButton.addEventListener("mouseenter", (ev) => {
settingsButton.addEventListener("mouseenter", async (ev) => {
const settingsMenu: PopupData[] = [
{
id: makeId("settings-openWorkspace"),
@ -76,6 +76,18 @@ export async function initEditorToolbar(editor: Zotero.EditorInstance) {
},
];
const parentAttachment = await noteItem.parentItem?.getBestAttachment();
if (parentAttachment) {
settingsMenu.push({
id: makeId("settings-openParent"),
text: getString("editor.toolbar.settings.openParent"),
callback: (e) => {
ZoteroPane.viewAttachment([parentAttachment.id]);
Zotero.Notifier.trigger("open", "file", parentAttachment.id);
},
});
}
const settingsPopup = registerEditorToolbarPopup(
editor,
settingsButton,