diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js index 584251b90bb..de69c9de751 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js @@ -1086,13 +1086,11 @@ export class OdooEditor extends EventTarget { return; } - let currentIndex; let concurentSteps = []; index++; while (index < this._historySteps.length) { if (this._historySteps[index].previousStepId === newStep.previousStepId) { if (this._historySteps[index].id.localeCompare(newStep.id) === 1) { - currentIndex = index; break; } else { concurentSteps = [this._historySteps[index].id]; @@ -1101,13 +1099,11 @@ export class OdooEditor extends EventTarget { if (concurentSteps.includes(this._historySteps[index].previousStepId)) { concurentSteps.push(this._historySteps[index].id); } else { - currentIndex = index; break; } } index++; } - currentIndex = typeof currentIndex !== 'undefined' ? currentIndex : index; const stepsAfterNewStep = this._historySteps.slice(index); @@ -1184,7 +1180,7 @@ export class OdooEditor extends EventTarget { } clientRects = Array.from(range.getClientRects()); - } catch (e) { + } catch { // Changes in the dom might prevent the range to be instantiated // (because of a removed node for example), in which case we ignore // the range. diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js index c861ab931ac..eaa161ffe5e 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js @@ -533,16 +533,6 @@ function deleteTable(editor, table) { setSelection(p, 0); } -function getTextNodes(editor) { - const selection = editor.document.getSelection(); - if (!selection.rangeCount || selection.getRangeAt(0).collapsed) { - return null; - } - getDeepRange(editor.editable, { splitText: true, select: true, correctTripleClick: true }); - return getSelectedNodes(editor.editable) - .filter(n => n.nodeType === Node.TEXT_NODE && n.nodeValue.trim().length); -} - // This is a whitelist of the commands that are implemented by the // editor itself rather than the node prototypes. It might be // possible to switch the conditions and test if the method exist on diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/deleteBackward.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/deleteBackward.js index a0c24356be0..05524c01692 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/deleteBackward.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/deleteBackward.js @@ -1,5 +1,5 @@ /** @odoo-module **/ -import { UNBREAKABLE_ROLLBACK_CODE, UNREMOVABLE_ROLLBACK_CODE } from '../utils/constants.js'; +import { UNREMOVABLE_ROLLBACK_CODE } from '../utils/constants.js'; import { boundariesOut, childNodeIndex, diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/sanitize.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/sanitize.js index 498f83bd6e7..5d3939836ee 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/sanitize.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/sanitize.js @@ -13,7 +13,6 @@ import { isMediaElement, getDeepRange, isUnbreakable, - isUnremovable } from './utils.js'; const NOT_A_NUMBER = /[^\d]/g; diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js index c02366648ce..9b9c754eb56 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js @@ -717,7 +717,7 @@ export function getDeepRange(editable, { range, sel, splitText, select, correctT sel.addRange(range); try { sel.extend(end, endOffset); - } catch (e) { + } catch { // Firefox yells not happy when setting selection on elem with contentEditable=false. } range = sel.getRangeAt(0); diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/test/editor-test.html b/addons/web_editor/static/src/js/editor/odoo-editor/test/editor-test.html index 2ee7f1b8e28..074e67e176f 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/test/editor-test.html +++ b/addons/web_editor/static/src/js/editor/odoo-editor/test/editor-test.html @@ -20,7 +20,7 @@ vertical-align: middle; } - + diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js index f68c343c201..677309d6318 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js @@ -1,5 +1,5 @@ import { - BasicEditor, customErrorMessage, + BasicEditor, testEditor } from "../utils.js"; import {CLIPBOARD_WHITELISTS} from "../../src/OdooEditor.js"; diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/editor.test.js b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/editor.test.js index 26ce1c8ef4f..a55b460fc6a 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/editor.test.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/editor.test.js @@ -1,6 +1,6 @@ import { applyInlineStyle } from '../../src/commands/commands.js'; import { OdooEditor } from '../../src/OdooEditor.js'; -import { getTraversedNodes, setCursorStart } from '../../src/utils/utils.js'; +import { getTraversedNodes } from '../../src/utils/utils.js'; import { BasicEditor, deleteBackward, diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/utils.test.js b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/utils.test.js index ffb24ae6b1f..7ed44a59565 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/utils.test.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/utils.test.js @@ -797,7 +797,6 @@ describe('Utils', () => {