@atlaskit/editor-plugin-history
Version:
History plugin for @atlaskit/editor-core
28 lines (27 loc) • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getPmHistoryPluginState = void 0;
var _utils = require("@atlaskit/editor-common/utils");
// Internal prosemirror history plugin does not export its plugin key.
// Previously we searched through all the plugins to find the history plugin
// but it's faster to look up the plugin directly via `getState`.
var fakePluginKey = {
key: _utils.pmHistoryPluginKey,
getState: function getState(state) {
// The plugin key is used to index state
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return state[_utils.pmHistoryPluginKey];
},
get: function get(state) {
return state.plugins.find(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function (plugin) {
return plugin.key === _utils.pmHistoryPluginKey;
});
}
};
var getPmHistoryPluginState = exports.getPmHistoryPluginState = function getPmHistoryPluginState(state) {
return fakePluginKey.getState(state);
};