tiptap/docs/api/commands/extend-mark-range.md
2021-09-16 14:41:25 +02:00

30 lines
779 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.

# extendMarkRange
The `extendMarkRange` command expands the current selection to encompass the current mark. If the current selection doesnt have the specified mark, nothing changes.
## Parameters
`typeOrName: string | MarkType`
Name or type of the mark.
`attributes?: Record<string, any>`
Optionally, you can specify attributes that the extented mark must contain.
## Usage
```js
// Expand selection to link marks
editor.commands.extendMarkRange('link')
// Expand selection to link marks with specific attributes
editor.commands.extendMarkRange('link', { href: 'https://google.com' })
// Expand selection to link mark and update attributes
editor
.chain()
.extendMarkRange('link')
.updateAttributes('link', {
href: 'https://duckduckgo.com'
})
.run()
```