summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2014-01-21 14:18:41 +0100
committerXavier Morel <xmo@openerp.com>2014-01-21 14:18:41 +0100
commita6ad36ef89bdfd51df7eba4e71c1eb464a7aefd6 (patch)
treef999c64dc5cdf3c272df9467de78968cca840e3f
parent35b8850ecc8d3cda929f77993e6a3c5bacab1276 (diff)
[ADD] attempt to correctly initialize ckeditor widgets (fontawesome icon things at the moment) within a dropped snippet
bzr revid: xmo@openerp.com-20140121131841-u0qzlk1ytng3af2h
-rw-r--r--addons/website/static/src/js/website.editor.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index 5f4cd8978c2..b6121464c01 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -821,6 +821,28 @@
document.execCommand("enableInlineTableEditing", false, "false");
} catch (e) {}
+
+ // detect & setup any CKEDITOR widget within a newly dropped
+ // snippet. There does not seem to be a simple way to do it for
+ // HTML not inserted via ckeditor APIs:
+ // https://dev.ckeditor.com/ticket/11472
+ $(document.body)
+ .off('snippet-dropped')
+ .on('snippet-dropped', function (e, el) {
+ // CKEDITOR data processor extended by widgets plugin
+ // to add wrappers around upcasting elements
+ el.outerHTML = editor.dataProcessor.toHtml(el.outerHTML, {
+ fixForBody: false,
+ dontFilter: true,
+ });
+ // then repository.initOnAll() handles the conversion
+ // from wrapper to actual widget instance (or something
+ // like that).
+ setTimeout(function () {
+ editor.widgets.initOnAll();
+ }, 0);
+ });
+
self.trigger('rte:ready');
def.resolve();
});