Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Enhance the post editor control #221

Open
westonruter opened this issue Aug 18, 2016 · 7 comments
Open

Enhance the post editor control #221

westonruter opened this issue Aug 18, 2016 · 7 comments

Comments

@westonruter
Copy link
Contributor

Building off of #216 some ideas for how we can improve the post editor control:

@mohdsayed
Copy link
Contributor

I am working on it here #222

@mohdsayed
Copy link
Contributor

mohdsayed commented Aug 19, 2016

Allow a PostEditorControl to have params which include which TinyMCE buttons should be made available. For example, there may be some postmeta field where only basic HTML should be allowed. When the editor is shown for this expanded control, then only the relevant TinyMCE buttons should be displayed.

@westonruter I cannot find any method to disable plus hide the buttons after the tinyMCE has been instantiated. I could do this which works well

/**
 * Toggle the editor buttons.
 *
 * @return {void}
 */
updateEditorButtons: function() {
    var control = this, button,
        editor = tinyMCE.get( 'customize-posts-content' ),
        mediaButton = $( '#wp-customize-posts-content-media-buttons' ),
        htmlTab = $( '#customize-posts-content-html' );

    _.each( control.params.editor_settings.mce_buttons, function( buttonState, buttonName ) {
        editor.controlManager.setDisabled( buttonName, ! buttonState );
        button = $( '.mce-i-' + buttonName ).closest( '.mce-btn' );
        button.toggleClass( 'hidden', ! buttonState );
    } );

    htmlTab.toggleClass( 'hidden', ! control.params.editor_settings.html_editor );
    mediaButton.toggleClass( 'hidden', ! control.params.editor_settings.media_buttons );
},

however editor.controlManager.setDisabled( buttonName, ! buttonState ); has been deprecated. Also if you use keyboard shortcuts like Cmd + B , the bold button reappears, though we can add or remove the shortcuts like this. There must be a simpler way of doing it.

@westonruter
Copy link
Contributor Author

@sayedwp I'd say this is low priority, so it can be addressed later.

@westonruter
Copy link
Contributor Author

Unless you have a direct need for this.

@westonruter
Copy link
Contributor Author

Your solution looks pretty good.

@westonruter
Copy link
Contributor Author

Regarding shortcuts causing the buttons to re-appear, that's a challenge I don't have an immediate suggestion for. My experience traversing the depths of TinyMCE is limited.

@mohdsayed
Copy link
Contributor

There is no direct need for this, so okay we will do this later.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants