Jelajahi Sumber

Change safe text mutation detection to check if element is inline in schema.

Maciej Gołaszewski 7 tahun lalu
induk
melakukan
9da1bed2b7

+ 6 - 3
packages/ckeditor5-typing/src/utils/injecttypingmutationshandling.js

@@ -136,8 +136,10 @@ class MutationHandler {
 			modelFromDomChildren.pop();
 			modelFromDomChildren.pop();
 		}
 		}
 
 
+		const schema = this.editor.model.schema;
+
 		// Skip situations when common ancestor has any container elements.
 		// Skip situations when common ancestor has any container elements.
-		if ( !isSafeForTextMutation( modelFromDomChildren ) || !isSafeForTextMutation( currentModelChildren ) ) {
+		if ( !isSafeForTextMutation( modelFromDomChildren, schema ) || !isSafeForTextMutation( currentModelChildren, schema ) ) {
 			return;
 			return;
 		}
 		}
 
 
@@ -273,9 +275,10 @@ function getMutationsContainer( mutations ) {
 // Returns true if provided array contains content that won't be problematic during diffing and text mutation handling.
 // Returns true if provided array contains content that won't be problematic during diffing and text mutation handling.
 //
 //
 // @param {Array.<module:engine/model/node~Node>} children
 // @param {Array.<module:engine/model/node~Node>} children
+// @param {module:engine/model/schema~Schema} schema
 // @returns {Boolean}
 // @returns {Boolean}
-function isSafeForTextMutation( children ) {
-	return children.every( child => child.is( 'text' ) || child.is( 'softBreak' ) || child.is( 'placeholder' ) );
+function isSafeForTextMutation( children, schema ) {
+	return children.every( child => schema.isInline( child ) );
 }
 }
 
 
 // Calculates first change index and number of characters that should be inserted and deleted starting from that index.
 // Calculates first change index and number of characters that should be inserted and deleted starting from that index.