Skip to main content

Creating a Mark

Use the static create method to define a new mark.
Partial<MarkConfig<Options, Storage>> | (() => Partial<MarkConfig<Options, Storage>>)
The mark configuration object or a function that returns a configuration object.

Configuration Options

Marks inherit all configuration options from Extension, plus the following:

inclusive

Whether the mark should be active when the cursor is at the boundary.
boolean
If true, the mark is active when the cursor is at its start/end. If false, it requires the cursor to be inside.
Example

excludes

Define which other marks this mark excludes.
string
Space-separated mark names, or "_" to exclude all other marks.
Example

exitable

Whether the mark can be exited at the end.
boolean
default:"false"
If true, pressing right arrow at the end of the mark will move outside of it.
Example

group

Define the group(s) this mark belongs to.
string
Space-separated group names.
Example

spanning

Whether the mark spans across multiple nodes.
boolean
If false, the mark is removed when split.

code

Whether the mark represents code.
boolean
default:"false"
Indicates that this mark contains code.
Example

keepOnSplit

Whether to keep the mark after splitting a node.
boolean
default:"true"
If true, the mark continues after splitting a text block.
Example

parseHTML()

Define how to parse HTML into this mark.
Example

renderHTML()

Define how to render the mark as HTML.
Example

addAttributes()

Define attributes for the mark.
Example

addMarkView()

Define a custom mark view.
Example

Methods

configure()

Create a configured version of the mark.
Partial<Options>
Options to override the default options.
Example

extend()

Extend the mark with additional configuration.
Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)
Additional configuration or a function that returns configuration.
Example

Complete Example