From 17deb1677922eeebfa128a0a4cf27ffa1bbce920 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Mon, 17 Jul 2023 11:56:35 +0300 Subject: [PATCH] Add partial underline annotation support for note-editor (changes to note-editor have to be merged to have full support) --- chrome/content/zotero/xpcom/editorInstance.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/editorInstance.js b/chrome/content/zotero/xpcom/editorInstance.js index 1869148db3..64455570dc 100644 --- a/chrome/content/zotero/xpcom/editorInstance.js +++ b/chrome/content/zotero/xpcom/editorInstance.js @@ -1394,8 +1394,13 @@ class EditorInstance { } } citationItems = encodeURIComponent(JSON.stringify(citationItems)); - // Note: Update schema version only if using new features - let schemaVersion = 8; + // Note: Update schema version only if using new features. + let schemaVersion = 9; + // If using underline annotations, increase schema version number + // TODO: Can be removed once most clients support schema version 10 + if (schemaVersion === 9 && annotations.some(x => x.annotationType === 'underline')) { + schemaVersion = 10; + } html = `
${html}
`; note.setNote(html); await note.saveTx(); @@ -1494,8 +1499,8 @@ class EditorInstanceUtilities { // Text if (annotation.text) { let text = this._transformTextToHTML(annotation.text.trim()); - highlightHTML = `${text}`; - quotedHighlightHTML = `${Zotero.getString('punctuation.openingQMark')}${text}${Zotero.getString('punctuation.closingQMark')}`; + highlightHTML = `${text}`; + quotedHighlightHTML = `${Zotero.getString('punctuation.openingQMark')}${text}${Zotero.getString('punctuation.closingQMark')}`; } // Note @@ -1504,7 +1509,7 @@ class EditorInstanceUtilities { } let template; - if (annotation.type === 'highlight') { + if (['highlight', 'underline'].includes(annotation.type)) { template = Zotero.Prefs.get('annotations.noteTemplates.highlight'); } else if (annotation.type === 'note') {