项目

tiptap 提升

lift 命令将指定的节点提升到其父节点。提升 指的是,块会移动到它当前所在的块的父级。

参数

typeOrName: String | NodeType

要提升的节点。如果在当前选区中找不到该节点,忽略此命令。

attributes: Record<string, any>

提升时节点应具有的属性。这可选

使用方法

// 提升任意标题
editor.commands.lift("headline");

// 只提升 h2
editor.commands.lift("headline", { level: 2 });

这里,“headline”代表标题类型,level: 2 是指特定级别的标题(例如二级标题)。如果你传递一个字符串和属性对象,会根据字符串查找匹配的节点并应用给定的属性。

在本文档中