Ticket #1376: 1376_3.patch

File 1376_3.patch, 13.2 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/print/plugin.js

     
    3737                        editor.document.$.execCommand( "Print" );
    3838        },
    3939        canUndo : false,
     40        readOnly : 1,
    4041        modes : { wysiwyg : !( CKEDITOR.env.opera ) }           // It is imposible to print the inner document in Opera.
    4142};
  • _source/plugins/clipboard/plugin.js

     
    293293                // keyboard paste or execCommand ) (#4874).
    294294                CKEDITOR.env.ie && ( depressBeforeEvent = 1 );
    295295
    296                 var retval = editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED;
     296                var retval = CKEDITOR.TRISTATE_OFF;
     297                try { retval = editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED; }catch( er ){}
     298
    297299                depressBeforeEvent = 0;
    298300                return retval;
    299301        }
  • _source/plugins/sourcearea/plugin.js

     
    4141                                                        textarea.addClass( 'cke_source' );
    4242                                                        textarea.addClass( 'cke_enable_context_menu' );
    4343
     44                                                        editor.readOnly && textarea.setAttribute( 'disabled', true );
     45
    4446                                                        var styles =
    4547                                                        {
    4648                                                                // IE7 has overflow the <textarea> from wrapping table cell.
     
    181183                {
    182184                        modes : { wysiwyg:1, source:1 },
    183185                        editorFocus : false,
    184 
     186                        readOnly : 1,
    185187                        exec : function( editor )
    186188                        {
    187189                                if ( editor.mode == 'wysiwyg' )
  • _source/plugins/enterkey/plugin.js

     
    1111
    1212                init : function( editor )
    1313                {
    14                         var specialKeys = editor.specialKeys;
    15                         specialKeys[ 13 ] = enter;
    16                         specialKeys[ CKEDITOR.SHIFT + 13 ] = shiftEnter;
     14                        editor.addCommand( 'enter', {
     15                                modes : { wysiwyg:1 },
     16                                editorFocus : false,
     17                                exec : enter
     18                        });
     19
     20                        editor.addCommand( 'shiftEnter', {
     21                                modes : { wysiwyg:1 },
     22                                editorFocus : false,
     23                                exec : shiftEnter
     24                        });
     25
     26                        var keystrokes = editor.keystrokeHandler.keystrokes;
     27                        keystrokes[ 13 ] = 'enter';
     28                        keystrokes[ CKEDITOR.SHIFT + 13 ] = 'shiftEnter';
    1729                }
    1830        });
    1931
  • _source/core/dom/range.js

     
    18701870                                                        return 0;
    18711871                                                }
    18721872                                                // Range enclosed entirely in an editable element.
    1873                                                 else if ( node.is( 'body' )
     1873                                                else if ( node.is( 'html' )
    18741874                                                        || node.getAttribute( 'contentEditable' ) == 'true'
    18751875                                                        && ( node.contains( anotherEnd ) || node.equals( anotherEnd ) ) )
    18761876                                                {
  • _source/plugins/toolbar/plugin.js

     
    3636                toolbarFocus :
    3737                {
    3838                        modes : { wysiwyg : 1, source : 1 },
     39                        readOnly : 1,
    3940
    4041                        exec : function( editor )
    4142                        {
  • _source/plugins/maximize/plugin.js

     
    155155                        editor.addCommand( 'maximize',
    156156                                {
    157157                                        modes : { wysiwyg : 1, source : 1 },
     158                                        readOnly : 1,
    158159                                        editorFocus : false,
    159160                                        exec : function()
    160161                                        {
  • _source/plugins/selection/plugin.js

     
    9292        var selectAllCmd =
    9393        {
    9494                modes : { wysiwyg : 1, source : 1 },
     95                readOnly : 1,
    9596                exec : function( editor )
    9697                {
    9798                        switch ( editor.mode )
  • _source/plugins/showblocks/plugin.js

     
    8989
    9090        var commandDefinition =
    9191        {
     92                readOnly : 1,
    9293                preserveState : true,
    9394                editorFocus : false,
    9495
  • _source/plugins/menu/plugin.js

     
    9797                                                {
    9898                                                        var item = this.editor.getMenuItem( itemName );
    9999
    100                                                         if ( item )
     100                                                        if ( item && ( !item.command || this.editor.getCommand( item.command ).state ) )
    101101                                                        {
    102                                                                 item.state = listenerItems[ itemName ];
     102                                                                item.state =  listenerItems[ itemName ];
    103103                                                                this.add( item );
    104104                                                        }
    105105                                                }
  • _source/plugins/showborders/plugin.js

     
    4040        {
    4141                preserveState : true,
    4242                editorFocus : false,
     43                readOnly: 1,
    4344
    4445                exec : function ( editor )
    4546                {
  • _source/plugins/editingblock/plugin.js

     
    3939
    4040                        editor.on( 'uiReady', function()
    4141                                {
    42                                         editor.setMode( editor.config.startupMode );
     42                                        editor.setReadOnly( editor.config.readOnly )
    4343                                });
    4444
    4545                        editor.on( 'afterSetData', function()
     
    151151         * // Switch to "source" view.
    152152         * CKEDITOR.instances.editor1.setMode( 'source' );
    153153         */
    154         CKEDITOR.editor.prototype.setMode = function( mode )
     154        CKEDITOR.editor.prototype.setMode = function( mode, forceReload )
    155155        {
    156156                this.fire( 'beforeSetMode', { newMode : mode } );
    157157
     
    162162                // Unload the previous mode.
    163163                if ( this.mode )
    164164                {
    165                         if ( mode == this.mode )
     165                        if ( !forceReload && mode == this.mode )
    166166                                return;
    167167
    168168                        this.fire( 'beforeModeUnload' );
     
    202202                if ( mode )
    203203                        mode.focus();
    204204        };
     205
     206        function resetCommandsState()
     207        {
     208                   // Disable non-readonly (button) commands.
     209                   var command,
     210                                   commands = this._.commands;
     211                   for ( var name in commands )
     212                   {
     213                           command = commands[ name ];
     214                           !command.readOnly && command.disable();
     215                   }
     216
     217                   // Deal with non-command-based toolbar items.
     218                   var i, j, toolbars = this.toolbox.toolbars;
     219                   for ( i = 0; i < toolbars.length; i++ )
     220                   {
     221                           var toolbarItems = toolbars[ i ].items;
     222                           for ( j = 0; j < toolbarItems.length; j++ )
     223                           {
     224                                   // Combos and panel buttons.
     225                                   var combo = toolbarItems[ j ].combo;
     226                                   if ( combo )
     227                                           combo.setState( CKEDITOR.TRISTATE_DISABLED );
     228
     229                                   var button = toolbarItems[ j ].button;
     230                                   if ( button instanceof CKEDITOR.ui.panelButton )
     231                                           button.setState( CKEDITOR.TRISTATE_DISABLED );
     232                           }
     233                   }
     234        }
     235
     236        /**
     237         * Turn the editor into read-only mode or restore it from read-only mode.
     238         * @param isReadOnly {Boolean} Whether to turn on read-only.
     239         * @since 3.6
     240         * <strong>Note:</strong> current editing block will be reloaded.
     241         */
     242        CKEDITOR.editor.prototype.setReadOnly = function( isReadOnly )
     243        {
     244                this.readOnly = !!isReadOnly;
     245
     246           this.on( 'mode', function( evt )
     247           {
     248                   evt.removeListener();
     249
     250                   isReadOnly && resetCommandsState.call( this );
     251                   this[ isReadOnly ? 'on' : 'removeListener' ]( 'selectionChange', resetCommandsState, this, null, Infinity );
     252           });
     253
     254                // Reload current mode.
     255                this.setMode( this.mode || this.config.startupMode, 1 );
     256        }
     257
    205258})();
    206259
    207260/**
     
    233286CKEDITOR.config.editingBlock = true;
    234287
    235288/**
     289 * Whether to start the editor in read-only mode.
     290 * @name CKEDITOR.config.readOnly
     291 * @see CKEDITOR.editor.setReadOnly
     292 * @type Boolean
     293 * @default false
     294 * @since 3.6
     295 * @example
     296 * config.readOnly = true;
     297 */
     298
     299/**
    236300 * Fired when a CKEDITOR instance is created, fully initialized and ready for interaction.
    237301 * @name CKEDITOR#instanceReady
    238302 * @event
  • _source/plugins/wysiwygarea/plugin.js

     
    597597
    598598                                                body.spellcheck = !editor.config.disableNativeSpellChecker;
    599599
     600                                                var editable = !editor.readOnly;
     601
    600602                                                if ( CKEDITOR.env.ie )
    601603                                                {
    602604                                                        // Don't display the focus border.
     
    605607                                                        // Disable and re-enable the body to avoid IE from
    606608                                                        // taking the editing focus at startup. (#141 / #523)
    607609                                                        body.disabled = true;
    608                                                         body.contentEditable = true;
     610                                                        body.contentEditable = editable;
    609611                                                        body.removeAttribute( 'disabled' );
    610612                                                }
    611613                                                else
     
    617619                                                                // Prefer 'contentEditable' instead of 'designMode'. (#3593)
    618620                                                                if ( CKEDITOR.env.gecko && CKEDITOR.env.version >= 10900
    619621                                                                                || CKEDITOR.env.opera )
    620                                                                         domDocument.$.body.contentEditable = true;
     622                                                                        domDocument.$.body.contentEditable = editable;
    621623                                                                else if ( CKEDITOR.env.webkit )
    622                                                                         domDocument.$.body.parentNode.contentEditable = true;
     624                                                                        domDocument.$.body.parentNode.contentEditable = editable;
    623625                                                                else
    624                                                                         domDocument.$.designMode = 'on';
     626                                                                        domDocument.$.designMode = editable? 'off' : 'on';
    625627                                                        }, 0 );
    626628                                                }
    627629
    628                                                 CKEDITOR.env.gecko && CKEDITOR.tools.setTimeout( activateEditing, 0, null, editor );
     630                                                editable && CKEDITOR.env.gecko && CKEDITOR.tools.setTimeout( activateEditing, 0, null, editor );
    629631
    630632                                                domWindow       = editor.window = new CKEDITOR.dom.window( domWindow );
    631633                                                domDocument     = editor.document       = new CKEDITOR.dom.document( domDocument );
    632634
    633                                                 domDocument.on( 'dblclick', function( evt )
     635                                                editable && domDocument.on( 'dblclick', function( evt )
    634636                                                {
    635637                                                        var element = evt.data.getTarget(),
    636638                                                                data = { element : element, dialog : '' };
     
    711713
    712714                                                // IE standard compliant in editing frame doesn't focus the editor when
    713715                                                // clicking outside actual content, manually apply the focus. (#1659)
    714                                                 if ( CKEDITOR.env.ie
    715                                                         && domDocument.$.compatMode == 'CSS1Compat'
     716                                                if ( editable &&
     717                                                                CKEDITOR.env.ie && domDocument.$.compatMode == 'CSS1Compat'
    716718                                                                || CKEDITOR.env.gecko
    717719                                                                || CKEDITOR.env.opera )
    718720                                                {
     
    761763                                                        });
    762764
    763765                                                var keystrokeHandler = editor.keystrokeHandler;
    764                                                 if ( keystrokeHandler )
    765                                                         keystrokeHandler.attach( domDocument );
     766                                                // Prevent backspace from navigating off the page.
     767                                                !editable && ( keystrokeHandler.blockedKeystrokes[ 8 ] = 1 );
     768                                                keystrokeHandler.attach( domDocument );
    766769
    767770                                                if ( CKEDITOR.env.ie )
    768771                                                {
    769772                                                        domDocument.getDocumentElement().addClass( domDocument.$.compatMode );
    770773                                                        // Override keystrokes which should have deletion behavior
    771774                                                        //  on control types in IE . (#4047)
    772                                                         domDocument.on( 'keydown', function( evt )
     775                                                        editable && domDocument.on( 'keydown', function( evt )
    773776                                                        {
    774777                                                                var keyCode = evt.data.getKeystroke();
    775778
  • _source/plugins/elementspath/plugin.js

     
    1515                toolbarFocus :
    1616                {
    1717                        editorFocus : false,
     18                        readOnly : 1,
    1819                        exec : function( editor )
    1920                        {
    2021                                var idBase = editor._.elementsPath.idBase;
  • _source/plugins/save/plugin.js

     
    1212        var saveCmd =
    1313        {
    1414                modes : { wysiwyg:1, source:1 },
     15                readOnly : 1,
    1516
    1617                exec : function( editor )
    1718                {
  • _source/plugins/a11yhelp/plugin.js

     
    3737                                                                });
    3838                                        },
    3939                                        modes : { wysiwyg:1, source:1 },
     40                                        readOnly : 1,
    4041                                        canUndo : false
    4142                                });
    4243
  • _source/plugins/about/plugin.js

     
    1111                var command = editor.addCommand( 'about', new CKEDITOR.dialogCommand( 'about' ) );
    1212                command.modes = { wysiwyg:1, source:1 };
    1313                command.canUndo = false;
     14                command.readOnly = 1;
    1415
    1516                editor.ui.addButton( 'About',
    1617                        {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy