diff --git a/addon/chrome/content/workspace.xul b/addon/chrome/content/workspace.xul index 4fcd122..ca5dde6 100644 --- a/addon/chrome/content/workspace.xul +++ b/addon/chrome/content/workspace.xul @@ -53,7 +53,7 @@
- Select Main Knowledge + Select Main Note
diff --git a/addon/chrome/locale/en-US/overlay.dtd b/addon/chrome/locale/en-US/overlay.dtd index 79496c9..ae88290 100644 --- a/addon/chrome/locale/en-US/overlay.dtd +++ b/addon/chrome/locale/en-US/overlay.dtd @@ -1,5 +1,5 @@ - + @@ -16,9 +16,9 @@ - - - + + + @@ -27,11 +27,11 @@ - + - + diff --git a/addon/chrome/locale/zh-CN/overlay.dtd b/addon/chrome/locale/zh-CN/overlay.dtd index e2d2ac3..8ed8972 100644 --- a/addon/chrome/locale/zh-CN/overlay.dtd +++ b/addon/chrome/locale/zh-CN/overlay.dtd @@ -1,7 +1,7 @@ - + - + @@ -16,22 +16,22 @@ - - - + + + - - - + + + - - + + - + diff --git a/addon/chrome/skin/default/Knowledge4Zotero/add-knowledge.gif b/addon/chrome/skin/default/Knowledge4Zotero/add-knowledge.gif deleted file mode 100644 index cc75fb5..0000000 Binary files a/addon/chrome/skin/default/Knowledge4Zotero/add-knowledge.gif and /dev/null differ diff --git a/addon/chrome/skin/default/Knowledge4Zotero/knowledge.png b/addon/chrome/skin/default/Knowledge4Zotero/knowledge.png deleted file mode 100644 index 8773692..0000000 Binary files a/addon/chrome/skin/default/Knowledge4Zotero/knowledge.png and /dev/null differ diff --git a/addon/chrome/skin/default/Knowledge4Zotero/knowledge@0.5x.png b/addon/chrome/skin/default/Knowledge4Zotero/knowledge@0.5x.png deleted file mode 100644 index 1acb3b8..0000000 Binary files a/addon/chrome/skin/default/Knowledge4Zotero/knowledge@0.5x.png and /dev/null differ diff --git a/addon/chrome/skin/default/Knowledge4Zotero/knowledge@2x.png b/addon/chrome/skin/default/Knowledge4Zotero/knowledge@2x.png deleted file mode 100644 index 9b993e9..0000000 Binary files a/addon/chrome/skin/default/Knowledge4Zotero/knowledge@2x.png and /dev/null differ diff --git a/src/events.ts b/src/events.ts index d973889..3b3c4b3 100644 --- a/src/events.ts +++ b/src/events.ts @@ -132,7 +132,17 @@ class AddonEvents extends AddonBase { /* message.content = {} */ + const res = confirm( + `Will create a new note under collection '${ZoteroPane_Local.getSelectedCollection().getName()}' and set it the main note. Continue?` + ); + if (!res) { + return; + } + const header = prompt("Enter new note header:"); const noteID = await ZoteroPane_Local.newNote(); + Zotero.Items.get(noteID).setNote( + `

${header}

\n
` + ); await this.onEditorEvent( new EditorMessage("setMainKnowledge", { params: { itemID: noteID }, @@ -199,7 +209,7 @@ class AddonEvents extends AddonBase { if (itemID === mainKnowledgeID) { this._Addon.views.showProgressWindow( "Knowledge", - "Already a main Knowledge." + "Already a main Note." ); return; } else if (!item.isNote()) { @@ -223,7 +233,7 @@ class AddonEvents extends AddonBase { await this._Addon.knowledge.setWorkspaceNote("main"); this._Addon.views.showProgressWindow( "Knowledge", - `Set main Knowledge to: ${item.getNoteTitle()}` + `Set main Note to: ${item.getNoteTitle()}` ); } } else if (message.type === "addNoteInstance") { @@ -247,9 +257,7 @@ class AddonEvents extends AddonBase { message.content.editorInstance, "knowledge-start", isMainKnowledge ? "isMainKnowledge" : "notMainKnowledge", - isMainKnowledge - ? "Edit the main knowledge in Workspace" - : "Open Workspace", + isMainKnowledge ? "Edit the main Note in Workspace" : "Open Workspace", "openWorkspace", "start" ); @@ -257,7 +265,7 @@ class AddonEvents extends AddonBase { message.content.editorInstance, "knowledge-addlink", "addToKnowledge", - "Add Note Link to Knowledge Workspace", + "Add link of current note to the main note", "addToKnowledge", "middle" ); @@ -328,8 +336,8 @@ class AddonEvents extends AddonBase { ); middle.innerHTML = ""; const header = _window.document.createElement("div"); - header.setAttribute("title", "This is a Main Knowledge"); - header.innerHTML = "Main Knowledge"; + header.setAttribute("title", "This is a Main Note"); + header.innerHTML = "Main Note"; header.setAttribute("style", "font-size: medium"); middle.append(header); } else { @@ -612,6 +620,18 @@ class AddonEvents extends AddonBase { const annotations = message.content.params.annotations; const annotationItem: ZoteroItem = message.content.params.annotationItem; + const text = annotationItem.annotationComment; + let link = text.substring(text.search(/zotero:\/\/note\//g)); + link = link.substring(0, link.search('"')); + + if (link) { + const note = (await this._Addon.knowledge.getNoteFromLink(link)).item; + if (note && note.id) { + Zotero.debug(note); + ZoteroPane.openNoteWindow(note.id); + return; + } + } const note: ZoteroItem = new Zotero.Item("note"); note.parentID = Zotero.Items.get( annotations[0].attachmentItemID @@ -622,6 +642,17 @@ class AddonEvents extends AddonBase { ); } await note.saveTx(); + let libraryID = note.libraryID; + let library = Zotero.Libraries.get(libraryID); + let groupID: string; + if (library.libraryType === "user") { + groupID = "u"; + } else if (library.libraryType === "group") { + groupID = `${library.id}`; + } + let noteKey = note.key; + annotationItem.annotationComment = `${annotationItem.annotationComment}\nnote link: "zotero://note/${groupID}/${noteKey}/"`; + await annotationItem.saveTx(); ZoteroPane.openNoteWindow(note.id); let t = 0; while (t < 100 && !ZoteroPane.findNoteWindow(note.id)) { diff --git a/src/knowledge.ts b/src/knowledge.ts index d0d2745..1e864b3 100644 --- a/src/knowledge.ts +++ b/src/knowledge.ts @@ -320,8 +320,8 @@ class Knowledge extends AddonBase { let linkText = linkedNote.getNoteTitle().trim(); this.addSubLineToNote( targetNote, - `${ - linkText ? linkText : `zotero://note/${groupID}/${noteKey}` + `${ + linkText ? linkText : `zotero://note/${groupID}/${noteKey}/` }`, lineIndex, true diff --git a/src/views.ts b/src/views.ts index bf4851a..500a882 100644 --- a/src/views.ts +++ b/src/views.ts @@ -202,20 +202,23 @@ class AddonViews extends AddonBase { addNewKnowledgeButton() { // Top toolbar button - let addNoteButton = document.getElementById("zotero-tb-note-add"); - let button = document.createElement("toolbarbutton"); + let addNoteItem = document + .getElementById("zotero-tb-note-add") + .getElementsByTagName("menuitem")[1]; + let button = document.createElement("menuitem"); button.setAttribute("id", "zotero-tb-knowledge-openwindow"); - button.setAttribute("tooltiptext", "Create new Knowledge Workspace"); + button.setAttribute("label", "New Main Note"); button.addEventListener("click", (e) => { this._Addon.events.onEditorEvent( new EditorMessage("createWorkspace", {}) ); }); + button.setAttribute("class", "menuitem-iconic"); button.setAttribute( "style", - "list-style-image: url('chrome://Knowledge4Zotero/skin/knowledge@0.5x.png');" + "list-style-image: url('chrome://Knowledge4Zotero/skin/favicon.png');" ); - addNoteButton.after(button); + addNoteItem.after(button); } addOpenWorkspaceButton() { @@ -224,7 +227,7 @@ class AddonViews extends AddonBase { treeRow.setAttribute("class", "row"); treeRow.setAttribute( "style", - "height: 22px; margin: 0 0 22px 0; padding: 0 6px 0 6px;" + "height: 22px; margin: 0 0 0 0; padding: 0 6px 0 6px;" ); const span1 = document.createElement("span"); span1.setAttribute("class", "cell label primary"); @@ -235,7 +238,7 @@ class AddonViews extends AddonBase { span3.setAttribute("class", "icon icon-bg cell-icon"); span3.setAttribute( "style", - "background-image:url(chrome://Knowledge4Zotero/skin/knowledge.png)" + "background-image:url(chrome://Knowledge4Zotero/skin/favicon.png)" ); const span4 = document.createElement("span"); span4.setAttribute("class", "cell-text"); @@ -249,13 +252,25 @@ class AddonViews extends AddonBase { treeRow.addEventListener("mouseover", (e: XULEvent) => { treeRow.setAttribute( "style", - "height: 22px; margin: 0 0 22px 0; padding: 0 6px 0 6px; background-color: grey;" + "height: 22px; margin: 0 0 0 0; padding: 0 6px 0 6px; background-color: grey;" ); }); treeRow.addEventListener("mouseleave", (e: XULEvent) => { treeRow.setAttribute( "style", - "height: 22px; margin: 0 0 22px 0; padding: 0 6px 0 6px;" + "height: 22px; margin: 0 0 0 0; padding: 0 6px 0 6px;" + ); + }); + treeRow.addEventListener("mousedown", (e: XULEvent) => { + treeRow.setAttribute( + "style", + "height: 22px; margin: 0 0 0 0; padding: 0 6px 0 6px; color: #FFFFFF;" + ); + }); + treeRow.addEventListener("mouseup", (e: XULEvent) => { + treeRow.setAttribute( + "style", + "height: 22px; margin: 0 0 0 0; padding: 0 6px 0 6px;" ); }); document @@ -446,7 +461,7 @@ class AddonViews extends AddonBase { */ async buildOutline(note: ZoteroItem) { - Zotero.debug(this.currentOutline) + Zotero.debug(this.currentOutline); if (this.currentOutline === OutlineType.treeView) { this._Addon.knowledge.currentNodeID = -1; let treeList = this._Addon.knowledge.getNoteTreeAsList(note, true, false); diff --git a/typing/global.d.ts b/typing/global.d.ts index 2877744..6ed20ea 100644 --- a/typing/global.d.ts +++ b/typing/global.d.ts @@ -147,7 +147,8 @@ declare const ZoteroPane: { }; declare const ZoteroPane_Local: { - newNote: () => Promise; + getSelectedCollection: () => ZoteroCollection; + newNote: (popup?, parentKey?, text?, citeURI?) => Promise; }; declare const Zotero_File_Interface: { @@ -155,6 +156,7 @@ declare const Zotero_File_Interface: { }; declare class ZoteroCollection { + getName: () => string; getChildItems: (arg1: boolean, arg2: boolean) => Array; }