From 14895a20567c54f6fde2cdd05e490ff30feed3a6 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 18 Apr 2012 17:38:24 +0200 Subject: [PATCH] BUGFIX Only call TinyMCE.init() once per window load (actual editor creation happens through new tinymce.Editor() --- javascript/HtmlEditorField.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/javascript/HtmlEditorField.js b/javascript/HtmlEditorField.js index 5f9fb0c01..a2a3af7e9 100644 --- a/javascript/HtmlEditorField.js +++ b/javascript/HtmlEditorField.js @@ -13,8 +13,15 @@ * Caution: Incomplete and unstable API. */ ss.editorWrappers = {}; + ss.editorWrappers.initial ss.editorWrappers.tinyMCE = (function() { return { + init: function(config) { + if(!ss.editorWrappers.tinyMCE.initialized) { + tinyMCE.init(config); + ss.editorWrappers.tinyMCE.initialized = true; + } + }, /** * @return Mixed Implementation specific object */ @@ -196,7 +203,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE; * Constructor: onmatch */ onmatch : function() { - var self = this, ed = ss.editorWrappers['default'](); + var self = this, edClass = this.data('editor') || ss.editorWrappers['default'], ed = edClass(); this.setEditor(ed); this.closest('form').bind('beforesave', function() { // TinyMCE modifies input, so change tracking might get false @@ -228,7 +235,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE; // Using a global config (generated through HTMLEditorConfig PHP logic) var config = ssTinyMceConfig, self = this, ed = this.getEditor(); - tinyMCE.init(config); + ed.init(config); // Avoid flicker (also set in CSS to apply as early as possible) self.css('visibility', '');