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
4bc6f4f
commit 4521209
Showing
8 changed files
with
188 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
24 changes: 24 additions & 0 deletions
24
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
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
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
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
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
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, | ||
} |
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, | ||
}, | ||
} |