[FIX] web_editor, website: consistently apply undo on CTRL-Z
This fixes a bug in Website, that can be reproduced like so: - insert a snippet - insert a char in it - 2x CTRL-Z The second CTRL-Z didn't do anything because Summernote moved the range to the header, which is not editable. This fix moves the range to the first editable element in the editor in these cases, thereby keeping the focus in an editable area, and ensuring that hotkeys still function. The history feature being non-tested as of this version, no test could be added for this fix. closes odoo/odoo#34834 Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
This commit is contained in:
committed by
Adrien Dieudonne
parent
c526715110
commit
2136ea5646
@@ -19,6 +19,12 @@ var HistoryPlugin = Plugins.history.extend({
|
||||
console.error(e);
|
||||
}
|
||||
this.context.invoke('editor.focus');
|
||||
var newRange = this.context.invoke('editor.createRange');
|
||||
if (!this.options.isEditableNode(newRange.sc)) {
|
||||
var firstEditableSel = '[contenteditable="true"]:not(":hidden")';
|
||||
var sc = this.$editable.find(firstEditableSel)[0];
|
||||
this.context.invoke('editor.setRange', sc, 0, sc, 0).select();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Clear the history.
|
||||
|
||||
Reference in New Issue
Block a user