@atlaskit/editor-plugin-history
Version:
History plugin for @atlaskit/editor-core
22 lines • 860 B
JavaScript
import { pmHistoryPluginKey } from '@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: pmHistoryPluginKey,
getState: function getState(state) {
// The plugin key is used to index state
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return state[pmHistoryPluginKey];
},
get: function get(state) {
return state.plugins.find(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function (plugin) {
return plugin.key === pmHistoryPluginKey;
});
}
};
export var getPmHistoryPluginState = function getPmHistoryPluginState(state) {
return fakePluginKey.getState(state);
};