summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/frontend/loader.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-09-13 18:07:59 +0200
committerChristophe Simonis <chs@odoo.com>2019-09-13 18:07:59 +0200
commit6c948c36bbf72dd896e0bff03aa7fbddadcbb0cd (patch)
treef8620905c011735d8a3c340c46d1417a54a75972 /addons/web_editor/static/src/js/frontend/loader.js
parent48503fcf08eac6fed12e080d4f501f9bbc8d257d (diff)
parent197474e5b9ad43ab2d587a98136a1a809ce9a2e7 (diff)
[MERGE] forward port branch saas-12.5 up to 197474e5b9a
Diffstat (limited to 'addons/web_editor/static/src/js/frontend/loader.js')
-rw-r--r--addons/web_editor/static/src/js/frontend/loader.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/addons/web_editor/static/src/js/frontend/loader.js b/addons/web_editor/static/src/js/frontend/loader.js
new file mode 100644
index 00000000000..9c6cf0ef984
--- /dev/null
+++ b/addons/web_editor/static/src/js/frontend/loader.js
@@ -0,0 +1,28 @@
+odoo.define('web_editor.loader', function (require) {
+'use strict';
+
+var Wysiwyg = require('web_editor.wysiwyg.root');
+
+function load(parent, textarea, options) {
+ var loading = textarea.nextElementSibling;
+ if (loading && !loading.classList.contains('o_wysiwyg_loading')) {
+ loading = null;
+ }
+
+ if (!textarea.value.match(/\S/)) {
+ textarea.value = '<p><br/></p>';
+ }
+
+ var wysiwyg = new Wysiwyg(parent, options);
+ return wysiwyg.attachTo(textarea).then(() => {
+ if (loading) {
+ loading.parentNode.removeChild(loading);
+ }
+ return wysiwyg;
+ });
+}
+
+return {
+ load: load,
+};
+});