Skip to content

Commit

Permalink
Fix failing unhangRange test case with inlines (ianstormtaylor#4814)
Browse files Browse the repository at this point in the history
* Add failing unhangRange test case

* Fix failing inline case?

* fix lint
  • Loading branch information
bryanph authored Jan 28, 2022
1 parent 667aa2c commit d25bed0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/interfaces/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ export const Editor: EditorInterface = {
match: n => Editor.isBlock(editor, n),
})
const blockPath = endBlock ? endBlock[1] : []
const first = Editor.start(editor, [])
const first = Editor.start(editor, start)
const before = { anchor: first, focus: end }
let skip = true

Expand Down
34 changes: 34 additions & 0 deletions test/interfaces/Editor/unhangRange/inline-range-normal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { jsx } from '../../..'

export const input = (
<editor>
<block>
<text>Block before</text>
</block>
<block>
<text>
<anchor />
Some text before{' '}
</text>
<inline void>
<focus />
</inline>
<text />
</block>
<block>
<text>Another block</text>
</block>
</editor>
)

export const test = editor => {
const range = Editor.unhangRange(editor, editor.selection)
return range
}

export const output = {
anchor: { path: [1, 0], offset: 0 },
focus: { path: [1, 1, 0], offset: 0 },
}

0 comments on commit d25bed0

Please sign in to comment.