UNPKG

@atlaskit/editor-plugin-selection-toolbar

Version:

@atlaskit/editor-plugin-selection-toolbar for @atlaskit/editor-core

30 lines 1.3 kB
import React from 'react'; import { useIntl } from 'react-intl'; import { selectionToolbarMessages } from '@atlaskit/editor-common/messages'; import { useEditorToolbar } from '@atlaskit/editor-common/toolbar'; import { PinnedIcon, ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar'; export var PinButton = function PinButton(_ref) { var api = _ref.api; var intl = useIntl(); var message = intl.formatMessage(selectionToolbarMessages.toolbarPositionPinedAtTop); var _useEditorToolbar = useEditorToolbar(), isDisabled = _useEditorToolbar.isOffline; var onClick = function onClick() { var _api$userPreferences; if (!api || isDisabled) { return; } api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.actions.updateUserPreference('toolbarDockingPosition', 'none')); }; return /*#__PURE__*/React.createElement(ToolbarTooltip, { content: message }, /*#__PURE__*/React.createElement(ToolbarButton, { iconBefore: /*#__PURE__*/React.createElement(PinnedIcon, { size: "small", label: "" }), label: message, onClick: onClick, isDisabled: isDisabled })); };