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

22 lines
838 B
Markdown
Raw Normal View History

# clearContent
2021-04-08 04:53:31 +08:00
The `clearContent` command deletes the current document.
2021-04-08 04:53:31 +08:00
Keep in mind that the editor will enforce the configured schema, and the document wont be `null`. The default [`Document`](/api/nodes/document) expects to have at least one block node, which is the paragraph by default. In other words: Even after running that command the document will have at least one (empty) paragraph.
See also: [setContent](/api/commands/set-content), [insertContent](/api/commands/insert-content)
## Parameters
`emitUpdate: boolean (false)`
2021-04-08 04:53:31 +08:00
By default, it doesnt trigger the update event. Passing `true` doesnt prevent triggering the update event.
## Usage
```js
2021-05-05 13:44:18 +08:00
// Remove all content from the document
2021-04-08 06:13:51 +08:00
editor.commands.clearContent()
2021-04-08 04:53:31 +08:00
// Remove all content, and trigger the `update` event
2021-04-08 06:13:51 +08:00
editor.commands.clearContent(true)
```