mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-30 02:19:52 +02:00
Standardize node matching APIs (#3327)
* add lowest mode and universal flag to `Editor.nodes` * add `mode` handling to all transforms * add extra `Editor.is*` helpers * change `Editor.previous` to make all optional * change `Editor.next` to make all optional * change `Editor.match` to make all optional * add `Editor.void` helper * remove non-function match arguments * remove NodeMatch interface * change to lowest match by default everywhere * rename `Editor.match` to `Editor.above` * use new helpers * cleanup * make NodeEntry generic, cleanup * fix NodeEntry generics * ensure only ancestors are returned from Editor.above * add type-narrowing to `Editor.nodes`, remove extras * remove other Node entry types * cleanup * remove `Editor.block` and `Editor.inline` helpers
This commit is contained in:
@@ -81,9 +81,6 @@ The `Editor` interface, like all Slate interfaces, exposes helper functions that
|
||||
// Get the start point of a specific node at path.
|
||||
const point = Editor.start(editor, [0, 0])
|
||||
|
||||
// Check whether an element matches a set of properties.
|
||||
const isMatch = Editor.isMatch(editor, element, { type: 'quote' })
|
||||
|
||||
// Get the fragment (a slice of the document) at a range.
|
||||
const fragment = Editor.fragment(editor, range)
|
||||
```
|
||||
@@ -91,8 +88,8 @@ const fragment = Editor.fragment(editor, range)
|
||||
There are also many iterator-based helpers, for example:
|
||||
|
||||
```js
|
||||
// Iterate over every element in a range.
|
||||
for (const [element, path] of Editor.elements(editor, { at: range })) {
|
||||
// Iterate over every node in a range.
|
||||
for (const [node, path] of Editor.nodes(editor, { at: range })) {
|
||||
// ...
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user