Ticket #4073: 4073_2.patch
File 4073_2.patch, 6.5 KB (added by , 15 years ago) |
---|
-
_tests/dt/core/dom/range.html
1062 1062 */ 1063 1063 test_enlarge_block6 : function() 1064 1064 { 1065 var range = getRange( 'S11' , null);1065 var range = getRange( 'S11' ); 1066 1066 range.enlarge( CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS ); 1067 1067 1068 1068 assert.areSame( document.getElementById( '_EnlargeP17' ), … … 1070 1070 assert.areSame( 0, range.startOffset, 'range.startOffset' ); 1071 1071 }, 1072 1072 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 1073 1086 test_deleteContents_W3C_1 : function() 1074 1087 { 1075 1088 // W3C DOM Range Specs - Section 2.6 - Example 1 … … 2385 2398 <p id="_EnlargeP4">Test <i id="_EnlargeI4"> Enlarge</i></p> 2386 2399 <p id="_EnlargeP5">Test <i id="_EnlargeI5">Enlarge</i></p> 2387 2400 <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> 2389 2402 <p id="_EnlargeP8">Test <span id="S2"></span>List<span id="E2"></span> <br /><br />Item Enlarge</p> 2390 2403 <p id="_EnlargeP9">Test List <br /><span id="S3"></span><br />Item Enlarge</p> 2391 2404 <p id="_EnlargeP10">Test List <br /><br />Item<span id="S4"></span> Enlarge</p> … … 2393 2406 <div id="_EnlargeP12">Test<span id="S6"></span> Block <div>Enlarge</div></div> 2394 2407 <div>Test <div id="_EnlargeP13">Blo<span id="S7"></span>ck</div> Enlarge</div> 2395 2408 <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> 2397 2410 <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> 2399 2413 <p id="_trim_ct">Test trim</p> 2400 2414 </div> 2401 2415 <script type="text/javascript"> -
_source/plugins/templates/dialogs/templates.js
81 81 82 82 if( isInsert ) 83 83 { 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 } ); 84 95 editor.setData( html ); 85 96 } 86 97 else 87 98 { 88 99 editor.insertHtml( html ); 89 } 90 91 dialog.hide(); 92 } 100 dialog.hide(); 101 } 102 } 93 103 94 104 CKEDITOR.dialog.add( 'templates', function( editor ) 95 105 { -
_source/plugins/dialog/plugin.js
576 576 */ 577 577 show : function() 578 578 { 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 } 581 585 582 586 // Insert the dialog's element to the root document. 583 587 var element = this._.element; … … 763 767 editor.focus(); 764 768 765 769 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 } 768 775 else 769 776 CKEDITOR.dialog._.currentZIndex -= 10; 770 777 -
_source/core/dom/range.js
1173 1173 1174 1174 walker.guard = boundaryGuard; 1175 1175 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; 1177 1179 1178 1180 // It's the body which stop the enlarging if no block boundary found. 1179 1181 blockBoundary = blockBoundary || body; 1180 1182 1181 1183 // Start the range at different position by comparing 1182 1184 // the document position of it with 'enlargeable' node. 1183 this.setStartAt( 1184 blockBoundary, 1185 this.setStartAt( blockBoundary, 1185 1186 !blockBoundary.is( 'br' ) && 1186 ( !enlargeable || blockBoundary.contains( enlargeable ) ) ? 1187 ( blockBoundary.contains( enlargeable ) 1188 || blockBoundary.equals( enlargeable ) ) ? 1187 1189 CKEDITOR.POSITION_AFTER_START : 1188 1190 CKEDITOR.POSITION_AFTER_END ); 1189 1191 … … 1199 1201 blockBoundary = null; 1200 1202 // End the range right before the block boundary node. 1201 1203 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; 1203 1207 1204 1208 // It's the body which stop the enlarging if no block boundary found. 1205 1209 blockBoundary = blockBoundary || body; 1206 1210 1207 1211 // Start the range at different position by comparing 1208 1212 // the document position of it with 'enlargeable' node. 1209 this.setEndAt( 1210 blockBoundary, 1213 this.setEndAt( blockBoundary, 1211 1214 !blockBoundary.is( 'br' ) && 1212 ( !enlargeable || blockBoundary.contains( enlargeable ) ) ? 1215 ( blockBoundary.contains( enlargeable ) 1216 || blockBoundary.equals( enlargeable ) ) ? 1213 1217 CKEDITOR.POSITION_BEFORE_END : 1214 1218 CKEDITOR.POSITION_BEFORE_START ); 1215 1219 // We must include the <br> at the end of range if there's