Ticket #3001: 3001_2.patch

File 3001_2.patch, 23.2 KB (added by Martin Kou, 15 years ago)
  • _source/plugins/pastetext/plugin.js

     
    2323                        }
    2424
    2525                        // Check if the selection is inside the editing area for IE. (#3216)
    26                         if ( !editor.getSelection() )
     26                        if ( CKEDITOR.env.ie )
    2727                                editor.focus();
    2828
    2929                        editor.insertText( window.clipboardData.getData( 'Text' ) );
  • _source/plugins/image/dialogs/image.js

     
    314314                                // Insert a new Image.
    315315                                if ( !this.imageEditMode )
    316316                                {
    317                                         // It doesn't work with IE.
    318                                         this.restoreSelection();
    319                                         this.clearSavedSelection();
    320 
    321317                                        if ( this.addLink )
    322318                                        {
    323319                                                //Insert a new Link.
  • _source/plugins/colorbutton/plugin.js

     
    1212                var config = editor.config,
    1313                        lang = editor.lang.colorButton;
    1414
    15                 var saveRanges,
    16                         clickFn;
     15                var clickFn;
    1716
    1817                addButton( 'TextColor', 'fore', lang.textColorTitle );
    1918                addButton( 'BGColor', 'back', lang.bgColorTitle );
     
    4443                                                keys[ 37 ]      = 'prev';                                       // ARROW-LEFT
    4544                                                keys[ CKEDITOR.SHIFT + 9 ]      = 'prev';       // SHIFT + TAB
    4645                                                keys[ 32 ]      = 'click';                                      // SPACE
    47                                         },
    48 
    49                                         onOpen : function()
    50                                         {
    51                                                 if ( CKEDITOR.env.ie )
    52                                                 {
    53                                                         editor.focus();
    54                                                         saveRanges = editor.getSelection().getRanges();
    55                                                 }
    56                                         },
    57 
    58                                         onClose : function()
    59                                         {
    60                                                 saveRanges = null;
    6146                                        }
    6247                                });
    6348                }
     
    8166
    8267                                                editor.focus();
    8368
    84                                                 if ( saveRanges )
    85                                                 {
    86                                                         editor.getSelection().selectRanges( saveRanges );
    87                                                         saveRanges = false;
    88                                                 }
    89 
    9069                                                panel.hide();
    9170
    9271                                                var style = new CKEDITOR.style( config['colorButton_' + type + 'Style'], { color : color || '#000' } );
  • _source/plugins/wysiwygarea/plugin.js

     
    2121                                data = this.dataProcessor.toHtml( data );
    2222
    2323                        if ( CKEDITOR.env.ie )
     24                        {
     25                                if ( $doc.selection.type == 'Control' )
     26                                        $doc.selection.clear();
    2427                                $doc.selection.createRange().pasteHTML( data );
     28                        }
    2529                        else
    2630                                $doc.execCommand( 'inserthtml', false, data );
    2731                }
  • _source/plugins/find/dialogs/find.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    798798                                if ( finder.range && finder.range.isMatched() )
    799799                                {
    800800                                        finder.range.removeHighlight();
     801                                        editor.focus();
    801802                                        editor.getSelection().selectRanges(
    802803                                                [ finder.range.toDomRange() ] );
    803804                                }
  • _source/plugins/selection/plugin.js

     
    1010        // The selection change check basically saves the element parent tree of
    1111        // the current node and check it on successive requests. If there is any
    1212        // change on the tree, then the selectionChange event gets fired.
    13         var checkSelectionChange = function()
     13        function checkSelectionChange()
    1414        {
    1515                // In IE, the "selectionchange" event may still get thrown when
    1616                // releasing the WYSIWYG mode, so we need to check it first.
     
    2828                }
    2929        };
    3030
    31         var checkSelectionChangeTimer;
    32         var checkSelectionChangeTimeoutPending;
    33         var checkSelectionChangeTimeout = function()
     31        var checkSelectionChangeTimer,
     32                checkSelectionChangeTimeoutPending;
     33
     34        function checkSelectionChangeTimeout()
    3435        {
    3536                // Firing the "OnSelectionChange" event on every key press started to
    3637                // be too slow. This function guarantees that there will be at least
     
    4445                checkSelectionChangeTimeoutExec.call( this );
    4546
    4647                checkSelectionChangeTimer = CKEDITOR.tools.setTimeout( checkSelectionChangeTimeoutExec, 200, this );
    47         };
     48        }
    4849
    49         var checkSelectionChangeTimeoutExec = function()
     50        function checkSelectionChangeTimeoutExec()
    5051        {
    5152                checkSelectionChangeTimer = null;
    5253
     
    6061
    6162                        checkSelectionChangeTimeoutPending = false;
    6263                }
    63         };
     64        }
    6465
    6566        // #### checkSelectionChange : END
    6667
     
    8586                {
    8687                        editor.on( 'contentDom', function()
    8788                                {
     89                                        var doc = editor.document;
     90
    8891                                        if ( CKEDITOR.env.ie )
    8992                                        {
     93                                                // Other browsers don't loose the selection if the
     94                                                // editor document loose the focus. In IE, we don't
     95                                                // have support for it, so we reproduce it here, other
     96                                                // than firing the selection change event.
     97
     98                                                var savedRange,
     99                                                        saveEnabled;
     100
     101                                                // "onfocusin" is fired before "onfocus". It makes it
     102                                                // possible to restore the selection before click
     103                                                // events get executed.
     104                                                doc.on( 'focusin', function()
     105                                                        {
     106                                                                // If we have saved a range, restore it at this
     107                                                                // point.
     108                                                                if ( savedRange )
     109                                                                {
     110                                                                        // Well not break because of this.
     111                                                                        try
     112                                                                        {
     113                                                                                savedRange.select();
     114                                                                        }
     115                                                                        catch (e)
     116                                                                        {}
     117
     118                                                                        savedRange = null;
     119                                                                }
     120                                                        });
     121
     122                                                editor.window.on( 'focus', function()
     123                                                        {
     124                                                                // Enable selections to be saved.
     125                                                                saveEnabled = true;
     126
     127                                                                saveSelection();
     128                                                        });
     129
     130                                                editor.window.on( 'blur', function()
     131                                                        {
     132                                                                // Disable selections from being saved.
     133                                                                saveEnabled = false;
     134
     135                                                                // IE may leave the selection still inside the
     136                                                                // document. Let's force it to be removed.
     137                                                                // TODO: The following has effect for
     138                                                                // collapsed selections.
     139                                                                editor.document.$.execCommand( 'Unselect' );
     140                                                        });
     141
     142                                                // IE fires the "selectionchange" event when clicking
     143                                                // inside a selection. We don't want to capture that.
     144                                                doc.on( 'mousedown', disableSave );
     145                                                doc.on( 'mouseup',
     146                                                        function()
     147                                                        {
     148                                                                saveEnabled = true;
     149                                                                setTimeout( function()
     150                                                                        {
     151                                                                                saveSelection( true );
     152                                                                        },
     153                                                                        0 );
     154                                                        });
     155
     156                                                doc.on( 'keydown', disableSave );
     157                                                doc.on( 'keyup',
     158                                                        function()
     159                                                        {
     160                                                                saveEnabled = true;
     161                                                                saveSelection();
     162                                                        });
     163
     164
    90165                                                // IE is the only to provide the "selectionchange"
    91166                                                // event.
    92                                                 editor.document.on( 'selectionchange', checkSelectionChangeTimeout, editor );
     167                                                doc.on( 'selectionchange', saveSelection );
     168
     169                                                function disableSave()
     170                                                {
     171                                                        saveEnabled = false;
     172                                                }
     173
     174                                                function saveSelection( testIt )
     175                                                {
     176                                                        if ( saveEnabled )
     177                                                        {
     178                                                                var doc = editor.document,
     179                                                                        sel = doc && doc.$.selection;
     180
     181                                                                // There is a very specific case, when clicking
     182                                                                // inside a text selection. In that case, the
     183                                                                // selection collapses at the clicking point,
     184                                                                // but the selection object remains in an
     185                                                                // unknown state, making createRange return a
     186                                                                // range at the very start of the document. In
     187                                                                // such situation we have to test the range, to
     188                                                                // be sure it's valid.
     189                                                                if ( testIt && sel && sel.type == 'None' )
     190                                                                {
     191                                                                        // The "InsertImage" command can be used to
     192                                                                        // test whether the selection is good or not.
     193                                                                        // If not, it's enough to give some time to
     194                                                                        // IE to put things in order for us.
     195                                                                        if ( !doc.$.queryCommandEnabled( 'InsertImage' ) )
     196                                                                        {
     197                                                                                CKEDITOR.tools.setTimeout( saveSelection, 50, this, true );
     198                                                                                return;
     199                                                                        }
     200                                                                }
     201
     202                                                                savedRange = sel && sel.createRange();
     203
     204                                                                checkSelectionChangeTimeout.call( editor );
     205                                                        }
     206                                                }
     207
     208                                                editor.lockSelection = function()
     209                                                {
     210                                                        saveEnabled = false;
     211                                                };
     212
     213                                                editor.unlockSelection = function()
     214                                                {
     215                                                        saveEnabled = true;
     216                                                        saveSelection( true );
     217                                                };
    93218                                        }
    94219                                        else
    95220                                        {
     
    97222                                                // check based on other events, like clicks or keys
    98223                                                // press.
    99224
    100                                                 editor.document.on( 'mouseup', checkSelectionChangeTimeout, editor );
    101                                                 editor.document.on( 'keyup', checkSelectionChangeTimeout, editor );
     225                                                doc.on( 'mouseup', checkSelectionChangeTimeout, editor );
     226                                                doc.on( 'keyup', checkSelectionChangeTimeout, editor );
    102227                                        }
    103228                                });
    104229
  • _source/plugins/forms/dialogs/checkbox.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    3838                        this.commitContent( element );
    3939
    4040                        if ( isInsertMode )
    41                         {
    42                                 this.restoreSelection();
    43                                 this.clearSavedSelection();
    4441                                editor.insertElement( element );
    45                         }
    4642                },
    4743                contents : [
    4844                        {
     
    6056                                                setup : function( element )
    6157                                                {
    6258                                                        this.setValue( element.getAttribute( 'name' ) );
    63                                                         this.focus();
    6459                                                },
    6560                                                commit : function( element )
    6661                                                {
  • _source/plugins/forms/dialogs/textfield.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    3636                        this.commitContent( element );
    3737
    3838                        if ( isInsertMode )
    39                         {
    40                                 this.restoreSelection();
    41                                 this.clearSavedSelection();
    4239                                editor.insertElement( element );
    43                         }
    4440                },
    4541                contents : [
    4642                        {
  • _source/plugins/forms/dialogs/button.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    3939                        this.commitContent( element );
    4040
    4141                        if ( isInsertMode )
    42                         {
    43                                 this.restoreSelection();
    44                                 this.clearSavedSelection();
    4542                                editor.insertElement( element );
    46                         }
    4743                },
    4844                contents : [
    4945                        {
  • _source/plugins/forms/dialogs/textarea.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    3535                        this.commitContent( element );
    3636
    3737                        if ( isInsertMode )
    38                         {
    39                                 this.restoreSelection();
    40                                 this.clearSavedSelection();
    4138                                editor.insertElement( element );
    42                         }
    4339                },
    4440                contents : [
    4541                        {
  • _source/plugins/forms/dialogs/radio.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    3636                        this.commitContent( element );
    3737
    3838                        if ( isInsertMode )
    39                         {
    40                                 this.restoreSelection();
    41                                 this.clearSavedSelection();
    4239                                editor.insertElement( element );
    43                         }
    4440                },
    4541                contents : [
    4642                        {
  • _source/plugins/forms/dialogs/hiddenfield.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    3636                        this.commitContent( element );
    3737
    3838                        if ( isInsertMode )
    39                         {
    40                                 this.restoreSelection();
    41                                 this.clearSavedSelection();
    4239                                editor.insertElement( element );
    43                         }
    4440                },
    4541                contents : [
    4642                        {
  • _source/plugins/forms/dialogs/select.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    163163                        this.commitContent( element );
    164164
    165165                        if ( isInsertMode )
    166                         {
    167                                 this.restoreSelection();
    168                                 this.clearSavedSelection();
    169166                                editor.insertElement( element );
    170                         }
    171167                },
    172168                contents : [
    173169                        {
  • _source/plugins/forms/dialogs/form.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    3636                        this.commitContent( element );
    3737
    3838                        if ( isInsertMode )
    39                         {
    40                                 this.restoreSelection();
    41                                 this.clearSavedSelection();
    4239                                editor.insertElement( element );
    43                         }
    4440                },
    4541                contents : [
    4642                        {
  • _source/plugins/table/dialogs/table.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    246246
    247247                                // Insert the table element if we're creating one.
    248248                                if ( !this._.selectedElement )
    249                                 {
    250                                         this.restoreSelection();
    251249                                        editor.insertElement( table );
    252                                         this.clearSavedSelection();
    253                                 }
    254250
    255251                                return true;
    256252                        },
  • _source/plugins/format/plugin.js

     
    1212                var config = editor.config,
    1313                        lang = editor.lang.format;
    1414
    15                 var saveRanges;
    16 
    1715                // Gets the list of tags from the settings.
    1816                var tags = config.format_tags.split( ';' );
    1917
     
    5351                                onClick : function( value )
    5452                                {
    5553                                        editor.focus();
    56 
    57                                         if ( saveRanges )
    58                                         {
    59                                                 editor.getSelection().selectRanges( saveRanges );
    60                                                 saveRanges = false;
    61                                         }
    62 
    6354                                        styles[ value ].apply( editor.document );
    6455                                },
    6556
     
    8576                                                        this.setValue( '' );
    8677                                                },
    8778                                                this);
    88                                 },
    89 
    90                                 onOpen : function()
    91                                 {
    92                                         if ( CKEDITOR.env.ie )
    93                                         {
    94                                                 editor.focus();
    95                                                 saveRanges = editor.getSelection().getRanges();
    96                                         }
    97                                 },
    98 
    99                                 onClose : function()
    100                                 {
    101                                         saveRanges = null;
    10279                                }
    10380                        });
    10481        }
  • _source/plugins/link/dialogs/anchor.js

     
    4545                        var fakeElement = editor.createFakeElement( element, 'cke_anchor', 'anchor' );
    4646                        if ( !this.editMode )
    4747                        {
    48                                 // It doesn't work with IE.
    49                                 this.restoreSelection();
    50                                 this.clearSavedSelection();
    51 
    5248                                editor.insertElement( fakeElement );
    5349                        }
    5450                        else
     51                        {
    5552                                fakeElement.replace( this.fakeObj );
     53
     54                                editor.focus();
     55                                editor.getSelection().selectElement( fakeElement );
     56                        }
     57                       
    5658                        return true;
    5759                },
    5860                onShow : function()
     
    7981                                        element = editor.restoreRealElement( this.fakeObj );
    8082                                        loadElements.apply( this, [ editor, selection, ranges, element ] );
    8183                                        selection.selectElement( this.fakeObj );
    82                                         this.saveSelection();
     84                                        editor.saveSelection();
    8385                                }
    8486                        }
    8587                        this.getContentElement( 'info', 'txtName' ).focus();
  • _source/plugins/flash/dialogs/flash.js

     
    279279                                if ( this.fakeImage )
    280280                                        newFakeImage.replace( this.fakeImage );
    281281                                else
    282                                 {
    283                                         this.restoreSelection();
    284282                                        editor.insertElement( newFakeImage );
    285                                 }
    286283                        },
    287284                        contents : [
    288285                                {
  • _source/plugins/dialog/plugin.js

     
    527527                 */
    528528                show : function()
    529529                {
     530                        this._.editor.lockSelection();
     531
    530532                        // Insert the dialog's element to the root document.
    531533                        var element = this._.element;
    532534                        var definition = this.definition;
     
    679681                                CKEDITOR.document.removeListener( 'keyup', accessKeyUpHandler );
    680682
    681683                                // Restore focus and (if not already restored) selection in the editing area.
    682                                 this.restoreSelection();
    683684                                this._.editor.focus();
     685                                this._.editor.unlockSelection();
    684686                        }
    685687                        else
    686688                                CKEDITOR.dialog._.currentZIndex -= 10;
     
    977979                 */
    978980                restoreSelection : function()
    979981                {
    980                         if ( this._.editor.mode && this._.selectedRanges )
    981                                 ( new CKEDITOR.dom.selection( this._.editor.document ) ).selectRanges( this._.selectedRanges );
     982                        this._.editor.focus();
     983//                      if ( this._.editor.mode && this._.selectedRanges )
     984//                              ( new CKEDITOR.dom.selection( this._.editor.document ) ).selectRanges( this._.selectedRanges );
    982985                }
    983986        };
    984987
  • _source/plugins/smiley/dialogs/smiley.js

     
    5454                        else if ( targetName != 'img' )
    5555                                return;
    5656
    57                         this.getDialog().restoreSelection();
    58 
    5957                        var src = target.getAttribute( 'src' ),
    6058                                title = target.getAttribute( 'title' );
    6159
  • _source/plugins/stylescombo/plugin.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    1414                        var config = editor.config,
    1515                                lang = editor.lang.stylesCombo,
    1616                                pluginPath = this.path,
    17                                 styles,
    18                                 saveRanges;
     17                                styles;
    1918
    2019                        editor.ui.addRichCombo( 'Styles',
    2120                                {
     
    9796                                                var style = styles[ value ],
    9897                                                        selection = editor.getSelection();
    9998
    100                                                 if ( saveRanges )
    101                                                 {
    102                                                         selection.selectRanges( saveRanges );
    103                                                         saveRanges = false;
    104                                                 }
    105 
    10699                                                if ( style.type == CKEDITOR.STYLE_OBJECT )
    107100                                                {
    108101                                                        var element = selection.getSelectedElement();
     
    159152
    160153                                                var selection = editor.getSelection();
    161154
    162                                                 if ( CKEDITOR.env.ie && selection )
    163                                                         saveRanges = selection.getRanges();
    164 
    165155                                                var elementPath,
    166156                                                        element = selection.getSelectedElement(),
    167157                                                        elementName = element && element.getName(),
     
    218208
    219209                                                if ( !counter[ CKEDITOR.STYLE_OBJECT ] )
    220210                                                        this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_OBJECT ) ] );
    221                                         },
    222 
    223                                         onClose : function()
    224                                         {
    225                                                 saveRanges = null;
    226211                                        }
    227212                                });
    228213                }
  • _source/plugins/font/plugin.js

     
    88        function addCombo( editor, comboName, styleType, lang, entries, defaultLabel, styleDefinition )
    99        {
    1010                var config = editor.config;
    11                 var saveRanges;
    1211
    1312                // Gets the list of fonts from the settings.
    1413                var names = entries.split( ';' ),
     
    5655                                {
    5756                                        editor.focus();
    5857
    59                                         if ( saveRanges )
    60                                         {
    61                                                 editor.getSelection().selectRanges( saveRanges );
    62                                                 saveRanges = false;
    63                                         }
    64 
    6558                                        var style = styles[ value ];
    6659
    6760                                        if ( this.getValue() == value )
     
    10194                                                        this.setValue( '', defaultLabel );
    10295                                                },
    10396                                                this);
    104                                 },
    105 
    106                                 onOpen : function()
    107                                 {
    108                                         if ( CKEDITOR.env.ie )
    109                                         {
    110                                                 editor.focus();
    111                                                 saveRanges = editor.getSelection().getRanges();
    112                                         }
    113                                 },
    114 
    115                                 onClose : function()
    116                                 {
    117                                         saveRanges = null;
    11897                                }
    11998                        });
    12099        }
  • _source/plugins/contextmenu/plugin.js

     
    6060                                        if ( item.onClick )
    6161                                                item.onClick();
    6262                                        else if ( item.command )
    63                                         {
    64                                                 if ( CKEDITOR.env.ie )
    65                                                         this.restoreSelection();
    66 
    6763                                                editor.execCommand( item.command );
    68                                         }
    6964                                }, this );
    7065
    7166                                menu.onEscape = function()
  • _source/core/command.js

     
    1010                if ( this.state == CKEDITOR.TRISTATE_DISABLED )
    1111                        return false;
    1212
     13                // The editor will always have the focus when executing a command.
     14                editor.focus();
     15
    1316                return ( commandDefinition.exec.call( this, editor, data ) !== false );
    1417        };
    1518
  • _source/core/editor.js

     
    559559                 */
    560560                insertHtml : function( data )
    561561                {
     562                        if ( CKEDITOR.env.ie )
     563                                this.focus();
     564
    562565                        this.fire( 'insertHtml', data );
    563566                },
    564567
     
    573576                 */
    574577                insertElement : function( element )
    575578                {
     579                        if ( CKEDITOR.env.ie )
     580                                this.focus();
     581
    576582                        this.fire( 'insertElement', element );
    577583                },
    578584
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy