探索 Tiptap V3 的最新功能

forEach 命令

遍历一个项目数组。

参数

items: any[]

一个项目数组。

fn: (item: any, props: CommandProps & { index: number }) => boolean

一个对你的项目执行任意操作的函数。

使用 forEach 命令

const items = ['foo', 'bar', 'baz']

editor.commands.forEach(items, (item, { commands }) => {
  return commands.insertContent(item)
})