@atlaskit/editor-plugin-text-color 12.1.2 → 12.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-text-color
2
2
 
3
+ ## 12.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`eb17ff47fd9d1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/eb17ff47fd9d1) -
8
+ [EDITOR-7588] Add an accessibility footer for the new text and highlight color experience behind
9
+ `platform_editor_lovability_text_bg_color`.
10
+
11
+ ### Patch Changes
12
+
13
+ - [`724e2a1ea50bb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/724e2a1ea50bb) -
14
+ Remove stale feature gate platform_editor_toolbar_aifc_text_color_config_jsm.
15
+ - Updated dependencies
16
+
17
+ ## 12.1.3
18
+
19
+ ### Patch Changes
20
+
21
+ - [`6f7b6c498b07c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6f7b6c498b07c) -
22
+ [EDITOR-7591] Align the no-color highlight palette tile icon with the updated transparent
23
+ highlight styling for the experiment `platform_editor_lovability_text_bg_color`.
24
+ - Updated dependencies
25
+
3
26
  ## 12.1.2
4
27
 
5
28
  ### Patch Changes
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getContrastRatio = getContrastRatio;
7
+ var _adfSchema = require("@atlaskit/adf-schema");
8
+ // from platform/packages/design-system/tokens/src/utils/get-contrast-ratio.tsx
9
+
10
+ function hexToRgb(hex) {
11
+ if (!(0, _adfSchema.isHex)(hex)) {
12
+ throw new Error('Invalid HEX');
13
+ }
14
+ var colorParts = hex.substring(1).split('');
15
+ var color = colorParts.length === 3 || colorParts.length === 4 ? "".concat(colorParts[0]).concat(colorParts[0]).concat(colorParts[1]).concat(colorParts[1]).concat(colorParts[2]).concat(colorParts[2]) : colorParts.slice(0, 6).join('');
16
+ var colorValue = Number("0x".concat(color));
17
+ return [colorValue >> 16 & 255, colorValue >> 8 & 255, colorValue & 255];
18
+ }
19
+ function relativeLuminanceW3C(r, g, b) {
20
+ var RsRGB = r / 255;
21
+ var GsRGB = g / 255;
22
+ var BsRGB = b / 255;
23
+ var R = RsRGB <= 0.03928 ? RsRGB / 12.92 : Math.pow((RsRGB + 0.055) / 1.055, 2.4);
24
+ var G = GsRGB <= 0.03928 ? GsRGB / 12.92 : Math.pow((GsRGB + 0.055) / 1.055, 2.4);
25
+ var B = BsRGB <= 0.03928 ? BsRGB / 12.92 : Math.pow((BsRGB + 0.055) / 1.055, 2.4);
26
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
27
+ }
28
+ function getContrastRatio(foreground, background) {
29
+ if (!(0, _adfSchema.isHex)(foreground) || !(0, _adfSchema.isHex)(background)) {
30
+ throw new Error('Invalid HEX');
31
+ }
32
+ var foregroundRgb = hexToRgb(foreground);
33
+ var backgroundRgb = hexToRgb(background);
34
+ var foregroundLuminance = relativeLuminanceW3C(foregroundRgb[0], foregroundRgb[1], foregroundRgb[2]);
35
+ var backgroundLuminance = relativeLuminanceW3C(backgroundRgb[0], backgroundRgb[1], backgroundRgb[2]);
36
+ // calculate the color contrast ratio
37
+ var brightest = Math.max(foregroundLuminance, backgroundLuminance);
38
+ var darkest = Math.min(foregroundLuminance, backgroundLuminance);
39
+ return (brightest + 0.05) / (darkest + 0.05);
40
+ }
@@ -3,8 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.overrideMarks = exports.DEFAULT_COLOR = void 0;
6
+ exports.overrideMarks = exports.TRANSPARENT_HIGHLIGHT_COLOR = exports.DIFFICULT_CONTRAST_RATIO = exports.DEFAULT_COLOR = exports.DEFAULT_BACKGROUND_COLOR = exports.ACCESSIBLE_CONTRAST_RATIO = void 0;
7
7
  var overrideMarks = exports.overrideMarks = ['backgroundColor'];
8
+ var ACCESSIBLE_CONTRAST_RATIO = exports.ACCESSIBLE_CONTRAST_RATIO = 4.5;
9
+ var DIFFICULT_CONTRAST_RATIO = exports.DIFFICULT_CONTRAST_RATIO = 3;
10
+ var DEFAULT_BACKGROUND_COLOR = exports.DEFAULT_BACKGROUND_COLOR = '#FFFFFF';
11
+ var TRANSPARENT_HIGHLIGHT_COLOR = exports.TRANSPARENT_HIGHLIGHT_COLOR = '#00000000';
8
12
  var DEFAULT_COLOR = exports.DEFAULT_COLOR = {
9
13
  // TODO: DSP-4137 - Remove usage of hardcoded color
10
14
  /* eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage */
@@ -53,7 +53,7 @@ var textColorPlugin = exports.textColorPlugin = function textColorPlugin(_ref) {
53
53
  });
54
54
  };
