• Resolved mythemes

    (@mythemes)


    For sample textarea and wordpress visual editor I use the code

    var code = mythemes_get_shortcode( sh ); // return [posts count="3"/]
    
    jQuery(function(){
    if( jQuery( 'div#wp-content-wrap' ).length &&
        jQuery( 'div#wp-content-wrap' ).hasClass( 'html-active' ) ) {
    
      var text = jQuery( 'textarea#content' ).val();
      jQuery( 'textarea#content' ).val( text + code );
    }
    else{
      if( typeof tinyMCE == 'object' )
        tinyMCE.execCommand( 'mceInsertRawHTML', false, code );
      }
    });
    

    When is installed the WP Editor plugin I try to use an additional code for the case with the textarea.

    var mythemes_sh_editor;
    
    ...
    
    if( jQuery( 'div#wp-content-wrap' ).length &&
        jQuery( 'div#wp-content-wrap' ).hasClass( 'html-active' ) ) {
    
      var text = jQuery( 'textarea#content' ).val();
      jQuery( 'textarea#content' ).val( text + code );
    
      if( typeof CodeMirror == 'function' &&
          typeof mythemes_editor == 'undefined' ){
    
        var textArea = document.getElementById('content');
        var mythemes_editor = CodeMirror.fromTextArea( textArea );
        mythemes_editor.getDoc().setValue( text + code );
      }
      else if( typeof CodeMirror == 'function' ){
        mythemes_editor.getDoc().setValue( text + code );
      }
    }
    ...
    

    but unfortunately it does not work.

    please, can you help me to make it to work correctly.

    https://ww.wp.xz.cn/plugins/wp-editor/

Viewing 1 replies (of 1 total)
  • Plugin Author benjaminprojas

    (@benjaminprojas)

    mythemes,

    Its hard to determine what the issue might be without seeing a bigger picture of what you are doing. Unfortunately, I am not able to fully troubleshoot this for you. I would recommend checking your JS console and if there is an issue there, resolve that. Otherwise, reach out to the folks at CodeMirror.net to see if they might have a solution.

Viewing 1 replies (of 1 total)

The topic ‘How insert the content with JavaScript ( textarea ).’ is closed to new replies.