WYSIWYG Field not swapping between editor modes

Support General WYSIWYG Field not swapping between editor modesResolved

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #11514
    SLG MarketingSLG Marketing
    Participant

    I have added the WYSIWYG editor on a custom post type but I can't toggle between the visual and plain text editors.

    I'm getting the following error in my dev console:

    TypeError: j is undefined[Learn More] 3 load-scripts.php:702:681
    e http://localhost/wp-admin/load-scripts.php:702:681
    c/< http://localhost/wp-admin/load-scripts.php:702:271
    C http://localhost/wp-includes/js/tinymce/wp-tinymce.php:3:11105
    d http://localhost/wp-includes/js/tinymce/wp-tinymce.php:3:11256

    My code for the metaboxes is:

    public function generateMetaBox($meta_boxes){
        $prefix = strtolower($this->attributes['post']['single']);
        // Content Area
        $meta_boxes[]=array(
            'id'=>'content',
            'title'=>'Case Study Content',
            'post_types' => $this->attributes['post']['slug'],
            'context'    => 'normal',
            'priority'   => 'high',
            'fields' => array(
                array(
                    'name'          =>  'cs-content',
                    'desc'          =>  'THIS NEEDS SOME INSTRUCTIONAL COPY',
                    'id'            =>  $prefix . '_content_group',
                    'type'          =>  'group',
                    'clone'         =>  true,
                    'sort_clone'    =>  true,
                    'fields'        =>  array(
                        array(
                    'name'  => 'Content Block',
                    'desc'  => 'Content block test',
                    'id'    => $prefix . '_content',
                    'type'  => 'wysiwyg',
                )
    
                    )
                ),
            )
        );
    
        return $meta_boxes;
    }
    

    There are no other plugins installed and the CPT doesn't have the standard editor.

    What am I doing wrong here?

    #11534
    Anh TranAnh Tran
    Keymaster

    Hi,

    I've just tried your code and it works for me. Here is my screenshot:

    https://i.imgur.com/JdbBHX7.png

    I think the problem might come from another part that has JavaScript error. Any JS error can breaks the execution of other JS, which might include the JS for the editors. Can you add these lines to wp-config.php and see what's in the console:

    define( 'WP_DEBUG', true );
    define( 'SCRIPT_DEBUG', true );
    define( 'CONCATENATE_SCRIPTS', false );
    #11591
    SLG MarketingSLG Marketing
    Participant

    Hi

    Sorry for taking so long to reply, I've been on another project. This is the output:

    TypeError: textarea is undefined[Learn More] editor.js:100:5
    switchEditor http://localhost/wp-admin/js/editor.js:100:5
    init/< http://localhost/wp-admin/js/editor.js:34:7
    C http://localhost/wp-includes/js/tinymce/tinymce.min.js:2:11105
    d http://localhost/wp-includes/js/tinymce/tinymce.min.js:2:11256

    Any ideas?

    #11592
    SLG MarketingSLG Marketing
    Participant

    I should add that we are using the classic editor and WP 4.9.8. No other plugins are installed.

    #11602
    Anh TranAnh Tran
    Keymaster

    Hi, can you send me a temporary admin account? I'll check that for you.

    #11607
    SLG MarketingSLG Marketing
    Participant

    Not really as this is a local development site. I'll see about deploying it somewhere for you to test.

    In the meantime I'll try reinstalling the Metabox plugin.

    #11610
    SLG MarketingSLG Marketing
    Participant

    I have set up a demo site for you to debug on. let me know if there is anything else you need.

    #11615
    Anh TranAnh Tran
    Keymaster

    Thanks for the info. I'm checking your site and found a problem: the ID of the field contains a space:

    https://i.imgur.com/sFnaTYm.png

    That comes from the $prefix = strtolower($this->attributes['post']['single']);, which transform Case Study to just case study. It should be case_study. Please try this code:

    $prefix = str_replace(' ', '_', strtolower($this->attributes['post']['single']));

    The space in field ID (and then in the input name/ID) causes unexpected behavior, and that might be a cause to this problem.

    #11623
    SLG MarketingSLG Marketing
    Participant

    Great spot! Thank you so much! It was driving me up the wall.

    Thanks again, this has restored the anticipated behaviour.

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.