55
55
  if (isToolbarAIFCEnabled) {
56
- if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_aifc_text_color_config') || (0, _platformFeatureFlags.fg)('platform_editor_toolbar_aifc_text_color_config_jsm')) {
56
+ if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_aifc_text_color_config')) {
57
57
  var _api$toolbar;
58
58
  if (api !== null && api !== void 0 && (_api$toolbar = api.toolbar) !== null && _api$toolbar !== void 0 && _api$toolbar.actions.registerComponents && isToolbarComponentEnabled(pluginConfig(textColorConfig))) {
59
59
  api.toolbar.actions.registerComponents((0, _toolbarComponents.getToolbarComponents)(api));
@@ -0,0 +1,9 @@
1
+
2
+ ._19itglyw{border:none}._19bvu2gc{padding-left:var(--ds-space-100,8px)}
3
+ ._19pku2gc{margin-top:var(--ds-space-100,8px)}
4
+ ._1bah1yb4{justify-content:space-between}
5
+ ._1e0c1txw{display:flex}
6
+ ._4cvr1h6o{align-items:center}
7
+ ._ca0q1b66{padding-top:var(--ds-space-050,4px)}
8
+ ._n3td1b66{padding-bottom:var(--ds-space-050,4px)}
9
+ ._u5f31b66{padding-right:var(--ds-space-050,4px)}
@@ -0,0 +1,146 @@
1
+ /* ColorAccessibilityMenuItem.tsx generated by @compiled/babel-plugin v0.39.1 */
2
+ "use strict";
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ColorAccessibilityMenuItem = void 0;
9
+ require("./ColorAccessibilityMenuItem.compiled.css");
10
+ var _runtime = require("@compiled/react/runtime");
11
+ var _react = _interopRequireDefault(require("react"));
12
+ var _reactIntl = require("react-intl");
13
+ var _new = require("@atlaskit/button/new");
14
+ var _hooks = require("@atlaskit/editor-common/hooks");
15
+ var _messages = require("@atlaskit/editor-common/messages");
16
+ var _uiColor = require("@atlaskit/editor-common/ui-color");
17
+ var _editorPalette = require("@atlaskit/editor-palette");
18
+ var _accessibility = _interopRequireDefault(require("@atlaskit/icon/core/accessibility"));
19
+ var _questionCircle = _interopRequireDefault(require("@atlaskit/icon/core/question-circle"));
20
+ var _compiled = require("@atlaskit/primitives/compiled");
21
+ var _tokens = require("@atlaskit/tokens");
22
+ var _colorContrast = require("../pm-plugins/utils/color-contrast");
23
+ var _constants = require("../pm-plugins/utils/constants");
24
+ var resolveColorValue = function resolveColorValue(color, fallback) {
25
+ return (0, _uiColor.getTokenCSSVariableValue)(color) || (color.startsWith('var(') ? fallback : color);
26
+ };
27
+ var getForegroundColor = function getForegroundColor(textColor, defaultColor) {
28
+ if (!textColor || defaultColor && textColor === defaultColor) {
29
+ return (0, _tokens.getTokenValue)('color.text', defaultColor || _constants.DEFAULT_COLOR.color);
30
+ }
31
+ var colorValue = (0, _editorPalette.hexToEditorTextPaletteColor)(textColor) || textColor;
32
+ return resolveColorValue(colorValue, textColor);
33
+ };
34
+ var getBackgroundColor = function getBackgroundColor(highlightColor) {
35
+ if (!highlightColor || highlightColor === _constants.TRANSPARENT_HIGHLIGHT_COLOR) {
36
+ return (0, _tokens.getTokenValue)('elevation.surface', _constants.DEFAULT_BACKGROUND_COLOR);
37
+ }
38
+ var colorValue = (0, _editorPalette.hexToEditorTextBackgroundPaletteColor)(highlightColor) || highlightColor;
39
+ return resolveColorValue(colorValue, highlightColor);
40
+ };
41
+ var useColorAccessibilityState = function useColorAccessibilityState(api) {
42
+ return (0, _hooks.useSharedPluginStateWithSelector)(api, ['textColor', 'highlight'], function (states) {
43
+ var _states$textColorStat, _states$highlightStat, _states$textColorStat2;
44
+ return {
45
+ defaultColor: (_states$textColorStat = states.textColorState) === null || _states$textColorStat === void 0 ? void 0 : _states$textColorStat.defaultColor,
46
+ highlightColor: (_states$highlightStat = states.highlightState) === null || _states$highlightStat === void 0 ? void 0 : _states$highlightStat.activeColor,
47
+ textColor: (_states$textColorStat2 = states.textColorState) === null || _states$textColorStat2 === void 0 ? void 0 : _states$textColorStat2.color
48
+ };
49
+ });
50
+ };
51
+ var getContrastRatio = function getContrastRatio(defaultColor, highlightColor, textColor) {
52
+ try {
53
+ var contrastRatio = (0, _colorContrast.getContrastRatio)(getForegroundColor(textColor, defaultColor), getBackgroundColor(highlightColor));
54
+ return contrastRatio;
55
+ }
56
+ // if we failed to calculate the contrast ratio, return null
57
+ catch (_unused) {
58
+ return null;
59
+ }
60
+ };
61
+ var getAccessibilityStatus = function getAccessibilityStatus(contrastRatio) {
62
+ if (contrastRatio >= _constants.ACCESSIBLE_CONTRAST_RATIO) {
63
+ return 'accessible';
64
+ } else if (contrastRatio >= _constants.DIFFICULT_CONTRAST_RATIO) {
65
+ return 'difficultToRead';
66
+ } else {
67
+ return 'inaccessible';
68
+ }
69
+ };
70
+ var AccessibilityStatus = function AccessibilityStatus(_ref) {
71
+ var accessibilityStatus = _ref.accessibilityStatus,
72
+ formatMessage = _ref.formatMessage;
73
+ if (accessibilityStatus === 'accessible') {
74
+ return /*#__PURE__*/_react.default.createElement(_compiled.Text, {
75
+ as: "span",
76
+ size: "small",
77
+ color: "color.text.success"
78
+ }, formatMessage(_messages.colorAccessibilityMessages.accessibleLabel));
79
+ } else if (accessibilityStatus === 'difficultToRead') {
80
+ return /*#__PURE__*/_react.default.createElement(_compiled.Text, {
81
+ as: "span",
82
+ size: "small",
83
+ color: "color.text.warning"
84
+ }, formatMessage(_messages.colorAccessibilityMessages.difficultToReadLabel));
85
+ } else {
86
+ return /*#__PURE__*/_react.default.createElement(_compiled.Text, {
87
+ as: "span",
88
+ size: "small",
89
+ color: "color.text.danger"
90
+ }, formatMessage(_messages.colorAccessibilityMessages.inaccessibleLabel));
91
+ }
92
+ };
93
+ var styles = {
94
+ container: "_19itglyw _19pku2gc _ca0q1b66 _n3td1b66 _19bvu2gc _u5f31b66 _1e0c1txw _4cvr1h6o _1bah1yb4"
95
+ };
96
+ var ColorAccessibilityMenuItem = exports.ColorAccessibilityMenuItem = function ColorAccessibilityMenuItem(_ref2) {
97
+ var api = _ref2.api;
98
+ var _useIntl = (0, _reactIntl.useIntl)(),
99
+ formatMessage = _useIntl.formatMessage;
100
+ var _useColorAccessibilit = useColorAccessibilityState(api),
101
+ defaultColor = _useColorAccessibilit.defaultColor,
102
+ highlightColor = _useColorAccessibilit.highlightColor,
103
+ textColor = _useColorAccessibilit.textColor;
104
+ var contrastRatio = getContrastRatio(defaultColor, highlightColor, textColor);
105
+ if (contrastRatio === null) {
106
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
107
+ }
108
+ var accessibilityStatus = getAccessibilityStatus(contrastRatio);
109
+ var tooltipContent = function tooltipContent(accessibilityStatus) {
110
+ if (accessibilityStatus === 'accessible') {
111
+ return formatMessage(_messages.colorAccessibilityMessages.accessibleTooltip);
112
+ } else if (accessibilityStatus === 'difficultToRead') {
113
+ return formatMessage(_messages.colorAccessibilityMessages.difficultToReadTooltip);
114
+ } else {
115
+ return formatMessage(_messages.colorAccessibilityMessages.inaccessibleTooltip);
116
+ }
117
+ };
118
+ return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
119
+ xcss: styles.container
120
+ }, /*#__PURE__*/_react.default.createElement(_compiled.Inline, {
121
+ alignBlock: "center",
122
+ space: "space.050"
123
+ }, /*#__PURE__*/_react.default.createElement(_accessibility.default, {
124
+ label: "",
125
+ size: "medium"
126
+ }), /*#__PURE__*/_react.default.createElement(_compiled.Text, {
127
+ as: "span",
128
+ size: "small",
129
+ color: "color.text.subtle"
130
+ }, formatMessage(_messages.colorAccessibilityMessages.accessibility)), /*#__PURE__*/_react.default.createElement(_compiled.Text, {
131
+ as: "span",
132
+ size: "small",
133
+ color: "color.text.subtle",
134
+ "aria-hidden": "true"
135
+ }, "\u2022"), /*#__PURE__*/_react.default.createElement(AccessibilityStatus, {
136
+ accessibilityStatus: accessibilityStatus,
137
+ formatMessage: formatMessage
138
+ })), /*#__PURE__*/_react.default.createElement(_new.IconButton, {
139
+ icon: _questionCircle.default,
140
+ shape: "circle",
141
+ label: tooltipContent(accessibilityStatus),
142
+ isTooltipDisabled: false,
143
+ spacing: "compact",
144
+ appearance: "subtle"
145
+ }));
146
+ };
@@ -25,6 +25,7 @@ var _editorPalette = require("@atlaskit/editor-palette");
25
25
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
26
26
  var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/core/chevron-down"));
