Ticket #1376: 1376.patch

File 1376.patch, 5.1 KB (added by Garry Yao, 14 years ago)
  • _source/core/config.js

     
    239239         * @type String
    240240         * @example
    241241         */
    242         plugins : 'about,a11yhelp,basicstyles,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,div,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,liststyle,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,smiley,showblocks,showborders,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
     242        plugins : 'about,a11yhelp,basicstyles,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,div,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,liststyle,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,readonly,removeformat,resize,save,scayt,smiley,showblocks,showborders,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
    243243
    244244        /**
    245245         * List of additional plugins to be loaded. This is a tool setting which
  • _source/plugins/readonly/plugin.js

     
     1/*
     2Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6CKEDITOR.plugins.add( 'readonly',
     7{
     8        requires : [ 'editingblock' ],
     9        init : function( editor )
     10        {
     11                editor.addCommand( 'readonly',
     12                {
     13                        modes : { wysiwyg : 1, source : 1 },
     14                        editorFocus : false,
     15                        canUndo : false,
     16                        exec : function ( editor )
     17                        {
     18                                editor.readOnly( this.state == CKEDITOR.TRISTATE_OFF );
     19                                this.toggleState();
     20                        }
     21                });
     22
     23                editor.ui.addButton( 'ReadOnly',
     24                        {
     25                                label : editor.lang.readOnly,
     26                                command : 'readonly'
     27                        });
     28        }
     29});
     30
     31( function()
     32{
     33         var cancelEvent = function( evt )
     34         {
     35                evt.cancel();
     36         };
     37
     38        function cancelKeyListener( evt )
     39        {
     40                var keystroke = evt.data.keyCode;
     41                if ( keystroke != 9 && keystroke != CKEDITOR.SHIFT + 9 )
     42                  cancelEvent( evt );
     43        }
     44
     45   // List of commands that are read-only.
     46        CKEDITOR.plugins.readyOnly =
     47   {
     48           readyOnlyCommands : { readonly:1,maximize:1,showblocks:1,showborders:1,preview:1,save:1,copy:1,print:1,selectAll:1,about:1 }
     49   };
     50
     51        CKEDITOR.editor.prototype.readOnly = function( isReadOnly )
     52   {
     53                // Disable all commands in wysiwyg mode.
     54                var command,
     55                        commands = this._.commands,
     56                        mode = this.mode;
     57
     58                for ( var name in commands )
     59                {
     60                        if ( name in CKEDITOR.plugins.readyOnly.readyOnlyCommands )
     61                                continue;
     62
     63                        command = commands[ name ];
     64                        isReadOnly ? command.disable() : command[ command.modes[ mode ] ? 'enable' : 'disable' ]();
     65                        this[ isReadOnly ? 'on' : 'removeListener' ]( 'state', cancelEvent, null, null, 0 );
     66                }
     67
     68                if ( this.mode == 'wysiwyg' )
     69                {
     70                        // Turn off contentEditable.
     71                        this.document.$.body.contentEditable = !isReadOnly;
     72
     73                        // Prevent key handling.
     74                        this[ isReadOnly ? 'on' : 'removeListener' ]( 'key', cancelKeyListener, null, null, 0 );
     75                        this[ isReadOnly ? 'on' : 'removeListener' ]( 'selectionChange', cancelEvent, null, null, 0 );
     76
     77                        // Deal with some toolbar items that don't get associated with commands.
     78                        var i, j, k;
     79                        var toolbars = this.toolbox.toolbars;
     80                        for ( i = 0; i < toolbars.length; i++ )
     81                        {
     82                                var toolbarItems = toolbars[ i ].items;
     83                                for ( j = 0; j < toolbarItems.length; j++ )
     84                                {
     85                                         // Combos and panel buttons.
     86                                        var combo = toolbarItems[ j ].combo;
     87                                        if ( combo )
     88                                                combo.setState( isReadOnly ? CKEDITOR.TRISTATE_DISABLED : CKEDITOR.TRISTATE_OFF );
     89
     90                                        var button = toolbarItems[ j ].button;
     91                                        if ( button instanceof CKEDITOR.ui.panelButton )
     92                                                button.setState( isReadOnly ? CKEDITOR.TRISTATE_DISABLED : CKEDITOR.TRISTATE_OFF );
     93                                }
     94                        }
     95                }
     96                else if ( this.mode == 'source' )
     97                {
     98                        if ( isReadOnly )
     99                                this.textarea.setAttribute( 'disabled', true );
     100                        else
     101                                this.textarea.removeAttribute( 'disabled' );
     102                }
     103   }
     104
     105} )();
  • _source/plugins/toolbar/plugin.js

     
    425425 */
    426426CKEDITOR.config.toolbar_Full =
    427427[
    428         ['Source','-','Save','NewPage','Preview','-','Templates'],
     428        ['Source','-','Save','NewPage','Preview','ReadOnly','-','Templates'],
    429429        ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
    430430        ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
    431431        ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy