I'm running into an issue where Drupal.settings.wysiwyg and Drupal.wysiwyg are not defined when the core overlay module is enabled. This was tested with the latest dev of wysiwyg.module and CKEditor 4.5.3. I've never needed to use those settings before, and was running into an issue debugging providing WYSIWYG support for Entity Embed when I noticed that they aren't always defined.

Steps to reproduce:
With overlay enabled, navigate to a form with a WYSIWYG.
Check in the browser console for Drupal.wysiwyg and Drupal.settings.wysiwyg which both will be undefined.

With overlay disabled, navigate to a form with a WYSIWYG.
Check in the browser console for Drupal.wysiwyg and Drupal.settings.wysiwyg which both will show the object.

Comments

bneil created an issue. See original summary.

TwoD’s picture

Status: Active » Postponed (maintainer needs more info)

Drupal.wysiwyg and Drupal.settings.wysiwyg won't be defined in the main window unless it also has at least one field with a WYSIWYG editor. If Overlay is enabled, it'll load contents, including scripts, inside an iFrame. So, you should be checking Drupal.overlay.iframeWindow.Drupal... for the data relevant to the document in the Overlay.

I'm tempted to close this as "works as designed", but Is this causing some kind of actual error?

Btw, you should never really have to access Drupal.settings.wysiwyg from within a plugin or some kind of integration with Wysiwyg. What's in there may not actually reflect the current state of the editors or even the settings a certain editor instance was created with, especially if AJAX responses have included more settings data since the initial page load.
Future versions of Wysiwyg will pass settings to the client in a more complex way, and store them in private caches and "instances" to avoid the risk of editor state getting out of sync.

bneil’s picture

TwoD, thank you for the quick response.

In #2538194: WYSIWYG Module Support the plugin is expecting Drupal.wysiwyg to be available and I noticed it wasn't when testing out the patch and had the field in the iFrame. Thanks for the information about where they exist when inside the overlay.

Do you have a recommendation for how the patch in #2538194: WYSIWYG Module Support should handle getting the field instance and text format? I've made some small widget plugins before, but the entity embed plugin is more advanced than what I've worked on in the past.

TwoD’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

I will have a look at the patch and comment in the other issue.
Meanwhile, I'll close this issue since I don't think there's a bug.

EDIT: I tested the patch in the other issue and found no problems when editing inside the overlay. As the entity_embed and wysiwyg code both run inside the overlay, they both have access to the local Drupal.wysiwyg.

However, I do have some other points I'd like to make about the code so I'll put a longer review in that issue.