From 4abd7c88279a3caeb508f5de973a3c4507c4686a Mon Sep 17 00:00:00 2001 From: Dominik Biedebach Date: Wed, 8 Jun 2022 12:41:14 +0200 Subject: [PATCH] docs(docs): :memo: add missing documentation for commands --- docs/api/commands/sink-list-item.md | 8 +++++--- docs/api/commands/split-block.md | 17 ++++++++++++++--- docs/api/commands/split-list-item.md | 13 ++++++++++--- docs/api/commands/toggle-list.md | 21 ++++++++++++++++++--- docs/api/commands/toggle-mark.md | 27 ++++++++++++++++++++++++--- docs/api/commands/toggle-node.md | 25 ++++++++++++++++++++++--- docs/api/commands/toggle-wrap.md | 18 +++++++++++++++--- docs/api/commands/undo-input-rule.md | 8 +++++--- docs/api/commands/unset-all-marks.md | 8 +++++--- docs/api/commands/unset-mark.md | 21 ++++++++++++++++++--- docs/api/commands/wrap-in-list.md | 18 +++++++++++++++--- docs/links.yaml | 11 ----------- 12 files changed, 151 insertions(+), 44 deletions(-) diff --git a/docs/api/commands/sink-list-item.md b/docs/api/commands/sink-list-item.md index 842a3bc5..c4b0afc8 100644 --- a/docs/api/commands/sink-list-item.md +++ b/docs/api/commands/sink-list-item.md @@ -1,5 +1,7 @@ # sinkListItem +The `sinkListItem` will try to sink the list item around the current selection down into a wrapping child list. -:::warning -Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis) -::: +## Usage +```js +editor.commands.liftListItem() +``` diff --git a/docs/api/commands/split-block.md b/docs/api/commands/split-block.md index 7e4f7b6c..ef816d44 100644 --- a/docs/api/commands/split-block.md +++ b/docs/api/commands/split-block.md @@ -1,5 +1,16 @@ # splitBlock +`splitBlock` will split the current node into two nodes at the current [NodeSelection](https://prosemirror.net/docs/ref/#state.NodeSelection). If the current selection is not splittable, the command will be ignored. -:::warning -Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis) -::: +## Parameters +`options: Record` + +* `keepMarks: boolean` - Defines if the marks should be kept or removed. Defaults to `true`. + +## Usage +```js +// split the current node and keep marks +editor.commands.splitBlock() + +// split the current node and don't keep marks +editor.commands.splitBlock({ keepMarks: false }) +``` diff --git a/docs/api/commands/split-list-item.md b/docs/api/commands/split-list-item.md index 4ce444df..7e100798 100644 --- a/docs/api/commands/split-list-item.md +++ b/docs/api/commands/split-list-item.md @@ -1,5 +1,12 @@ # splitListItem +`splitListItem` splits one list item into two separate list items. If this is a nested list, the wrapping list item should be split. -:::warning -Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis) -::: +## Parameters +`typeOrName: string | NodeType` + +The type of node that should be split into two separate list items. + +## Usage +```js +editor.commands.splitListItem('bullet_list') +``` diff --git a/docs/api/commands/toggle-list.md b/docs/api/commands/toggle-list.md index 78e5ecd6..6b77285a 100644 --- a/docs/api/commands/toggle-list.md +++ b/docs/api/commands/toggle-list.md @@ -1,5 +1,20 @@ # toggleList +`toggleList` will toggle between different types of lists. -:::warning -Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis) -::: +## Parameters +`listTypeOrName: string | NodeType` + +The type of node that should be used for the wrapping list + +`itemTypeOrName: string | NodeType` + +The type of node that should be used for the list items + +## Usage +```js +// toggle a bullet list with list items +editor.commands.toggleList('bullet_list', 'list_item') + +// toggle a numbered list with list items +editor.commands.toggleList('ordered_list', 'list_item') +``` diff --git a/docs/api/commands/toggle-mark.md b/docs/api/commands/toggle-mark.md index 0b6ee229..23eb49b3 100644 --- a/docs/api/commands/toggle-mark.md +++ b/docs/api/commands/toggle-mark.md @@ -1,5 +1,26 @@ # toggleMark +The `toggleMark` command toggles a specific mark on and off at the current selection. -:::warning -Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis) -::: +## Parameters +`typeOrName: string | MarkType` + +The type of mark that should be toggled. + +`attributes?: Record` + +The attributes that should be applied to the mark. **This is optional.** + +`options?: Record` +* `extendEmptyMarkRange: boolean` - Removes the mark even across the current selection. Defaults to `false` + +## Usage +```js +// toggles a bold mark +editor.commands.toggleMark('bold') + +// toggles bold mark with a color attribute +editor.commands.toggleMark('bold', { color: 'red' }) + +// toggles a bold mark with a color attribute and removes the mark across the current selection +editor.commands.toggleMark('bold', { color: 'red' }, { extendEmptyMarkRange: true }) +``` diff --git a/docs/api/commands/toggle-node.md b/docs/api/commands/toggle-node.md index 210cfb78..15c3ea1e 100644 --- a/docs/api/commands/toggle-node.md +++ b/docs/api/commands/toggle-node.md @@ -1,5 +1,24 @@ # toggleNode +`toggleNode` will a node with another node. -:::warning -Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis) -::: +## Parameters +`typeOrName: string | NodeType` + +The type of node that should be toggled. + +`toggleTypeOrName: string | NodeType` + +The type of node that should be used for the toggling. + +`attributes?: Record` + +The attributes that should be applied to the node. **This is optional.** + +## Usage +```js +// toggle a paragraph with a heading node +editor.commands.toggleNode('paragraph', 'heading', { level: 1 }) + +// toggle a paragraph with a image node +editor.commands.toggleNode('paragraph', 'image', { src: 'https://example.com/image.png' }) +``` diff --git a/docs/api/commands/toggle-wrap.md b/docs/api/commands/toggle-wrap.md index aada62c1..f2d81231 100644 --- a/docs/api/commands/toggle-wrap.md +++ b/docs/api/commands/toggle-wrap.md @@ -1,5 +1,17 @@ # toggleWrap +`toggleWrap` wraps the current node with a new node or removes a wrapping node. -:::warning -Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis) -::: +## Parameters +`typeOrName: string | NodeType` + +The type of node that should be used for the wrapping node. + +`attributes?: Record` + +The attributes that should be applied to the node. **This is optional.** + +## Usage +```js +// toggle wrap the current selection with a heading node +editor.commands.toggleWrap('heading', { level: 1 }) +``` diff --git a/docs/api/commands/undo-input-rule.md b/docs/api/commands/undo-input-rule.md index 693c9ebe..9512f1ae 100644 --- a/docs/api/commands/undo-input-rule.md +++ b/docs/api/commands/undo-input-rule.md @@ -1,5 +1,7 @@ # undoInputRule +`undoInputRule` will undo the most recent input rule that was triggered. -:::warning -Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis) -::: +## Usage +```js +editor.commands.undoInputRule() +``` diff --git a/docs/api/commands/unset-all-marks.md b/docs/api/commands/unset-all-marks.md index 5c713290..eb5666e2 100644 --- a/docs/api/commands/unset-all-marks.md +++ b/docs/api/commands/unset-all-marks.md @@ -1,5 +1,7 @@ # unsetAllMarks +`unsetAllMarks` will remove all marks from the current selection. -:::warning -Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis) -::: +## Usage +```js +editor.commands.unsetAllMarks() +``` diff --git a/docs/api/commands/unset-mark.md b/docs/api/commands/unset-mark.md index ab527be4..f0600a48 100644 --- a/docs/api/commands/unset-mark.md +++ b/docs/api/commands/unset-mark.md @@ -1,5 +1,20 @@ # unsetMark +`unsetMark` will remove the mark from the current selection. Can also remove all marks across the current selection. -:::warning -Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis) -::: +## Parameters +`typeOrName: string | MarkType` + +The type of mark that should be removed. + +`options?: Record` + +* `extendEmptyMarkRange?: boolean` - Removes the mark even across the current selection. Defaults to `false` + +## Usage +```js +// removes a bold mark +editor.commands.unsetMark('bold') + +// removes a bold mark across the current selection +editor.commands.unsetMark('bold', { extendEmptyMarkRange: true }) +``` diff --git a/docs/api/commands/wrap-in-list.md b/docs/api/commands/wrap-in-list.md index ea6a1866..11d7c8f9 100644 --- a/docs/api/commands/wrap-in-list.md +++ b/docs/api/commands/wrap-in-list.md @@ -1,5 +1,17 @@ # wrapInList +`wrapInList` will wrap a node in the current selection in a list. -:::warning -Oops, we didn’t find time to fill this page. Writing documentation needs attention to detail, a great understanding of the project and time to write. Though Tiptap is used by thousands of developers all around the world, it’s still a side project for us. Let’s change that and make open source our full-time job! [Become a sponsor!](https://github.com/sponsors/ueberdosis) -::: +## Parameters +`typeOrName: string | NodeType` + +The type of node that should be wrapped in a list. + +`attributes?: Record` + +The attributes that should be applied to the list. **This is optional.** + +## Usage +```js +// wrap a paragraph in a bullet list +editor.commands.wrapInList('paragraph') +``` diff --git a/docs/links.yaml b/docs/links.yaml index abf02ec3..235543a8 100644 --- a/docs/links.yaml +++ b/docs/links.yaml @@ -222,39 +222,28 @@ link: /api/commands/set-text-selection - title: sinkListItem link: /api/commands/sink-list-item - type: draft - title: splitBlock link: /api/commands/split-block - type: draft - title: splitListItem link: /api/commands/split-list-item - type: draft - title: toggleList link: /api/commands/toggle-list - type: draft - title: toggleMark link: /api/commands/toggle-mark - type: draft - title: toggleNode link: /api/commands/toggle-node - type: draft - title: toggleWrap link: /api/commands/toggle-wrap - type: draft - title: undoInputRule link: /api/commands/undo-input-rule - type: draft - title: unsetAllMarks link: /api/commands/unset-all-marks - type: draft - title: unsetMark link: /api/commands/unset-mark - type: draft - title: updateAttributes link: /api/commands/update-attributes - title: wrapInList link: /api/commands/wrap-in-list - type: draft - title: Nodes link: /api/nodes items: