forked from ianstormtaylor/slate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix point transform for insert_text to account for affinity (ianstorm…
…taylor#4848) * fix point transform for insert_text * add changeset
- Loading branch information
1 parent
ffca574
commit 07641bc
Showing
9 changed files
with
193 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'slate': minor | ||
--- | ||
|
||
fix point transform for insert_text operations to account for affinity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/slate/test/interfaces/Point/transform/backward-insert-text-after-point.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Point } from 'slate' | ||
|
||
export const input = { | ||
path: [0, 0], | ||
offset: 0, | ||
} | ||
|
||
export const test = value => { | ||
return Point.transform( | ||
value, | ||
{ | ||
type: 'insert_text', | ||
path: [0, 0], | ||
text: 'a', | ||
offset: 1, | ||
properties: {}, | ||
}, | ||
{ affinity: 'backward' } | ||
) | ||
} | ||
export const output = { | ||
path: [0, 0], | ||
offset: 0, | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/slate/test/interfaces/Point/transform/backward-insert-text-at-point.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Point } from 'slate' | ||
|
||
export const input = { | ||
path: [0, 0], | ||
offset: 1, | ||
} | ||
|
||
export const test = value => { | ||
return Point.transform( | ||
value, | ||
{ | ||
type: 'insert_text', | ||
path: [0, 0], | ||
text: 'a', | ||
offset: 1, | ||
properties: {}, | ||
}, | ||
{ affinity: 'backward' } | ||
) | ||
} | ||
export const output = { | ||
path: [0, 0], | ||
offset: 1, | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/slate/test/interfaces/Point/transform/backward-insert-text-before-point.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Point } from 'slate' | ||
|
||
export const input = { | ||
path: [0, 0], | ||
offset: 1, | ||
} | ||
|
||
export const test = value => { | ||
return Point.transform( | ||
value, | ||
{ | ||
type: 'insert_text', | ||
path: [0, 0], | ||
text: 'a', | ||
offset: 0, | ||
properties: {}, | ||
}, | ||
{ affinity: 'backward' } | ||
) | ||
} | ||
export const output = { | ||
path: [0, 0], | ||
offset: 2, | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/slate/test/interfaces/Point/transform/forward-insert-text-after-point.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Point } from 'slate' | ||
|
||
export const input = { | ||
path: [0, 0], | ||
offset: 0, | ||
} | ||
|
||
export const test = value => { | ||
return Point.transform( | ||
value, | ||
{ | ||
type: 'insert_text', | ||
path: [0, 0], | ||
text: 'a', | ||
offset: 1, | ||
properties: {}, | ||
}, | ||
{ affinity: 'forward' } | ||
) | ||
} | ||
export const output = { | ||
path: [0, 0], | ||
offset: 0, | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/slate/test/interfaces/Point/transform/forward-insert-text-at-point.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Point } from 'slate' | ||
|
||
export const input = { | ||
path: [0, 0], | ||
offset: 1, | ||
} | ||
|
||
export const test = value => { | ||
return Point.transform( | ||
value, | ||
{ | ||
type: 'insert_text', | ||
path: [0, 0], | ||
text: 'a', | ||
offset: 1, | ||
properties: {}, | ||
}, | ||
{ affinity: 'forward' } | ||
) | ||
} | ||
export const output = { | ||
path: [0, 0], | ||
offset: 2, | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/slate/test/interfaces/Point/transform/forward-insert-text-before-point.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Point } from 'slate' | ||
|
||
export const input = { | ||
path: [0, 0], | ||
offset: 1, | ||
} | ||
|
||
export const test = value => { | ||
return Point.transform( | ||
value, | ||
{ | ||
type: 'insert_text', | ||
path: [0, 0], | ||
text: 'a', | ||
offset: 0, | ||
properties: {}, | ||
}, | ||
{ affinity: 'forward' } | ||
) | ||
} | ||
export const output = { | ||
path: [0, 0], | ||
offset: 2, | ||
} |
39 changes: 39 additions & 0 deletions
39
packages/slate/test/interfaces/Range/transform/outward-collapsed.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Range } from 'slate' | ||
|
||
/** | ||
* If a collapsed Range is transformed with affinity outward by an insert_text operation, it should expand. | ||
*/ | ||
|
||
export const input = { | ||
anchor: { | ||
path: [0, 0], | ||
offset: 1, | ||
}, | ||
focus: { | ||
path: [0, 0], | ||
offset: 1, | ||
}, | ||
} | ||
export const test = value => { | ||
return Range.transform( | ||
value, | ||
{ | ||
type: 'insert_text', | ||
path: [0, 0], | ||
text: 'a', | ||
offset: 1, | ||
properties: {}, | ||
}, | ||
{ affinity: 'outward' } | ||
) | ||
} | ||
export const output = { | ||
anchor: { | ||
path: [0, 0], | ||
offset: 1, | ||
}, | ||
focus: { | ||
path: [0, 0], | ||
offset: 2, | ||
}, | ||
} |