From b5edc0d9c18bdf0c11cef348c3cac2161e0f7219 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Thu, 17 Jun 2021 14:03:33 +0300 Subject: [PATCH] Reorganize note-editor toolbar --- chrome/content/zotero/xpcom/editorInstance.js | 62 +++++++++++-------- chrome/locale/en-US/zotero/zotero.properties | 12 ++++ note-editor | 2 +- 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/chrome/content/zotero/xpcom/editorInstance.js b/chrome/content/zotero/xpcom/editorInstance.js index 5b638afa59..c3fd3c70e3 100644 --- a/chrome/content/zotero/xpcom/editorInstance.js +++ b/chrome/content/zotero/xpcom/editorInstance.js @@ -746,36 +746,48 @@ class EditorInstance { } _openPopup(x, y, pos, itemGroups) { + let appendItems = (parentNode, itemGroups) => { + for (let itemGroup of itemGroups) { + for (let item of itemGroup) { + if (item.groups) { + let menu = parentNode.ownerDocument.createElement('menu'); + menu.setAttribute('label', item.label); + let menupopup = parentNode.ownerDocument.createElement('menupopup'); + menu.append(menupopup); + appendItems(menupopup, item.groups); + parentNode.appendChild(menu); + } + else { + let menuitem = parentNode.ownerDocument.createElement('menuitem'); + menuitem.setAttribute('value', item.name); + menuitem.setAttribute('label', item.label); + menuitem.setAttribute('disabled', !item.enabled); + menuitem.setAttribute('checked', item.checked); + menuitem.addEventListener('command', () => { + this._postMessage({ + action: 'contextMenuAction', + ctxAction: item.name, + pos + }); + }); + parentNode.appendChild(menuitem); + } + } + + if (itemGroups.indexOf(itemGroup) !== itemGroups.length - 1) { + let separator = parentNode.ownerDocument.createElement('menuseparator'); + parentNode.appendChild(separator); + } + } + }; + this._popup.hidePopup(); while (this._popup.firstChild) { this._popup.removeChild(this._popup.firstChild); } - - for (let itemGroup of itemGroups) { - for (let item of itemGroup) { - let menuitem = this._popup.ownerDocument.createElement('menuitem'); - menuitem.setAttribute('value', item.name); - menuitem.setAttribute('label', item.label); - if (!item.enabled) { - menuitem.setAttribute('disabled', true); - } - menuitem.addEventListener('command', () => { - this._postMessage({ - action: 'contextMenuAction', - ctxAction: item.name, - pos - }); - }); - this._popup.appendChild(menuitem); - } - - if (itemGroups.indexOf(itemGroup) !== itemGroups.length - 1) { - let separator = this._popup.ownerDocument.createElement('menuseparator'); - this._popup.appendChild(separator); - } - } - + + appendItems(this._popup, itemGroups); this._popup.openPopupAtScreen(x, y, true); } diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 8cebfc2d2b..b0431d84c6 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -80,6 +80,12 @@ general.item = Item general.pdf = PDF general.back = Back +general.yellow = Yellow +general.red = Red +general.green = Green +general.blue = Blue +general.purple = Purple + general.operationInProgress = A Zotero operation is currently in progress. general.operationInProgress.waitUntilFinished = Please wait until it has finished. general.operationInProgress.waitUntilFinishedAndTryAgain = Please wait until it has finished and try again. @@ -1279,9 +1285,14 @@ noteEditor.bulletList = Bulleted List noteEditor.orderedList = Numbered List noteEditor.blockquote = Block Quote noteEditor.formatText = Format Text +noteEditor.highlightText = Highlight Text +noteEditor.removeColor = Remove Color noteEditor.bold = Bold noteEditor.italic = Italic noteEditor.underline = Underline +noteEditor.strikethrough = Strikethrough +noteEditor.subscript = Subscript +noteEditor.superscript = Superscript noteEditor.returnToNotesList = Return to Notes List noteEditor.insertLink = Insert Link noteEditor.clearFormatting = Clear Formatting @@ -1310,6 +1321,7 @@ noteEditor.addCitation = Add Citation noteEditor.findAndReplace = Find and Replace noteEditor.showInLibrary = Show in Library noteEditor.editInWindow = Edit in a Separate Window +noteEditor.applyAnnotationColors = Apply Annotation Colors pdfReader.annotations = Annotations pdfReader.showAnnotations = Show Annotations diff --git a/note-editor b/note-editor index c801eb5df1..0651ded628 160000 --- a/note-editor +++ b/note-editor @@ -1 +1 @@ -Subproject commit c801eb5df1b15b73e118494a7dffb9c86f55ba29 +Subproject commit 0651ded628bb5a00b0b471ea5d43cf9fac015361