Ticket #3820: 3820_2.patch

File 3820_2.patch, 7.1 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/list/plugin.js

     
    491491                                             sibling.getName() == listCommand.type )
    492492                                        {
    493493                                                sibling.remove();
    494                                                 sibling.moveChildren( listNode );
     494                                                // Move children order by merge direction.(#3820) 
     495                                                sibling.moveChildren( listNode, rtl ? true : false );
    495496                                        }
    496497                                } )();
    497498                                mergeSibling( true );
  • _source/tests/plugins/list/list.html

     
    11<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    22<html xmlns="http://www.w3.org/1999/xhtml">
    33<head>
    4         <title>Plugin: toolbar</title>
     4        <title>Plugin: list</title>
    55        <link rel="stylesheet" type="text/css" href="../../test.css" />
    66        <script type="text/javascript" src="../../../../ckeditor_source.js"></script>
    77        <script type="text/javascript" src="../../test.js"></script>
     
    2626                                        document.getElementById( elementId );
    2727                        if ( isMe )
    2828                        {
    29                                 callback.call( context, evt.editor );
     29                                var editor = evt.editor;
     30                                // Force result data unformatted.
     31                                editor.dataProcessor.writer._.rules = {};
     32                                callback.call( context, editor );
    3033                        }
    3134                }, this );
    3235
     
    105108                                                {
    106109                                                        editor.focus();
    107110
    108                                                         // Force result data unformatted.
    109                                                         editor.dataProcessor.writer._.rules = {};
    110 
    111111                                                        var doc = editor.document,
    112112                                                                range = new CKEDITOR.dom.range( doc );
    113113
     
    119119                                                        this.wait( function(){
    120120                                                                // Remove list.
    121121                                                                editor.execCommand( 'numberedlist' );
    122                                                                 assert.areSame( getTextAreaValue( 'test_ticket_3151_resultContent' ),
     122                                                                assert.areSame( getTextAreaValue( 'test_ticket_3151_result' ),
    123123                                                                        editor.getData(),
    124124                                                                        'Remove list result not correct.' );
    125                                                         }, 1000);
     125                                                        }, 1000 );
    126126
    127127                                                } );
    128128                                        }, this );
    129129                                        this.wait();
    130130                        },
    131131
    132                         name :document.title
    133                 };
    134         } )() );
    135         //]]>
    136         </script>
    137 </head>
    138 <body>
    139 <textarea id="test_ticket_3151_editor"><ol><li>text</li></ol></textarea>
    140 <textarea id="test_ticket_3151_resultContent">text</textarea>
    141 </body>
    142 </html>
    143 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    144 <html xmlns="http://www.w3.org/1999/xhtml">
    145 <head>
    146         <title>Plugin: toolbar</title>
    147         <link rel="stylesheet" type="text/css" href="../../test.css" />
    148         <script type="text/javascript" src="../../../../ckeditor_source.js"></script>
    149         <script type="text/javascript" src="../../test.js"></script>
    150         <script type="text/javascript">
    151         //<![CDATA[
    152 /**
    153  * Load the editor and wait for fully interactable.
    154  * @param {Object} elementId
    155  * @parma {Object} mode
    156  * @param {Object} config
    157  * @param {Object} callback Continuation with {@param editor}.
    158  * @param {Object} context
    159  */
    160 function prepareEditor( elementId, mode, config, callback, context )
    161 {
    162         CKEDITOR.on( 'instanceReady',
    163                 function( evt )
    164                 {
    165                         var isMe = mode == CKEDITOR.ELEMENT_MODE_REPLACE ?
    166                                 evt.editor.name == elementId
    167                                 : evt.editor.element.$ ==
    168                                         document.getElementById( elementId );
    169                         if ( isMe )
    170                         {
    171                                 callback.call( context, evt.editor );
    172                         }
    173                 }, this );
    174 
    175         mode = mode || CKEDITOR.ELEMENT_MODE_REPLACE;
    176         switch( mode )
    177         {
    178                 case CKEDITOR.ELEMENT_MODE_REPLACE :
    179                         CKEDITOR.replace( elementId, config );
    180                         break;
    181                 case CKEDITOR.ELEMENT_MODE_APPENDTO :
    182                         CKEDITOR.appendTo( elementId, config );
    183                         break;
    184         }
    185 }
    186 
    187 /**
    188  * IE always returning CRLF for line-feed, so remove it when retrieving
    189  * pre-formated text from text area.
    190  */
    191 function getTextAreaValue( id )
    192 {
    193         return CKEDITOR.document.getById( id ).getValue().replace( /\r/gi, '' );
    194 }
    195 
    196 CKEDITOR.test.addTestCase( ( function()
    197         {
    198 
    199                 // Local references.
    200                 var assert = CKEDITOR.test.assert,
    201                         doc = CKEDITOR.document,
    202                         action = YAHOO.util.UserAction,
    203                         selector = YAHOO.util.Selector;
    204 
    205                 /**
    206                  * Set the range with the start/end position specified by the locator, which in form of bookmark2.
    207                  * @param {Object} range
    208                  * @param {Array} startPosition range start path including offset
    209                  * @param {Array|Boolean} endPositoin range end path including offset or is collapsed
    210                  */
    211                 function setRange( range, startPosition, endPositoin )
    212                 {
    213                         var bm = {
    214                                 end : null,
    215                                 start : null,
    216                                 is2: true,
    217                                 startOffset : 0,
    218                                 endoffset : 0
    219                         };
    220                         bm.start = startPosition.slice( 0, startPosition.length - 1 );
    221                         bm.startOffset = startPosition[ startPosition.length -1];
    222                         if( endPositoin === true )
    223                         {
    224                                 bm.end = bm.start.slice();
    225                                 bm.endOffset = bm.startOffset;
    226                         }
    227                         else
    228                         {
    229                                 bm.end = endPositoin.slice( 0, endPositoin.length - 1 );
    230                                 bm.endOffset = endPositoin[ endPositoin.length -1 ];
    231                         }
    232                         range.moveToBookmark( bm );
    233                 }
    234 
    235                 return  {
    236 
    237                         /**
    238                          *  Test remove numbered list with 'enterMode = BR'.
    239                          */
    240                         test_ticket_3151 : function()
    241                         {
    242                                 prepareEditor( 'test_ticket_3151_editor', null,
     132                        /**
     133                         *  Test merge newlist with previous list.
     134                         */
     135                        test_ticket_3820 : function()
     136                        {
     137                                prepareEditor( 'test_ticket_3820_editor', null,
    243138                                        { enterMode : CKEDITOR.ENTER_BR },
    244139                                        function( editor )
    245140                                        {
     
    247142                                                {
    248143                                                        editor.focus();
    249144
    250                                                         // Force result data unformatted.
    251                                                         editor.dataProcessor.writer._.rules = {};
    252 
    253145                                                        var doc = editor.document,
    254146                                                                range = new CKEDITOR.dom.range( doc );
    255 
    256                                                         setRange( range, [ 1, 0, 0, 0, 0 ], true );
     147                                                        setRange( range, [ 1, 1, 0 ], true );
    257148                                                        var sel = editor.getSelection();
    258149                                                        sel.selectRanges( [ range ] );
    259150
    260151                                                        // Waiting for 'comand state' effected.
    261152                                                        this.wait( function(){
    262153                                                                // Remove list.
    263                                                                 editor.execCommand( 'numberedlist' );
    264                                                                 assert.areSame( getTextAreaValue( 'test_ticket_3151_resultContent' ),
     154                                                                editor.execCommand( 'bulletedlist' );
     155                                                                assert.areSame( getTextAreaValue( 'test_ticket_3820_result' ),
    265156                                                                        editor.getData(),
    266                                                                         'Remove list result not correct.' );
    267                                                         }, 1000);
     157                                                                        'Merge list result not correct.' );
     158                                                        }, 1000 );
    268159
    269160                                                } );
    270161                                        }, this );
     
    277168        //]]>
    278169        </script>
    279170</head>
    280 <body>
     171<body>?
    281172<textarea id="test_ticket_3151_editor"><ol><li>text</li></ol></textarea>
    282 <textarea id="test_ticket_3151_resultContent">text</textarea>
     173<textarea id="test_ticket_3151_result">text</textarea>
     174<textarea id="test_ticket_3820_editor"><ul><li>bullet line 1</li><li>bullet line 2</li></ul><p>Second line</p></textarea>
     175<textarea id="test_ticket_3820_result"><ul><li>bullet line 1</li><li>bullet line 2</li><li>Second line</li></ul></textarea>
    283176</body>
    284177</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy