@atlaskit/editor-plugin-text-color
Version:
Text color plugin for @atlaskit/editor-core
55 lines (54 loc) • 2.16 kB
JavaScript
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';
const 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 const PrimaryToolbarComponent = ({
api,
isReducedSpacing,
editorView,
popupsMountPoint,
popupsScrollableElement,
popupsBoundariesElement,
dispatchAnalyticsEvent,
disabled
}) => {
const {
color,
defaultColor,
palette,
disabled: textColorDisabled
} = useSharedPluginStateWithSelector(api, ['textColor'], selector);
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,
defaultColor,
palette,
disabled: textColorDisabled
},
isReducedSpacing: isReducedSpacing,
editorView: editorView,
popupsMountPoint: popupsMountPoint,
popupsBoundariesElement: popupsBoundariesElement,
popupsScrollableElement: popupsScrollableElement,
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
disabled: disabled,
pluginInjectionApi: api,
toolbarType: ToolbarType.PRIMARY
});
};