diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/web_editor/static/src/js/frontend/loader.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/web_editor/static/src/js/frontend/loader.js')
| -rw-r--r-- | addons/web_editor/static/src/js/frontend/loader.js | 28 |
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 00000000..9c6cf0ef --- /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, +}; +}); |
