docs: update content

This commit is contained in:
Hans Pagel 2021-04-07 23:08:24 +02:00
parent b5cf0892c4
commit e597ed9f55
6 changed files with 35 additions and 5 deletions

View File

@ -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 doesnt trigger the update event. Passing `true` doesnt prevent triggering the update event.
## Usage
```js
// Remoe all content from the document
this.editor.commands.clearContent()

View File

@ -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()
```

View File

@ -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.

View File

@ -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 whats allowed according to the [schema](/api/schema).
@ -18,7 +17,6 @@ By default, it doesnt trigger the update event. Passing `true` doesnt 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('<p>Example Text</p>')

View File

@ -0,0 +1,22 @@
# updateAttributes
The `updateAttributes` command sets attributes of a node or mark to new values. Not passed attributes wont 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 doesnt 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' })
```

View File

@ -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: