Freeze note schema version to 8

We can do it because it was only used to create a note from annotations.

No need to update schema version in Zotero client, unless using new
features when creating a note from annotations.
This commit is contained in:
Martynas Bagdonas 2022-07-25 18:04:00 +03:00
parent e1997620a4
commit 6733f2edca
3 changed files with 9 additions and 7 deletions

View file

@ -43,9 +43,6 @@ const DOWNLOADED_IMAGE_TYPE = [
'image/png' 'image/png'
]; ];
// Schema version here has to be the same as in note-editor!
const SCHEMA_VERSION = 8;
class EditorInstance { class EditorInstance {
constructor() { constructor() {
this.instanceID = Zotero.Utilities.randomString(); this.instanceID = Zotero.Utilities.randomString();
@ -1261,7 +1258,9 @@ class EditorInstance {
let { html: serializedHTML, citationItems } = Zotero.EditorInstanceUtilities.serializeAnnotations(jsonAnnotations, true); let { html: serializedHTML, citationItems } = Zotero.EditorInstanceUtilities.serializeAnnotations(jsonAnnotations, true);
html += serializedHTML; html += serializedHTML;
citationItems = encodeURIComponent(JSON.stringify(citationItems)); citationItems = encodeURIComponent(JSON.stringify(citationItems));
html = `<div data-citation-items="${citationItems}" data-schema-version="${SCHEMA_VERSION}">${html}</div>`; // Note: Update schema version only if using new features
let schemaVersion = 8;
html = `<div data-citation-items="${citationItems}" data-schema-version="${schemaVersion}">${html}</div>`;
note.setNote(html); note.setNote(html);
await note.saveTx(); await note.saveTx();
return note; return note;
@ -1556,5 +1555,4 @@ class EditorInstanceUtilities {
} }
Zotero.EditorInstance = EditorInstance; Zotero.EditorInstance = EditorInstance;
Zotero.EditorInstance.SCHEMA_VERSION = SCHEMA_VERSION;
Zotero.EditorInstanceUtilities = new EditorInstanceUtilities(); Zotero.EditorInstanceUtilities = new EditorInstanceUtilities();

@ -1 +1 @@
Subproject commit cf3afa60d846a23f29b7a8c48d99917e4f37cc33 Subproject commit 5920f9674eeef6da5b43128248b82033cbd0c471

View file

@ -304,7 +304,11 @@ describe("Item pane", function () {
// Wait for asynchronous editor update // Wait for asynchronous editor update
do { do {
yield Zotero.Promise.delay(10); yield Zotero.Promise.delay(10);
} while(noteEditor._editorInstance._iframeWindow.wrappedJSObject.getDataSync().html.replace(/\n/g,'') != `<div data-schema-version="${Zotero.EditorInstance.SCHEMA_VERSION}"><p>Test</p></div>`); } while (
!/<div data-schema-version=".*"><p>Test<\/p><\/div>/.test(
noteEditor._editorInstance._iframeWindow.wrappedJSObject.getDataSync().html.replace(/\n/g, '')
)
);
}); });
}); });