UNPKG

@atlaskit/editor-plugin-text-color

Version:

Text color plugin for @atlaskit/editor-core

53 lines (52 loc) 2.57 kB
import React from 'react'; import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'; import { ToolbarType } from '../types'; // Ignored via go/ees005 // eslint-disable-next-line import/no-named-as-default import ToolbarTextColor from './ToolbarTextColor'; var selector = function selector(states) { var _states$textColorStat, _states$textColorStat2, _states$textColorStat3, _states$textColorStat4; return { color: (_states$textColorStat = states.textColorState) === null || _states$textColorStat === void 0 ? void 0 : _states$textColorStat.color, defaultColor: (_states$textColorStat2 = states.textColorState) === null || _states$textColorStat2 === void 0 ? void 0 : _states$textColorStat2.defaultColor, palette: (_states$textColorStat3 = states.textColorState) === null || _states$textColorStat3 === void 0 ? void 0 : _states$textColorStat3.palette, disabled: (_states$textColorStat4 = states.textColorState) === null || _states$textColorStat4 === void 0 ? void 0 : _states$textColorStat4.disabled }; }; export var PrimaryToolbarComponent = function PrimaryToolbarComponent(_ref) { var api = _ref.api, isReducedSpacing = _ref.isReducedSpacing, editorView = _ref.editorView, popupsMountPoint = _ref.popupsMountPoint, popupsScrollableElement = _ref.popupsScrollableElement, popupsBoundariesElement = _ref.popupsBoundariesElement, dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent, disabled = _ref.disabled; var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['textColor'], selector), color = _useSharedPluginState.color, defaultColor = _useSharedPluginState.defaultColor, palette = _useSharedPluginState.palette, textColorDisabled = _useSharedPluginState.disabled; if (color === undefined || defaultColor === undefined || palette === undefined) { return null; } return /*#__PURE__*/React.createElement(ToolbarTextColor // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed) , { pluginState: { color: color, defaultColor: defaultColor, palette: palette, disabled: textColorDisabled }, isReducedSpacing: isReducedSpacing, editorView: editorView, popupsMountPoint: popupsMountPoint, popupsBoundariesElement: popupsBoundariesElement, popupsScrollableElement: popupsScrollableElement, dispatchAnalyticsEvent: dispatchAnalyticsEvent, disabled: disabled, pluginInjectionApi: api, toolbarType: ToolbarType.PRIMARY }); };