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

update docs

This commit is contained in:
Ian Storm Taylor
2021-04-07 18:16:45 -04:00
parent 41aa2754ee
commit 9613d832e5

View File

@@ -174,13 +174,17 @@ Using `match` can make representing complex logic a lot simpler.
For example, consider wanting to add a bold mark to any text nodes that aren't already italic: For example, consider wanting to add a bold mark to any text nodes that aren't already italic:
```js ```js
Transform.setNodes(editor, { Transform.setNodes(
// This path references the editor, and is expanded to a range that editor,
// will encompass all the content of the editor. { bold: true },
at: [], {
// This only matches text nodes that are not already italic. // This path references the editor, and is expanded to a range that
match: (node, path) => Text.isText(node) && node.italic !== true, // will encompass all the content of the editor.
}) at: [],
// This only matches text nodes that are not already italic.
match: (node, path) => Text.isText(node) && node.italic !== true,
}
)
``` ```
When performing transforms, if you're ever looping over nodes and transforming them one at a time, consider seeing if `match` can solve your use case, and offload the complexity of managing loops to Slate instead. When performing transforms, if you're ever looping over nodes and transforming them one at a time, consider seeing if `match` can solve your use case, and offload the complexity of managing loops to Slate instead.