@atlaskit/editor-plugin-quick-insert
Version:
Quick insert plugin for @atlaskit/editor-core
29 lines • 1.35 kB
JavaScript
import React, { useCallback } from 'react';
import { useIntl } from 'react-intl';
import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
import AddIcon from '@atlaskit/icon/core/add';
export var QuickInsertSectionOverflowMenuItem = function QuickInsertSectionOverflowMenuItem(_ref) {
var api = _ref.api,
category = _ref.category;
var _useIntl = useIntl(),
formatMessage = _useIntl.formatMessage;
var onSelect = useCallback(function (_ref2) {
var _api$quickInsert$comm, _api$quickInsert;
var insert = _ref2.insert;
var tr = insert(undefined);
return (_api$quickInsert$comm = api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.commands.openElementBrowser({
category: category
})({
tr: tr
})) !== null && _api$quickInsert$comm !== void 0 ? _api$quickInsert$comm : tr;
}, [api, category]);
return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
iconBefore: /*#__PURE__*/React.createElement(AddIcon, {
label: ""
}),
isDisabled: !(api !== null && api !== void 0 && api.quickInsert),
onSelect: onSelect,
title: formatMessage(toolbarInsertBlockMessages.viewMore)
});
};