From 06091482013b2b854975f2841e9e284e9ee5dcdc Mon Sep 17 00:00:00 2001 From: Bryan Haakman Date: Fri, 28 Jan 2022 17:33:20 +0100 Subject: [PATCH] Fix failing unhangRange test case with inlines (#4814) * Add failing unhangRange test case * Fix failing inline case? * fix lint --- packages/slate/src/interfaces/editor.ts | 2 +- .../unhangRange/inline-range-normal.tsx | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 packages/slate/test/interfaces/Editor/unhangRange/inline-range-normal.tsx diff --git a/packages/slate/src/interfaces/editor.ts b/packages/slate/src/interfaces/editor.ts index cf0e2ad3fb3..90ab78e7b5b 100644 --- a/packages/slate/src/interfaces/editor.ts +++ b/packages/slate/src/interfaces/editor.ts @@ -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 diff --git a/packages/slate/test/interfaces/Editor/unhangRange/inline-range-normal.tsx b/packages/slate/test/interfaces/Editor/unhangRange/inline-range-normal.tsx new file mode 100644 index 00000000000..ad376324e59 --- /dev/null +++ b/packages/slate/test/interfaces/Editor/unhangRange/inline-range-normal.tsx @@ -0,0 +1,34 @@ +/** @jsx jsx */ +import { Editor } from 'slate' +import { jsx } from '../../..' + +export const input = ( + + + Block before + + + + + Some text before{' '} + + + + + + + + Another block + + +) + +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 }, +}