Ticket #2864: 2864.patch

File 2864.patch, 11.7 KB (added by Martin Kou, 15 years ago)
  • _source/plugins/selection/plugin.js

     
    110110                                });
    111111                }
    112112        });
    113 })();
    114113
    115 /**
    116  * Gets the current selection from the editing area when in WYSIWYG mode.
    117  * @returns {CKEDITOR.dom.selection} A selection object or null if not on
    118  *              WYSIWYG mode or no selection is available.
    119  * @example
    120  * var selection = CKEDITOR.instances.editor1.<b>getSelection()</b>;
    121  * alert( selection.getType() );
    122  */
    123 CKEDITOR.editor.prototype.getSelection = function()
    124 {
    125         var retval = this.document ? this.document.getSelection() : null;
     114        /**
     115        * Gets the current selection from the editing area when in WYSIWYG mode.
     116        * @returns {CKEDITOR.dom.selection} A selection object or null if not on
     117        *              WYSIWYG mode or no selection is available.
     118        * @example
     119        * var selection = CKEDITOR.instances.editor1.<b>getSelection()</b>;
     120        * alert( selection.getType() );
     121        */
     122        CKEDITOR.editor.prototype.getSelection = function()
     123        {
     124                var retval = this.document ? this.document.getSelection() : null;
    126125
     126                /**
     127                 * IE BUG: The selection's document may be a different document than the
     128                 * editor document. Return null if that's the case.
     129                 */
     130                if ( retval && CKEDITOR.env.ie )
     131                {
     132                        var range = retval.getNative().createRange();
     133                        if ( !range )
     134                                return null;
     135                        else if ( range.item )
     136                                return range.item(0).ownerDocument == this.document.$ ? retval : null;
     137                        else
     138                                return range.parentElement().ownerDocument == this.document.$ ? retval : null;
     139                }
     140
     141                retval.on( 'selectionSet', checkSelectionChangeTimeout, this );
     142                return retval;
     143        };
     144
    127145        /**
    128          * IE BUG: The selection's document may be a different document than the
    129          * editor document. Return null if that's the case.
     146         * Gets the current selection from the document.
     147         * @returns {CKEDITOR.dom.selection} A selection object.
     148         * @example
     149         * var selection = CKEDITOR.instances.editor1.document.<b>getSelection()</b>;
     150         * alert( selection.getType() );
    130151         */
    131         if ( retval && CKEDITOR.env.ie )
     152        CKEDITOR.dom.document.prototype.getSelection = function()
    132153        {
    133                 var range = retval.getNative().createRange();
    134                 if ( !range )
    135                         return null;
    136                 else if ( range.item )
    137                         return range.item(0).ownerDocument == this.document.$ ? retval : null;
    138                 else
    139                         return range.parentElement().ownerDocument == this.document.$ ? retval : null;
    140         }
    141         return retval;
    142 };
     154                return new CKEDITOR.dom.selection( this );
     155        };
    143156
    144 /**
    145  * Gets the current selection from the document.
    146  * @returns {CKEDITOR.dom.selection} A selection object.
    147  * @example
    148  * var selection = CKEDITOR.instances.editor1.document.<b>getSelection()</b>;
    149  * alert( selection.getType() );
    150  */
    151 CKEDITOR.dom.document.prototype.getSelection = function()
    152 {
    153         return new CKEDITOR.dom.selection( this );
    154 };
     157        /**
     158         * No selection.
     159         * @constant
     160         * @example
     161         * if ( editor.getSelection().getType() == CKEDITOR.SELECTION_NONE )
     162         *     alert( 'Nothing is selected' );
     163         */
     164        CKEDITOR.SELECTION_NONE         = 1;
    155165
    156 /**
    157  * No selection.
    158  * @constant
    159  * @example
    160  * if ( editor.getSelection().getType() == CKEDITOR.SELECTION_NONE )
    161  *     alert( 'Nothing is selected' );
    162  */
    163 CKEDITOR.SELECTION_NONE         = 1;
     166        /**
     167         * Text or collapsed selection.
     168        * @constant
     169        * @example
     170         * if ( editor.getSelection().getType() == CKEDITOR.SELECTION_TEXT )
     171         *     alert( 'Text is selected' );
     172        */
     173        CKEDITOR.SELECTION_TEXT         = 2;
    164174
    165 /**
    166  * Text or collapsed selection.
    167  * @constant
    168  * @example
    169  * if ( editor.getSelection().getType() == CKEDITOR.SELECTION_TEXT )
    170  *     alert( 'Text is selected' );
    171  */
    172 CKEDITOR.SELECTION_TEXT         = 2;
     175        /**
     176         * Element selection.
     177        * @constant
     178        * @example
     179         * if ( editor.getSelection().getType() == CKEDITOR.SELECTION_ELEMENT )
     180         *     alert( 'An element is selected' );
     181        */
     182        CKEDITOR.SELECTION_ELEMENT      = 3;
    173183
    174 /**
    175  * Element selection.
    176  * @constant
    177  * @example
    178  * if ( editor.getSelection().getType() == CKEDITOR.SELECTION_ELEMENT )
    179  *     alert( 'An element is selected' );
    180  */
    181 CKEDITOR.SELECTION_ELEMENT      = 3;
     184        /**
     185         * Manipulates the selection in a DOM document.
     186         * @constructor
     187         * @example
     188         */
     189        CKEDITOR.dom.selection = function( document )
     190        {
     191                this.document = document;
     192                this._ =
     193                {
     194                        cache : {}
     195                };
    182196
    183 /**
    184  * Manipulates the selection in a DOM document.
    185  * @constructor
    186  * @example
    187  */
    188 CKEDITOR.dom.selection = function( document )
    189 {
    190         this.document = document;
    191         this._ =
    192         {
    193                 cache : {}
     197                CKEDITOR.event.implementOn( this );
    194198        };
    195 };
    196199
    197 (function()
    198 {
    199200        var styleObjectElements = { img:1,hr:1,li:1,table:1,tr:1,td:1,embed:1,object:1,ol:1,ul:1 };
    200201
    201202        CKEDITOR.dom.selection.prototype =
     
    578579                                        }
    579580
    580581                                        range.select();
     582                                        this.fire( 'selectionSet' );
    581583                                }
    582584                        :
    583585                                function( element )
     
    590592                                        var sel = this.getNative();
    591593                                        sel.removeAllRanges();
    592594                                        sel.addRange( range );
     595                                        this.fire( 'selectionSet' );
    593596                                },
    594597
    595598                selectRanges :
     
    600603                                        // select the first one.
    601604                                        if ( ranges[ 0 ] )
    602605                                                ranges[ 0 ].select();
     606                                        this.fire( 'selectionSet' );
    603607                                }
    604608                        :
    605609                                function( ranges )
     
    617621                                                // Select the range.
    618622                                                sel.addRange( nativeRange );
    619623                                        }
     624                                        this.fire( 'selectionSet' );
    620625                                },
    621626
    622627                createBookmarks : function()
  • _source/plugins/toolbar/plugin.js

     
    209209                'Source', '-',
    210210                'NewPage', '-',
    211211                'Bold', 'Italic', 'Underline', 'Strike', '-',
     212                'NumberedList', 'BulletedList', '-',
    212213                'Subscript', 'Superscript', '-',
    213214                'SelectAll', 'RemoveFormat', '-',
    214215                'Smiley', 'HorizontalRule', 'SpecialChar', 'PageBreak'
  • _source/skins/default/toolbar.css

     
    305305{
    306306        background-position: 0 -880px;
    307307}
     308
     309.cke_skin_default a.cke_button_numberedlist .cke_icon
     310{
     311        background-position: 0 -400px;
     312}
     313
     314.cke_skin_default a.cke_button_bulletedlist .cke_icon
     315{
     316        background-position: 0 -416px;
     317}
  • _source/core/config.js

     
    146146         * @example
    147147         * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea';
    148148         */
    149         plugins : 'basicstyles,button,elementspath,horizontalrule,htmldataprocessor,keystrokes,newpage,pagebreak,removeformat,smiley,sourcearea,specialchar,tab,toolbar,wysiwygarea',
     149        plugins : 'basicstyles,button,elementspath,horizontalrule,htmldataprocessor,keystrokes,newpage,pagebreak,removeformat,smiley,list,sourcearea,specialchar,tab,toolbar,wysiwygarea',
    150150
    151151        /**
    152152         * The theme to be used to build the UI.
  • _source/core/dom/node.js

     
    305305                        return parents;
    306306                },
    307307
     308                getCommonAncestor : function( node )
     309                {
     310                        if ( node.equals( this ) )
     311                                return this;
     312
     313                        if ( node.contains && node.contains( this ) )
     314                                return node;
     315
     316                        var start = this.contains ? this : this.getParent();
     317
     318                        do
     319                        {
     320                                if ( start.contains( end ) )
     321                                        return start;
     322                        }
     323                        while ( ( start = start.getParent() ) );
     324
     325                        return null;
     326                },
     327
    308328                getPosition : function( otherNode )
    309329                {
    310330                        var $ = this.$;
  • _source/core/dom/domobject.js

     
    165165                var expandoNumber = this.$._cke_expando,
    166166                        dataSlot = expandoNumber && customData[ expandoNumber ];
    167167
    168                 return ( dataSlot && dataSlot[ key ] ) || null;
     168                if ( dataSlot && dataSlot[ key ] !== undefined )
     169                        return dataSlot[ key ];
     170                return null;
    169171        };
    170172
     173        domObjectProto.removeCustomData = function( key )
     174        {
     175                var expandoNumber = this.$._cke_expando,
     176                        dataSlot = expandoNumber && customData[ expandoNumber ],
     177                        retval = dataSlot[ key ];
     178
     179                delete dataSlot[ key ];
     180                return retval || null;
     181        };
     182
    171183        // Implement CKEDITOR.event.
    172184        CKEDITOR.event.implementOn( domObjectProto );
    173185
  • _source/core/dom/element.js

     
    7373        return temp.getFirst().remove();
    7474};
    7575
     76CKEDITOR.dom.element.setMarker = function( database, element, name, value )
     77{
     78        var id = element.getCustomData( 'list_marker_id' ) ||
     79                        ( element.setCustomData( 'list_marker_id', CKEDITOR.tools.getNextNumber() ).getCustomData( 'list_marker_id' ) ),
     80                markerNames = element.getCustomData( 'list_marker_names' ) ||
     81                        ( element.setCustomData( 'list_marker_names', {} ).getCustomData( 'list_marker_names' ) );
     82        database[id] = element;
     83        markerNames[name] = 1;
     84
     85        return element.setCustomData( name, value );
     86};
     87
     88CKEDITOR.dom.element.clearAllMarkers = function( database )
     89{
     90        for ( var i in database )
     91                CKEDITOR.dom.element.clearMarkers( database, database[i], true );
     92};
     93
     94CKEDITOR.dom.element.clearMarkers = function( database, element, removeFromDatabase )
     95{
     96        var names = element.getCustomData( 'list_marker_names' ),
     97                id = element.getCustomData( 'list_marker_id' );
     98        for ( var i in names )
     99                element.removeCustomData( names[i] );
     100        element.removeCustomData( 'list_marker_names' );
     101        if ( removeFromDatabase )
     102        {
     103                element.removeCustomData( 'list_marker_id' );
     104                delete database[id];
     105        }
     106};
     107
    76108CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
    77109        /** @lends CKEDITOR.dom.element.prototype */
    78110        {
  • _source/core/dom/documentFragment.js

     
    2626                                targetElement.$.appendChild( this.$ );
    2727                },
    2828
     29                moveChildren : elementPrototype.moveChildren,
     30
    2931                insertAfterNode : function( node )
    3032                {
    3133                        var $ = this.$;
     
    3941                        }
    4042                        else
    4143                                $parent.insertBefore( $, $node.nextSibling );
    42                 }
     44                },
     45
     46                replace : function( nodeToReplace )
     47                {
     48                        this.insertAfterNode( nodeToReplace );
     49                        nodeToReplace.remove();
     50                },
     51
     52                trim : elementPrototype.trim,
     53                ltrim : elementPrototype.ltrim,
     54                rtrim : elementPrototype.rtrim,
     55                getFirst : elementPrototype.getFirst,
     56                getLast : elementPrototype.getLast,
     57                getDocument : elementPrototype.getDocument,
     58                getChildCount : elementPrototype.getChildCount,
     59                getChild : elementPrototype.getChild,
     60                contains : elementPrototype.contains
    4361        };
    4462})();
  • _source/core/tools.js

     
    310310                                return i;
    311311                }
    312312                return -1;
     313        },
     314
     315        bind : function( func, obj )
     316        {
     317                return function() { return func.apply( obj, arguments ); };
    313318        }
    314319};
    315320
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy