UNPKG

@atlaskit/editor-plugin-focus

Version:

Focus plugin for @atlaskit/editor-core

34 lines (33 loc) 903 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.focusPlugin = void 0; var _main = require("./pm-plugins/main"); /** * Focus plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor` * from `@atlaskit/editor-core`. */ var focusPlugin = exports.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 = _main.key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.hasFocus) }; }, pmPlugins: function pmPlugins() { return [{ name: 'focusHandlerPlugin', plugin: _main.createPlugin }]; } }; };