From 3e6d3dca1f642d74ffff17389f7be62efab0c066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 4 Jun 2021 22:58:34 +0200 Subject: [PATCH] docs: update content --- docs/src/docPages/api/commands/for-each.md | 20 ++++++++++++++++++++ docs/src/links.yaml | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 docs/src/docPages/api/commands/for-each.md 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