27
27
  var _textStyle = _interopRequireDefault(require("@atlaskit/icon/core/text-style"));
28
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
28
29
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
29
30
  var _changeColor = require("../../pm-plugins/commands/change-color");
30
31
  var _inputType = require("../../pm-plugins/utils/inputType");
@@ -143,7 +144,7 @@ var ToolbarTextColor = exports.ToolbarTextColor = /*#__PURE__*/function (_React$
143
144
  disabled = _this$props.disabled,
144
145
  pluginInjectionApi = _this$props.pluginInjectionApi;
145
146
  var palette = pluginState.palette;
146
- var isNewColorPaletteEnabled = (0, _experiments.editorExperiment)('platform_editor_lovability_text_bg_color', true);
147
+ var isNewColorPaletteEnabled = (0, _expValEquals.expValEquals)('platform_editor_lovability_text_bg_color', 'isEnabled', true);
147
148
  var colorPickerColumns = isNewColorPaletteEnabled ? 10 : undefined;
148
149
  var fitWidth;
149
150
  if (document.body.clientWidth <= 740) {
@@ -6,8 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getToolbarComponents = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
10
  var _react = _interopRequireDefault(require("react"));
10
11
  var _toolbar = require("@atlaskit/editor-common/toolbar");
12
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
+ var _ColorAccessibilityMenuItem = require("./ColorAccessibilityMenuItem");
11
14
  var _RemoveColorMenuItem = require("./RemoveColorMenuItem");
12
15
  var _TextColorHighlightMenu = require("./TextColorHighlightMenu");
13
16
  var _TextColorMenuItem = require("./TextColorMenuItem");
@@ -64,5 +67,14 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
64
67
  parents: parents
65
68
  });
66
69
  }
67
- })];
70
+ })].concat((0, _toConsumableArray2.default)((0, _expValEquals.expValEquals)('platform_editor_lovability_text_bg_color', 'isEnabled', true) ? [_objectSpread(_objectSpread({}, _toolbar.COLOR_ACCESSIBILITY_MENU_ITEM), {}, {
71
+ parents: [_objectSpread(_objectSpread({}, _toolbar.TEXT_COLOR_HIGHLIGHT_MENU_SECTION), {}, {
72
+ rank: _toolbar.TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK[_toolbar.COLOR_ACCESSIBILITY_MENU_ITEM.key]
73
+ })],
74
+ component: function component() {
75
+ return /*#__PURE__*/_react.default.createElement(_ColorAccessibilityMenuItem.ColorAccessibilityMenuItem, {
76
+ api: api
77
+ });
78
+ }
79
+ })] : []));
68
80
  };
@@ -0,0 +1,34 @@
1
+ // from platform/packages/design-system/tokens/src/utils/get-contrast-ratio.tsx
2
+
3
+ import { isHex } from '@atlaskit/adf-schema';
4
+ function hexToRgb(hex) {
5
+ if (!isHex(hex)) {
6
+ throw new Error('Invalid HEX');
7
+ }
8
+ const colorParts = hex.substring(1).split('');
9
+ const color = colorParts.length === 3 || colorParts.length === 4 ? `${colorParts[0]}${colorParts[0]}${colorParts[1]}${colorParts[1]}${colorParts[2]}${colorParts[2]}` : colorParts.slice(0, 6).join('');
10
+ const colorValue = Number(`0x${color}`);
11
+ return [colorValue >> 16 & 255, colorValue >> 8 & 255, colorValue & 255];
12
+ }
13
+ function relativeLuminanceW3C(r, g, b) {
14
+ const RsRGB = r / 255;
15
+ const GsRGB = g / 255;
16
+ const BsRGB = b / 255;
17
+ const R = RsRGB <= 0.03928 ? RsRGB / 12.92 : Math.pow((RsRGB + 0.055) / 1.055, 2.4);
18
+ const G = GsRGB <= 0.03928 ? GsRGB / 12.92 : Math.pow((GsRGB + 0.055) / 1.055, 2.4);
19
+ const B = BsRGB <= 0.03928 ? BsRGB / 12.92 : Math.pow((BsRGB + 0.055) / 1.055, 2.4);
20
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
21
+ }
22
+ export function getContrastRatio(foreground, background) {
23
+ if (!isHex(foreground) || !isHex(background)) {
24
+ throw new Error('Invalid HEX');
25
+ }
26
+ const foregroundRgb = hexToRgb(foreground);
27
+ const backgroundRgb = hexToRgb(background);
28
+ const foregroundLuminance = relativeLuminanceW3C(foregroundRgb[0], foregroundRgb[1], foregroundRgb[2]);
29
+ const backgroundLuminance = relativeLuminanceW3C(backgroundRgb[0], backgroundRgb[1], backgroundRgb[2]);
30
+ // calculate the color contrast ratio
31
+ const brightest = Math.max(foregroundLuminance, backgroundLuminance);
32
+ const darkest = Math.min(foregroundLuminance, backgroundLuminance);
33
+ return (brightest + 0.05) / (darkest + 0.05);
34
+ }
@@ -1,4 +1,8 @@
1
1
  export const overrideMarks = ['backgroundColor'];
