justintadlock / butterbean

A neat little post meta framework.
GNU General Public License v2.0
204 stars 31 forks source link

New control: tinymce #14

Open slaFFik opened 7 years ago

slaFFik commented 7 years ago

Hi @justintadlock

I've added locally to your post meta box framework for own needs a new control: tinymce (using the one built-in WordPress). I think it's better to have it in core for wider use, as this is quite a common thing.

I can prepare a PR, but I need from you a development branch :)

Usage example:

$manager->register_control(
    'bbe_tinymce_a',
    array(
        'type'          => 'tinymce',
        'section'       => 'bbe_text_fields',
        'attr'          => array( 'class' => 'widefat' ),
        'editor_params' => array('media_buttons' => true, 'textarea_rows' => 5),
        'label'         => 'Example TinyMCE',
        'description'   => 'Example description.'
    )
);

Control template is the same as for textarea, some logic is in custom class-control-tinymce.php and in api.controls.tinymce view.

What do you think?

justintadlock commented 7 years ago

I'm about to push some code live shortly that will open up the JS to extension. We can talk a patch at that point.

slaFFik commented 7 years ago

Great, Justin. Will wait for it. Oh, I believe this is it: https://github.com/justintadlock/butterbean/commit/eef32a37f155cd6031c11e02a28f63d4dd11f72b

slaFFik commented 7 years ago

Hi @justintadlock,

Would you like to see a PR, separate plugin or a patch attached? For own usage I just created a separate plugin butterbean-tinymce, that does all the things (control class, template file, js-file loading).

justintadlock commented 7 years ago

Can you link up the butterbean-tinymce plugin? I'd like to see the solution first before going through the trouble of a PR.

slaFFik commented 7 years ago

Sure, here it is: https://github.com/slaFFik/butterbean-tinymce Proof of concept, obviously. Lots of cleanup required.

justintadlock commented 7 years ago

Cool. That looks simple enough. I'm going to give it a test run in a little while.

slaFFik commented 7 years ago

Some things should be tweaked, example: hide those new tinymce DFM buttons, because they are triggering the main post/page/CPT editor, not the one you clicked. Perhaps might be a good idea to give ability to pass some options from register_control() to tinymce, so it will be init'ed with a slightly modified behaviour. Just ideas.

slaFFik commented 7 years ago

@justintadlock Is there any way to speed up this new control development inside the ButterBean core?

justintadlock commented 7 years ago

Not really. 1.0.0 just got released. It'll be a while before I put out 1.1.0, so I'm not in any big rush at the moment.

justintadlock commented 7 years ago

For later: https://make.wordpress.org/core/2017/05/20/editor-api-changes-in-4-8/