Skip to main content

Custom Marks

Marks are inline styles that can be applied to text, like bold, italic, underline, or links. Unlike nodes which are structural, marks are formatting that can be toggled on and off for portions of text.

Understanding Marks

The Mark class extends the Extendable class and provides functionality for inline formatting.
Source: packages/core/src/Mark.ts:146

Creating a Simple Mark

Let’s start with the bold mark.
Source: packages/extension-bold/src/bold.tsx:56

Mark with Attributes

Here’s the highlight mark that demonstrates using attributes.
Source: packages/extension-highlight/src/highlight.ts:57

Simple Italic Mark

The italic mark shows a minimal implementation.
Source: packages/extension-italic/src/italic.ts:58

Mark Properties

Marks have several important properties that control their behavior.
Source: packages/core/src/Mark.ts:25

Mark Attributes

Attributes allow marks to store additional data.
Source: packages/core/src/Mark.ts:130

Mark Input Rules

Input rules automatically apply marks based on text patterns.

Mark Paste Rules

Paste rules apply marks when content is pasted.

Exitable Marks

Some marks should be easy to exit with arrow keys.
Source: packages/core/src/Mark.ts:159

Mark Exclusion

Some marks cannot coexist with others.
Source: packages/core/src/Mark.ts:42

TypeScript Commands

Add type-safe commands to your mark.
Source: packages/extension-highlight/src/highlight.ts:19

Extending Marks

You can extend existing marks to customize behavior.
Source: packages/core/src/Mark.ts:191
Marks are ideal for inline formatting that can be toggled on and off. Use Nodes for block-level content and Extensions for editor-wide functionality.

Next Steps

Custom Nodes

Create custom block content

Styling

Style your editor and content