Plugins
You've already seen how the behaviors of Slate editors can be overriden. 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 handles images:
And then to use the plugin, simply:
This plugin composition model makes Slate extremely easy to extend!
Helpers Functions
In addition to the plugin functions, you might want to expose helper functions that are used alongside your plugins. For example:
That way you can reuse your helpers. Or even mix them with the core Slate helpers to create your own bundle, like:
Then you can use MyElement
everywhere and have access to all your helpers in one place.
Last updated