探索 Tiptap V3 的最新功能

clearContent 命令

clearContent 命令用于删除当前文档。编辑器将保持至少一个空段落,以满足架构要求。

另见:setContentinsertContent

参数

emitUpdate?: boolean (true) 是否发出更新事件。默认为 true(注意:在 v2 中从 false 更改为此)。

示例

// 清除内容(默认发出更新事件)
editor.commands.clearContent()

// 清除内容而不发出更新
editor.commands.clearContent(false)