Ticket #5170: 5170.patch

File 5170.patch, 2.9 KB (added by brooks, 14 years ago)
  • _source/plugins/specialchar/dialogs/specialchar.js

     
    2323                {
    2424                        target.removeClass( "cke_light_background" );
    2525                        dialog.hide();
    26                         editor.insertHtml( value );
     26                       
     27                        // Firefox has some bug on insert html, so let's process it single (#5170)
     28                        if ( CKEDITOR.env.gecko )
     29                        {
     30                                editor.fire( 'insertSpecialChar', value, editor );
     31                        }
     32                        else {
     33                                editor.insertHtml( value );
     34                        }
     35                       
    2736                }
    2837        };
    2938
  • _source/plugins/specialchar/plugin.js

     
    22Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     5(function(){
     6        /**
     7         * @file Special Character plugin
     8         */
     9       
     10        CKEDITOR.plugins.add( 'specialchar',
     11        {
     12                init : function( editor )
     13                {
     14                        var pluginName = 'specialchar';
     15       
     16                        // Register the dialog.
     17                        CKEDITOR.dialog.add( pluginName, this.path + 'dialogs/specialchar.js' );
     18       
     19                        // Register the command.
     20                        editor.addCommand( pluginName, new CKEDITOR.dialogCommand( pluginName ) );
     21       
     22                        // Register the toolbar button.
     23                        editor.ui.addButton( 'SpecialChar',
     24                                {
     25                                        label : editor.lang.specialChar.toolbar,
     26                                        command : pluginName
     27                                });
     28                       
     29                        // Register the handler for Firefox (#5170)
     30                        if ( CKEDITOR.env.gecko )
     31                        {
     32                                editor.on( 'insertSpecialChar', function( event )
     33                                        {
     34                                                var range = getRange( editor );
     35                                               
     36                                                if ( range )
     37                                                        range.insertNode( editor.document.createText( event.data ));
     38                                                else
     39                                                        editor.insertHtml( event.data );
     40                                        }
     41                                );
     42                        }
     43                }
     44        } );
    545
    6 /**
    7  * @file Special Character plugin
    8  */
    9 
    10 CKEDITOR.plugins.add( 'specialchar',
    11 {
    12         init : function( editor )
     46        function getRange( editor )
    1347        {
    14                 var pluginName = 'specialchar';
     48                // Get the selection ranges.
     49                var ranges = editor.getSelection().getRanges();
    1550
    16                 // Register the dialog.
    17                 CKEDITOR.dialog.add( pluginName, this.path + 'dialogs/specialchar.js' );
     51                // Delete the contents of all ranges .
     52                for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
     53                {
     54                        ranges[ i ].deleteContents();
     55                }
    1856
    19                 // Register the command.
    20                 editor.addCommand( pluginName, new CKEDITOR.dialogCommand( pluginName ) );
    21 
    22                 // Register the toolbar button.
    23                 editor.ui.addButton( 'SpecialChar',
    24                         {
    25                                 label : editor.lang.specialChar.toolbar,
    26                                 command : pluginName
    27                         });
     57                // Return the first range.
     58                return ranges[ 0 ];
    2859        }
    29 } );
     60})()
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy