From 16199d63a26f3cbdf9afd63170454f35b60f8ec3 Mon Sep 17 00:00:00 2001 From: Justine Doutreloux Date: Wed, 25 Oct 2023 11:24:08 +0200 Subject: [PATCH] [IMP] web_widget_ck_editor: pre-commit stuff --- .../odoo/addons/web_widget_ckeditor | 1 + setup/web_widget_ckeditor/setup.py | 6 +++ .../static/src/js/field_ckeditor.js | 43 +++++++++++-------- .../static/src/js/field_html_override.js | 2 +- 4 files changed, 32 insertions(+), 20 deletions(-) create mode 120000 setup/web_widget_ckeditor/odoo/addons/web_widget_ckeditor create mode 100644 setup/web_widget_ckeditor/setup.py diff --git a/setup/web_widget_ckeditor/odoo/addons/web_widget_ckeditor b/setup/web_widget_ckeditor/odoo/addons/web_widget_ckeditor new file mode 120000 index 000000000..79281285a --- /dev/null +++ b/setup/web_widget_ckeditor/odoo/addons/web_widget_ckeditor @@ -0,0 +1 @@ +../../../../web_widget_ckeditor \ No newline at end of file diff --git a/setup/web_widget_ckeditor/setup.py b/setup/web_widget_ckeditor/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_widget_ckeditor/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_widget_ckeditor/static/src/js/field_ckeditor.js b/web_widget_ckeditor/static/src/js/field_ckeditor.js index 0f212abe4..6e7b55899 100644 --- a/web_widget_ckeditor/static/src/js/field_ckeditor.js +++ b/web_widget_ckeditor/static/src/js/field_ckeditor.js @@ -3,7 +3,7 @@ @author Iván Todorovich License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ -odoo.define("web_widget_ckeditor.field_ckeditor", function (require) { +odoo.define("web_widget_ckeditor.field_ckeditor", function(require) { "use strict"; const core = require("web.core"); @@ -49,7 +49,7 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) { /** * @override */ - willStart: function () { + willStart: function() { return Promise.all([ this._super.apply(this, arguments), loadCKEditorLanguagePromise, @@ -59,7 +59,7 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) { /** * @override */ - destroy: function () { + destroy: function() { if (this.ckeditor) { this.ckeditor.destroy(); this.ckeditor = undefined; @@ -74,7 +74,7 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) { /** * @override */ - activate: function () { + activate: function() { if (this.ckeditor) { this.ckeditor.focus(); return true; @@ -85,11 +85,14 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) { * * @override */ - isSet: function () { + isSet: function() { // Removing spaces & html spaces const value = this.value && - this.value.split(" ").join("").replace(/\s/g, ""); + this.value + .split(" ") + .join("") + .replace(/\s/g, ""); return ( value && value !== "

" && @@ -102,7 +105,7 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) { * * @override */ - getFocusableElement: function () { + getFocusableElement: function() { return this.$target || $(); }, /** @@ -111,7 +114,7 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) { * * @override */ - reset: function (record, event) { + reset: function(record, event) { this._reset(record, event); const value = this._textToHtml(this.value); if (!event || event.target !== this) { @@ -131,7 +134,7 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) { /** * @override */ - _getValue: function () { + _getValue: function() { if (this.mode === "edit" && this.ckeditor) { return this.ckeditor.getData(); } @@ -141,11 +144,11 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) { * Gets the CKEditor toolbar items configuration. * If not found, returns the default configuration. */ - _getCKEditorToolbarItems: async function () { + _getCKEditorToolbarItems: async function() { try { const ckconfig = await getCKEditorConfigPromise; if (ckconfig.toolbar) { - return ckconfig.toolbar.split(/[\s,]+/).filter((item) => item); + return ckconfig.toolbar.split(/[\s,]+/).filter(item => item); } } catch (error) { console.warn( @@ -193,7 +196,7 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) { * * @returns EditorConfig */ - _getCKEditorConfig: async function () { + _getCKEditorConfig: async function() { const res = { toolbar: { items: await this._getCKEditorToolbarItems(), @@ -231,7 +234,7 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) { * @private * @returns {$.Promise} */ - _createCKEditorIntance: async function () { + _createCKEditorIntance: async function() { const editorConfig = await this._getCKEditorConfig(); this.ckeditor = await window.ClassicEditor.create( this.$target.get(0), @@ -248,16 +251,18 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) { /** * @override */ - _renderEdit: function () { + _renderEdit: function() { const value = this._textToHtml(this.value); - this.$target = $("