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.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | panopoly_magic-wysiwyg-live-preview-2317467-5.patch | 4.89 KB | dsnopek |
| #4 | panopoly_test-wysiwyg-live-preview-2317467-4.patch | 4.52 KB | dsnopek |
Comments
Comment #1
dsnopekAttached 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! :-)
Comment #2
dsnopekOn 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 afterDrupal.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.
Comment #3
dsnopekDid 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.
Comment #4
dsnopekAnd 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/49481014EDIT-2: I messed up that last build, here's a new one: https://travis-ci.org/dsnopek/panopoly/builds/49485486
Comment #5
dsnopek@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
Comment #6
cboyden commentedThis is working in my testing - Chrome and FF on Mac.
Comment #8
dsnopek@cboyden: Thanks for testing! Committed. :-)