UNPKG

@atlaskit/editor-plugin-block-type

Version:

BlockType plugin for @atlaskit/editor-core

53 lines 1.92 kB
/* QuoteBlockMenuItem.tsx generated by @compiled/babel-plugin v0.39.1 */ import "./QuoteBlockMenuItem.compiled.css"; import { ax, ix } from "@compiled/react/runtime"; import React from 'react'; import { useIntl } from 'react-intl'; import { INPUT_METHOD } from '@atlaskit/editor-common/analytics'; import { blockTypeMessages } from '@atlaskit/editor-common/messages'; import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar'; import QuotationMarkIcon from '@atlaskit/icon/core/quotation-mark'; const styles = { svgOverflow: "_1wrmewfl _172sewfl" }; const NODE_NAME = 'blockquote'; const QuoteBlockMenuItem = ({ api }) => { const { formatMessage } = useIntl(); const handleClick = event => { const triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE; const inputMethod = INPUT_METHOD.BLOCK_MENU; api === null || api === void 0 ? void 0 : api.core.actions.execute(({ tr }) => { var _api$blockMenu; const command = api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.transformNode(tr.doc.type.schema.nodes.blockquote, { inputMethod, triggeredFrom, targetTypeName: NODE_NAME }); return command ? command({ tr }) : null; }); }; return /*#__PURE__*/React.createElement(ToolbarDropdownItem, { onClick: handleClick, elemBefore: /*#__PURE__*/React.createElement("span", { className: ax([styles.svgOverflow]) }, /*#__PURE__*/React.createElement(QuotationMarkIcon, { label: "", size: "small" })) }, formatMessage(blockTypeMessages.blockquote)); }; export const createQuoteBlockMenuItem = ({ api }) => { return () => /*#__PURE__*/React.createElement(QuoteBlockMenuItem, { api: api }); };