From 19423e9a44dc520c0db2850ec2ab2d8bcef2e928 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 23 Apr 2015 10:08:33 +1200 Subject: [PATCH] BUG Fix tinymce errors crashing CMS When removing a tinymce field, internal third party errors should be caught and ignored gracefully rather than breaking the whole CMS. --- javascript/HtmlEditorField.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/javascript/HtmlEditorField.js b/javascript/HtmlEditorField.js index c2596095d..815c8e311 100644 --- a/javascript/HtmlEditorField.js +++ b/javascript/HtmlEditorField.js @@ -293,8 +293,15 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE; onremove: function() { var ed = tinyMCE.get(this.attr('id')); if (ed) { - ed.remove(); - ed.destroy(); + try { + ed.remove(); + } catch(ex) {} + try { + ed.destroy(); + } catch(ex) {} + + // Remove any residual tinyMCE editor element + this.next('.mceEditor').remove(); // TinyMCE leaves behind events. We should really fix TinyMCE, but lets brute force it for now $.each(jQuery.cache, function(){