@atlaskit/editor-plugin-alignment
Version:
Alignment plugin for @atlaskit/editor-core
33 lines • 1.01 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({
label,
isSelected,
content,
shortcut,
onClick,
value
}) {
const onClickCallback = e => {
// detect if the click event comes from keyboard where screenX and screenY are 0
const 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;