mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-18 21:27:49 +08:00
18 lines
510 B
Markdown
18 lines
510 B
Markdown
# setNode
|
|
The `setNode` command will replace a given range with a given node. The range depends on the current selection. **Important**: Currently `setNode` only supports text block nodes.
|
|
|
|
## Parameters
|
|
|
|
`typeOrName: string | NodeType`
|
|
|
|
The type of the node that will replace the range. Can be a string or a NodeType.
|
|
|
|
`attributes?: Record<string, any>`
|
|
|
|
The attributes that should be applied to the node. **This is optional.**
|
|
|
|
## Usage
|
|
```js
|
|
editor.commands.setNode("paragraph", { id: "paragraph-01" })
|
|
```
|