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);
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3172792_2.patch | 1.19 KB | shabbir |
Comments
Comment #2
shabbir commentedAdding patch file, also removed extra initialization of variable (unused variable) var wysiwygInstance = this;
Comment #4
twodThanks for spotting the double initialization, committed that as a separate cleanup patch.
I'm unable to reproduce this error though.
If
this._drupalWysiwygInstanceis undefined it meanseditor._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 meansthisinsideprepareContentwill point to thewindowobject instead of Wysiwyg's internal editor instance for that field. The change would work right now becausethisis 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?