@atlaskit/editor-plugin-type-ahead
Version:
Type-ahead plugin for @atlaskit/editor-core
46 lines • 2.82 kB
JavaScript
import React from 'react';
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
import { TypeAheadMenu } from './TypeAheadMenu';
export function ContentComponent(_ref) {
var api = _ref.api,
editorView = _ref.editorView,
popupMountRef = _ref.popupMountRef;
var _useSharedPluginState = 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.createElement(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
});
}