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

361 B

forEach

Loop through an array of items.

Parameters

items: any[]

An array of items.

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

A function to do anything with your item.

Usage

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

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