tiptap/docs/api/commands/update-attributes.md
2021-09-16 14:41:25 +02:00

24 lines
664 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# updateAttributes
The `updateAttributes` command sets attributes of a node or mark to new values. Not passed attributes wont be touched.
See also: [extendMarkRange](/api/commands/extend-mark-range)
## Parameters
`typeOrName: string | NodeType | MarkType`
Pass the type you want to update, for example `'heading'`.
`attributes: Record<string, any>`
This expects an object with the attributes that need to be updated. It doesnt need to have all attributes.
## Usage
```js
// Update node attributes
editor.commands.updateAttributes('heading', { level: 1 })
// Update mark attributes
editor.commands.updateAttributes('highlight', { color: 'pink' })
```