mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-04-21 13:51:59 +02:00
fix: isBlockActive should use Array.from() (#4662)
* fix: isBlockActive should use Array.from() The richtext.tsx example `isBlockActive` was not working for me in my environtment because `Editor.nodes` returns a Generator, not an Array. So `isBlockActive` always returned false. Wrapping it in `Array.from` fixes the example. * run prettier Co-authored-by: Dan Tello <dtello@medallia.com>
This commit is contained in:
parent
ab62da2064
commit
65708358bb
@ -96,11 +96,13 @@ const isBlockActive = (editor, format) => {
|
||||
const { selection } = editor
|
||||
if (!selection) return false
|
||||
|
||||
const [match] = Editor.nodes(editor, {
|
||||
at: Editor.unhangRange(editor, selection),
|
||||
match: n =>
|
||||
!Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format,
|
||||
})
|
||||
const [match] = Array.from(
|
||||
Editor.nodes(editor, {
|
||||
at: Editor.unhangRange(editor, selection),
|
||||
match: n =>
|
||||
!Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format,
|
||||
})
|
||||
)
|
||||
|
||||
return !!match
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user