瀏覽代碼

Merge pull request #1150 from ckeditor/t/ckeditor5-undo/65/1

Fix: Undo did no changes instead of merging elements, in a scenario when an element was split and then the "new" element was removed. See https://github.com/ckeditor/ckeditor5-undo/issues/65#issuecomment-323682195.
Piotrek Koszuliński 8 年之前
父節點
當前提交
8b6597a3c6
共有 1 個文件被更改,包括 8 次插入4 次删除
  1. 8 4
      packages/ckeditor5-engine/src/model/delta/basic-transformations.js

+ 8 - 4
packages/ckeditor5-engine/src/model/delta/basic-transformations.js

@@ -141,8 +141,10 @@ addTransformationCase( MarkerDelta, RenameDelta, transformMarkerDelta );
 
 // Add special case for MoveDelta x MergeDelta transformation.
 addTransformationCase( MoveDelta, MergeDelta, ( a, b, context ) => {
-	// Do not apply special transformation case if `MergeDelta` has `NoOperation` as the second operation.
-	if ( !b.position ) {
+	const undoMode = context.aWasUndone || context.bWasUndone;
+
+	// Do not apply special transformation case in undo mode or if `MergeDelta` has `NoOperation` as the second operation.
+	if ( undoMode || !b.position ) {
 		return defaultTransform( a, b, context );
 	}
 
@@ -185,8 +187,10 @@ addTransformationCase( MergeDelta, InsertDelta, ( a, b, context ) => {
 
 // Add special case for MergeDelta x MoveDelta transformation.
 addTransformationCase( MergeDelta, MoveDelta, ( a, b, context ) => {
-	// Do not apply special transformation case if `MergeDelta` has `NoOperation` as the second operation.
-	if ( !a.position ) {
+	const undoMode = context.aWasUndone || context.bWasUndone;
+
+	// Do not apply special transformation case in undo mode or if `MergeDelta` has `NoOperation` as the second operation.
+	if ( undoMode || !a.position ) {
 		return defaultTransform( a, b, context );
 	}