Thank you for your review and ratings.
I will definitely update the code you have suggested, in next plugin update.
also with some other code optimization to improve performance.
I have added the code you have suggested.
You can now access all instance of editor with window.wpcm.editors object array.
just update your plugin to 1.0.3 or greater.
If any problem occurs or any other suggestions, just reply here…
Great! Thanks for following my suggestion.
I saw you put the wpcm.editors.push(editor) in the initialize and not in the wpcm.codemirrorInit. Unfortunately if you use blocks in WP it doesn’t call that function so I had yo write in the
wpcm.codemirrorInit
after
wpcm.autoLoadTheme(editor, setting.theme);
the line
wpcm.editors.push(editor);
But maybe there’s another way to.
Please Wait.
I will Update the plugin soon…
I thought you have to do something in admin side.
But, now i understand what is your needs.
You have to use initialized Editor instance on front end.
Now, I have updated the code to use. (in Plugin Version 1.0.6)
Now, you can use window.wpcm.editors object array on front end.
I also have added 2 events listener, triggered at the time of editor initialization.
1. wpcm_editor_loaded is triggered (with editor object) after an editor instance is pushed in the window.wpcm.editors object array.
2. wpcm_editors_loaded is triggered after all editor instance is pushed in the window.wpcm.editors object array.
You can use any event to initialize your code…
For Example
( function( $ ) {
$(document.body).on('wpcm_editor_loaded', function (e, editor) {
console.log('current editor', editor);
// your code.
});
$(document.body).on('wpcm_editors_loaded', function (e) {
console.log('all editors', window.wpcm.editors);
// your code.
});
} )( jQuery );