Problem/Motivation

After updating to drupal 7.73 and wysiwyg to 7.26 branch, the editor (full html format) neither shows the text nor saves the text that you enter in your textarea/body field. This is mainly due to the error Uncaught TypeError: Cannot read property 'prepareContent' of undefined which indicates that on line 168 the code e.content = this._drupalWysiwygInstance.prepareContent(e.content); is not getting called when the text area is loaded for the first time. It works if you disable rich text editor and enable it again

Steps to reproduce

Update to drupal 7.73 and wysiwyg to 7.26 branch and PHP to 7.3 with jquery to 1.10, create/edit a node with body field (textarea) and you will see the error.

Proposed resolution

We need to switch the code from e.content = this._drupalWysiwygInstance.prepareContent(e.content); to

          e.content = Drupal.wysiwyg.editor.instance.tinymce.prepareContent(e.content);
CommentFileSizeAuthor
#2 3172792_2.patch1.19 KBshabbir

Comments

Shabbir created an issue. See original summary.

shabbir’s picture

StatusFileSize
new1.19 KB

Adding patch file, also removed extra initialization of variable (unused variable) var wysiwygInstance = this;

  • TwoD committed 05312fe on 7.x-2.x authored by Shabbir
    - #3172792 by Shabbir: Fixed variable initialized twice.
    
twod’s picture

Thanks for spotting the double initialization, committed that as a separate cleanup patch.

I'm unable to reproduce this error though.
If this._drupalWysiwygInstance is undefined it means editor._drupalWysiwygInstance = wysiwygInstance; in the setup callback has failed or not been called.
If we change to using Drupal.wysiwyg.editor.instance.tinymce.prepareContent(e.content) it means this inside prepareContent will point to the window object instead of Wysiwyg's internal editor instance for that field. The change would work right now because this is not currently used but it would break in the future if we need to reference something in that instance.

Can you give some more details exactly on which settings you're using? Is the editor enabled by default? Is it on the first format enabled when the form loads? Do you have any additional plugins enabled which do not come with Wysiwyg itself?