Clear undo history when switching notes
This prevents notes from being overwritten with each other's contents. This used to work right, but it was broken with the switch to rich-text notes.
This commit is contained in:
parent
512ae575fa
commit
5275dafbc9
4 changed files with 26 additions and 30 deletions
|
@ -308,27 +308,10 @@
|
||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<method name="disableUndo">
|
|
||||||
<body>
|
|
||||||
<![CDATA[
|
|
||||||
//this.noteField.editor.enableUndo(true);
|
|
||||||
]]>
|
|
||||||
</body>
|
|
||||||
</method>
|
|
||||||
|
|
||||||
<method name="enableUndo">
|
|
||||||
<body>
|
|
||||||
<![CDATA[
|
|
||||||
//this.noteField.editor.enableUndo(false);
|
|
||||||
]]>
|
|
||||||
</body>
|
|
||||||
</method>
|
|
||||||
|
|
||||||
<method name="clearUndo">
|
<method name="clearUndo">
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
this.disableUndo();
|
this._id('noteField').clearUndo();
|
||||||
this.enableUndo();
|
|
||||||
]]>
|
]]>
|
||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
|
|
|
@ -330,6 +330,14 @@
|
||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
|
<method name="clearUndo">
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
this._editor.undoManager.clear();
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
|
||||||
<field name="_loaded"/>
|
<field name="_loaded"/>
|
||||||
<method name="_load">
|
<method name="_load">
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -49,12 +49,16 @@ function onLoad() {
|
||||||
if (itemID) {
|
if (itemID) {
|
||||||
var ref = Zotero.Items.get(itemID);
|
var ref = Zotero.Items.get(itemID);
|
||||||
|
|
||||||
// Make sure Undo doesn't wipe out the note
|
var clearUndo = noteEditor.item ? noteEditor.item.id != ref.id : false;
|
||||||
if (!noteEditor.item || noteEditor.item.id != ref.id) {
|
|
||||||
noteEditor.disableUndo();
|
|
||||||
}
|
|
||||||
noteEditor.item = ref;
|
noteEditor.item = ref;
|
||||||
noteEditor.enableUndo();
|
|
||||||
|
// If loading new or different note, disable undo while we repopulate the text field
|
||||||
|
// so Undo doesn't end up clearing the field. This also ensures that Undo doesn't
|
||||||
|
// undo content from another note into the current one.
|
||||||
|
if (clearUndo) {
|
||||||
|
noteEditor.clearUndo();
|
||||||
|
}
|
||||||
|
|
||||||
document.title = ref.getNoteTitle();
|
document.title = ref.getNoteTitle();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1154,16 +1154,17 @@ var ZoteroPane = new function()
|
||||||
var noteEditor = document.getElementById('zotero-note-editor');
|
var noteEditor = document.getElementById('zotero-note-editor');
|
||||||
noteEditor.mode = this.collectionsView.editable ? 'edit' : 'view';
|
noteEditor.mode = this.collectionsView.editable ? 'edit' : 'view';
|
||||||
|
|
||||||
// If loading new or different note, disable undo while we repopulate the text field
|
var clearUndo = noteEditor.item ? noteEditor.item.id != item.id : false;
|
||||||
// so Undo doesn't end up clearing the field. This also ensures that Undo doesn't
|
|
||||||
// undo content from another note into the current one.
|
|
||||||
if (!noteEditor.item || noteEditor.item.id != item.id) {
|
|
||||||
noteEditor.disableUndo();
|
|
||||||
}
|
|
||||||
noteEditor.parent = null;
|
noteEditor.parent = null;
|
||||||
noteEditor.item = item;
|
noteEditor.item = item;
|
||||||
|
|
||||||
noteEditor.enableUndo();
|
// If loading new or different note, disable undo while we repopulate the text field
|
||||||
|
// so Undo doesn't end up clearing the field. This also ensures that Undo doesn't
|
||||||
|
// undo content from another note into the current one.
|
||||||
|
if (clearUndo) {
|
||||||
|
noteEditor.clearUndo();
|
||||||
|
}
|
||||||
|
|
||||||
var viewButton = document.getElementById('zotero-view-note-button');
|
var viewButton = document.getElementById('zotero-view-note-button');
|
||||||
if (this.collectionsView.editable) {
|
if (this.collectionsView.editable) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue