Fix Undo behavior in notes (right pane and separate window) to not undo content from other notes into current one and to not undo to empty where possible
This commit is contained in:
parent
c357a25045
commit
6a71c39d91
|
@ -45,7 +45,14 @@ function onLoad()
|
|||
|
||||
if (itemID) {
|
||||
var ref = Zotero.Items.get(itemID);
|
||||
|
||||
// Make sure Undo doesn't wipe out the note
|
||||
if (!noteEditor.note || noteEditor.note.getID() != ref.getID()) {
|
||||
noteEditor.id('noteField').editor.enableUndo(false);
|
||||
}
|
||||
noteEditor.note = ref;
|
||||
noteEditor.id('noteField').editor.enableUndo(true);
|
||||
|
||||
document.title = ref.getNoteTitle();
|
||||
}
|
||||
else if (parentItemID) {
|
||||
|
@ -72,9 +79,18 @@ function onUnload()
|
|||
var NotifyCallback = {
|
||||
notify: function(action, type, ids){
|
||||
// DEBUG: why does this reset without checking the modified ids?
|
||||
if (noteEditor.note){
|
||||
if (noteEditor.note) {
|
||||
noteEditor.note = noteEditor.note;
|
||||
document.title = noteEditor.note.getNoteTitle();
|
||||
|
||||
// If the document title hasn't yet been set, reset undo so
|
||||
// undoing to empty isn't possible
|
||||
var noteTitle = noteEditor.note.getNoteTitle();
|
||||
if (!document.title && noteTitle != '') {
|
||||
noteEditor.id('noteField').editor.enableUndo(false);
|
||||
noteEditor.id('noteField').editor.enableUndo(true);
|
||||
document.title = noteTitle;
|
||||
}
|
||||
|
||||
// Update the window name (used for focusing) in case this is a new note
|
||||
window.name = 'zotero-note-' + noteEditor.note.getID();
|
||||
}
|
||||
|
|
|
@ -763,8 +763,18 @@ var ZoteroPane = new function()
|
|||
if(item.isNote())
|
||||
{
|
||||
var noteEditor = document.getElementById('zotero-note-editor');
|
||||
|
||||
// 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 (!noteEditor.note || noteEditor.note.getID() != item.ref.getID()) {
|
||||
noteEditor.id('noteField').editor.enableUndo(false);
|
||||
}
|
||||
noteEditor.item = null;
|
||||
noteEditor.note = item.ref;
|
||||
|
||||
noteEditor.id('noteField').editor.enableUndo(true);
|
||||
|
||||
document.getElementById('zotero-view-note-button').setAttribute('noteID',item.ref.getID());
|
||||
if(item.ref.getSource())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user