diff --git a/docs/src/docPages/api/commands/for-each.md b/docs/src/docPages/api/commands/for-each.md new file mode 100644 index 00000000..0f413800 --- /dev/null +++ b/docs/src/docPages/api/commands/for-each.md @@ -0,0 +1,20 @@ +# 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 +```js +const items = ['foo', 'bar', 'baz'] + +editor.commands.forEach(items, (item, { commands }) => { + return commands.insertContent(item) +}) +``` diff --git a/docs/src/links.yaml b/docs/src/links.yaml index d92fc950..83f1ffdb 100644 --- a/docs/src/links.yaml +++ b/docs/src/links.yaml @@ -157,6 +157,9 @@ - title: focus link: /api/commands/focus type: new + - title: forEach + link: /api/commands/for-each + type: new - title: insertContent link: /api/commands/insert-content - title: insertContentAt