2
+ export const ACCESSIBLE_CONTRAST_RATIO = 4.5;
3
+ export const DIFFICULT_CONTRAST_RATIO = 3;
4
+ export const DEFAULT_BACKGROUND_COLOR = '#FFFFFF';
5
+ export const TRANSPARENT_HIGHLIGHT_COLOR = '#00000000';
2
6
  export const DEFAULT_COLOR = {
3
7
  // TODO: DSP-4137 - Remove usage of hardcoded color
4
8
  /* eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage */
@@ -48,7 +48,7 @@ export const textColorPlugin = ({
48
48
  });
49
49
  };
50
50
  if (isToolbarAIFCEnabled) {
51
- if (fg('platform_editor_toolbar_aifc_text_color_config') || fg('platform_editor_toolbar_aifc_text_color_config_jsm')) {
51
+ if (fg('platform_editor_toolbar_aifc_text_color_config')) {
52
52
  var _api$toolbar;
53
53
  if (api !== null && api !== void 0 && (_api$toolbar = api.toolbar) !== null && _api$toolbar !== void 0 && _api$toolbar.actions.registerComponents && isToolbarComponentEnabled(pluginConfig(textColorConfig))) {
54
54
  api.toolbar.actions.registerComponents(getToolbarComponents(api));
@@ -0,0 +1,9 @@
1
+
2
+ ._19itglyw{border:none}._19bvu2gc{padding-left:var(--ds-space-100,8px)}
3
+ ._19pku2gc{margin-top:var(--ds-space-100,8px)}
4
+ ._1bah1yb4{justify-content:space-between}
5
+ ._1e0c1txw{display:flex}
6
+ ._4cvr1h6o{align-items:center}
7
+ ._ca0q1b66{padding-top:var(--ds-space-050,4px)}
8
+ ._n3td1b66{padding-bottom:var(--ds-space-050,4px)}
9
+ ._u5f31b66{padding-right:var(--ds-space-050,4px)}
@@ -0,0 +1,143 @@
1
+ /* ColorAccessibilityMenuItem.tsx generated by @compiled/babel-plugin v0.39.1 */
2
+ import "./ColorAccessibilityMenuItem.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React from 'react';
5
+ import { useIntl } from 'react-intl';
6
+ import { IconButton } from '@atlaskit/button/new';
7
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
8
+ import { colorAccessibilityMessages as messages } from '@atlaskit/editor-common/messages';
9
+ import { getTokenCSSVariableValue } from '@atlaskit/editor-common/ui-color';
10
+ import { hexToEditorTextBackgroundPaletteColor, hexToEditorTextPaletteColor } from '@atlaskit/editor-palette';
11
+ import AccessibilityIcon from '@atlaskit/icon/core/accessibility';
12
+ import QuestionCircleIcon from '@atlaskit/icon/core/question-circle';
13
+ import { Box, Inline, Text } from '@atlaskit/primitives/compiled';
14
+ import { getTokenValue } from '@atlaskit/tokens';
15
+ import { getContrastRatio as calcContrastRatio } from '../pm-plugins/utils/color-contrast';
16
+ import { DEFAULT_COLOR, DEFAULT_BACKGROUND_COLOR, TRANSPARENT_HIGHLIGHT_COLOR, ACCESSIBLE_CONTRAST_RATIO, DIFFICULT_CONTRAST_RATIO } from '../pm-plugins/utils/constants';
17
+ const resolveColorValue = (color, fallback) => {
18
+ return getTokenCSSVariableValue(color) || (color.startsWith('var(') ? fallback : color);
19
+ };
20
+ const getForegroundColor = (textColor, defaultColor) => {
21
+ if (!textColor || defaultColor && textColor === defaultColor) {
22
+ return getTokenValue('color.text', defaultColor || DEFAULT_COLOR.color);
23
+ }
24
+ const colorValue = hexToEditorTextPaletteColor(textColor) || textColor;
25
+ return resolveColorValue(colorValue, textColor);
26
+ };
27
+ const getBackgroundColor = highlightColor => {
28
+ if (!highlightColor || highlightColor === TRANSPARENT_HIGHLIGHT_COLOR) {
29
+ return getTokenValue('elevation.surface', DEFAULT_BACKGROUND_COLOR);
30
+ }
31
+ const colorValue = hexToEditorTextBackgroundPaletteColor(highlightColor) || highlightColor;
32
+ return resolveColorValue(colorValue, highlightColor);
33
+ };
34
+ const useColorAccessibilityState = api => {
35
+ return useSharedPluginStateWithSelector(api, ['textColor', 'highlight'], states => {
36
+ var _states$textColorStat, _states$highlightStat, _states$textColorStat2;
37
+ return {
38
+ defaultColor: (_states$textColorStat = states.textColorState) === null || _states$textColorStat === void 0 ? void 0 : _states$textColorStat.defaultColor,
39
+ highlightColor: (_states$highlightStat = states.highlightState) === null || _states$highlightStat === void 0 ? void 0 : _states$highlightStat.activeColor,
40
+ textColor: (_states$textColorStat2 = states.textColorState) === null || _states$textColorStat2 === void 0 ? void 0 : _states$textColorStat2.color
41
+ };
42
+ });
43
+ };
44
+ const getContrastRatio = (defaultColor, highlightColor, textColor) => {
45
+ try {
46
+ const contrastRatio = calcContrastRatio(getForegroundColor(textColor, defaultColor), getBackgroundColor(highlightColor));
47
+ return contrastRatio;
48
+ }
49
+ // if we failed to calculate the contrast ratio, return null
50
+ catch {
51
+ return null;
52
+ }
53
+ };
54
+ const getAccessibilityStatus = contrastRatio => {
55
+ if (contrastRatio >= ACCESSIBLE_CONTRAST_RATIO) {
56
+ return 'accessible';
57
+ } else if (contrastRatio >= DIFFICULT_CONTRAST_RATIO) {
58
+ return 'difficultToRead';
59
+ } else {
60
+ return 'inaccessible';
61
+ }
62
+ };
63
+ const AccessibilityStatus = ({
64
+ accessibilityStatus,
65
+ formatMessage
66
+ }) => {
67
+ if (accessibilityStatus === 'accessible') {
68
+ return /*#__PURE__*/React.createElement(Text, {
69
+ as: "span",
70
+ size: "small",
71
+ color: "color.text.success"
72
+ }, formatMessage(messages.accessibleLabel));
73
+ } else if (accessibilityStatus === 'difficultToRead') {
74
+ return /*#__PURE__*/React.createElement(Text, {
75
+ as: "span",
76
+ size: "small",
77
+ color: "color.text.warning"
78
+ }, formatMessage(messages.difficultToReadLabel));
79
+ } else {
80
+ return /*#__PURE__*/React.createElement(Text, {
81
+ as: "span",
82
+ size: "small",
83
+ color: "color.text.danger"
84
+ }, formatMessage(messages.inaccessibleLabel));
85
+ }
86
+ };
87
+ const styles = {
88
+ container: "_19itglyw _19pku2gc _ca0q1b66 _n3td1b66 _19bvu2gc _u5f31b66 _1e0c1txw _4cvr1h6o _1bah1yb4"
89
+ };
90
+ export const ColorAccessibilityMenuItem = ({
91
+ api
92
+ }) => {
93
+ const {
94
+ formatMessage
95
+ } = useIntl();
96
+ const {
97
+ defaultColor,
98
+ highlightColor,
99
+ textColor
100
+ } = useColorAccessibilityState(api);
101
+ const contrastRatio = getContrastRatio(defaultColor, highlightColor, textColor);
102
+ if (contrastRatio === null) {
103
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
104
+ }
105
+ const accessibilityStatus = getAccessibilityStatus(contrastRatio);
106
+ const tooltipContent = accessibilityStatus => {
107
+ if (accessibilityStatus === 'accessible') {
108
+ return formatMessage(messages.accessibleTooltip);
109
+ } else if (accessibilityStatus === 'difficultToRead') {
110
+ return formatMessage(messages.difficultToReadTooltip);
111
+ } else {
112
+ return formatMessage(messages.inaccessibleTooltip);
113
+ }
114
+ };
115
+ return /*#__PURE__*/React.createElement(Box, {
116
+ xcss: styles.container
117
+ }, /*#__PURE__*/React.createElement(Inline, {
118
+ alignBlock: "center",
119
+ space: "space.050"
120
+ }, /*#__PURE__*/React.createElement(AccessibilityIcon, {
121
+ label: "",
122
+ size: "medium"
123
+ }), /*#__PURE__*/React.createElement(Text, {
124
+ as: "span",
125
+ size: "small",
126
+ color: "color.text.subtle"
127
+ }, formatMessage(messages.accessibility)), /*#__PURE__*/React.createElement(Text, {
128
+ as: "span",
129
+ size: "small",
130
+ color: "color.text.subtle",
131
+ "aria-hidden": "true"
132
+ }, "\u2022"), /*#__PURE__*/React.createElement(AccessibilityStatus, {
133
+ accessibilityStatus: accessibilityStatus,
134
+ formatMessage: formatMessage
135
+ })), /*#__PURE__*/React.createElement(IconButton, {
136
+ icon: QuestionCircleIcon,
137
+ shape: "circle",
138
+ label: tooltipContent(accessibilityStatus),
139
+ isTooltipDisabled: false,
140
+ spacing: "compact",
141
+ appearance: "subtle"
142
+ }));
143
+ };
@@ -18,6 +18,7 @@ import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette';
18
18
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
19
19
  import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
20
20
  import TextStyleIcon from '@atlaskit/icon/core/text-style';
21
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
21
22
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
23
  import { changeColor as changeColorWithAnalytics } from '../../pm-plugins/commands/change-color';
23
24
  import { getInputMethod } from '../../pm-plugins/utils/inputType';
@@ -124,7 +125,7 @@ export class ToolbarTextColor extends React.Component {
124
125
  pluginInjectionApi
125
126
  } = this.props;
126
127
  const palette = pluginState.palette;
127
- const isNewColorPaletteEnabled = editorExperiment('platform_editor_lovability_text_bg_color', true);
128
+ const isNewColorPaletteEnabled = expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true);
128
129
  const colorPickerColumns = isNewColorPaletteEnabled ? 10 : undefined;
129
130
  let fitWidth;
130
131
  if (document.body.clientWidth <= 740) {
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
- import { TEXT_SECTION, TEXT_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP, TEXT_COLOR_HIGHLIGHT_MENU, TEXT_COLOR_HIGHLIGHT_MENU_SECTION, TEXT_COLOR_MENU_ITEM, TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP_RANK, TEXT_COLOR_HIGHLIGHT_MENU_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU, CLEAR_COLOR_MENU_ITEM, TEXT_SECTION_PRIMARY_TOOLBAR_RANK, TEXT_SECTION_PRIMARY_TOOLBAR } from '@atlaskit/editor-common/toolbar';
2
+ import { TEXT_SECTION, TEXT_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP, TEXT_COLOR_HIGHLIGHT_MENU, TEXT_COLOR_HIGHLIGHT_MENU_SECTION, TEXT_COLOR_MENU_ITEM, TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP_RANK, TEXT_COLOR_HIGHLIGHT_MENU_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU, CLEAR_COLOR_MENU_ITEM, COLOR_ACCESSIBILITY_MENU_ITEM, TEXT_SECTION_PRIMARY_TOOLBAR_RANK, TEXT_SECTION_PRIMARY_TOOLBAR } from '@atlaskit/editor-common/toolbar';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
+ import { ColorAccessibilityMenuItem } from './ColorAccessibilityMenuItem';
3
5
  import { RemoveColorMenuItem } from './RemoveColorMenuItem';
4
6
  import { TextColorHighlightMenu } from './TextColorHighlightMenu';
5
7
  import { TextColorMenuItem } from './TextColorMenuItem';
@@ -63,5 +65,16 @@ export const getToolbarComponents = api => {
63
65
  parents: parents
64
66
  });
65
67
  }
66
- }];
68
+ }, ...(expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true) ? [{
69
+ ...COLOR_ACCESSIBILITY_MENU_ITEM,
70
+ parents: [{
71
+ ...TEXT_COLOR_HIGHLIGHT_MENU_SECTION,
72
+ rank: TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK[COLOR_ACCESSIBILITY_MENU_ITEM.key]
73
+ }],
74
+ component: () => {
75
+ return /*#__PURE__*/React.createElement(ColorAccessibilityMenuItem, {
76
+ api: api
77
+ });
78
+ }
79
+ }] : [])];
67
80
  };
@@ -0,0 +1,34 @@
1
+ // from platform/packages/design-system/tokens/src/utils/get-contrast-ratio.tsx
2
+
3
+ import { isHex } from '@atlaskit/adf-schema';
4
+ function hexToRgb(hex) {
5
+ if (!isHex(hex)) {
6
+ throw new Error('Invalid HEX');
7
+ }
8
+ var colorParts = hex.substring(1).split('');
9
+ var color = colorParts.length === 3 || colorParts.length === 4 ? "".concat(colorParts[0]).concat(colorParts[0]).concat(colorParts[1]).concat(colorParts[1]).concat(colorParts[2]).concat(colorParts[2]) : colorParts.slice(0, 6).join('');
10
+ var colorValue = Number("0x".concat(color));
11
+ return [colorValue >> 16 & 255, colorValue >> 8 & 255, colorValue & 255];
12
+ }
13
+ function relativeLuminanceW3C(r, g, b) {
14
+ var RsRGB = r / 255;
15
+ var GsRGB = g / 255;
16
+ var BsRGB = b / 255;
17
+ var R = RsRGB <= 0.03928 ? RsRGB / 12.92 : Math.pow((RsRGB + 0.055) / 1.055, 2.4);
18
+ var G = GsRGB <= 0.03928 ? GsRGB / 12.92 : Math.pow((GsRGB + 0.055) / 1.055, 2.4);
19
+ var B = BsRGB <= 0.03928 ? BsRGB / 12.92 : Math.pow((BsRGB + 0.055) / 1.055, 2.4);
20
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
21
+ }
22
+ export function getContrastRatio(foreground, background) {
23
+ if (!isHex(foreground) || !isHex(background)) {
24
+ throw new Error('Invalid HEX');
25
+ }
26
+ var foregroundRgb = hexToRgb(foreground);
27
+ var backgroundRgb = hexToRgb(background);
28
+ var foregroundLuminance = relativeLuminanceW3C(foregroundRgb[0], foregroundRgb[1], foregroundRgb[2]);
29
+ var backgroundLuminance = relativeLuminanceW3C(backgroundRgb[0], backgroundRgb[1], backgroundRgb[2]);
30
+ // calculate the color contrast ratio
31
+ var brightest = Math.max(foregroundLuminance, backgroundLuminance);
32
+ var darkest = Math.min(foregroundLuminance, backgroundLuminance);
33
+ return (brightest + 0.05) / (darkest + 0.05);
34
+ }
@@ -1,4 +1,8 @@
1
1
  export var overrideMarks = ['backgroundColor'];
