I have two issues, probably related. I'm using the WYSIWYG module with TinyMCE in my case -- the latest version of TinyMCE, 3.5.7. My default input format is Full HTML, but that and Filtered HTML both are configured to use TinyMCE. If I switch from Full to Filtered, everything is fine. If I switch back, the whole textarea disappears and will not come back until page refresh.

In addition, I get a Javascript console error on pageload -- though it does not recur even when switching formats. That error is:

Uncaught TypeError: Cannot read property 'configs' of undefined wysiwyg.js:28
Drupal.wysiwygInit wysiwyg.js:28
b.extend.each jquery.js:33
Drupal.wysiwygInit wysiwyg.js:26
(anonymous function) wysiwyg.js:274
(anonymous function)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Georgii’s picture

Version: 7.x-2.x-dev » 7.x-2.2

Hi! I have the same issue reproduced with the same version of TinyMCE (3.5.7) and in the latest release of this module 7.x-2.2

Just a couple of notes:

  1. I do not see any JS errors in FireBug console. Neither on page load nor during text format switch (Filtered HTML <-> Full HTML).
  2. I do see TinyMCE editor blinking when I witch text format. For a couple of moments it appears and then disappears.
  3. If I switch to Plain Text format then I can do oe switch to Filtered/Full HTML without a problem but the next switch will again hide the editor.
TwoD’s picture

Status: Active » Postponed (maintainer needs more info)

@Offlein, that sounds like a problem with Drupal's settings object. Could you try inspecting the JavaScript object in Drupal.settings.wysiwyg and see if it looks complete?
There should be a 'configs' property in there, with a sub-objects keyed by the names of enabled editors, holding settings objects in turn keyed by the formats they've been assigned to.

@Georgii, do you by any chance have the old tinymce.module enabled as well? If so, please disable it.
Do you have any modules enabled that use JavaScript on the node edit forms or alter them in any way?

Offlein’s picture

Hello,

Apparently, that warning is no longer appearing for whatever reason. The disappearing text input remains, however. (For what it's worth, I do not have any old tinymce.module enabled either.)

It seems that, more specifically, the textarea will only disappear if the user switches from one TinyMCE format to another -- like what Georgii says. I have 4 formats: "Filtered HTML" "Full HTML", "Plaintext" and "Email" (also a plaintext format) If I switch to one of the plaintext formats the textarea will be there (or return if it was gone), and will convert properly back into a TinyMCE textarea when switching to Filtered or Full.

The only thing that causes the textarea to disappear is a switch from Filtered to Full or vice-versa.

Georgii’s picture

@TwoD
No tinymce.module and I was reproducing the issue on a /comment/*/edit page where the only standard set of JS is included
Please take a look at my e-mail I send to you via contact form. You can find information about how to reproduce the issue there.

TwoD’s picture

I've traced this down to a problem in TinyMCE itself.
There was an issue with IE9 crashing if there was no content in the editor when it was removed.
They applied a patch that delayed the hiding of the editor elements using a setTimeout() call:

Fix IE9 crash when calling hide(). This fixes bug 4921 (http://www.tinymce.com/develop/bugtracker_view.php?id=4921)

.

A commenter in the original TinyMCE thread noted that this fix also hid new editor instances after replacing an old instance, much like we do in Wysiwyg.
This lead to another patch:

Fixed an add/remove editor logic issue

That patch has not yet made it into an official TinyMCE release, but can be tested using the nightly TinyMCE builds. The last patch seems to have fixed the issue without hiding the new editor instance.

I've made a simple patch to force TinyMCE to be shown again if this version is detected.

TwoD’s picture

Status: Postponed (maintainer needs more info) » Needs review

Forgot the status.

sun’s picture

+++ b/editors/js/tinymce-3.js
@@ -76,6 +76,12 @@ Drupal.wysiwyg.editor.attach.tinymce = function(context, params, settings) {
+  if (tinymce.minorVersion == '5.7') {

Shouldn't this be >= or <=?

TwoD’s picture

If I'm not mistaken, the patch introducing the issue was added in 3.5.7, and the patch fixing it will be part of 3.5.8 since it's already in the nightly build. I'm on my phone right now, so I can't verify it.

Offlein’s picture

Great success!

TwoD’s picture

Status: Needs review » Fixed
FileSize
582 bytes

I've confirmed the fix is only needed for TinyMCE 3.5.7.

The hide delay causing the issue was introduced between 3.5.6 and 3.5.7:

#git diff 3.5.6...3.5.7 jscripts/tiny_mce/classes/Editor.js
diff --git a/jscripts/tiny_mce/classes/Editor.js b/jscripts/tiny_mce/classes/Editor.js
index f466594..8bc8c6d 100644
--- a/jscripts/tiny_mce/classes/Editor.js
+++ b/jscripts/tiny_mce/classes/Editor.js
@@ -1416,7 +1416,11 @@
 
                        // We must save before we hide so Safari doesn't crash
                        self.save();
-                       DOM.hide(self.getContainer());
+
+                       // defer the call to hide to prevent an IE9 crash #4921
+                       setTimeout(function() {
+                               DOM.hide(self.getContainer());
+                       }, 1);
                        DOM.setStyle(self.id, 'display', self.orgDisplay);
                },

Between 3.5.7 and the current HEAD, they've reverted that change and done it differently, without a delay.

git diff 3.5.7...HEAD jscripts/tiny_mce/classes/Editor.js
diff --git a/jscripts/tiny_mce/classes/Editor.js b/jscripts/tiny_mce/classes/Editor.js
index 8bc8c6d..6695eeb 100644
--- a/jscripts/tiny_mce/classes/Editor.js
+++ b/jscripts/tiny_mce/classes/Editor.js
@@ -1418,9 +1418,7 @@
                        self.save();
 
                        // defer the call to hide to prevent an IE9 crash #4921
-                       setTimeout(function() {
-                               DOM.hide(self.getContainer());
-                       }, 1);
+                       DOM.hide(self.getContainer());
                        DOM.setStyle(self.id, 'display', self.orgDisplay);
                },
 
@@ -1849,11 +1847,19 @@
                 * @method remove
                 */
                remove : function() {
-                       var self = this, elm = self.getContainer();
+                       var self = this, elm = self.getContainer(), doc = self.getDoc();
 
                        if (!self.removed) {
                                self.removed = 1; // Cancels post remove event execution
-                               self.hide();
+
+                               // Fixed bug where IE has a blinking cursor left from the editor
+                               if (isIE && doc)
+                                       doc.execCommand('SelectAll');
+
+                               // We must save before we hide so Safari doesn't crash
+                               self.save();
+
+                               DOM.setStyle(self.id, 'display', self.orgDisplay);
 
                                // Don't clear the window or document if content editable
                                // is enabled since other instances might still be present

The log confirms that as well:

git log 3.5.6...HEAD jscripts/tiny_mce/classes/Editor.js
commit a12d6859e81408b12c956c3504b1fe7ff35aabae
Author: Spocke <spocke@moxiecode.com>
Date:   Fri Sep 21 11:18:01 2012 +0200

    Fixed an add/remove editor logic issue

commit 0e90011e6ef37bc914916de184358c42b0ab5d90
Author: Spocke <spocke@moxiecode.com>
Date:   Wed Sep 19 17:37:48 2012 +0200

    Added bug id reference to hide fix

commit e0378ceb7792fb7949c3aca3487306a78668595e
Author: Tommy Morgan <tommy@spredfast.com>
Date:   Fri Aug 31 11:36:29 2012 -0500

    Fix IE9 crash when calling hide().  This fixes bug 4921 (http://www.tinymce.com/develop/bugtracker_view.php?id=4921)

The bug we're seeing was reported as http://www.tinymce.com/develop/bugtracker_view.php?id=5510 so I've added a reference to it in the patch and committed it to D6 and D7 branches.

Thank you all for reporting, reviewing and testing. The -dev snapshots will be updated within 12hrs and this patch will be part of the next release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.