Ticket #4073: 4073_2.patch

File 4073_2.patch, 6.5 KB (added by Garry Yao, 15 years ago)
  • _tests/dt/core/dom/range.html

     
    10621062                 */
    10631063                test_enlarge_block6 : function()
    10641064                {
    1065                         var range = getRange( 'S11', null );
     1065                        var range = getRange( 'S11' );
    10661066                        range.enlarge( CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS );
    10671067
    10681068                        assert.areSame( document.getElementById( '_EnlargeP17' ),
     
    10701070                        assert.areSame( 0, range.startOffset, 'range.startOffset' );
    10711071                },
    10721072
     1073                /**
     1074                 * Test enlarge block when there's no nodes to enlarge.
     1075                 */
     1076                test_enlarge_block7 : function()
     1077                {
     1078                        var range = getRange( 'S12' );
     1079                        range.enlarge( CKEDITOR.ENLARGE_BLOCK_CONTENTS );
     1080                        var frag = range.extractContents(),
     1081                                tmp = new CKEDITOR.dom.element( 'div' );
     1082                        tmp.append( frag );
     1083                        assert.areSame( '<span>test block</span>', CKEDITOR.test.getInnerHtml( tmp ) );
     1084                },
     1085
    10731086                test_deleteContents_W3C_1 : function()
    10741087                {
    10751088                        // W3C DOM Range Specs - Section 2.6 - Example 1
     
    23852398                <p id="_EnlargeP4">Test <i id="_EnlargeI4"> Enlarge</i></p>
    23862399                <p id="_EnlargeP5">Test <i id="_EnlargeI5">Enlarge</i></p>
    23872400                <p id="_EnlargeP6">Test <i id="_EnlargeI6"><b></b>Enlarge</i></p>
    2388                 <p id="_EnlargeP7">Test <span id="S1"></span>List<br/ >Item Enlarge</p>
     2401                <p id="_EnlargeP7">Test <span id="S1"></span>List<br />Item Enlarge</p>
    23892402                <p id="_EnlargeP8">Test <span id="S2"></span>List<span id="E2"></span> <br /><br />Item Enlarge</p>
    23902403                <p id="_EnlargeP9">Test List <br /><span id="S3"></span><br />Item Enlarge</p>
    23912404                <p id="_EnlargeP10">Test List <br /><br />Item<span id="S4"></span> Enlarge</p>
     
    23932406                <div id="_EnlargeP12">Test<span id="S6"></span> Block <div>Enlarge</div></div>
    23942407                <div>Test <div id="_EnlargeP13">Blo<span id="S7"></span>ck</div> Enlarge</div>
    23952408                <p id="_EnlargeP14"><span id="S8"></span></p>
    2396                 <p id="_EnlargeP15">Test <span id="S9"></span>List<br/ >Item Enlarge</p>
     2409                <p id="_EnlargeP15">Test <span id="S9"></span>List<br />Item Enlarge</p>
    23972410                <p id="_EnlargeP16">Test <strong>Block<span id="S10"></span></strong><br /><br />Enlarge</p>
    2398                 <p id="_EnlargeP17"><span><span id="S11"></span>Test Block Enlarge<span id="E11"></span></span></p>
     2411                <p id="_EnlargeP17"><span><span id="S11"></span>Test Block Enlarge</span></p>
     2412                <div id="_EnlargeP18"><span>Test Block</span><span id="S12"></span><p> Enlarge</p></div>
    23992413                <p id="_trim_ct">Test trim</p>
    24002414        </div>
    24012415        <script type="text/javascript">
  • _source/plugins/templates/dialogs/templates.js

     
    8181
    8282                if( isInsert )
    8383                {
     84                        // Everything should happen after the document is loaded (#4073).
     85                        editor.on( 'contentDom', function( evt )
     86                        {
     87                                evt.removeListener();
     88                                dialog.hide();
     89
     90                                // Place the cursor at the first editable place.
     91                                var range = new CKEDITOR.dom.range( editor.document );
     92                                range.moveToElementEditStart( editor.document.getBody() );
     93                                range.select( true );
     94                        } );
    8495                        editor.setData( html );
    8596                }
    8697                else
    8798                {
    8899                        editor.insertHtml( html );
    89                 }
    90 
    91                 dialog.hide();
    92         }
     100                        dialog.hide();
     101                }
     102        }
    93103
    94104        CKEDITOR.dialog.add( 'templates', function( editor )
    95105                {
  • _source/plugins/dialog/plugin.js

     
    576576                 */
    577577                show : function()
    578578                {
    579                         if ( this._.editor.mode == 'wysiwyg' && CKEDITOR.env.ie )
    580                                 this._.editor.getSelection().lock();
     579                        var editor = this._.editor;
     580                        if ( editor.mode == 'wysiwyg' && CKEDITOR.env.ie )
     581                        {
     582                                var selection = editor.getSelection();
     583                                selection && selection.lock();
     584                        }
    581585
    582586                        // Insert the dialog's element to the root document.
    583587                        var element = this._.element;
     
    763767                                editor.focus();
    764768
    765769                                if ( editor.mode == 'wysiwyg' && CKEDITOR.env.ie )
    766                                         editor.getSelection().unlock( true );
    767                         }
     770                                {
     771                                        var selection = editor.getSelection();
     772                                        selection && selection.unlock( true );
     773                                }
     774                        }
    768775                        else
    769776                                CKEDITOR.dialog._.currentZIndex -= 10;
    770777
  • _source/core/dom/range.js

     
    11731173
    11741174                                        walker.guard = boundaryGuard;
    11751175
    1176                                         enlargeable = walker.lastBackward();
     1176                                        // Take the range end container if there's no
     1177                                        // nodes to enlarge( #4073 ).
     1178                                        enlargeable = walker.lastBackward() || walkerRange.endContainer;
    11771179
    11781180                                        // It's the body which stop the enlarging if no block boundary found.
    11791181                                        blockBoundary = blockBoundary || body;
    11801182
    11811183                                        // Start the range at different position by comparing
    11821184                                        // the document position of it with 'enlargeable' node.
    1183                                         this.setStartAt(
    1184                                                         blockBoundary,
     1185                                        this.setStartAt( blockBoundary,
    11851186                                                        !blockBoundary.is( 'br' ) &&
    1186                                                         ( !enlargeable || blockBoundary.contains( enlargeable ) ) ?
     1187                                                        ( blockBoundary.contains( enlargeable )
     1188                                                          || blockBoundary.equals( enlargeable ) ) ?
    11871189                                                                CKEDITOR.POSITION_AFTER_START :
    11881190                                                                CKEDITOR.POSITION_AFTER_END );
    11891191
     
    11991201                                        blockBoundary = null;
    12001202                                        // End the range right before the block boundary node.
    12011203
    1202                                         enlargeable = walker.lastForward();
     1204                                        // Take the range start container if there's no
     1205                                        // nodes to enlarge( #4073 ).
     1206                                        enlargeable = walker.lastForward() || walkerRange.startContainer;
    12031207
    12041208                                        // It's the body which stop the enlarging if no block boundary found.
    12051209                                        blockBoundary = blockBoundary || body;
    12061210
    12071211                                        // Start the range at different position by comparing
    12081212                                        // the document position of it with 'enlargeable' node.
    1209                                         this.setEndAt(
    1210                                                         blockBoundary,
     1213                                        this.setEndAt( blockBoundary,
    12111214                                                        !blockBoundary.is( 'br' ) &&
    1212                                                         ( !enlargeable || blockBoundary.contains( enlargeable ) ) ?
     1215                                                        ( blockBoundary.contains( enlargeable )
     1216                                                          || blockBoundary.equals( enlargeable ) ) ?
    12131217                                                                CKEDITOR.POSITION_BEFORE_END :
    12141218                                                                CKEDITOR.POSITION_BEFORE_START );
    12151219                                        // We must include the <br> at the end of range if there's
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy