tiptap 重置属性
resetAttributes
会将某些节点的属性恢复到其默认值。
参数
typeOrName: string | Node
要重置的节点。可以是字符串或 Node 对象。
attributes: string | string[]
一个字符串或字符串数组,定义应重置哪些属性。
使用示例
// 将当前选中的段落节点的样式和类属性重置
editor.commands.resetAttributes("paragraph", ["style", "class"]);
这里提到的 editor
可能是某个富文本编辑器(如 CKEditor 或 ContentEditable)中的一个对象,它提供了对文档元素进行操作的方法。resetAttributes
命令用于控制元素的属性设置,typeOrName
参数指定要操作的元素类型(如 'paragraph'),而 attributes
则是需要还原的属性列表。