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

Use mark functions for docs and examples (#5441)

When documenting how to apply character-level styling, use `addMark` and `removeMark` instead of `setNodes`. This avoids new users creating code that only works in the simplest cases.

Similarly, update the Hovering Toolbar example to apply marks instead of setting nodes.

This change was prompted by a discussion on Slack where the developer was disappointed that `markableVoid` did not appear to be working. The problem was they were using `setNodes` to apply Marks, and did not use the same `match` function that `addMark` uses.
This commit is contained in:
Brian Bucknam
2023-06-12 15:08:10 -07:00
committed by GitHub
parent a94d64ec09
commit 5eb589dbbb
5 changed files with 36 additions and 49 deletions

View File

@@ -44,6 +44,9 @@ Transforms are a specific set of helpers that allow you to perform a wide variet
```javascript
// Set a "bold" format on all of the text nodes in a range.
// Normally you would apply a style like bold using the Editor.addMark() command.
// The addMark() command performs a similar setNodes transform, but it uses a more
// complicated match function in order to apply marks within markableVoid elements.
Transforms.setNodes(
editor,
{ bold: true },