-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix mergeNodes moving node into parent sibling (#4296)
* test: add test case for bug * prefer next will transforming selection in remove_node * add remove_node test * Add changeset * review: handle nested blocks * refactor * Revert "refactor" This reverts commit 45a8aab. Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>
- Loading branch information
1 parent
4dea740
commit 479a759
Showing
8 changed files
with
187 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': patch | ||
--- | ||
|
||
Fix mergeNodes moving node into parent sibling |
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
28 changes: 28 additions & 0 deletions
28
packages/slate/test/normalization/text/merge-adjacent-empty-after-nested.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,28 @@ | ||
/** @jsx jsx */ | ||
import { jsx } from '../..' | ||
|
||
export const input = ( | ||
<editor> | ||
<block> | ||
<text /> | ||
</block> | ||
<block> | ||
<block> | ||
<cursor /> | ||
<text /> | ||
</block> | ||
</block> | ||
</editor> | ||
) | ||
export const output = ( | ||
<editor> | ||
<block> | ||
<text /> | ||
</block> | ||
<block> | ||
<block> | ||
<cursor /> | ||
</block> | ||
</block> | ||
</editor> | ||
) |
24 changes: 24 additions & 0 deletions
24
packages/slate/test/normalization/text/merge-adjacent-empty-after.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 @@ | ||
/** @jsx jsx */ | ||
import { jsx } from '../..' | ||
|
||
export const input = ( | ||
<editor> | ||
<block> | ||
<text /> | ||
</block> | ||
<block> | ||
<cursor /> | ||
<text /> | ||
</block> | ||
</editor> | ||
) | ||
export const output = ( | ||
<editor> | ||
<block> | ||
<text /> | ||
</block> | ||
<block> | ||
<cursor /> | ||
</block> | ||
</editor> | ||
) |
35 changes: 35 additions & 0 deletions
35
packages/slate/test/operations/remove_node/cursor-nested.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,35 @@ | ||
/** @jsx jsx */ | ||
import { jsx } from 'slate-hyperscript' | ||
|
||
export const input = ( | ||
<editor> | ||
<element> | ||
<text /> | ||
</element> | ||
<element> | ||
<element> | ||
<cursor /> | ||
<text /> | ||
</element> | ||
</element> | ||
</editor> | ||
) | ||
export const operations = [ | ||
{ | ||
type: 'remove_node', | ||
path: [1, 0, 0], | ||
node: { text: '' }, | ||
}, | ||
] | ||
export const output = ( | ||
<editor> | ||
<element> | ||
<text /> | ||
</element> | ||
<element> | ||
<element> | ||
<cursor /> | ||
</element> | ||
</element> | ||
</editor> | ||
) |
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,31 @@ | ||
/** @jsx jsx */ | ||
import { jsx } from 'slate-hyperscript' | ||
|
||
export const input = ( | ||
<editor> | ||
<element> | ||
<text /> | ||
</element> | ||
<element> | ||
<cursor /> | ||
<text /> | ||
</element> | ||
</editor> | ||
) | ||
export const operations = [ | ||
{ | ||
type: 'remove_node', | ||
path: [1, 0], | ||
node: { text: '' }, | ||
}, | ||
] | ||
export const output = ( | ||
<editor> | ||
<element> | ||
<text /> | ||
</element> | ||
<element> | ||
<cursor /> | ||
</element> | ||
</editor> | ||
) |
28 changes: 28 additions & 0 deletions
28
packages/slate/test/transforms/mergeNodes/path/text-hanging-nested.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,28 @@ | ||
/** @jsx jsx */ | ||
import { Transforms, Text } from 'slate' | ||
import { jsx } from '../../..' | ||
|
||
export const input = ( | ||
<editor> | ||
<block>one</block> | ||
<block> | ||
<block> | ||
<cursor /> | ||
<text /> | ||
</block> | ||
</block> | ||
</editor> | ||
) | ||
export const run = editor => { | ||
Transforms.mergeNodes(editor, { at: [1, 0, 1], match: Text.isText }) | ||
} | ||
export const output = ( | ||
<editor> | ||
<block>one</block> | ||
<block> | ||
<block> | ||
<cursor /> | ||
</block> | ||
</block> | ||
</editor> | ||
) |
24 changes: 24 additions & 0 deletions
24
packages/slate/test/transforms/mergeNodes/path/text-hanging.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 @@ | ||
/** @jsx jsx */ | ||
import { Transforms, Text } from 'slate' | ||
import { jsx } from '../../..' | ||
|
||
export const input = ( | ||
<editor> | ||
<block>one</block> | ||
<block> | ||
<cursor /> | ||
<text /> | ||
</block> | ||
</editor> | ||
) | ||
export const run = editor => { | ||
Transforms.mergeNodes(editor, { at: [1, 1], match: Text.isText }) | ||
} | ||
export const output = ( | ||
<editor> | ||
<block>one</block> | ||
<block> | ||
<cursor /> | ||
</block> | ||
</editor> | ||
) |