Home » Javascript » How to call the TinyMCE Visual Editor from within “Turbo Editor”

How to call the TinyMCE Visual Editor from within “Turbo Editor”

Posted by: admin November 1, 2017 Leave a comment

Questions:

A few years ago, I built a website using the Turbo Framework for WordPress. Since that time, development of the framework has ceased. Recently, I needed to upgrade that site from 3.8 to 4.8. Everything went smoothly except for a few JavaScript errors in the WP Admin. I was able to fix all of those errors. However, I still have one issue…

Inside the Turbo Framework is an alternate editor that can be enabled for any post. It adds simple layout configurations and then lets you use the standard WP editors to add content to those layout blocks. This was one of the first true “Visual Composers”. However, after the update, when I attempt to edit the content of the layout blocks with WP’s “visual” editor (TinyMCE). I get some lines written to the console from the JavaScript calling the editor. Here are a few…

Upon loading content window:

Uncaught TypeError: switchEditors.switchto is not a function
    at afl_composer_view (admin-script.js?ver=4.8.2:829)
    at HTMLAnchorElement.<anonymous> (admin-script.js?ver=4.8.2:901)
    at HTMLDocument.dispatch (jquery.js?ver=1.12.4:3)
    at HTMLDocument.r.handle (jquery.js?ver=1.12.4:3)

Upon attempting to switch from “Text” to “Visual” editor:

admin-script.js?ver=4.8.2:156 Editor id: content
admin-script.js?ver=4.8.2:173 before
admin-script.js?ver=4.8.2:176 after
admin-script.js?ver=4.8.2:191 else else

Upon clicking “Save” or “Cancel” in the content window:

admin-script.js?ver=4.8.2:949 
Uncaught TypeError: tinyMCE.getInstanceById is not a function
    at HTMLTextAreaElement.<anonymous> (admin-script.js?ver=4.8.2:949)
    at Function.each (jquery.js?ver=1.12.4:2)
    at a.fn.init.each (jquery.js?ver=1.12.4:2)
    at HTMLAnchorElement.<anonymous> (admin-script.js?ver=4.8.2:947)
    at HTMLDocument.dispatch (jquery.js?ver=1.12.4:3)
    at HTMLDocument.r.handle (jquery.js?ver=1.12.4:3)

Upon attempting to activate the editor in a new post:

admin-script.js?ver=4.8.2:829 
Uncaught TypeError: switchEditors.switchto is not a function
    at afl_composer_view (admin-script.js?ver=4.8.2:829)
    at HTMLAnchorElement.<anonymous> (admin-script.js?ver=4.8.2:901)
    at HTMLDocument.dispatch (jquery.js?ver=1.12.4:3)
    at HTMLDocument.r.handle (jquery.js?ver=1.12.4:3)

Here is the code of admin-script.js which controls the loading of TinyMCE:
http://jsfiddle.net/YaegerDesign/vak2g63k/1/

Answers: