@atlaskit/editor-plugin-focus
Version:
Focus plugin for @atlaskit/editor-core
29 lines (28 loc) • 780 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 var focusPlugin = function focusPlugin(_ref) {
var _api = _ref.api;
return {
name: 'focus',
getSharedState: function 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: function pmPlugins() {
return [{
name: 'focusHandlerPlugin',
plugin: createPlugin
}];
}
};
};