|
@@ -64,7 +64,7 @@ addTransformationCase( MoveDelta, MergeDelta, ( a, b, isStrong ) => {
|
|
|
|
|
|
|
|
const operateInSameParent =
|
|
const operateInSameParent =
|
|
|
a.sourcePosition.root == b.position.root &&
|
|
a.sourcePosition.root == b.position.root &&
|
|
|
- compareArrays( a.sourcePosition.getParentPath(), b.position.getParentPath() ) === 'SAME';
|
|
|
|
|
|
|
+ compareArrays( a.sourcePosition.getParentPath(), b.position.getParentPath() ) === 'same';
|
|
|
|
|
|
|
|
const mergeInsideMoveRange = a.sourcePosition.offset <= b.position.offset && a.sourcePosition.offset + a.howMany > b.position.offset;
|
|
const mergeInsideMoveRange = a.sourcePosition.offset <= b.position.offset && a.sourcePosition.offset + a.howMany > b.position.offset;
|
|
|
|
|
|
|
@@ -96,7 +96,7 @@ addTransformationCase( MergeDelta, MoveDelta, ( a, b, isStrong ) => {
|
|
|
|
|
|
|
|
const operateInSameParent =
|
|
const operateInSameParent =
|
|
|
a.position.root == b.sourcePosition.root &&
|
|
a.position.root == b.sourcePosition.root &&
|
|
|
- compareArrays( a.position.getParentPath(), b.sourcePosition.getParentPath() ) === 'SAME';
|
|
|
|
|
|
|
+ compareArrays( a.position.getParentPath(), b.sourcePosition.getParentPath() ) === 'same';
|
|
|
|
|
|
|
|
const mergeInsideMoveRange = b.sourcePosition.offset <= a.position.offset && b.sourcePosition.offset + b.howMany > a.position.offset;
|
|
const mergeInsideMoveRange = b.sourcePosition.offset <= a.position.offset && b.sourcePosition.offset + b.howMany > a.position.offset;
|
|
|
|
|
|
|
@@ -113,7 +113,7 @@ addTransformationCase( SplitDelta, SplitDelta, ( a, b, isStrong ) => {
|
|
|
const pathB = b.position.getParentPath();
|
|
const pathB = b.position.getParentPath();
|
|
|
|
|
|
|
|
// The special case is for splits inside the same parent.
|
|
// The special case is for splits inside the same parent.
|
|
|
- if ( compareArrays( pathA, pathB ) == 'SAME' ) {
|
|
|
|
|
|
|
+ if ( compareArrays( pathA, pathB ) == 'same' ) {
|
|
|
if ( a.position.offset == b.position.offset ) {
|
|
if ( a.position.offset == b.position.offset ) {
|
|
|
// We are applying split at the position where split already happened. Additional split is not needed.
|
|
// We are applying split at the position where split already happened. Additional split is not needed.
|
|
|
return [ noDelta() ];
|
|
return [ noDelta() ];
|
|
@@ -167,7 +167,7 @@ addTransformationCase( SplitDelta, SplitDelta, ( a, b, isStrong ) => {
|
|
|
addTransformationCase( SplitDelta, UnwrapDelta, ( a, b, isStrong ) => {
|
|
addTransformationCase( SplitDelta, UnwrapDelta, ( a, b, isStrong ) => {
|
|
|
// If incoming split delta tries to split a node that just got unwrapped, there is actually nothing to split,
|
|
// If incoming split delta tries to split a node that just got unwrapped, there is actually nothing to split,
|
|
|
// so we discard that delta.
|
|
// so we discard that delta.
|
|
|
- if ( compareArrays( b.position.path, a.position.getParentPath() ) === 'SAME' ) {
|
|
|
|
|
|
|
+ if ( compareArrays( b.position.path, a.position.getParentPath() ) === 'same' ) {
|
|
|
return [ noDelta() ];
|
|
return [ noDelta() ];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -179,12 +179,12 @@ addTransformationCase( SplitDelta, WrapDelta, ( a, b, isStrong ) => {
|
|
|
// If split is applied at the position between wrapped nodes, we cancel the split as it's results may be unexpected and
|
|
// If split is applied at the position between wrapped nodes, we cancel the split as it's results may be unexpected and
|
|
|
// very weird. Even if we do some "magic" we don't know what really are users' expectations.
|
|
// very weird. Even if we do some "magic" we don't know what really are users' expectations.
|
|
|
|
|
|
|
|
- const operateInSameParent = compareArrays( a.position.getParentPath(), b.range.start.getParentPath() ) === 'SAME';
|
|
|
|
|
|
|
+ const operateInSameParent = compareArrays( a.position.getParentPath(), b.range.start.getParentPath() ) === 'same';
|
|
|
const splitInsideWrapRange = b.range.start.offset < a.position.offset && b.range.end.offset >= a.position.offset;
|
|
const splitInsideWrapRange = b.range.start.offset < a.position.offset && b.range.end.offset >= a.position.offset;
|
|
|
|
|
|
|
|
if ( operateInSameParent && splitInsideWrapRange ) {
|
|
if ( operateInSameParent && splitInsideWrapRange ) {
|
|
|
return [ noDelta() ];
|
|
return [ noDelta() ];
|
|
|
- } else if ( compareArrays( a.position.getParentPath(), b.range.end.getShiftedBy( -1 ).path ) === 'SAME' ) {
|
|
|
|
|
|
|
+ } else if ( compareArrays( a.position.getParentPath(), b.range.end.getShiftedBy( -1 ).path ) === 'same' ) {
|
|
|
// Split position is directly inside the last node from wrap range.
|
|
// Split position is directly inside the last node from wrap range.
|
|
|
// If that's the case, we manually change split delta so it will "target" inside the wrapping element.
|
|
// If that's the case, we manually change split delta so it will "target" inside the wrapping element.
|
|
|
// By doing so we will be inserting split node right to the original node which feels natural and is a good UX.
|
|
// By doing so we will be inserting split node right to the original node which feels natural and is a good UX.
|
|
@@ -229,7 +229,7 @@ addTransformationCase( SplitDelta, WrapDelta, ( a, b, isStrong ) => {
|
|
|
addTransformationCase( UnwrapDelta, SplitDelta, ( a, b, isStrong ) => {
|
|
addTransformationCase( UnwrapDelta, SplitDelta, ( a, b, isStrong ) => {
|
|
|
// If incoming unwrap delta tries to unwrap node that got split we should unwrap the original node and the split copy.
|
|
// If incoming unwrap delta tries to unwrap node that got split we should unwrap the original node and the split copy.
|
|
|
// This can be achieved either by reverting split and applying unwrap to singular node, or creating additional unwrap delta.
|
|
// This can be achieved either by reverting split and applying unwrap to singular node, or creating additional unwrap delta.
|
|
|
- if ( compareArrays( a.position.path, b.position.getParentPath() ) === 'SAME' ) {
|
|
|
|
|
|
|
+ if ( compareArrays( a.position.path, b.position.getParentPath() ) === 'same' ) {
|
|
|
const transformed = [
|
|
const transformed = [
|
|
|
b.getReversed(),
|
|
b.getReversed(),
|
|
|
a.clone()
|
|
a.clone()
|
|
@@ -266,7 +266,7 @@ addTransformationCase( WrapDelta, SplitDelta, ( a, b, isStrong ) => {
|
|
|
// If incoming wrap delta tries to wrap range that contains split position, we have to cancel the split and apply
|
|
// If incoming wrap delta tries to wrap range that contains split position, we have to cancel the split and apply
|
|
|
// the wrap. Since split was already applied, we have to revert it.
|
|
// the wrap. Since split was already applied, we have to revert it.
|
|
|
|
|
|
|
|
- const operateInSameParent = compareArrays( a.range.start.getParentPath(), b.position.getParentPath() ) === 'SAME';
|
|
|
|
|
|
|
+ const operateInSameParent = compareArrays( a.range.start.getParentPath(), b.position.getParentPath() ) === 'same';
|
|
|
const splitInsideWrapRange = a.range.start.offset < b.position.offset && a.range.end.offset >= b.position.offset;
|
|
const splitInsideWrapRange = a.range.start.offset < b.position.offset && a.range.end.offset >= b.position.offset;
|
|
|
|
|
|
|
|
if ( operateInSameParent && splitInsideWrapRange ) {
|
|
if ( operateInSameParent && splitInsideWrapRange ) {
|
|
@@ -274,7 +274,7 @@ addTransformationCase( WrapDelta, SplitDelta, ( a, b, isStrong ) => {
|
|
|
b.getReversed(),
|
|
b.getReversed(),
|
|
|
a.clone()
|
|
a.clone()
|
|
|
];
|
|
];
|
|
|
- } else if ( compareArrays( b.position.getParentPath(), a.range.end.getShiftedBy( -1 ).path ) === 'SAME' ) {
|
|
|
|
|
|
|
+ } else if ( compareArrays( b.position.getParentPath(), a.range.end.getShiftedBy( -1 ).path ) === 'same' ) {
|
|
|
const delta = a.clone();
|
|
const delta = a.clone();
|
|
|
|
|
|
|
|
// Move wrapping element insert position one node further so it is after the split node insertion.
|
|
// Move wrapping element insert position one node further so it is after the split node insertion.
|