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..d68dfa15d --- /dev/null +++ b/packages/slate-react/src/plugins/debug/noop.js @@ -0,0 +1,41 @@ +import EVENT_HANDLERS from '../../constants/event-handlers' + +/** + * A plugin immediately after any Debug plugins that prevents events from + * going any further. + * + * 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. + * + * @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 diff --git a/packages/slate-react/src/plugins/react/index.js b/packages/slate-react/src/plugins/react/index.js index 346c4dd6c..633151c4c 100644 --- a/packages/slate-react/src/plugins/react/index.js +++ b/packages/slate-react/src/plugins/react/index.js @@ -9,6 +9,7 @@ import DOMPlugin from '../dom' import RestoreDOMPlugin from './restore-dom' import DebugEventsPlugin from '../debug/debug-events' import DebugBatchEventsPlugin from '../debug/debug-batch-events' +import NoopPlugin from '../debug/noop' /** * A plugin that adds the React-specific rendering logic to the editor. @@ -25,6 +26,7 @@ function ReactPlugin(options = {}) { const debugBatchEventsPlugin = Debug.enabled('slate:batch-events') ? DebugBatchEventsPlugin(options) : null + const noopPlugin = Debug.enabled('slate:noop') ? NoopPlugin(options) : null const renderingPlugin = RenderingPlugin(options) const commandsPlugin = CommandsPlugin(options) const queriesPlugin = QueriesPlugin(options) @@ -45,6 +47,7 @@ function ReactPlugin(options = {}) { return [ debugEventsPlugin, debugBatchEventsPlugin, + noopPlugin, domPlugin, restoreDomPlugin, placeholderPlugin,