Track the inUndoState

This commit is contained in:
the-djmaze 2023-12-05 16:18:17 +01:00
parent 7e2cc69a23
commit 5d6fb0c705
2 changed files with 5 additions and 4 deletions

View file

@ -619,6 +619,7 @@ class SquireUI
// Move cursor above signature // Move cursor above signature
div.before(br); div.before(br);
div.before(br.cloneNode()); div.before(br.cloneNode());
// squire._docWasChanged();
} }
this._prev_txt_sig = signature; this._prev_txt_sig = signature;
} catch (e) { } catch (e) {

View file

@ -2034,14 +2034,14 @@ class EditStack extends Array
this[undoIndex] = html; this[undoIndex] = html;
this.index = undoIndex; this.index = undoIndex;
this.inUndoState = true; this.inUndoState = true;
} else {
console.error('EditStack in inUndoState');
} }
} }
saveUndoState(range) { saveUndoState(range) {
let squire = this.squire; let squire = this.squire;
if (range === undefined) { range = range || squire.getSelection();
range = squire.getSelection();
}
this.recordUndoState(range, true); this.recordUndoState(range, true);
squire._getRangeAndRemoveBookmark(range); squire._getRangeAndRemoveBookmark(range);
} }
@ -2617,7 +2617,6 @@ class Squire
const range = this._getRangeAndRemoveBookmark() || createRange(root.firstElementChild || root, 0); const range = this._getRangeAndRemoveBookmark() || createRange(root.firstElementChild || root, 0);
this.saveUndoState(range); this.saveUndoState(range);
this.setRange(range); this.setRange(range);
return this; return this;
} }
@ -3148,6 +3147,7 @@ class Squire
let node; let node;
let nodeAfterSplit; let nodeAfterSplit;
// TODO: why was _docWasChanged() not triggered?
this.editStack.inUndoState && this._docWasChanged(); this.editStack.inUndoState && this._docWasChanged();
this._recordUndoState(range); this._recordUndoState(range);
// self._config.addLinks && addLinks(range.startContainer, root); // self._config.addLinks && addLinks(range.startContainer, root);