Fix undo/redo not firing when in a text box.
This commit is contained in:
parent
65beb3509c
commit
03804cc476
1 changed files with 13 additions and 1 deletions
|
|
@ -76,7 +76,14 @@ function initGridWidget(root, opts = {}) {
|
||||||
const key = e.key.toLowerCase();
|
const key = e.key.toLowerCase();
|
||||||
const t = e.target;
|
const t = e.target;
|
||||||
|
|
||||||
if (t && root.contains(t) && (t.matches('input, textarea, select') || t.isContentEditable)) return;
|
const isTextField = t && root.contains(t) && (t.matches('input, textarea, select') || t.isContentEditable);
|
||||||
|
|
||||||
|
if (isTextField) {
|
||||||
|
const isUndo = (e.ctrlKey || e.metaKey) && key === 'z';
|
||||||
|
const isRedo = (e.ctrlKey || e.metaKey) && (key === 'y' || (key === 'z' && e.shiftKey));
|
||||||
|
|
||||||
|
if (!isUndo && !isRedo) return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((e.ctrlKey || e.metaKey) && key === 'z') {
|
if ((e.ctrlKey || e.metaKey) && key === 'z') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
@ -660,6 +667,11 @@ function initGridWidget(root, opts = {}) {
|
||||||
};
|
};
|
||||||
|
|
||||||
saveDoc(doc);
|
saveDoc(doc);
|
||||||
|
|
||||||
|
history.length = 0;
|
||||||
|
history.push(structuredClone(shapes));
|
||||||
|
historyIndex = 0;
|
||||||
|
|
||||||
redrawAll();
|
redrawAll();
|
||||||
} catch {
|
} catch {
|
||||||
toastMessage('Failed to load data from JSON file.', 'danger');
|
toastMessage('Failed to load data from JSON file.', 'danger');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue