From 47d4949b2a0522587536b9cb074641802b451cf2 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Wed, 22 Sep 2021 19:30:44 +0300 Subject: [PATCH] Upgrade note-editor schema to v5: - Make citation node a leaf node. - Don't parse citation node inner text. - Don't trigger citation inner text updating on citation item changes. - Format citation text only when serializing note HTML. - Wrap individual citation items into ``. --- chrome/content/zotero/xpcom/editorInstance.js | 11 ++++++----- note-editor | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/xpcom/editorInstance.js b/chrome/content/zotero/xpcom/editorInstance.js index d5198c4032..73d8937923 100644 --- a/chrome/content/zotero/xpcom/editorInstance.js +++ b/chrome/content/zotero/xpcom/editorInstance.js @@ -44,7 +44,7 @@ const DOWNLOADED_IMAGE_TYPE = [ ]; // Schema version here has to be the same as in note-editor! -const SCHEMA_VERSION = 4; +const SCHEMA_VERSION = 5; class EditorInstance { constructor() { @@ -372,8 +372,7 @@ class EditorInstance { let citationWithData = JSON.parse(JSON.stringify(citation)); citationWithData.citationItems[0].itemData = itemData; let formatted = this._formatCitation(citationWithData); - - citationHTML = `(${formatted})`; + citationHTML = `${formatted}`; } // Image @@ -440,7 +439,7 @@ class EditorInstance { properties: {} }; let formatted = this._formatCitation(citation); - html += `

(${formatted})

`; + html += `

${formatted}

`; } else if (item.isNote()) { let note = item.note; @@ -1133,7 +1132,9 @@ class EditorInstance { } _formatCitation(citation) { - return citation.citationItems.map(x => this._formatCitationItemPreview(x)).join('; '); + return '(' + citation.citationItems.map((x) => { + return `${this._formatCitationItemPreview(x)}`; + }).join('; ') + ')'; } _arrayBufferToBase64(buffer) { diff --git a/note-editor b/note-editor index 4ba41a4168..ddcba7de02 160000 --- a/note-editor +++ b/note-editor @@ -1 +1 @@ -Subproject commit 4ba41a41689448aecc21a72aec0559d39ca4509e +Subproject commit ddcba7de027099cdc5a792e2dc186a810e72d556