Concepts

Plugins

3min

You've already seen how the behaviors of Slate editors can be overridden. These overrides can also be packaged up into "plugins" to be reused, tested and shared. This is one of the most powerful aspects of Slate's architecture.

A plugin is simply a function that takes an Editor object and returns it after it has augmented it in some way.

For example, a plugin that marks image nodes as "void":

JS


And then to use the plugin, simply:

JS


This plugin composition model makes Slate extremely easy to extend!

Helper Functions

In addition to the plugin functions, you might want to expose helper functions that are used alongside your plugins. For example:

JS


Then you can use MyEditor and MyElement everywhere and have access to all your helpers in one place.

Updated 08 May 2024
Doc contributor
Did this page help you?