michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
339 stars 71 forks source link

Use advanced TinyMCE editor with Site Origin #201

Closed vladkucherov closed 9 years ago

vladkucherov commented 9 years ago

Good day,

I was wondering, how I can use more advanced editor? image

I would prefer it to be: image

I couldn't find an option to set it "tiny". I did find this in your code:

wp_editor(
    $aField['value'],
    $aField['attributes']['id'],
    $this->uniteArrays(
        (array) $aField['rich'],
        array(
            'wpautop' => true, // use wpautop?
            'media_buttons' => true, // show insert/upload button(s)
            'textarea_name' => $aField['attributes']['name'],
            'textarea_rows' => $aField['attributes']['rows'],
            'tabindex' => '',
            'tabfocus_elements' => ':prev,:next', // the previous and next element ID to move the focus to when pressing the Tab key in TinyMCE
            'editor_css' => '', // intended for extra styles for both visual and Text editors buttons, needs to include the <style> tags, can use "scoped".
            'editor_class' => $aField['attributes']['class'], // add extra class(es) to the editor textarea
            'teeny' => false, // output the minimal editor config used in Press This
            'dfw' => false, // replace the default fullscreen with DFW (needs specific DOM elements and css)
            'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
            'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array()     
        )
    )
);

AdminPageFramework_FileType_textarea.php _Line:_ 517

I did find that you set tiny => false but I still get the tiny one.

Any ideas?

michaeluno commented 9 years ago

Maybe

    'teeny' => false,

not

    'tiny' => false,

It should be already false by default though.

vladkucherov commented 9 years ago

in wp-includes/class-wp-editor.php _Line:_ 318 it's teeny so your code key is correct but still doesn't explain why I get the teeny one :disappointed:

michaeluno commented 9 years ago

How do you set the rich argument?

It should look like

    'rich' => array(
         'teeny' => false,
    ),

You may post a very simple example plugin that only demonstrates the problem so that others can reproduce the problem, something like this one.

vladkucherov commented 9 years ago

the default is teeny => false, and it looks like you don't change it. of course I don't change it - so it leaves us with an issue not with the settings

vladkucherov commented 9 years ago

I came up with this idea... The post edit page already loads the WYSIWYG editor, but then SiteOrigin Panels (after it loads) hides the editor. After, when you try to open the widget that has WYSIWYG it won't show it as rich editor because the rich one is already has been loaded.

The idea is based on what i saw in wp_editor any ideas?

vladkucherov commented 9 years ago

Did you have a chance to take a look at this?

vladkucherov commented 9 years ago

Like you requested I created a gist of a widget using the editor https://gist.github.com/vladkucherov/9c881d14b8b2d75da9de

michaeluno commented 9 years ago

I could reproduce the problem in my environment.

To see what is going on, I changed the constructor of your code to check the passed TinyMCE settings.

    public function __construct() {
        parent::__construct('Text Section', array(
            'classname'     => 'widget_text_section',
            'description'   =>  'Some description'
        ));

        add_filter( 'tiny_mce_before_init', array( $this, 'replyToLogTinyMCESettings' ) );

    }

        public function replyToLogTinyMCESettings( $aTinyMCESettings ) {

            AdminPageFramework_Debug::log( $aTinyMCESettings );
            return $aTinyMCESettings;

        }

The log indicates that the textarea id is modified by the SiteOrigin plugin. You'll see something like this.

    [selector] => #widget-text_section_widget-{$id}-tf_content__0

The part {$id} is where being modified. This means the set options in the rich field argument of APF will not be set because they change the textarea ID after the TinyMCE settings for the field are passed and apply their original ID afterwards.

Still, it should be possible to apply the default TinyMCE settings to an APF generated textarea field. You may try to find a hook which gets triggered when they apply an ID to the widget, the code that converts an ID like widget-text_section_widget-{$id}-tf_content__0 to widget-text_section_widget-c14-tf_content__0 Let me know if you find one.

michaeluno commented 9 years ago

Closing the topic due to inactivity.