8
0
Просмотр исходного кода

Merge branch 't/ckeditor5-engine/1012'

Internal: Aligned implementation to changes in ckeditor/ckeditor5-engine#1012.
Piotrek Koszuliński 8 лет назад
Родитель
Сommit
4566f05036

+ 6 - 7
packages/ckeditor5-enter/src/entercommand.js

@@ -43,14 +43,13 @@ function enterBlock( dataController, batch, selection, schema ) {
 	const startElement = range.start.parent;
 	const startElement = range.start.parent;
 	const endElement = range.end.parent;
 	const endElement = range.end.parent;
 
 
-	// Do nothing if selection starts or ends inside `limit` elements.
+	// Don't touch the roots and other limit elements.
 	if ( schema.limits.has( startElement.name ) || schema.limits.has( endElement.name ) ) {
 	if ( schema.limits.has( startElement.name ) || schema.limits.has( endElement.name ) ) {
-		return;
-	}
-
-	// Don't touch the root.
-	if ( startElement.root == startElement ) {
-		if ( !isSelectionEmpty ) {
+		// Delete the selected content but only if inside a single limit element.
+		// Abort, when crossing limit elements boundary (e.g. <limit1>x[x</limit1>donttouchme<limit2>y]y</limit2>).
+		// This is an edge case and it's hard to tell what should actually happen because such a selection
+		// is not entirely valid.
+		if ( !isSelectionEmpty && startElement == endElement ) {
 			dataController.deleteContent( selection, batch );
 			dataController.deleteContent( selection, batch );
 		}
 		}
 
 

+ 1 - 1
packages/ckeditor5-enter/tests/entercommand.js

@@ -126,7 +126,7 @@ describe( 'EnterCommand', () => {
 			test(
 			test(
 				'should not break inline limit elements',
 				'should not break inline limit elements',
 				'<p><inlineLimit>foo[bar]baz</inlineLimit></p>',
 				'<p><inlineLimit>foo[bar]baz</inlineLimit></p>',
-				'<p><inlineLimit>foo[bar]baz</inlineLimit></p>'
+				'<p><inlineLimit>foo[]baz</inlineLimit></p>'
 			);
 			);
 
 
 			test(
 			test(