From 82dfb82b21a00c640c7c6e3c6dc3eb7d65069e1e Mon Sep 17 00:00:00 2001 From: "Rodopho Cammarosano de Lima (rcdl)" Date: Thu, 26 Jan 2023 11:27:18 +0000 Subject: [PATCH] [REM] web_editor: remove table-related code from toolbar The UI elements related to table creation and edition are no longer present in the toolbar, as the Wysiwyg and SnippetEditor instances remove the `#table` div section from toolbar. Furthermore, the OdooEditor instantiates a TablePicker instance to be appended to the tablepicker dropdown menu under the (inexistant) #table div in the toolbar. This commit removes dead code related to table creation/edition via the toolbar. task-3074598 Part-of: odoo/odoo#111131 --- .../static/src/xml/mass_mailing.editor.xml | 3 -- .../js/editor/odoo-editor/src/OdooEditor.js | 16 ---------- .../src/js/editor/odoo-editor/src/style.scss | 4 +-- .../static/src/js/editor/snippets.editor.js | 1 - .../static/src/js/wysiwyg/wysiwyg.js | 3 +- addons/web_editor/static/src/xml/editor.xml | 30 ------------------- 6 files changed, 3 insertions(+), 54 deletions(-) diff --git a/addons/mass_mailing/static/src/xml/mass_mailing.editor.xml b/addons/mass_mailing/static/src/xml/mass_mailing.editor.xml index 3e3bff26429..5557cf79bf6 100644 --- a/addons/mass_mailing/static/src/xml/mass_mailing.editor.xml +++ b/addons/mass_mailing/static/src/xml/mass_mailing.editor.xml @@ -4,8 +4,5 @@ - - - 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 5b69160db6a..37eed349ea9 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 @@ -344,14 +344,6 @@ export class OdooEditor extends EventTarget { colNumber: ev.detail.colNumber, }); }); - // Create the table picker for the toolbar. - this.toolbarTablePicker = new TablePicker({ document: this.document }); - this.toolbarTablePicker.addEventListener('cell-selected', ev => { - this.execCommand('insertTable', { - rowNumber: ev.detail.rowNumber, - colNumber: ev.detail.colNumber, - }); - }); // Create the table UI. const parser = new DOMParser(); for (const direction of ['row', 'column']) { @@ -634,14 +626,6 @@ export class OdooEditor extends EventTarget { // Ensure anchors in the toolbar don't trigger a hash change. const toolbarAnchors = this.toolbar.querySelectorAll('a'); toolbarAnchors.forEach(a => a.addEventListener('click', e => e.preventDefault())); - const tablepickerDropdown = this.toolbar.querySelector('.oe-tablepicker-dropdown'); - tablepickerDropdown && tablepickerDropdown.append(this.toolbarTablePicker.el); - this.toolbarTablePicker.show(); - const tableDropdownButton = this.toolbar.querySelector('#tableDropdownButton'); - tableDropdownButton && - tableDropdownButton.addEventListener('click', () => { - this.toolbarTablePicker.reset(); - }); for (const colorLabel of this.toolbar.querySelectorAll('label')) { colorLabel.addEventListener('mousedown', ev => { // Hack to prevent loss of focus (done by preventDefault) while still opening diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/style.scss b/addons/web_editor/static/src/js/editor/odoo-editor/src/style.scss index 542a916366b..2a9bf83bb58 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/style.scss +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/style.scss @@ -223,7 +223,7 @@ } } -.oe-tablepicker-dropdown .oe-tablepicker { +.oe-tablepicker { margin: -3px 2px -6px 2px; } .oe-tablepicker-wrapper.oe-floating { @@ -261,7 +261,7 @@ text-align: center; margin-top: 7px; } -.oe-tablepicker-dropdown .oe-tablepicker-size { +.oe-tablepicker-size { color: white; } @media only screen and (max-width: 767px) { diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 28a20cd4e06..0ce3b2b266e 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -4057,7 +4057,6 @@ var SnippetsMenu = Widget.extend({ this._$removeFormatButton = this._$removeFormatButton || this.options.wysiwyg.toolbar.$el.find('#removeFormat'); $title.append(this._$removeFormatButton); - this.options.wysiwyg.toolbar.$el.find('#table').remove(); this._checkEditorToolbarVisibility(); }, diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index ad8ff8eb198..be627b30ba3 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1490,7 +1490,7 @@ const Wysiwyg = Widget.extend({ } }; if (!this.options.snippets) { - $toolbar.find('#justify, #table, #media-insert').remove(); + $toolbar.find('#justify, #media-insert').remove(); } $toolbar.find('#media-insert, #media-replace, #media-description').click(openTools); $toolbar.find('#create-link').click(openTools); @@ -1867,7 +1867,6 @@ const Wysiwyg = Widget.extend({ '#justifyFull', '#list', '#colorInputButtonGroup', - '#table', '#create-link', '#media-insert', // "Insert media" should be replaced with "Replace media". ].join(',')).toggleClass('d-none', isInMedia); diff --git a/addons/web_editor/static/src/xml/editor.xml b/addons/web_editor/static/src/xml/editor.xml index ec60ab859f8..afda59e56d8 100644 --- a/addons/web_editor/static/src/xml/editor.xml +++ b/addons/web_editor/static/src/xml/editor.xml @@ -126,36 +126,6 @@ -
- - -
-