Ticket #2862: 2862_5.patch

File 2862_5.patch, 13.4 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/sourcearea/plugin.js

     
    6868
    6969                                                        // Set the <textarea> value.
    7070                                                        this.loadData( data );
    71 
     71                                                        editor.sourceField = textarea;
    7272                                                        editor.mode = 'source';
    7373                                                        editor.fire( 'mode' );
    7474                                                },
  • _source/plugins/selection/plugin.js

     
    147147        {
    148148                delete this._.selectionPreviousPath;
    149149        };
    150 
     150       
     151        /**
     152         * Force firing of the 'selectionChange' event.
     153         */
     154        CKEDITOR.editor.prototype.checkSelection = checkSelectionChange;
     155       
    151156        /**
    152157         * Gets the current selection from the document.
    153158         * @returns {CKEDITOR.dom.selection} A selection object.
  • _source/plugins/maximize/plugin.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6/**
     7 * @fileOverview The "maximize" plugin. Enable it will make the editor chrome
     8 *               being maximized and fullfill the view size. Disable it _restore
     9 *               editor chrome into original size.
     10 */
     11
     12( function()
     13{
     14        var body = CKEDITOR.document.getBody();
     15       
     16        //Only one editor instance is allowed to be full screen at a time.
     17        var hasMaximized = false;
     18       
     19        function maximizeCommand(editor)
     20        {
     21                this.editor = editor;
     22                // elements along with styles.
     23                this.savedAttributes = [];
     24                // Keep track of the need-to-_restore data
     25                this._restore =
     26                {
     27                        // document content
     28                        content : '',
     29                        // selection range bookmark
     30                        bookmark : null,
     31                        // editor focus state
     32                        focus : false,
     33                        // scrollbar position
     34                        scroll : null
     35                };
     36                // Whether pending the restoring due to asynchroniz loading of
     37                // content.
     38                this.restorePending = false;
     39        }
     40       
     41        maximizeCommand.prototype =
     42        {
     43                /**
     44                 * Save the css style of the element for later restoring.
     45                 *
     46                 * @param {CKEDITOR.dom.element}        element
     47                 */
     48                saveStyles : function ( element )
     49                {
     50                        this.savedAttributes.push( {
     51                                element : element,
     52                                attributes : {
     53                                        'class' : element.getAttribute( 'class' ),
     54                                        'style' : element.getAttribute( 'style' )
     55                                }
     56                        } );
     57                },
     58               
     59                /**
     60                 * _restore the saved attributes for elements
     61                 */
     62                restoreAllStyles : function ()
     63                {
     64                        var i = 0, l = this.savedAttributes.length, attrs, element;
     65                        var attrName, attribute;
     66                        for ( ; i < l ; i++ )
     67                        {
     68                                attrs = this.savedAttributes[ i ].attributes;
     69                                element = this.savedAttributes[ i ].element;
     70
     71                                for ( attrName in attrs )
     72                                {
     73                                        if ( attrs[ attrName ] )
     74                                                element.setAttribute( attrName, attrs[ attrName ] );
     75                                        else
     76                                                element.removeAttribute( attrName );
     77                                }
     78                        }
     79                },
     80               
     81                /**
     82                 * Alter the element style while keep record of the original styles.
     83                 */
     84                changeStyle : function ( element, styles )
     85                {
     86                        this.saveStyles( element );
     87                        element.setStyles( styles );
     88                },
     89               
     90               
     91                /**
     92                 * Lift the whole editor to became the first child of body element, OR
     93                 * _restore the editor to it's original position.
     94                 * @param {Boolean} isRestore
     95                 */
     96                moveEditor : function ( isRestore )
     97                {
     98                        var container = this.editor.container;
     99
     100                        if ( isRestore )
     101                        {
     102                                // place right after the remembered previous sibling.
     103                                container.insertAfter( this.lastPreviousSibling );
     104                        }
     105                        else
     106                        {
     107                                this.lastPreviousSibling = this.editor.container.getPrevious();
     108                                body.append( this.editor.container, true );
     109                        }
     110                },
     111               
     112                saveSelection : function ()
     113                {
     114                        if ( this.editor.mode == 'wysiwyg' )
     115                        {
     116                                var editorFocus = this.editor.focusManager.hasFocus;
     117                               
     118                                // IE failed to create selection on editor blur
     119                                if ( CKEDITOR.env.ie && !editorFocus )
     120                                        return;
     121                                       
     122                                var sel = this.editor.document.getSelection();
     123                                if ( sel )
     124                                {
     125                                        this._restore.bookmark = sel.createBookmarks( true );
     126                                        this._restore.focus = editorFocus;
     127                                }
     128                        }
     129                },
     130               
     131                restoreSelection : function ()
     132                {
     133                        if ( this._restore.bookmark && !this.restorePending )
     134                        {
     135                                var sel = this.editor.document.getSelection();
     136                                if ( sel )
     137                                {
     138                                        sel.selectBookmarks( this._restore.bookmark );
     139                                       
     140                                        if ( this._restore.focus )
     141                                        {
     142                                                this.editor.focus();
     143                                                this.editor.forceNextSelectionCheck();
     144                                        }
     145                                        else
     146                                                this.editor.checkSelection();
     147                                               
     148                                        delete this._restore.focus;
     149                                        delete this._restore.bookmark;
     150                                }
     151                        }
     152                },
     153               
     154                /**
     155                 * Force reconstruct the current mode with the saved content.
     156                 * @param {Object} data Content snapshot
     157                 */
     158                reloadMode : function (data)
     159                {
     160                        //Clear holder element
     161                        var holderElement = this.editor.getThemeSpace( 'contents' );
     162                        holderElement.setHtml( '' );
     163                        // Reload current mode.
     164                        var currentModeEditor = this.editor._.modes[this.editor.mode];
     165                        currentModeEditor.load( holderElement, data );
     166                },
     167       
     168                saveContent : function ()
     169                {
     170                        // Kludge: Fix for Gecko and Webkit bug of iframe reloads when moved
     171                        // around the DOM tree.
     172                        if ( this.editor.mode == 'wysiwyg' && !CKEDITOR.env.ie )
     173                        {
     174                                // Get the dirty content along with bookmark
     175                                this._restore.content = this.editor.getSnapshot();
     176                                this.restorePending = true;
     177                        }
     178                },
     179               
     180                restoreContent : function ()
     181                {
     182                        if ( this._restore.content )
     183                        {
     184                                this.editor.on( 'mode', function()
     185                                {
     186                                        this.restorePending = false;
     187                                        this.restoreScrollPosition();
     188                                        this.restoreSelection();
     189                                        this.editor.removeListener( 'mode', arguments.callee );
     190                                        delete this._restore.content;
     191                                }, this );
     192
     193                                // reload document content
     194                                this.reloadMode( this._restore.content );
     195                        }
     196                },
     197               
     198                getEditorElement : function()
     199                {
     200                        var element = ( this.editor.mode == 'wysiwyg' ) ?
     201                                this.editor.document.$.documentElement
     202                                : this.editor.sourceField;
     203
     204                        return element.$ || element;
     205                },
     206               
     207                saveScrollPosition : function ( )
     208                {
     209                        if ( CKEDITOR.env.ie && this.editor.mode == 'wysiwyg' )
     210                                return;
     211                        var element = this.getEditorElement();
     212                        this._restore.scroll =
     213                        {
     214                                'element' : element,
     215                                'left' : element.scrollLeft + element.clientWidth,
     216                                'top' : element.scrollTop + element.clientHeight
     217                        };
     218                },
     219               
     220                restoreScrollPosition : function ()
     221                {
     222                        if ( this._restore.scroll && !this.restorePending )
     223                        {
     224                                var element = this.getEditorElement();
     225                                var translatedScroll =
     226                                {
     227                                        'left' :  this._restore.scroll.left - element.clientWidth ,
     228                                        'top' :  this._restore.scroll.top - element.clientHeight
     229                                };
     230                                element.scrollLeft = translatedScroll.left;
     231                                element.scrollTop = translatedScroll.top;
     232
     233                                delete this._restore.scroll;
     234                        }
     235                },
     236               
     237                save: function()
     238                {
     239                        this.saveSelection();
     240                        this.saveContent();
     241                        this.saveScrollPosition();
     242                },
     243               
     244                restore : function()
     245                {
     246                        this.restoreContent();
     247                        this.restoreScrollPosition();
     248                        this.restoreSelection();
     249                },
     250               
     251                exec : function( editor )
     252                {
     253                       
     254                        if( this.state == CKEDITOR.TRISTATE_ON || !hasMaximized )
     255                        {
     256                                this.save();
     257                               
     258                                if ( this.state == CKEDITOR.TRISTATE_ON )
     259                                {
     260                                        this.moveEditor( true );
     261                                        this.restoreAllStyles();
     262                                        hasMaximized = false;
     263                                }
     264                                else
     265                                {
     266                                        this.moveEditor();
     267                                        // fix IE and Opera viewport scrolling
     268                                        if ( CKEDITOR.env.ie || CKEDITOR.env.opera )
     269                                        {
     270                                                var view = new CKEDITOR.dom.element(
     271                                                CKEDITOR.document.$.documentElement );
     272                                                this.changeStyle( view, {
     273                                                        'overflow' :'hidden'
     274                                                } );
     275                                        }
     276                                       
     277                                        this.changeStyle( body, {
     278                                                'top' : '0px',
     279                                                'left' : '0px',
     280                                                'height' : '100%',
     281                                                'width' : '100%',
     282                                                'overflow' : 'hidden',
     283                                                'position' : 'absolute',
     284                                                'margin' : '0px'
     285                                        } );
     286                                       
     287                                        if ( CKEDITOR.env.webkit )
     288                                        {
     289                                                this.changeStyle( editor.container, {
     290                                                        'position' : 'absolute',
     291                                                        'height' : '100%',
     292                                                        'width' : '100%',
     293                                                        'z-index' : '10'
     294                                                } );
     295                                        }
     296                               
     297                                        this.changeStyle( editor.container.getFirst(), {
     298                                                'width' : '100%',
     299                                                // Kludge: Fix IE and Opera table over-height on fit parent.
     300                                                'height' : ( ( CKEDITOR.env.ie &&
     301                                                        CKEDITOR.document.$.compatMode != 'BackCompat' )
     302                                                || CKEDITOR.env.opera ) ? '90%' : '100%',
     303                                                'z-index' : '10'
     304                                        } );
     305                                       
     306                                        // Fix IE 'source' mode bug of #2764
     307                                        if( editor.mode == 'source' && CKEDITOR.env.ie )
     308                                        {
     309                                                var element = this.editor.sourceField;
     310                                                this.changeStyle( element , {
     311                                                        'width' : element.getParent().$.clientWidth,
     312                                                        'height' : element.getParent().$.clientHeight
     313                                                } );
     314                                        }
     315                                       
     316                                        hasMaximized = true;
     317                                }
     318                        }
     319                       
     320                        this.restore();
     321                        // refresh command state
     322                        this.toggleState();
     323                }
     324        };
     325       
     326        CKEDITOR.plugins.add( 'maximize',
     327        {
     328                requires : [ 'editingblock' ],
     329
     330                init : function( editor )
     331                {
     332                        editor.addCommand( 'maximize', new maximizeCommand( editor ) );
     333                        editor.ui.addButton( 'Maximize', {
     334                                label : editor.lang.maximize,
     335                                command : 'maximize'
     336                        } );
     337                       
     338                        if(editor.config.startupMaximize)
     339                        {
     340                                editor.on( 'mode', function()
     341                                {
     342                                        // defer the execution to avoid DUP event registration in
     343                                        // event-handler.
     344                                        setTimeout( function()
     345                                        {
     346                                                editor.getCommand( 'maximize' ).exec();
     347                                        }, 0 );
     348                                       
     349                                        editor.removeListener( 'mode', arguments.callee );
     350                                });
     351                        }
     352                }
     353        });
     354       
     355})();
     356
     357CKEDITOR.config.startupMaximize = false;
     358 No newline at end of file
  • _source/plugins/toolbar/plugin.js

     
    216216                'SelectAll', 'RemoveFormat', '-',
    217217                'Link', 'Unlink', 'Anchor', '-',
    218218                'Image', '-',
    219                 'Table', 'Smiley', 'HorizontalRule', 'SpecialChar', 'PageBreak'
     219                'Table', 'Smiley', 'HorizontalRule', 'SpecialChar', 'PageBreak','-',
     220                'Maximize'
    220221        ]
    221222];
  • _source/lang/en.js

     
    4343        horizontalrule  : 'Insert Horizontal Line',
    4444        pagebreak               : 'Insert Page Break',
    4545        unlink                  : 'Unlink',
     46        maximize                        : 'Maximize',
    4647
    4748        // Common messages and labels.
    4849        common :
  • _source/core/command.js

     
    3434                this.fire( 'state' );
    3535
    3636                return true;
     37        },
     38        /*
     39         * Toggle the current state of command and refresh.
     40         */
     41        toggleState : function()
     42        {
     43                this.setState( this.state == CKEDITOR.TRISTATE_ON ?
     44                                CKEDITOR.TRISTATE_OFF
     45                                : CKEDITOR.TRISTATE_ON );
    3746        }
    3847}
    3948
  • _source/core/config.js

     
    147147         * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea';
    148148         */
    149149
    150         plugins : 'basicstyles,blockquote,button,elementspath,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,newpage,pagebreak,preview,print,removeformat,smiley,sourcearea,table,specialchar,tab,toolbar,wysiwygarea',
     150        plugins : 'basicstyles,blockquote,button,elementspath,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,preview,print,removeformat,smiley,sourcearea,table,specialchar,tab,toolbar,wysiwygarea',
    151151
    152152        /**
    153153         * The theme to be used to build the UI.
  • _source/core/dom/element.js

     
    379379
    380380                                                        return tabIndex;
    381381                                                        break;
     382                                                       
     383                                                case 'style' :
     384                                                        return this.$.style.cssText;
    382385                                        }
    383386
    384387                                        return standard.call( this, name );
     
    846849                                {
    847850                                        if ( name == 'class' )
    848851                                                name = 'className';
     852                                        else if ( name == 'style' )
     853                                        {
     854                                                if(this.$.style)
     855                                                        this.$.style.cssText = ' ';
     856                                                return;
     857                                        }
    849858                                        standard.call( this, name );
    850859                                };
    851860                        }
  • _source/skins/default/toolbar.css

     
    310310{
    311311        background-position: 0 -880px;
    312312}
     313.cke_skin_default a.cke_button_maximize .cke_icon
     314{
     315        background-position: 0 -1040px;
     316}
    313317
    314318.cke_skin_default a.cke_button_numberedlist .cke_icon
    315319{
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy