From f1882fb6a0908c450f12e26ac85502f7c48cacbd Mon Sep 17 00:00:00 2001 From: Jan-Christoph Ihrens Date: Sun, 22 Sep 2013 19:02:00 +0200 Subject: [PATCH] I encountered the following bug: Using TinyMCE's template plugin, I tried to insert a snippet where the outmost tag was a DIV with a class:

Content of the left column

Content of the right column

After adding it, only the outmost DIV was inserted, the other elements just disappeared. I found out that this happened because my template_selected_content_classes list was empty. In the jscripts\tiny_mce\plugins\template\editor_plugin_src.js there needs to be a test if it is empty before replacing, otherwise every time a construct like this is inserted, the inner HTML will be replaced (with the empty string if nothing is selected in the editor). IMPORTANT: Since the minified editor_plugin.js is used instead of the editor_plugin_src.js, both files should be renamed so that the editor_plugin_src.js is then the editor_plugin.js. I'll try to submit this fix to the TinyMCE repository as well; hopefully there'll be a fixed minified version, too. Signed-off-by: Jan-Christoph Ihrens --- .../tiny_mce/plugins/template/editor_plugin_src.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/components/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin_src.js b/assets/components/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin_src.js index 9cac269..cad085e 100644 --- a/assets/components/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin_src.js +++ b/assets/components/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin_src.js @@ -93,8 +93,11 @@ n.innerHTML = t._getDateTime(new Date(), ed.getParam("template_mdate_format", ed.getLang("template.mdate_format"))); // Replace selection - if (hasClass(n, ed.getParam('template_selected_content_classes', 'selcontent').replace(/\s+/g, '|'))) - n.innerHTML = sel; + var replClass = ed.getParam('template_selected_content_classes', 'selcontent'); + if ('' != replClass.replace(/\s+/g, '')) { + if (hasClass(n, replClass.replace(/\s+/g, '|'))) + n.innerHTML = sel; + } }); t._replaceVals(el);