File tree Expand file tree Collapse file tree 8 files changed +53
-13
lines changed Expand file tree Collapse file tree 8 files changed +53
-13
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ New Features:
10
10
Fixed Issues:
11
11
12
12
* [ #13386 ] ( http://dev.ckeditor.com/ticket/13386 ) : [ Edge] Fixed: Issues with selecting and editing images.
13
+ * [ #13568 ] ( http://dev.ckeditor.com/ticket/13568 ) : Fixed: Method [ ` editor.getSelectedHtml() ` ] ( http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-getSelectedHtml ) returns invalid results for entire content selection.
13
14
14
15
## CKEditor 4.5.2
15
16
Original file line number Diff line number Diff line change @@ -310,13 +310,6 @@ CKEDITOR.dom.range = function( root ) {
310
310
// The second step is to handle full selection of the content between the left branch and the right branch.
311
311
312
312
while ( nextSibling ) {
313
- // TODO this case and the below are exactly the same because endNode is part of endParents.
314
- // The start and end nodes are on the same level. Handle this case fully here, because it's simple.
315
- if ( nextSibling . equals ( endNode ) ) {
316
- lastConnectedLevel = level ;
317
- break ;
318
- }
319
-
320
313
// We can't clone entire endParent just like we can't clone entire startParent -
321
314
// - they are not fully selected with the range. Partial endParent selection
322
315
// will be cloned in the next loop.
@@ -374,10 +367,18 @@ CKEDITOR.dom.range = function( root ) {
374
367
}
375
368
376
369
levelParent = nextLevelParent ;
370
+ } else if ( doClone ) {
371
+ // If this is "shared" node and we are in cloning mode we have to update levelParent to
372
+ // reflect that we visited the node (even though we didn't process it).
373
+ // If we don't do that, in next iterations nodes will be appended to wrong parent.
374
+ //
375
+ // We can just take first child because the algorithm guarantees
376
+ // that this will be the only child on this level. (#13568)
377
+ levelParent = levelParent . getChild ( 0 ) ;
377
378
}
378
379
}
379
380
380
- // Detete or Extract.
381
+ // Delete or Extract.
381
382
// We need to update the range and if mergeThen was passed do it.
382
383
if ( ! isClone ) {
383
384
mergeAndUpdate ( ) ;
Original file line number Diff line number Diff line change 1
1
< div id ="playground " style ="visibility:hidden "> < h1 id ="_H1 "> FCKW3CRange Test</ h1 > < p id ="_Para "> This is < b id ="_B "> some</ b > text.</ p > < p > Another paragraph.</ p > </ div >
2
- < div id ="editable_playground " contenteditable ="true "> </ div >
2
+ < div id ="editable_playground " contenteditable ="true "> </ div >
3
+ < div id ="bogus "> < p > Foo bar< br /> </ p > </ div >
Original file line number Diff line number Diff line change 514
514
assert . areSame ( root . findOne ( 'div' ) , range . endContainer , 'range.startContainer' ) ;
515
515
assert . areSame ( 0 , range . startOffset , 'range.startOffset' ) ;
516
516
assert . areSame ( 1 , range . endOffset , 'range.startOffset' ) ;
517
+ } ,
518
+
519
+ // #13568.
520
+ 'test cloneContents - bogus br' : function ( ) {
521
+ var range = new CKEDITOR . dom . range ( doc ) ;
522
+ range . setStart ( doc . getById ( 'bogus' ) , 0 ) ; // <p>
523
+ range . setEnd ( doc . getById ( 'bogus' ) . getFirst ( ) , 1 ) ; // <br /> in <p>
524
+
525
+ var docFrag = range . cloneContents ( ) ;
526
+
527
+ // See: execContentsAction in range.js.
528
+ assert . isInnerHtmlMatching ( '<p>Foo bar</p>' , docFrag . getHtml ( ) , 'Cloned HTML' ) ;
517
529
}
518
530
} ) ;
519
- } ) ( ) ;
531
+ } ) ( ) ;
Original file line number Diff line number Diff line change 1
- < div id ="playground " style ="visibility:hidden "> < h1 id ="_H1 "> FCKW3CRange Test</ h1 > < p id ="_Para "> This is < b id ="_B "> some</ b > text.</ p > < p > Another paragraph.</ p > </ div >
1
+ < div id ="playground " style ="visibility:hidden "> < h1 id ="_H1 "> FCKW3CRange Test</ h1 > < p id ="_Para "> This is < b id ="_B "> some</ b > text.</ p > < p > Another paragraph.</ p > </ div >
2
+ < div id ="bogus "> < p > Foo bar< br /> </ p > </ div >
Original file line number Diff line number Diff line change 367
367
assert . areSame ( playground , range . startContainer , 'range.startContainer' ) ;
368
368
assert . areSame ( 1 , range . startOffset , 'range.startOffset' ) ;
369
369
assert . isTrue ( range . collapsed , 'range.collapsed' ) ;
370
+ } ,
371
+
372
+ // #13568.
373
+ 'test extractContents - bogus br' : function ( ) {
374
+ var range = new CKEDITOR . dom . range ( doc ) ;
375
+ range . setStart ( doc . getById ( 'bogus' ) , 0 ) ; // <p>
376
+ range . setEnd ( doc . getById ( 'bogus' ) . getFirst ( ) , 1 ) ; // <br /> in <p>
377
+
378
+ var docFrag = range . extractContents ( ) ;
379
+
380
+ // See: execContentsAction in range.js.
381
+ assert . isInnerHtmlMatching ( '<p>Foo bar</p>' , docFrag . getHtml ( ) , 'Extracted HTML' ) ;
370
382
}
371
383
} ;
372
384
373
385
bender . test ( tests ) ;
374
- } ) ( ) ;
386
+ } ) ( ) ;
Original file line number Diff line number Diff line change 198
198
[ '<p><b>{a}</b>@</p>' , '<b>a</b>' , '<p>[]@!</p>' ] ,
199
199
[ '<p>{a}<br />@</p>' , 'a' , '<p>[]<br />@</p>' ] ,
200
200
[ '<p>{a<br />]@</p>' , 'a<br />' , '<p>[]@!</p>' ] ,
201
- [ '<div>b<p>{a@]</p>b</div>' , 'a' , '<div>b<p>[]@!</p>b</div>' ]
201
+ [ '<div>b<p>{a@]</p>b</div>' , 'a' , '<div>b<p>[]@!</p>b</div>' ] ,
202
+ // #13568.
203
+ [ '<div>[<p>Foo bar@</p>]</div>' , '<p>Foo bar</p>' , '<div>[]@!</div>' ]
204
+
202
205
] ,
203
206
204
207
// #13101
Original file line number Diff line number Diff line change @@ -78,6 +78,15 @@ bender.test( {
78
78
assert . isNull ( selectedHtml , 'There should be no error but null should be returns if selection contains no ranges' ) ;
79
79
} ,
80
80
81
+ // #13568.
82
+ 'test getSelectedHtml with possible bogus br' : function ( ) {
83
+ var editor = this . editors . editor ,
84
+ filler = CKEDITOR . env . needsBrFiller ? '<br />' : '' ;
85
+ bender . tools . selection . setWithHtml ( editor , '[<p>Foo bar' + filler + '</p>]' ) ;
86
+
87
+ assert . isInnerHtmlMatching ( [ '<p>Foo bar@</p>' , 'Foo bar' ] , editor . getSelectedHtml ( true ) ) ;
88
+ } ,
89
+
81
90
'test extractSelectedHtml' : function ( ) {
82
91
var editor = this . editors . editor ;
83
92
bender . tools . selection . setWithHtml ( editor , '<p>fo{ob}ar</p>' ) ;
You can’t perform that action at this time.
0 commit comments