tiptap/docs/src/docPages/api/commands/update-attributes.md

23 lines
603 B
Markdown
Raw Normal View History

2021-04-08 05:08:24 +08:00
# 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' })
```