Getting current instance of Inline CKEditor in plugin command
We recently moved away from tinymce and the custom function we created was a toolbar button that, when clicked, placed the custom div right above the toolbar that was added to the toolbar on page load.
The problem now does the same for CKEditor when using the Inline version. Since there are multiple instances at one point, how can I get an instance of the current popup inline Ckeditor so that I can add it using jQuery after clicking the custom plugin button?
Using the latest 4.x version of CKEditor.
source to share
It is difficult to imagine what you are trying to achieve. Either way, you can observe which instance of the editor is focused (you may end up storing the reference in some variable):
CKEDITOR.on( 'instanceReady', function( event ) {
event.editor.on( 'focus', function() {
console.log( 'focused', this );
});
});
After all, you can also view the editor instances as they are stored in an object CKEDITOR.instances
in the global namespace. That being said, you can find your instance by name, id, whatever (i.e. previously associated with your button).
source to share
Using the accepted answer above, I found that the editor "name" (as you know) of the editor instance that invoked the given plugin is accessible via this._.editor.name (using CKEditor v4.3)
So you can get the content of the editor this way.
CKEDITOR.instances[this._.editor.name].getData();
source to share