lundi 29 juin 2015

CKEditor Remove (selected) from label on click


I have created a simple plugin to move some of the formatting buttons to a dropdown button. The dropdown button has both an icon and a label. The plugin works as intended except that when clicked on the label shows both the intended text as well as adding "(selected)" to the end.

Here is the button default view (the formatting button):

enter image description here

And here is how it looks when clicked on:

enter image description here

Here is the code for the plugin:

CKEDITOR.plugins.add( 'sf_formatting', {
init: function( editor ) {
     var format = {};
        editor.addMenuGroup( 'format_group' );


        format.indent = {
            label: 'Increase Indent',
            group: 'format_group',
            command: 'indent',
            order: 6
        };

        format.outdent = {
            label: 'Decrease Indent',
            group: 'format_group',
            command: 'outdent',
            order: 7
        };



        editor.addMenuItems( format );

        editor.ui.add( 'Formatting', CKEDITOR.UI_MENUBUTTON, {
            label: 'Formatting',
            // Disable in source mode.
            modes: { 
                wysiwyg: 1 
            },
            icon: 'dropdown',
            onMenu: function() {
                var active = {};

                // Make all items active.
                for ( var p in format )
                    active[ p ] = CKEDITOR.TRISTATE_OFF;
                    return active;
                }
            } ); 
        }
});

I have a second issue

The outdent (decrease indent) only appears when the text has been indented. In the main menu it is always there but greyed out. How can I force the outdent button to always be visible in the dropdown box but not accessible.

Here is a screenshot of the dropdown when the text has been indented:

enter image description here

I'd be really grateful for any help.


Aucun commentaire:

Enregistrer un commentaire