tiptap/docs/api/commands/clear-nodes.md

11 lines
614 B
Markdown
Raw Normal View History

2021-04-08 05:08:24 +08:00
# clearNodes
2021-04-09 04:56:09 +08:00
The `clearNodes` command normalizes nodes to the default node, which is the paragraph by default. Itll even normalize all kind of lists. For advanced use cases it can come in handy, before applying a new node type.
If you wonder how you can define the default node: It depends on whats in the `content` attribute of your [`Document`](/api/nodes/document), by default thats `block+` (at least one block node) and the [`Paragraph`](/api/nodes/paragraph) node has the highest priority, so its loaded first and is therefore the default node.
2021-04-08 05:08:24 +08:00
## Usage
```js
2021-04-08 06:13:51 +08:00
editor.commands.clearNodes()
2021-04-08 05:08:24 +08:00
```