From 8311767108961d219fbd68f892e22ab824b7a83d Mon Sep 17 00:00:00 2001 From: Sunny Hirai Date: Wed, 22 May 2019 17:57:58 -0700 Subject: [PATCH] Add noop plugin as detached plugin (#2824) --- .../slate-react/src/plugins/debug/noop.js | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 packages/slate-react/src/plugins/debug/noop.js diff --git a/packages/slate-react/src/plugins/debug/noop.js b/packages/slate-react/src/plugins/debug/noop.js new file mode 100644 index 000000000..0997a2c18 --- /dev/null +++ b/packages/slate-react/src/plugins/debug/noop.js @@ -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