diff --git a/content/notes/menus.js b/content/notes/menus.js index fe85ad0..65acf18 100644 --- a/content/notes/menus.js +++ b/content/notes/menus.js @@ -36,31 +36,37 @@ Menus = { var items0 = { "edit": {name: "Edit note", icon: "fa-pencil-alt"}, - "editpdfnote": {name: "Edit annotation", icon: "fa-edit"}, + "editannotation": {name: "Edit annotation", icon: "fa-edit"}, + "showannotation": {name: "Show annotation", icon: "fa-edit"}, "sep": "---------", } var items_ai = {} - if(Zotero.ZeNotes.Prefs.getb("bard-api-key")!="google-translate-key") + var tlcode = Zotero.ZeNotes.Prefs.get("target-language"); + var tl = ""; + if(tlcode=="") + { + tl = "English"; + } + else { - var tlcode = Zotero.ZeNotes.Prefs.get("target-language"); - var tl = ""; for(a of Languages.list()) { if(tlcode.toUpperCase()==a.code.toUpperCase()) { tl = a.name; + break; } } - - items_ai["translate-google-en"] = {name: "Translate to "+tl+" (Google)", icon: "fa-language"}; - items_ai["sep-ai-02"] = "---------"; } + items_ai["translate-google-en"] = {name: "Translate to "+tl+" (Google)", icon: "fa-google"}; + items_ai["sep-ai-02"] = "---------"; + if(Zotero.ZeNotes.Prefs.getb("bard-api-key")!="") { - items_ai["paraphrase-bard"] = {name: "Paraphrase annotation (Bard)", icon: "fa-language"}; + items_ai["paraphrase-bard"] = {name: "Paraphrase annotation (Bard)", icon: "fa-b"}; items_ai["sep-ai-01"] = "---------"; } @@ -241,7 +247,37 @@ Menus = { this.opennote(notekey); } } - else if(key=="editpdfnote") + else if(key=="editannotation") + { + if(!annotationkey) + { + alert("Annotation not found!"); + return; + } + + var annotation = Zotero.Items.get(annotationid); + var currentcomment = annotation.annotationComment; + + var html = document.createElement("div"); + html.style = "width:100%; padding: 0.5em;" + html.innerHTML = currentcomment.split("\n").join("
"); + html.contentEditable = true; + Dialog.open(html, function(){ + var value = html.innerHTML.split("
").join("\n"); + + value = value.split(" xmlns=\"http://www.w3.org/1999/xhtml\"").join(""); + value = value.split("
").join(""); + value = value.split("
").join("\n"); + value = value.split("
").join("\n"); + value = value.split("
").join("\n"); + + annotation.annotationComment = value; + annotation.saveTx({skipSelect:true}).then(e=>{ + Zotero.ZeNotes.Ui.reload(); + }); + }, "Edit annotation comment", "save"); + } + else if(key=="showannotation") { var attachment = Zotero.Items.get(attachmentid); if(!annotationkey) diff --git a/content/notes/notes.css b/content/notes/notes.css index 5df5510..29f2bb7 100644 --- a/content/notes/notes.css +++ b/content/notes/notes.css @@ -16,6 +16,7 @@ th { text-transform: capitalize; } + .notekey { width: 100%; padding: 0.1em; @@ -128,6 +129,11 @@ body { color: black; } +.context-menu-separator +{ + border: solid 1px #dfdfff!important; +} + .zn-menuitem:hover { background-color: #d8e6f2; border: solid 1px #c0dcf3; diff --git a/content/ui/dialog.js b/content/ui/dialog.js index c38b181..6207a70 100644 --- a/content/ui/dialog.js +++ b/content/ui/dialog.js @@ -19,7 +19,7 @@ Dialog = { document.body.appendChild(this.dialog); this.dialog.appendChild(this.contents); this.dialog.id = "main-dialog"; - this.dialog.title = "Coding dialog"; + this.dialog.title = "ZeNotes Dialog"; this.contents.style = "height: 100%; width: 100%;"; this.contents.innerHTML = ``; }, @@ -83,6 +83,22 @@ Dialog = { } } } + else if(buttons=="save") + { + buttons = { + Cancel: function() + { + $("#main-dialog").dialog( "close" ); + }, + Save: function(){ + $("#main-dialog").dialog( "close" ); + if(callback!=null) + { + callback(); + } + } + } + } $("#main-dialog").dialog({ height: "auto", diff --git a/core/ai.js b/core/ai.js index 6fbf91d..9b3d267 100644 --- a/core/ai.js +++ b/core/ai.js @@ -48,6 +48,17 @@ Ai={ return Promise.resolve(["Error: "+e]); } } + else if(mode=="bing") + { + try { + // Google translate without api key + return Promise.resolve(data.map(function(e){return e[0]})); + } + catch(e) + { + return Promise.resolve(["Error: "+e, JSON.stringify(data)]); + } + } }).catch(e=>{ return Promise.reject(["Error: "+e]); diff --git a/install.rdf b/install.rdf index a484669..f9741db 100644 --- a/install.rdf +++ b/install.rdf @@ -5,7 +5,7 @@ zenotes@alefa.net ZeNotes - 0.5.8 + 0.5.9 true https://raw.githubusercontent.com/frianasoa/zenotes/main/zenote-update.json https://github.com/frianasoa/zenotes diff --git a/manifest.json b/manifest.json index f0226ad..5e4a69e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Ze Notes", - "version": "0.5.8", + "version": "0.5.9", "description": "Advanced notes manager", "homepage_url": "https://github.com/frianasoa/zenotes", "author": "Fanantenana Rianasoa Andriariniaina", diff --git a/zenote-update.json b/zenote-update.json index be8a7a8..47546bd 100644 --- a/zenote-update.json +++ b/zenote-update.json @@ -3,9 +3,9 @@ "zenotes@alefa.net": { "updates": [ { - "version": "0.5.8", - "update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.5.8/zenotes-v0.5.8.xpi", - "update_hash": "sha256:0e3bb0d1b40a66a304969b96eac75ee2dd3985879912fe674bcff6854720da9a", + "version": "0.5.9", + "update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.5.9/zenotes-v0.5.9.xpi", + "update_hash": "sha256:03f0e0fef1eda2a893fccb6a70fd55ab3f6565a8cb480f540fb257e3b11e9a65", "applications": { "gecko": { "strict_min_version": "60.0" diff --git a/zenote-update.rdf b/zenote-update.rdf index cd43d53..5792bbc 100644 --- a/zenote-update.rdf +++ b/zenote-update.rdf @@ -5,13 +5,13 @@ - 0.5.8 + 0.5.9 zotero@chnm.gmu.edu 5.0.0 6.* - https://github.com/frianasoa/Ze-Notes/releases/download/v0.5.8/zenotes-v0.5.8.xpi + https://github.com/frianasoa/Ze-Notes/releases/download/v0.5.9/zenotes-v0.5.9.xpi @@ -20,7 +20,7 @@ juris-m@juris-m.github.io 4.999 6.* - https://github.com/frianasoa/Ze-Notes/releases/download/v0.5.8/zenotes-v0.5.8.xpi + https://github.com/frianasoa/Ze-Notes/releases/download/v0.5.9/zenotes-v0.5.9.xpi