@atlaskit/editor-plugin-alignment
Version:
Alignment plugin for @atlaskit/editor-core
63 lines (61 loc) • 2.18 kB
JavaScript
/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
import "./index.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
import { injectIntl } from 'react-intl';
import { alignCenter, alignLeft, alignRight } from '@atlaskit/editor-common/keymaps';
import { alignmentMessages } from '@atlaskit/editor-common/messages';
import { IconMap } from '../ToolbarAlignment/icon-map';
import AlignmentButton from './AlignmentButton';
const alignmentWrapper = null;
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage -- This rule thinks this isn't a `css()` call due to the name mapping
const alignmentWrapperStylesUnbounded = null;
const alignCenterKeyboardShortcut = alignCenter;
const alignRightKeyboardShortcut = alignRight;
const alignmentOptions = [{
title: alignmentMessages.alignLeft,
shortcut: alignLeft,
value: 'start'
}, {
title: alignmentMessages.alignCenter,
shortcut: alignCenterKeyboardShortcut,
value: 'center'
}, {
title: alignmentMessages.alignRight,
shortcut: alignRightKeyboardShortcut,
value: 'end'
}];
function Alignment({
onClick,
selectedAlignment,
className,
intl
}) {
return /*#__PURE__*/React.createElement("div", {
"data-testid": "alignment-buttons"
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
,
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
className: ax(["_1e0c1txw _ca0qze3t _n3tdze3t _19bvu2gc _u5f3u2gc _p12f53f4 _gy1pv77o", "_1fvdglyw", className])
}, alignmentOptions.map(alignment => {
const {
value,
title,
shortcut
} = alignment;
const message = intl.formatMessage(title);
return /*#__PURE__*/React.createElement(AlignmentButton, {
content: /*#__PURE__*/React.createElement(IconMap, {
alignment: value
}),
key: value,
value: value,
label: message,
shortcut: shortcut,
onClick: onClick,
isSelected: value === selectedAlignment
});
}));
}
const _default_1 = injectIntl(Alignment);
export default _default_1;