2
+ export var ACCESSIBLE_CONTRAST_RATIO = 4.5;
3
+ export var DIFFICULT_CONTRAST_RATIO = 3;
4
+ export var DEFAULT_BACKGROUND_COLOR = '#FFFFFF';
5
+ export var TRANSPARENT_HIGHLIGHT_COLOR = '#00000000';
2
6
  export var DEFAULT_COLOR = {
3
7
  // TODO: DSP-4137 - Remove usage of hardcoded color
4
8
  /* eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage */
@@ -46,7 +46,7 @@ export var textColorPlugin = function textColorPlugin(_ref) {
46
46
  });
47
47
  };
48
48
  if (isToolbarAIFCEnabled) {
49
- if (fg('platform_editor_toolbar_aifc_text_color_config') || fg('platform_editor_toolbar_aifc_text_color_config_jsm')) {
49
+ if (fg('platform_editor_toolbar_aifc_text_color_config')) {
50
50
  var _api$toolbar;
51
51
  if (api !== null && api !== void 0 && (_api$toolbar = api.toolbar) !== null && _api$toolbar !== void 0 && _api$toolbar.actions.registerComponents && isToolbarComponentEnabled(pluginConfig(textColorConfig))) {
52
52
  api.toolbar.actions.registerComponents(getToolbarComponents(api));
@@ -0,0 +1,9 @@
1
+
2
+ ._19itglyw{border:none}._19bvu2gc{padding-left:var(--ds-space-100,8px)}
3
+ ._19pku2gc{margin-top:var(--ds-space-100,8px)}
4
+ ._1bah1yb4{justify-content:space-between}
5
+ ._1e0c1txw{display:flex}
6
+ ._4cvr1h6o{align-items:center}
7
+ ._ca0q1b66{padding-top:var(--ds-space-050,4px)}
8
+ ._n3td1b66{padding-bottom:var(--ds-space-050,4px)}
9
+ ._u5f31b66{padding-right:var(--ds-space-050,4px)}
@@ -0,0 +1,139 @@
1
+ /* ColorAccessibilityMenuItem.tsx generated by @compiled/babel-plugin v0.39.1 */
2
+ import "./ColorAccessibilityMenuItem.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React from 'react';
5
+ import { useIntl } from 'react-intl';
6
+ import { IconButton } from '@atlaskit/button/new';
7
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
8
+ import { colorAccessibilityMessages as messages } from '@atlaskit/editor-common/messages';
9
+ import { getTokenCSSVariableValue } from '@atlaskit/editor-common/ui-color';
10
+ import { hexToEditorTextBackgroundPaletteColor, hexToEditorTextPaletteColor } from '@atlaskit/editor-palette';
11
+ import AccessibilityIcon from '@atlaskit/icon/core/accessibility';
12
+ import QuestionCircleIcon from '@atlaskit/icon/core/question-circle';
13
+ import { Box, Inline, Text } from '@atlaskit/primitives/compiled';
14
+ import { getTokenValue } from '@atlaskit/tokens';
15
+ import { getContrastRatio as calcContrastRatio } from '../pm-plugins/utils/color-contrast';
16
+ import { DEFAULT_COLOR, DEFAULT_BACKGROUND_COLOR, TRANSPARENT_HIGHLIGHT_COLOR, ACCESSIBLE_CONTRAST_RATIO, DIFFICULT_CONTRAST_RATIO } from '../pm-plugins/utils/constants';
17
+ var resolveColorValue = function resolveColorValue(color, fallback) {
18
+ return getTokenCSSVariableValue(color) || (color.startsWith('var(') ? fallback : color);
19
+ };
20
+ var getForegroundColor = function getForegroundColor(textColor, defaultColor) {
21
+ if (!textColor || defaultColor && textColor === defaultColor) {
22
+ return getTokenValue('color.text', defaultColor || DEFAULT_COLOR.color);
23
+ }
24
+ var colorValue = hexToEditorTextPaletteColor(textColor) || textColor;
25
+ return resolveColorValue(colorValue, textColor);
26
+ };
27
+ var getBackgroundColor = function getBackgroundColor(highlightColor) {
28
+ if (!highlightColor || highlightColor === TRANSPARENT_HIGHLIGHT_COLOR) {
29
+ return getTokenValue('elevation.surface', DEFAULT_BACKGROUND_COLOR);
30
+ }
31
+ var colorValue = hexToEditorTextBackgroundPaletteColor(highlightColor) || highlightColor;
32
+ return resolveColorValue(colorValue, highlightColor);
33
+ };
34
+ var useColorAccessibilityState = function useColorAccessibilityState(api) {
35
+ return useSharedPluginStateWithSelector(api, ['textColor', 'highlight'], function (states) {
36
+ var _states$textColorStat, _states$highlightStat, _states$textColorStat2;
37
+ return {
38
+ defaultColor: (_states$textColorStat = states.textColorState) === null || _states$textColorStat === void 0 ? void 0 : _states$textColorStat.defaultColor,
39
+ highlightColor: (_states$highlightStat = states.highlightState) === null || _states$highlightStat === void 0 ? void 0 : _states$highlightStat.activeColor,
40
+ textColor: (_states$textColorStat2 = states.textColorState) === null || _states$textColorStat2 === void 0 ? void 0 : _states$textColorStat2.color
41
+ };
42
+ });
43
+ };
44
+ var getContrastRatio = function getContrastRatio(defaultColor, highlightColor, textColor) {
45
+ try {
46
+ var contrastRatio = calcContrastRatio(getForegroundColor(textColor, defaultColor), getBackgroundColor(highlightColor));
47
+ return contrastRatio;
48
+ }
49
+ // if we failed to calculate the contrast ratio, return null
50
+ catch (_unused) {
51
+ return null;
52
+ }
53
+ };
54
+ var getAccessibilityStatus = function getAccessibilityStatus(contrastRatio) {
55
+ if (contrastRatio >= ACCESSIBLE_CONTRAST_RATIO) {
56
+ return 'accessible';
57
+ } else if (contrastRatio >= DIFFICULT_CONTRAST_RATIO) {
58
+ return 'difficultToRead';
59
+ } else {
60
+ return 'inaccessible';
61
+ }
62
+ };
63
+ var AccessibilityStatus = function AccessibilityStatus(_ref) {
64
+ var accessibilityStatus = _ref.accessibilityStatus,
65
+ formatMessage = _ref.formatMessage;
66
+ if (accessibilityStatus === 'accessible') {
67
+ return /*#__PURE__*/React.createElement(Text, {
68
+ as: "span",
69
+ size: "small",
70
+ color: "color.text.success"
71
+ }, formatMessage(messages.accessibleLabel));
72
+ } else if (accessibilityStatus === 'difficultToRead') {
73
+ return /*#__PURE__*/React.createElement(Text, {
74
+ as: "span",
75
+ size: "small",
76
+ color: "color.text.warning"
77
+ }, formatMessage(messages.difficultToReadLabel));
78
+ } else {
79
+ return /*#__PURE__*/React.createElement(Text, {
80
+ as: "span",
81
+ size: "small",
82
+ color: "color.text.danger"
83
+ }, formatMessage(messages.inaccessibleLabel));
84
+ }
85
+ };
86
+ var styles = {
87
+ container: "_19itglyw _19pku2gc _ca0q1b66 _n3td1b66 _19bvu2gc _u5f31b66 _1e0c1txw _4cvr1h6o _1bah1yb4"
88
+ };
89
+ export var ColorAccessibilityMenuItem = function ColorAccessibilityMenuItem(_ref2) {
90
+ var api = _ref2.api;
91
+ var _useIntl = useIntl(),
92
+ formatMessage = _useIntl.formatMessage;
93
+ var _useColorAccessibilit = useColorAccessibilityState(api),
94
+ defaultColor = _useColorAccessibilit.defaultColor,
95
+ highlightColor = _useColorAccessibilit.highlightColor,
96
+ textColor = _useColorAccessibilit.textColor;
97
+ var contrastRatio = getContrastRatio(defaultColor, highlightColor, textColor);
98
+ if (contrastRatio === null) {
99
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
100
+ }
101
+ var accessibilityStatus = getAccessibilityStatus(contrastRatio);
102
+ var tooltipContent = function tooltipContent(accessibilityStatus) {
103
+ if (accessibilityStatus === 'accessible') {
104
+ return formatMessage(messages.accessibleTooltip);
105
+ } else if (accessibilityStatus === 'difficultToRead') {
106
+ return formatMessage(messages.difficultToReadTooltip);
107
+ } else {
108
+ return formatMessage(messages.inaccessibleTooltip);
109
+ }
110
+ };
111
+ return /*#__PURE__*/React.createElement(Box, {
112
+ xcss: styles.container
113
+ }, /*#__PURE__*/React.createElement(Inline, {
114
+ alignBlock: "center",
115
+ space: "space.050"
116
+ }, /*#__PURE__*/React.createElement(AccessibilityIcon, {
117
+ label: "",
118
+ size: "medium"
119
+ }), /*#__PURE__*/React.createElement(Text, {
120
+ as: "span",
121
+ size: "small",
122
+ color: "color.text.subtle"
123
+ }, formatMessage(messages.accessibility)), /*#__PURE__*/React.createElement(Text, {
124
+ as: "span",
125
+ size: "small",
126
+ color: "color.text.subtle",
127
+ "aria-hidden": "true"
128
+ }, "\u2022"), /*#__PURE__*/React.createElement(AccessibilityStatus, {
129
+ accessibilityStatus: accessibilityStatus,
130
+ formatMessage: formatMessage
131
+ })), /*#__PURE__*/React.createElement(IconButton, {
132
+ icon: QuestionCircleIcon,
133
+ shape: "circle",
134
+ label: tooltipContent(accessibilityStatus),
135
+ isTooltipDisabled: false,
136
+ spacing: "compact",
137
+ appearance: "subtle"
138
+ }));
139
+ };
@@ -28,6 +28,7 @@ import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette';
28
28
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
29
29
  import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
30
30
  import TextStyleIcon from '@atlaskit/icon/core/text-style';
31
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
31
32
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
32
33
  import { changeColor as changeColorWithAnalytics } from '../../pm-plugins/commands/change-color';
33
34
  import { getInputMethod } from '../../pm-plugins/utils/inputType';
@@ -139,7 +140,7 @@ export var ToolbarTextColor = /*#__PURE__*/function (_React$Component) {
139
140
  disabled = _this$props.disabled,
140
141
  pluginInjectionApi = _this$props.pluginInjectionApi;
141
142
  var palette = pluginState.palette;
142
- var isNewColorPaletteEnabled = editorExperiment('platform_editor_lovability_text_bg_color', true);
143
+ var isNewColorPaletteEnabled = expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true);
143
144
  var colorPickerColumns = isNewColorPaletteEnabled ? 10 : undefined;
144
145
  var fitWidth;
145
146
  if (document.body.clientWidth <= 740) {
@@ -1,8 +1,11 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
5
  import React from 'react';
5
- import { TEXT_SECTION, TEXT_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP, TEXT_COLOR_HIGHLIGHT_MENU, TEXT_COLOR_HIGHLIGHT_MENU_SECTION, TEXT_COLOR_MENU_ITEM, TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP_RANK, TEXT_COLOR_HIGHLIGHT_MENU_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU, CLEAR_COLOR_MENU_ITEM, TEXT_SECTION_PRIMARY_TOOLBAR_RANK, TEXT_SECTION_PRIMARY_TOOLBAR } from '@atlaskit/editor-common/toolbar';
6
+ import { TEXT_SECTION, TEXT_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP, TEXT_COLOR_HIGHLIGHT_MENU, TEXT_COLOR_HIGHLIGHT_MENU_SECTION, TEXT_COLOR_MENU_ITEM, TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP_RANK, TEXT_COLOR_HIGHLIGHT_MENU_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU, CLEAR_COLOR_MENU_ITEM, COLOR_ACCESSIBILITY_MENU_ITEM, TEXT_SECTION_PRIMARY_TOOLBAR_RANK, TEXT_SECTION_PRIMARY_TOOLBAR } from '@atlaskit/editor-common/toolbar';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
+ import { ColorAccessibilityMenuItem } from './ColorAccessibilityMenuItem';
6
9
  import { RemoveColorMenuItem } from './RemoveColorMenuItem';
7
10
  import { TextColorHighlightMenu } from './TextColorHighlightMenu';
8
11
  import { TextColorMenuItem } from './TextColorMenuItem';
@@ -57,5 +60,14 @@ export var getToolbarComponents = function getToolbarComponents(api) {
57
60
  parents: parents
58
61
  });
59
62
  }
60
- })];
63
+ })].concat(_toConsumableArray(expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true) ? [_objectSpread(_objectSpread({}, COLOR_ACCESSIBILITY_MENU_ITEM), {}, {
64
+ parents: [_objectSpread(_objectSpread({}, TEXT_COLOR_HIGHLIGHT_MENU_SECTION), {}, {
65
+ rank: TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK[COLOR_ACCESSIBILITY_MENU_ITEM.key]
66
+ })],
67
+ component: function component() {
68
+ return /*#__PURE__*/React.createElement(ColorAccessibilityMenuItem, {
69
+ api: api
70
+ });
71
+ }
72
+ })] : []));
61
73
  };
