@atlaskit/editor-plugin-focus
Version:
Focus plugin for @atlaskit/editor-core
30 lines (29 loc) • 708 B
JavaScript
import { createPlugin, key } from './pm-plugins/main';
/**
* Focus plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
* from `@atlaskit/editor-core`.
*/
export const focusPlugin = ({
api: _api
}) => {
return {
name: 'focus',
getSharedState(editorState) {
var _key$getState;
if (!editorState) {
return {
hasFocus: false
};
}
return {
hasFocus: Boolean((_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.hasFocus)
};
},
pmPlugins() {
return [{
name: 'focusHandlerPlugin',
plugin: createPlugin
}];
}
};
};