UNPKG

@atlaskit/editor-plugin-text-formatting

Version:

Text-formatting plugin for @atlaskit/editor-core

34 lines (33 loc) 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pluginKey = exports.plugin = void 0; var _safePlugin = require("@atlaskit/editor-common/safe-plugin"); var _state = require("@atlaskit/editor-prosemirror/state"); var _utils = require("../editor-commands/utils"); var pluginKey = exports.pluginKey = new _state.PluginKey('clearFormattingPlugin'); var plugin = exports.plugin = function plugin(dispatch) { return new _safePlugin.SafePlugin({ state: { init: function init(_config, state) { return { formattingIsPresent: (0, _utils.checkFormattingIsPresent)(state) }; }, apply: function apply(_tr, pluginState, _oldState, newState) { var formattingIsPresent = (0, _utils.checkFormattingIsPresent)(newState); if (formattingIsPresent !== pluginState.formattingIsPresent) { dispatch(pluginKey, { formattingIsPresent: formattingIsPresent }); return { formattingIsPresent: formattingIsPresent }; } return pluginState; } }, key: pluginKey }); };