[IMP] web_editor: add label to prepareUpdate
This adds a label to the prepareUpdate function to be able to easily track which update is being restored when debugging. X-original-commit: 5bb8a5a9b5d54ebe93c473087981e3464cd61368 Part-of: odoo/odoo#138549
This commit is contained in:
@@ -2082,7 +2082,10 @@ export class OdooEditor extends EventTarget {
|
||||
splitTextNode(start, startOffset);
|
||||
startOffset = 0;
|
||||
}
|
||||
const restoreUpdate = prepareUpdate(...boundariesOut(start).slice(0, 2), ...boundariesOut(end).slice(2, 4), { allowReenter: false });
|
||||
const restoreUpdate = prepareUpdate(
|
||||
...boundariesOut(start).slice(0, 2),
|
||||
...boundariesOut(end).slice(2, 4),
|
||||
{ allowReenter: false, label: 'deleteRange' });
|
||||
|
||||
// Let the DOM split and delete the range.
|
||||
const contents = range.extractContents();
|
||||
|
||||
@@ -2080,13 +2080,16 @@ const prepareUpdateLockedEditables = new Set();
|
||||
* @param {Object} [options]
|
||||
* @param {boolean} [options.allowReenter = true] - if false, all calls to
|
||||
* prepareUpdate before this one gets restored will be ignored.
|
||||
* @param {string} [options.label = <random 6 character string>]
|
||||
* @returns {function}
|
||||
*/
|
||||
export function prepareUpdate(...args) {
|
||||
const closestRoot = args.length && ancestors(args[0]).find(ancestor => ancestor.oid === 'root');
|
||||
const isPrepareUpdateLocked = closestRoot && prepareUpdateLockedEditables.has(closestRoot);
|
||||
const hash = (Math.random() + 1).toString(36).substring(7);
|
||||
const options = {
|
||||
allowReenter: true,
|
||||
label: hash,
|
||||
...(args.length && args[args.length - 1] instanceof Object ? args.pop() : {}),
|
||||
};
|
||||
if (isPrepareUpdateLocked) {
|
||||
|
||||
Reference in New Issue
Block a user