Skip to main content

Custom Extensions

Extensions are the building blocks of Tiptap. They allow you to add new functionality to the editor without modifying nodes or marks. Extensions are perfect for adding editor-wide features like commands, keyboard shortcuts, or plugins.

Understanding Extensions

The Extension class is the base class for all extensions in Tiptap. It provides a rich API for extending the editor’s functionality.

Creating a Simple Extension

Let’s create a simple extension that replaces emoticons with emojis as you type.
Source: demos/src/Examples/Savvy/React/SmilieReplacer.ts:1

Extension with ProseMirror Plugins

Here’s a more advanced extension that uses ProseMirror plugins to highlight color codes in the editor.
Source: demos/src/Examples/Savvy/React/ColorHighlighter.ts:1

Extension Configuration

Adding Options

Extensions can accept configuration options that customize their behavior.

Configuring Extensions

Extension Storage

Extensions can maintain their own state using storage.

Lifecycle Hooks

Extensions can hook into various editor lifecycle events.
Source: packages/core/src/Extendable.ts:341

Keyboard Shortcuts

Add custom keyboard shortcuts to your extension.
Source: packages/core/src/Extendable.ts:133

Global Attributes

Extensions can add attributes to other nodes or marks.
Source: packages/core/src/Extendable.ts:79

Priority

Control the order in which extensions are loaded and executed.
Source: packages/core/src/Extendable.ts:50

Extending Existing Extensions

You can extend existing extensions to customize their behavior.
Source: packages/core/src/Extension.ts:35
Extensions are ideal for adding editor-wide functionality. Use Nodes for block content and Marks for inline formatting.

Next Steps

Custom Nodes

Learn how to create custom block content

Custom Marks

Create custom inline formatting