@atlaskit/editor-plugin-alignment
Version:
Alignment plugin for @atlaskit/editor-core
32 lines • 1.14 kB
JavaScript
import React from 'react';
import { getAriaKeyshortcuts, tooltip, ToolTipContent } from '@atlaskit/editor-common/keymaps';
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
function AlignmentButton(_ref) {
var label = _ref.label,
isSelected = _ref.isSelected,
content = _ref.content,
shortcut = _ref.shortcut,
onClick = _ref.onClick,
value = _ref.value;
var onClickCallback = function onClickCallback(e) {
// detect if the click event comes from keyboard where screenX and screenY are 0
var isMouseEvent = e instanceof MouseEvent;
e.preventDefault();
onClick(value, isMouseEvent);
};
return /*#__PURE__*/React.createElement(ToolbarButton, {
disabled: false,
selected: isSelected,
title: /*#__PURE__*/React.createElement(ToolTipContent, {
description: label,
keymap: shortcut
}),
"aria-label": shortcut ? tooltip(shortcut, label) : label,
"aria-pressed": isSelected,
"aria-keyshortcuts": getAriaKeyshortcuts(shortcut),
onClick: onClickCallback,
iconBefore: content,
titlePosition: 'bottom'
});
}
export default AlignmentButton;