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:
5
.changeset/wet-tigers-double.md
Normal file
5
.changeset/wet-tigers-double.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'slate': patch
|
||||
---
|
||||
|
||||
Fixed Editor.above method that always returned undefined with Point location
|
@@ -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) &&
|
||||
|
18
packages/slate/test/interfaces/Editor/above/point.tsx
Normal file
18
packages/slate/test/interfaces/Editor/above/point.tsx
Normal 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]]
|
Reference in New Issue
Block a user