tiptap/docs/api/commands/clear-content.md
2021-09-16 14:41:25 +02:00

22 lines
838 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# clearContent
The `clearContent` command deletes the current document.
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)`
By default, it doesnt trigger the update event. Passing `true` doesnt prevent triggering the update event.
## Usage
```js
// Remove all content from the document
editor.commands.clearContent()
// Remove all content, and trigger the `update` event
editor.commands.clearContent(true)
```