diff --git a/chrome/content/zotero/bindings/oldnoteeditor.xml b/chrome/content/zotero/bindings/oldnoteeditor.xml
new file mode 100644
index 0000000000..35f8af0c3c
--- /dev/null
+++ b/chrome/content/zotero/bindings/oldnoteeditor.xml
@@ -0,0 +1,578 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+ "view"
+
+
+ ed.setMode('readonly'));
+ }
+ break;
+
+ case 'edit':
+ if (this.noteField) {
+ this.noteField.onInit(ed => ed.setMode('design'));
+ }
+ this.editable = true;
+ this.saveOnEdit = true;
+ this.parentClickHandler = this.selectParent;
+ this.keyDownHandler = this.handleKeyDown;
+ this.commandHandler = this.save;
+ this.displayTags = true;
+ this.displayRelated = true;
+ break;
+
+ default:
+ throw ("Invalid mode '" + val + "' in noteeditor.xml");
+ }
+
+ this._mode = val;
+ document.getAnonymousNodes(this)[0].setAttribute('mode', val);
+ this._id('links-box').mode = val;
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ if (!noteField.hasFocus()) {
+ document.getElementById(id).focus();
+ }
+ }, 0);
+ }
+ return;
+ }
+
+ break;
+ }
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0) {
+ var x = this.boxObject.screenX;
+ var y = this.boxObject.screenY;
+ this.id('relatedPopup').openPopupAtScreen(x, y, false);
+ }
+ else {
+ this.id('related').add();
+ }
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/chrome/content/zotero/containers/noteEditor.xul b/chrome/content/zotero/noteBackup.js
similarity index 53%
rename from chrome/content/zotero/containers/noteEditor.xul
rename to chrome/content/zotero/noteBackup.js
index e0c0d45b35..e227a78457 100644
--- a/chrome/content/zotero/containers/noteEditor.xul
+++ b/chrome/content/zotero/noteBackup.js
@@ -1,8 +1,7 @@
-
-
- %globalDTD;
- %zoteroDTD;
- ]>
+*/
-
-
-
-
-
\ No newline at end of file
+var noteEditor;
+
+async function onLoad() {
+ noteEditor = document.getElementById('zotero-note-editor');
+ noteEditor.mode = 'view';
+
+ // Set font size from pref
+ Zotero.setFontSize(noteEditor);
+
+ if (window.arguments) {
+ var io = window.arguments[0];
+ }
+
+ var itemID = parseInt(io.itemID);
+
+ var item = await Zotero.Items.getAsync(itemID);
+
+ let note = await Zotero.NoteBackups.getNote(item.id);
+ if (!note) {
+ note = item.getNote();
+ }
+
+ var tmpItem = new Zotero.Item('note');
+ tmpItem.libraryID = item.libraryID;
+ tmpItem.setNote(note);
+ noteEditor.item = tmpItem;
+ document.title = 'BACKUP OF: ' + item.getNoteTitle();
+
+ noteEditor.focus();
+}
+
+addEventListener("load", function(e) { onLoad(e); }, false);
diff --git a/chrome/content/zotero/noteBackup.xul b/chrome/content/zotero/noteBackup.xul
new file mode 100644
index 0000000000..a757c294b1
--- /dev/null
+++ b/chrome/content/zotero/noteBackup.xul
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/chrome/content/zotero/xpcom/editorInstance.js b/chrome/content/zotero/xpcom/editorInstance.js
index 01950e12b6..2b98b36032 100644
--- a/chrome/content/zotero/xpcom/editorInstance.js
+++ b/chrome/content/zotero/xpcom/editorInstance.js
@@ -347,6 +347,7 @@ class EditorInstance {
}
// Update note
if (this._item) {
+ await Zotero.NoteBackups.ensureBackup(this._item);
await Zotero.DB.executeTransaction(async () => {
let changed = this._item.setNote(html, schemaVersion);
if (changed && this._saveOnEdit) {
diff --git a/chrome/content/zotero/xpcom/noteBackups.js b/chrome/content/zotero/xpcom/noteBackups.js
new file mode 100644
index 0000000000..9804aa0926
--- /dev/null
+++ b/chrome/content/zotero/xpcom/noteBackups.js
@@ -0,0 +1,40 @@
+/*
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2020 Corporation for Digital Scholarship
+ Vienna, Virginia, USA
+ http://digitalscholar.org/
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see .
+
+ ***** END LICENSE BLOCK *****
+*/
+
+Zotero.NoteBackups = {
+ init: async function () {
+ await Zotero.DB.queryAsync("CREATE TABLE IF NOT EXISTS noteBackups (\n itemID INTEGER PRIMARY KEY,\n note TEXT,\n FOREIGN KEY (itemID) REFERENCES items(itemID) ON DELETE CASCADE\n);");
+ },
+
+ getNote: async function(itemID) {
+ return Zotero.DB.valueQueryAsync("SELECT note FROM noteBackups WHERE itemID=?", [itemID]);
+ },
+
+ ensureBackup: async function(item) {
+ if (item.noteSchemaVersion === 0) {
+ await Zotero.DB.queryAsync("INSERT OR IGNORE INTO noteBackups VALUES (?, ?)", [item.id, item.note]);
+ }
+ },
+};
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
index 28617e491e..9c3d2d4533 100644
--- a/chrome/content/zotero/xpcom/zotero.js
+++ b/chrome/content/zotero/xpcom/zotero.js
@@ -719,6 +719,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
yield Zotero.Groups.init();
yield Zotero.Relations.init();
yield Zotero.Retractions.init();
+ yield Zotero.NoteBackups.init();
// Migrate fields from Extra that can be moved to item fields after a schema update
yield Zotero.Schema.migrateExtraFields();
diff --git a/chrome/skin/default/zotero/zotero.css b/chrome/skin/default/zotero/zotero.css
index 4d0b9bf208..8b591d8ac9 100644
--- a/chrome/skin/default/zotero/zotero.css
+++ b/chrome/skin/default/zotero/zotero.css
@@ -46,9 +46,9 @@ zoteronoteeditor
-moz-binding: url('chrome://zotero/content/bindings/noteeditor.xml#note-editor');
}
-zoteronoteeditor2
+oldzoteronoteeditor
{
- -moz-binding: url('chrome://zotero/content/bindings/noteeditor2.xml#note-editor');
+ -moz-binding: url('chrome://zotero/content/bindings/oldnoteeditor.xml#note-editor');
}
linksbox
diff --git a/components/zotero-service.js b/components/zotero-service.js
index 5092f1556c..7cb2dd8ecb 100644
--- a/components/zotero-service.js
+++ b/components/zotero-service.js
@@ -105,6 +105,7 @@ const xpcomFilesLocal = [
'locale',
'locateManager',
'mime',
+ 'noteBackups',
'notifier',
'openPDF',
'viewer',