UNPKG

@atlaskit/editor-plugin-type-ahead

Version:

Type-ahead plugin for @atlaskit/editor-core

53 lines (52 loc) 3.06 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.ContentComponent = ContentComponent; var _react = _interopRequireDefault(require("react")); var _hooks = require("@atlaskit/editor-common/hooks"); var _TypeAheadMenu = require("./TypeAheadMenu"); function ContentComponent(_ref) { var api = _ref.api, editorView = _ref.editorView, popupMountRef = _ref.popupMountRef; var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['typeAhead'], function (states) { var _states$typeAheadStat, _states$typeAheadStat2, _states$typeAheadStat3, _states$typeAheadStat4, _states$typeAheadStat5, _states$typeAheadStat6, _states$typeAheadStat7; return { triggerHandler: (_states$typeAheadStat = states.typeAheadState) === null || _states$typeAheadStat === void 0 ? void 0 : _states$typeAheadStat.triggerHandler, items: (_states$typeAheadStat2 = states.typeAheadState) === null || _states$typeAheadStat2 === void 0 ? void 0 : _states$typeAheadStat2.items, errorInfo: (_states$typeAheadStat3 = states.typeAheadState) === null || _states$typeAheadStat3 === void 0 ? void 0 : _states$typeAheadStat3.errorInfo, decorationElement: (_states$typeAheadStat4 = states.typeAheadState) === null || _states$typeAheadStat4 === void 0 ? void 0 : _states$typeAheadStat4.decorationElement, decorationSet: (_states$typeAheadStat5 = states.typeAheadState) === null || _states$typeAheadStat5 === void 0 ? void 0 : _states$typeAheadStat5.decorationSet, query: (_states$typeAheadStat6 = states.typeAheadState) === null || _states$typeAheadStat6 === void 0 ? void 0 : _states$typeAheadStat6.query, selectedIndex: (_states$typeAheadStat7 = states.typeAheadState) === null || _states$typeAheadStat7 === void 0 ? void 0 : _states$typeAheadStat7.selectedIndex }; }), triggerHandler = _useSharedPluginState.triggerHandler, items = _useSharedPluginState.items, errorInfo = _useSharedPluginState.errorInfo, decorationElement = _useSharedPluginState.decorationElement, decorationSet = _useSharedPluginState.decorationSet, query = _useSharedPluginState.query, selectedIndex = _useSharedPluginState.selectedIndex; if (items === undefined || decorationSet === undefined || errorInfo === undefined || decorationElement === undefined || query === undefined || selectedIndex === undefined) { return null; } return /*#__PURE__*/_react.default.createElement(_TypeAheadMenu.TypeAheadMenu, { editorView: editorView, popupMountRef: popupMountRef // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed) , typeAheadState: { triggerHandler: triggerHandler, items: items, errorInfo: errorInfo, decorationElement: decorationElement, decorationSet: decorationSet, query: query }, selectedIndex: selectedIndex, api: api }); }