• Really good plugin.
    I suggest you to put these lines, so that you can work on editors you created with js:

    if ( ‘undefined’ === typeof window.wpcm.editors ) {
    window.wpcm.editors = [];
    }

    #in wpcm.codemirrorInit after editor creation
    wpcm.editors.push(editor);

    • This topic was modified 5 years, 9 months ago by ilserra. Reason: new release
    • This topic was modified 5 years, 9 months ago by ilserra.
    • This topic was modified 5 years, 9 months ago by ilserra.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Vicky Agravat

    (@vickyagravat)

    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.

    Plugin Author Vicky Agravat

    (@vickyagravat)

    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…

    Thread Starter ilserra

    (@ilserra)

    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.

    Plugin Author Vicky Agravat

    (@vickyagravat)

    Please Wait.
    I will Update the plugin soon…

    • This reply was modified 5 years, 9 months ago by Vicky Agravat.
    Plugin Author Vicky Agravat

    (@vickyagravat)

    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 );
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Very good, just one suggestion’ is closed to new replies.