Prevent Undo from clearing existing note
When loading the first note of a session in the right-hand pane or when loading a note in the separate window, if you made a change and then pressed Undo twice (or maybe only once in some situations), it could undo to empty (though you could usually Redo to restore it).
This commit is contained in:
parent
bf122add81
commit
724329d948
2 changed files with 6 additions and 15 deletions
|
@ -605,6 +605,7 @@
|
|||
<![CDATA[
|
||||
if (this._editor) {
|
||||
this._editor.undoManager.clear();
|
||||
this._editor.undoManager.add();
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
|
@ -690,6 +691,10 @@
|
|||
}
|
||||
if (self._value) {
|
||||
self.value = self._value;
|
||||
|
||||
// Prevent undoing to empty note after initialization
|
||||
self._editor.undoManager.clear();
|
||||
self._editor.undoManager.add();
|
||||
}
|
||||
if (self._focus) {
|
||||
setTimeout(function () {
|
||||
|
|
|
@ -43,18 +43,7 @@ async function onLoad() {
|
|||
|
||||
if (itemID) {
|
||||
var ref = await Zotero.Items.getAsync(itemID);
|
||||
|
||||
// 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.
|
||||
let clearUndo = noteEditor.item ? noteEditor.item.id != itemID : false;
|
||||
|
||||
noteEditor.item = ref;
|
||||
|
||||
if (clearUndo) {
|
||||
noteEditor.clearUndo();
|
||||
}
|
||||
|
||||
document.title = ref.getNoteTitle();
|
||||
}
|
||||
else {
|
||||
|
@ -96,12 +85,9 @@ function onUnload() {
|
|||
|
||||
var NotifyCallback = {
|
||||
notify: function(action, type, ids){
|
||||
if (noteEditor.item && ids.indexOf(noteEditor.item.id) != -1) {
|
||||
// If the document title hasn't yet been set, reset undo so
|
||||
// undoing to empty isn't possible
|
||||
if (noteEditor.item && ids.includes(noteEditor.item.id)) {
|
||||
var noteTitle = noteEditor.item.getNoteTitle();
|
||||
if (!document.title && noteTitle != '') {
|
||||
noteEditor.clearUndo();
|
||||
document.title = noteTitle;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue