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