From a6ad36ef89bdfd51df7eba4e71c1eb464a7aefd6 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 21 Jan 2014 14:18:41 +0100 Subject: [PATCH] [ADD] attempt to correctly initialize ckeditor widgets (fontawesome icon things at the moment) within a dropped snippet bzr revid: xmo@openerp.com-20140121131841-u0qzlk1ytng3af2h --- .../website/static/src/js/website.editor.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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(); });