@@ -0,0 +1 @@
1
+ export declare function getContrastRatio(foreground: string, background: string): number;
@@ -1,4 +1,8 @@
1
1
  export declare const overrideMarks: string[];
2
+ export declare const ACCESSIBLE_CONTRAST_RATIO = 4.5;
3
+ export declare const DIFFICULT_CONTRAST_RATIO = 3;
4
+ export declare const DEFAULT_BACKGROUND_COLOR = "#FFFFFF";
5
+ export declare const TRANSPARENT_HIGHLIGHT_COLOR = "#00000000";
2
6
  export declare const DEFAULT_COLOR: {
3
7
  color: string;
4
8
  label: string;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { TextColorPlugin } from '../textColorPluginType';
4
+ type ColorAccessibilityMenuItemProps = {
5
+ api: ExtractInjectionAPI<TextColorPlugin> | undefined;
6
+ };
7
+ export declare const ColorAccessibilityMenuItem: ({ api }: ColorAccessibilityMenuItemProps) => React.JSX.Element;
8
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-text-color",
3
- "version": "12.1.2",
3
+ "version": "12.2.0",
4
4
  "description": "Text color plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -41,13 +41,13 @@
41
41
  "@atlaskit/platform-feature-flags": "^2.0.0",
42
42
  "@atlaskit/platform-feature-flags-react": "^1.0.0",
43
43
  "@atlaskit/primitives": "^20.0.0",
44
- "@atlaskit/tmp-editor-statsig": "^108.3.0",
44
+ "@atlaskit/tmp-editor-statsig": "^109.0.0",
45
45
  "@atlaskit/tokens": "^14.0.0",
46
46
  "@babel/runtime": "^7.0.0",
47
47
  "@emotion/react": "^11.7.1"
48
48
  },
49
49
  "peerDependencies": {
50
- "@atlaskit/editor-common": "^116.4.0",
50
+ "@atlaskit/editor-common": "^116.6.0",
51
51
  "react": "^18.2.0",
52
52
  "react-dom": "^18.2.0",
53
53
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -102,9 +102,6 @@
102
102
  },
103
103
  "platform_editor_toolbar_aifc_text_color_config": {
104
104
  "type": "boolean"
105
- },
106
- "platform_editor_toolbar_aifc_text_color_config_jsm": {
107
- "type": "boolean"
108
105
  }
109
106
  }
110
107
  }