Plugin shape
A plugin is a function that receives the editor instance and returns nothing:plugins option.
Plugins run after the editor has fully mounted and its DOM is ready. This means
editor.root is available and all built-in modules have already been initialized when your plugin function executes.Full example: word count plugin
The following plugin appends a live word-count display beneath the editor and updates it on every change:Accessing the DOM
Inside your plugin,editor.root is the live contenteditable element that the editor manages. You can append child elements to it, add event listeners, or read its innerHTML and textContent:
Subscribing to events
Useeditor.on(eventName, handler) inside your plugin to react to editor events. All of the editor’s built-in events are available:
Installing plugins
You can install plugins in two ways:1
Via the plugins option at initialization
Pass an array of plugin functions to the
plugins option. All plugins in the array run once, in order, after the editor mounts:2
Via editor.use() after initialization
Call
editor.use(plugin) at any point after the editor has been constructed. The plugin function runs immediately: