Skip to content

Commit

Permalink
Reverted 03861af (#4804) and added a test for the exception it caused (
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSpyder committed Mar 2, 2022
1 parent 442d263 commit 33be22f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-walls-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'slate': patch
---

Reverted #4804 as it triggered an exception when inserting text with multi-block selection
3 changes: 1 addition & 2 deletions packages/slate/src/transforms/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,7 @@ export const TextTransforms: TextTransforms = {
if (!voids && Editor.void(editor, { at: end })) {
return
}
const start = Range.start(at)
const pointRef = Editor.pointRef(editor, start)
const pointRef = Editor.pointRef(editor, end)
Transforms.delete(editor, { at, voids })
at = pointRef.unref()!
Transforms.setSelection(editor, { anchor: at, focus: at })
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** @jsx jsx */
import { Transforms } from 'slate'
import { jsx } from '../../..'

export const run = editor => {
Transforms.insertText(editor, 'a')
}
export const input = (
<editor>
<block>
<anchor />
first paragraph
</block>
<block>
second
<focus /> paragraph
</block>
</editor>
)
export const output = (
<editor>
<block>
a<cursor /> paragraph
</block>
</editor>
)

0 comments on commit 33be22f

Please sign in to comment.