[IMP] web_widget_ck_editor: pre-commit stuff

pull/2373/head
Justine Doutreloux 2023-10-25 11:24:08 +02:00
parent 97e1bdbb46
commit 16199d63a2
4 changed files with 32 additions and 20 deletions

View File

@ -0,0 +1 @@
../../../../web_widget_ckeditor

View File

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

View File

@ -89,7 +89,10 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) {
// Removing spaces & html spaces // Removing spaces & html spaces
const value = const value =
this.value && this.value &&
this.value.split(" ").join("").replace(/\s/g, ""); this.value
.split(" ")
.join("")
.replace(/\s/g, "");
return ( return (
value && value &&
value !== "<p></p>" && value !== "<p></p>" &&
@ -145,7 +148,7 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) {
try { try {
const ckconfig = await getCKEditorConfigPromise; const ckconfig = await getCKEditorConfigPromise;
if (ckconfig.toolbar) { if (ckconfig.toolbar) {
return ckconfig.toolbar.split(/[\s,]+/).filter((item) => item); return ckconfig.toolbar.split(/[\s,]+/).filter(item => item);
} }
} catch (error) { } catch (error) {
console.warn( console.warn(
@ -250,7 +253,9 @@ odoo.define("web_widget_ckeditor.field_ckeditor", function (require) {
*/ */
_renderEdit: function() { _renderEdit: function() {
const value = this._textToHtml(this.value); const value = this._textToHtml(this.value);
this.$target = $("<textarea>").val(value).hide(); this.$target = $("<textarea>")
.val(value)
.hide();
this.$target.appendTo(this.$el); this.$target.appendTo(this.$el);
return this._createCKEditorIntance(); return this._createCKEditorIntance();
}, },