Ticket #6020: 6020_2.patch

File 6020_2.patch, 1.6 KB (added by Sa'ar Zac Elias, 13 years ago)
  • _source/plugins/clipboard/plugin.js

     
    6262        {
    6363                this.type = type;
    6464                this.canUndo = ( this.type == 'cut' );          // We can't undo copy to clipboard.
     65                this.startDisabled = true;
    6566        };
    6667
    6768        cutCopyCmd.prototype =
     
    281282                }
    282283        }
    283284
     285        function setToolbarStates()
     286        {
     287                if ( this.mode != 'wysiwyg' )
     288                        return;
     289
     290                var selection = this.getSelection(),
     291                        readOnly = selection.getCommonAncestor().isReadOnly(),
     292                        state = selection.getRanges()[0].collapsed ? CKEDITOR.TRISTATE_DISABLED : CKEDITOR.TRISTATE_OFF;
     293
     294                this.getCommand( 'cut' ).setState( readOnly ? CKEDITOR.TRISTATE_DISABLED : state );
     295                this.getCommand( 'copy' ).setState( state );
     296        }
     297
    284298        // Register the plugin.
    285299        CKEDITOR.plugins.add( 'clipboard',
    286300                {
     
    348362                                editor.on( 'contentDom', function()
    349363                                {
    350364                                        var body = editor.document.getBody();
    351                                         body.on( ( (mode == 'text' && CKEDITOR.env.ie ) || CKEDITOR.env.webkit ) ? 'paste' : 'beforepaste',
     365                                        body.on( ( ( mode == 'text' && CKEDITOR.env.ie ) || CKEDITOR.env.webkit ) ? 'paste' : 'beforepaste',
    352366                                                function( evt )
    353367                                                {
    354368                                                        if ( depressBeforeEvent )
     
    368382                                                });
    369383
    370384                                        body.on( 'beforecut', function() { !depressBeforeEvent && fixCut( editor ); } );
     385
     386                                        body.on( 'mouseup', setToolbarStates, editor );
     387                                        editor.on( 'key', setToolbarStates, editor );
    371388                                });
    372389
    373390                                // If the "contextmenu" plugin is loaded, register the listeners.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy