From fb68e559bd77f197c8777782bab4c0f5a51643e5 Mon Sep 17 00:00:00 2001 From: frianasoa Date: Thu, 10 Oct 2024 19:50:05 +0900 Subject: [PATCH] Added font family settings in preferences --- .gitignore | 3 ++- README.md | 2 +- content/notes/notes-dark.css | 7 ++++-- content/notes/notes.css | 2 +- content/notes/notes.js | 11 ++++++++++ content/settings/display.xhtml | 1 + content/settings/preferences.js | 34 +++++++++++++++++++++++++++++- content/settings/preferences.xhtml | 2 +- content/settings/zotero.js | 2 +- core/ai.js | 25 ++++++++++++++++------ install.rdf | 2 +- manifest.json | 2 +- zenote-update.json | 6 +++--- zenote-update.rdf | 6 +++--- 14 files changed, 83 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 7b60151..1316bd6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build run.cmd -run7.cmd \ No newline at end of file +run7.cmd +stats.py \ No newline at end of file diff --git a/README.md b/README.md index ecd46ef..de0d090 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![zotero](https://raw.githubusercontent.com/frianasoa/zenotes/main/docs/images/for-zotero-6.svg)](https://zotero.org)
-Now works with Zotero 7 Beta. +Now works with Zotero 7. ## Description ZeNotes is a Zotero plugin that will help you manage and visualize your notes. It is helpfull if you intend to make a systematic review directly on your Zotero using notes and pdf annotations. This tool will help you organize your notes on Zotero. It will show you on a table what you have been writing. You can edit your notes right on the table or add new notes. On the latest versions, you can add translations of your notes using Google or DeepL. You can also apply a generative AI prompts (Bard and ChatGPT for the moment) to a cell, a row, or the entire table. These actions are also available right in the pdf reader of Zotero. diff --git a/content/notes/notes-dark.css b/content/notes/notes-dark.css index 7fafb50..f9fbfdc 100644 --- a/content/notes/notes-dark.css +++ b/content/notes/notes-dark.css @@ -61,6 +61,9 @@ a { } .zn-menuitem:hover { - background-color: black; - border-bottom: solid 1px white; + background-color: black!important; + border-bottom: solid 1px white!important; +} +.context-menu-one:hover { + background-color: rgb(25, 25, 55)!important; } \ No newline at end of file diff --git a/content/notes/notes.css b/content/notes/notes.css index 74affa5..e0c8d39 100644 --- a/content/notes/notes.css +++ b/content/notes/notes.css @@ -1,6 +1,6 @@ * { font-size: 1.02em; - font-family: Arial; + /* font-family: Arial; */ box-sizing: border-box; } diff --git a/content/notes/notes.js b/content/notes/notes.js index 2385dd3..02ef3e0 100644 --- a/content/notes/notes.js +++ b/content/notes/notes.js @@ -367,6 +367,16 @@ Notes = { Zotero.ZeNotes.Prefs.set("font-size", pxsize); }, + loadfont() + { + var fontfamily = Zotero.ZeNotes.Prefs.get('font-family', "Arial"); + if(!fontfamily) + { + fontfamily="Arial"; + } + document.getElementById("zn-body").style.setProperty("font-family", fontfamily, "important"); + }, + loaddark() { var isdark = Zotero.Prefs.get('general.theme')=="dark" || window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; @@ -388,6 +398,7 @@ window.addEventListener("load", function(){ Notes.loaddata(); Notes.initscroll(); Notes.loaddark(); + Notes.loadfont(); }); document.addEventListener("wheel", function(e){ diff --git a/content/settings/display.xhtml b/content/settings/display.xhtml index 99a045d..31a2f8d 100644 --- a/content/settings/display.xhtml +++ b/content/settings/display.xhtml @@ -5,6 +5,7 @@ Header size Column width (for vertical) Font size + Font family Filter html (replace) diff --git a/content/settings/preferences.js b/content/settings/preferences.js index f44802c..c97a6fd 100644 --- a/content/settings/preferences.js +++ b/content/settings/preferences.js @@ -1,3 +1,8 @@ +if(typeof Zotero_Preferences == 'undefined') { + var Zotero_Preferences= { + }; +} + Zotero_Preferences.ZeNotes = { async init(){ if(!this.parser) @@ -273,8 +278,12 @@ Zotero_Preferences.ZeNotes = { ["header-size", "zn-header-size-val"], ["vertical-table", "zn-vertical-table"], ["font-size", "zn-font-size"], - ["font-size", "zn-font-size-val"] + ["font-size", "zn-font-size-val"], + ["font-family", "zn-font-family"], + ["font-family-secondary", "zn-font-family-secondary"], + ["custom-font-family", "zn-custom-font-family"] ]; + Zotero_Preferences.ZeNotes.loadfonts(); break; case 'translation': @@ -343,6 +352,29 @@ Zotero_Preferences.ZeNotes = { } }, + loadfonts() + { + var fontlist = ["Arial", "Verdana", "Tahoma", "Trebuchet MS", "Times New Roman", "Georgia", "Garamond", "Courier New", "Brush Script MT", "Times New Roman", "MS Mincho", "MS Gothic", "Microsoft MingLiU", "SimSun", "NSimSun", "SimHei", "system-ui"]; + var userfonts = Zotero.ZeNotes.Prefs.get("custom-font-family", ""); + try { + userfonts = userfonts.split(",").map(item => item.trim()); + fontlist = [...new Set([...fontlist, ...userfonts])]; + } + catch(e) + {} + + fontlist = fontlist.sort(); + + var sel = document.getElementById("zn-font-family"); + for(let font of fontlist) + { + let opt = document.createElementNS("http://www.w3.org/1999/xhtml", "option"); + opt.innerHTML = font; + opt.value = font; + sel.appendChild(opt); + } + }, + promptdataselection() { var fields = Zotero.ZeNotes.Filter.excludefields; diff --git a/content/settings/preferences.xhtml b/content/settings/preferences.xhtml index b4c06a1..c3d9b66 100644 --- a/content/settings/preferences.xhtml +++ b/content/settings/preferences.xhtml @@ -37,7 +37,7 @@

Global settings

Global display -
+
diff --git a/content/settings/zotero.js b/content/settings/zotero.js index 8430508..d5dedee 100644 --- a/content/settings/zotero.js +++ b/content/settings/zotero.js @@ -9,7 +9,7 @@ XPCOMUtils.defineLazyModuleGetters(this, { setTimeout: "resource://gre/modules/Timer.jsm", }); -if (typeof Zotero_Preferences == 'undefined') { +if(typeof Zotero_Preferences == 'undefined') { var Zotero_Preferences= { }; } \ No newline at end of file diff --git a/core/ai.js b/core/ai.js index 69bfc10..9c68dc5 100644 --- a/core/ai.js +++ b/core/ai.js @@ -85,7 +85,6 @@ Ai={ else if(mode=="bing") { try { - // Google translate without api key return Promise.resolve(data.map(function(e){return e[0]})); } catch(e) @@ -215,8 +214,6 @@ Ai.Bard = { }, body: JSON.stringify(payload), } - - return Ai.request(url, options, model); }, } @@ -281,7 +278,8 @@ Ai.DeepL = { } Ai.OpenAi = { - paraphrase(sentence){ + paraphrase(sentence) + { var model = Zotero.ZeNotes.Prefs.get("openai-model"); var defaultprompt = Zotero.ZeNotes.Prefs.get("paraphrase-custom-prompt"); if(!defaultprompt) @@ -348,6 +346,21 @@ Ai.OpenAi = { } return Ai.request(url, options, model); }, +} + +Ai.custom = { - -} \ No newline at end of file + async sendprompt(sentence, prompts) { + var apikey = Zotero.ZeNotes.Prefs.getb("custom-ai-api-key"); + var url = Zotero.ZeNotes.Prefs.get("custom-ai-url"); + var method = Zotero.ZeNotes.Prefs.get("custom-ai-method", "POST"); + var headers = Zotero.ZeNotes.Prefs.get("custom-ai-headers"); + var payload = Zotero.ZeNotes.Prefs.get("custom-ai-payload", ""); + var options = { + method: method, + headers: headers, + body: payload, + } + return Ai.request(url, options); + }, +} diff --git a/install.rdf b/install.rdf index da831b0..11f33cc 100644 --- a/install.rdf +++ b/install.rdf @@ -5,7 +5,7 @@ zenotes@alefa.net ZeNotes - 0.8.6 + 0.8.7 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 65c45e3..1e23f3f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Ze Notes", - "version": "0.8.6", + "version": "0.8.7", "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 a51ada1..5bf98d5 100644 --- a/zenote-update.json +++ b/zenote-update.json @@ -3,9 +3,9 @@ "zenotes@alefa.net": { "updates": [ { - "version": "0.8.6", - "update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.6/zenotes-v0.8.6.xpi", - "update_hash": "sha256:4e7ea16353b566369ea455cb97cc0663285dce684287f9eb43d63b24d4dc3e10", + "version": "0.8.7", + "update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.7/zenotes-v0.8.7.xpi", + "update_hash": "sha256:603a125444cd8fb84566b5e1cc05c77654faee7d494c7de24c679eec7b50d9fa", "applications": { "gecko": { "strict_min_version": "60.0" diff --git a/zenote-update.rdf b/zenote-update.rdf index c0ce128..7868191 100644 --- a/zenote-update.rdf +++ b/zenote-update.rdf @@ -5,13 +5,13 @@ - 0.8.6 + 0.8.7 zotero@chnm.gmu.edu 5.0.0 6.* - https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.6/zenotes-v0.8.6.xpi + https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.7/zenotes-v0.8.7.xpi @@ -20,7 +20,7 @@ juris-m@juris-m.github.io 4.999 6.* - https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.6/zenotes-v0.8.6.xpi + https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.7/zenotes-v0.8.7.xpi