Currently, when adding a Text widget, for example, the live preview won't get updated as your typing into the WYSIWYG editor. However, if you switch to "Plain text", it will!

Basically, this is caused by the fact that events attached from the WYSIWYG won't bubble up to the textarea (where CTools Autosubmit is attaching it's event handlers).

While all WYSIWYG editors will provide a way to get events from the editor, they all do it in a different way in their API. However, I think we can get this to work at least for the restricted set of WYSIWYG editors we include in Panopoly by default!

I'll attach a patch in a moment that allows this to work with TinyMCE.

Comments

dsnopek’s picture

Status: Active » Needs work
StatusFileSize
new2.21 KB

Attached is a patch that works for TinyMCE. We should add support for at least MarkItUp and CKEditor as well. And this will need some Behat tests if possible!

Also, I've only tried it in Chrome so far - this will need testing in Firefox, IE, etc. Really, just more testing in general! :-)

dsnopek’s picture

Status: Needs work » Needs review
StatusFileSize
new4.92 KB
new6.17 KB

On further testing, there were a number of problems with this patch, namely: it only worked on the TinyMCE editor that was first loaded. If you changed the format selector, it wouldn't affect the new editors (even if you switched WYSYWYG -> HTML -> WYSIWYG).

So, ended up rolling with a new approach that fakes an alter hook in Javascript to change the settings before the editor is attached, allowing us to pass some event callbacks in.

Unfortunately, this requires monkey patching Drupal.wysiwygAttach() so there is some hacky-ness in making sure we patch after Drupal.wysiwygAttach() is defined, but then deal with the case where some editors are attached before we do that (since the order of behaviors is non-deterministic).

But I was also able to add support for MarkItUp!

So far, I've still just been testing in Chrome - I still need to try out some other browsers.

dsnopek’s picture

StatusFileSize
new5.03 KB

Did loads more testing, including in Firefox and IE11. Worked the same across all the browser I've tried!

I found a bug when switching to a text format that doesn't have a WYSIWYG editor associated with it. Here is a new patch to fix.

dsnopek’s picture

And here are some tests for this new functionality! I'll try on Travis-CI in a moment.

EDIT: Here's the Travis-CI link: https://travis-ci.org/dsnopek/panopoly/builds/49481014

EDIT-2: I messed up that last build, here's a new one: https://travis-ci.org/dsnopek/panopoly/builds/49485486

dsnopek’s picture

StatusFileSize
new4.89 KB
new886 bytes

@cboyden found an issue with the latest patch where this wouldn't work on the 2nd type of Widget that you edited without reloading the page. Here is a new patch that should fix!

EDIT: Here's the Travis-CI build: https://travis-ci.org/dsnopek/panopoly/builds/52151188

cboyden’s picture

Status: Needs review » Reviewed & tested by the community

This is working in my testing - Chrome and FF on Mac.

  • dsnopek committed 7c5d50a on 7.x-1.x
    Update Panopoly Magic and Test for Issue #2317467 by dsnopek: Allow live...
dsnopek’s picture

Status: Reviewed & tested by the community » Fixed

@cboyden: Thanks for testing! Committed. :-)

Status: Fixed » Closed (fixed)

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