1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-19 13:41:19 +02:00

Fix editor above with point (#5235)

* Fix Editor.above with point

Editor.above should ignore checking text nodes (they're never above
anything) and continue looking for ancestors.
Otherwise it won't be able to find any above nodes when starting to look
from a text node.

* Add changeset
This commit is contained in:
Pawel Piotrowicz
2022-12-22 06:44:41 +01:00
committed by GitHub
parent 766e0b6d9a
commit 36203b3f10
3 changed files with 24 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'slate': patch
---
Fixed Editor.above method that always returned undefined with Point location

View File

@@ -359,7 +359,7 @@ export const Editor: EditorInterface = {
match,
reverse,
})) {
if (Text.isText(n)) return
if (Text.isText(n)) continue
if (Range.isRange(at)) {
if (
Path.isAncestor(p, at.anchor.path) &&

View File

@@ -0,0 +1,18 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { jsx } from '../../..'
export const input = (
<editor>
<block>
<block>one</block>
</block>
</editor>
)
export const test = editor => {
return Editor.above(editor, { at: { path: [0, 0, 0], offset: 1 } })
}
export const output = [<block>one</block>, [0, 0]]