Creating an Extension
Use the staticcreate method to define a new extension.
Partial<ExtensionConfig<Options, Storage>> | (() => Partial<ExtensionConfig<Options, Storage>>)
The extension configuration object or a function that returns a configuration object.
Configuration Options
name
The unique name for the extension.string
required
A unique identifier for the extension. This must be unique across all extensions.
priority
The priority of the extension. Higher values are called earlier.number
default:"100"
Extensions with higher priority take precedence. Core extensions typically use 100.
addOptions()
Define options for the extension.addStorage()
Define storage for the extension to persist data.addGlobalAttributes()
Add attributes to specific node or mark types.addCommands()
Add commands to the editor.addKeyboardShortcuts()
Register keyboard shortcuts.addInputRules()
Add input rules that trigger on typing patterns.addPasteRules()
Add paste rules that trigger on pasting content.addProseMirrorPlugins()
Add ProseMirror plugins.addExtensions()
Add additional extensions (useful for extension kits).Lifecycle Hooks
onBeforeCreate()
Called before the editor is created.onCreate()
Called when the editor is ready.onUpdate()
Called when the content changes.onSelectionUpdate()
Called when the selection changes.onTransaction()
Called after each transaction.onFocus()
Called when the editor gains focus.onBlur()
Called when the editor loses focus.onDestroy()
Called when the editor is destroyed.Methods
configure()
Create a configured version of the extension.Partial<Options>
Options to override the default options.
extend()
Extend the extension with additional configuration.Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)
Additional configuration or a function that returns configuration.