1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-15 19:54:02 +02:00

Add noop plugin as detached plugin (#2824)

This commit is contained in:
Sunny Hirai
2019-05-22 17:57:58 -07:00
committed by GitHub
parent b73632d42f
commit 8311767108

View File

@@ -0,0 +1,45 @@
import EVENT_HANDLERS from '../../constants/event-handlers'
/**
* This plugin prevents events from going any further and is useful in dev.
*
* The purpose is to see how the editor events and mutations behave without
* the noise of the editor also adding its own events and mutations.
*
* IMPORTANT:
*
* This plugin is detached (i.e. there is no way to turn it on in Slate).
* You must hard code it into `plugins/react/index`.
*
* @return {Object}
*/
function NoopPlugin() {
/**
* Plugin Object
*
* @type {Object}
*/
const plugin = {}
for (const eventName of EVENT_HANDLERS) {
plugin[eventName] = function(event, editor, next) {}
}
/**
* Return the plugin.
*
* @type {Object}
*/
return plugin
}
/**
* Export.
*
* @type {Function}
*/
export default NoopPlugin