From e597ed9f555c3cac2561eb003f324bb3d5f8dbf4 Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Wed, 7 Apr 2021 23:08:24 +0200 Subject: [PATCH] docs: update content --- .../docPages/api/commands/clear-content.md | 2 -- docs/src/docPages/api/commands/clear-nodes.md | 8 +++++++ .../docPages/api/commands/insert-content.md | 1 - docs/src/docPages/api/commands/set-content.md | 2 -- .../api/commands/update-attributes.md | 22 +++++++++++++++++++ docs/src/links.yaml | 5 +++++ 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 docs/src/docPages/api/commands/clear-nodes.md create mode 100644 docs/src/docPages/api/commands/update-attributes.md diff --git a/docs/src/docPages/api/commands/clear-content.md b/docs/src/docPages/api/commands/clear-content.md index 08bff9c2..112f31e7 100644 --- a/docs/src/docPages/api/commands/clear-content.md +++ b/docs/src/docPages/api/commands/clear-content.md @@ -6,13 +6,11 @@ Keep in mind that the editor will enforce the configured schema, and the documen See also: [setContent](/api/commands/set-content), [insertContent](/api/commands/insert-content) ## Parameters - `emitUpdate: Boolean (false)` By default, it doesn’t trigger the update event. Passing `true` doesn’t prevent triggering the update event. ## Usage - ```js // Remoe all content from the document this.editor.commands.clearContent() diff --git a/docs/src/docPages/api/commands/clear-nodes.md b/docs/src/docPages/api/commands/clear-nodes.md new file mode 100644 index 00000000..334b4bee --- /dev/null +++ b/docs/src/docPages/api/commands/clear-nodes.md @@ -0,0 +1,8 @@ +# clearNodes +The `clearNodes` command normalizes nodes to a simple paragraph, it even normalizes all kind of lists. For advanced use cases it can come in handy, before applying a new node type. + +## Usage +```js +this.editor.commands.clearNodes() +``` + diff --git a/docs/src/docPages/api/commands/insert-content.md b/docs/src/docPages/api/commands/insert-content.md index 43fb3e71..a504a705 100644 --- a/docs/src/docPages/api/commands/insert-content.md +++ b/docs/src/docPages/api/commands/insert-content.md @@ -4,7 +4,6 @@ The `insertContent` command adds a passed value to the document. See also: [setContent](/api/commands/set-content), [clearContent](/api/commands/clear-content) ## Parameters - `value: Content` The command is pretty flexible and takes plain text, HTML or even JSON as a value. diff --git a/docs/src/docPages/api/commands/set-content.md b/docs/src/docPages/api/commands/set-content.md index ca0868aa..e7a94f6b 100644 --- a/docs/src/docPages/api/commands/set-content.md +++ b/docs/src/docPages/api/commands/set-content.md @@ -4,7 +4,6 @@ The `setContent` command replaces the document with a new one. You can pass JSON See also: [insertContent](/api/commands/insert-content), [clearContent](/api/commands/clear-content) ## Parameters - `content: string` Pass a string (JSON or HTML) as [content](/guide/output). The editor will only render what’s allowed according to the [schema](/api/schema). @@ -18,7 +17,6 @@ By default, it doesn’t trigger the update event. Passing `true` doesn’t prev Options to configure the parsing can be passed during initialization and/or with setContent. Read more about parseOptions in the [ProseMirror documentation](https://prosemirror.net/docs/ref/#model.ParseOptions). ## Usage - ```js // HTML this.editor.commands.setContent('

Example Text

') diff --git a/docs/src/docPages/api/commands/update-attributes.md b/docs/src/docPages/api/commands/update-attributes.md new file mode 100644 index 00000000..3c40caf2 --- /dev/null +++ b/docs/src/docPages/api/commands/update-attributes.md @@ -0,0 +1,22 @@ +# updateAttributes +The `updateAttributes` command sets attributes of a node or mark to new values. Not passed attributes won’t be touched. + +## Parameters + +`typeOrName: string | NodeType | MarkType` + +Pass the type you want to update, for example `'heading'`. + +`attributes: AnyObject` + +This expects an object with the attributes that need to be updated. It doesn’t need to have all attributes. + +## Usage +```js +// Update node attributes +this.editor.commands.updateAttributes('heading', { level: 1 }) + +// Update mark attributes +this.editor.commands.updateAttributes('highlight', { color: 'pink' }) +``` + diff --git a/docs/src/links.yaml b/docs/src/links.yaml index 8a4fcd0c..a3187d4f 100644 --- a/docs/src/links.yaml +++ b/docs/src/links.yaml @@ -139,6 +139,11 @@ link: /api/commands/insert-content - title: setContent link: /api/commands/set-content + + - title: clearNodes + link: /api/commands/clear-nodes + - title: updateAtttributes + link: /api/commands/update-attributes - title: Nodes link: /api/nodes items: