@atlaskit/editor-plugin-text-color 12.0.2 → 12.1.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 +12 -0
- package/dist/cjs/pm-plugins/main.js +3 -1
- package/dist/cjs/ui/TextColorMenuItem.js +10 -7
- package/dist/cjs/ui/ToolbarTextColor/index.js +10 -6
- package/dist/es2019/pm-plugins/main.js +4 -2
- package/dist/es2019/ui/TextColorMenuItem.js +11 -8
- package/dist/es2019/ui/ToolbarTextColor/index.js +10 -6
- package/dist/esm/pm-plugins/main.js +4 -2
- package/dist/esm/ui/TextColorMenuItem.js +10 -7
- package/dist/esm/ui/ToolbarTextColor/index.js +10 -6
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-color
|
|
2
2
|
|
|
3
|
+
## 12.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`1498129c7eef2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1498129c7eef2) -
|
|
8
|
+
[EDITOR-7591] adds updated text color and highlight color palettes behind the
|
|
9
|
+
`platform_editor_lovability_text_bg_color` experiment
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 12.0.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -12,6 +12,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
12
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
13
|
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
14
14
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
15
16
|
var _color = require("./utils/color");
|
|
16
17
|
var _constants = require("./utils/constants");
|
|
17
18
|
var _disabled = require("./utils/disabled");
|
|
@@ -19,11 +20,12 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
19
20
|
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) { (0, _defineProperty2.default)(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; }
|
|
20
21
|
function createInitialPluginState(editorState, pluginConfig) {
|
|
21
22
|
var defaultColor = (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.defaultColor) || _constants.DEFAULT_COLOR;
|
|
23
|
+
var paletteColors = (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_text_bg_color', 'isEnabled', true) ? _uiColor.textColorPaletteNew : _uiColor.textColorPalette;
|
|
22
24
|
var palette = [{
|
|
23
25
|
value: defaultColor.color,
|
|
24
26
|
label: defaultColor.label,
|
|
25
27
|
border: "var(--ds-border, #0B120E24)"
|
|
26
|
-
}].concat((0, _toConsumableArray2.default)(
|
|
28
|
+
}].concat((0, _toConsumableArray2.default)(paletteColors));
|
|
27
29
|
var state = {
|
|
28
30
|
color: (0, _color.getActiveColor)(editorState),
|
|
29
31
|
disabled: (0, _disabled.getDisabledState)(editorState),
|
|
@@ -21,6 +21,7 @@ var _heading = _interopRequireDefault(require("@atlaskit/heading"));
|
|
|
21
21
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
22
22
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
23
23
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
24
|
+
var TEXT_COLOR_PICKER_COLUMNS = 10;
|
|
24
25
|
var styles = {
|
|
25
26
|
container: "_zulp12x7"
|
|
26
27
|
};
|
|
@@ -42,6 +43,9 @@ function TextColorMenuItem(_ref) {
|
|
|
42
43
|
editorView = _useEditorToolbar.editorView;
|
|
43
44
|
var context = (0, _editorToolbar.useToolbarDropdownMenu)();
|
|
44
45
|
var closeMenu = context === null || context === void 0 ? void 0 : context.closeMenu;
|
|
46
|
+
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
47
|
+
formatMessage = _useIntl.formatMessage;
|
|
48
|
+
var isNewColorPaletteEnabled = (0, _expValEquals.expValEquals)('platform_editor_lovability_text_bg_color', 'isEnabled', true);
|
|
45
49
|
var handleTextColorChange = (0, _react.useCallback)(function (color, event) {
|
|
46
50
|
var _api$textColor;
|
|
47
51
|
if (!(editorView !== null && editorView !== void 0 && editorView.state) || !(editorView !== null && editorView !== void 0 && editorView.dispatch)) {
|
|
@@ -49,21 +53,20 @@ function TextColorMenuItem(_ref) {
|
|
|
49
53
|
}
|
|
50
54
|
if (api !== null && api !== void 0 && (_api$textColor = api.textColor) !== null && _api$textColor !== void 0 && (_api$textColor = _api$textColor.actions) !== null && _api$textColor !== void 0 && _api$textColor.changeColor) {
|
|
51
55
|
api.textColor.actions.changeColor(color, (0, _toolbar.getInputMethodFromParentKeys)(parents))(editorView.state, editorView.dispatch);
|
|
52
|
-
if (!
|
|
56
|
+
if (!isNewColorPaletteEnabled) {
|
|
53
57
|
closeMenu === null || closeMenu === void 0 || closeMenu(event);
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
|
-
}, [editorView === null || editorView === void 0 ? void 0 : editorView.state, editorView === null || editorView === void 0 ? void 0 : editorView.dispatch, api === null || api === void 0 ? void 0 : api.textColor.actions, parents, closeMenu]);
|
|
57
|
-
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
58
|
-
formatMessage = _useIntl.formatMessage;
|
|
60
|
+
}, [editorView === null || editorView === void 0 ? void 0 : editorView.state, editorView === null || editorView === void 0 ? void 0 : editorView.dispatch, api === null || api === void 0 ? void 0 : api.textColor.actions, parents, closeMenu, isNewColorPaletteEnabled]);
|
|
59
61
|
return /*#__PURE__*/_react.default.createElement(_compiled.Stack, {
|
|
60
62
|
xcss: styles.container,
|
|
61
63
|
testId: "text-color-menu-item"
|
|
62
64
|
}, /*#__PURE__*/_react.default.createElement(_heading.default, {
|
|
63
65
|
size: "xxsmall"
|
|
64
|
-
}, formatMessage(_messages.textColorMessages.textColorTooltip)), /*#__PURE__*/_react.default.createElement(_editorToolbar.ColorPalette
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
}, formatMessage(_messages.textColorMessages.textColorTooltip)), /*#__PURE__*/_react.default.createElement(_editorToolbar.ColorPalette, {
|
|
67
|
+
cols: isNewColorPaletteEnabled ? TEXT_COLOR_PICKER_COLUMNS : undefined
|
|
68
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
69
|
+
,
|
|
67
70
|
onClick: function onClick(color, _, event) {
|
|
68
71
|
handleTextColorChange(color, event);
|
|
69
72
|
},
|
|
@@ -143,13 +143,16 @@ var ToolbarTextColor = exports.ToolbarTextColor = /*#__PURE__*/function (_React$
|
|
|
143
143
|
disabled = _this$props.disabled,
|
|
144
144
|
pluginInjectionApi = _this$props.pluginInjectionApi;
|
|
145
145
|
var palette = pluginState.palette;
|
|
146
|
+
var isNewColorPaletteEnabled = (0, _experiments.editorExperiment)('platform_editor_lovability_text_bg_color', true);
|
|
147
|
+
var colorPickerColumns = isNewColorPaletteEnabled ? 10 : undefined;
|
|
146
148
|
var fitWidth;
|
|
147
149
|
if (document.body.clientWidth <= 740) {
|
|
148
150
|
// This was originally hard-coded, but moved here to a const
|
|
149
151
|
// My guess is it's based off (width of button * columns) + left/right padding
|
|
150
|
-
// 240 = (32 * 7) + (8 + 8)
|
|
152
|
+
// 7 cols: 240 = (32 * 7) + (8 + 8)
|
|
153
|
+
// 10 cols: 338 = (32 * 10) + (8 + 8)
|
|
151
154
|
// Not sure where the extra 2px comes from
|
|
152
|
-
fitWidth = 242;
|
|
155
|
+
fitWidth = isNewColorPaletteEnabled ? 338 : 242;
|
|
153
156
|
}
|
|
154
157
|
var selectedColor = this.getSelectedColor(pluginState);
|
|
155
158
|
// TODO: ED-26959 - This doesn't work, the label isn't translated
|
|
@@ -161,7 +164,7 @@ var ToolbarTextColor = exports.ToolbarTextColor = /*#__PURE__*/function (_React$
|
|
|
161
164
|
selectedColorName: selectedColorPaletteItemLabelText
|
|
162
165
|
});
|
|
163
166
|
var tooltipTextColor = formatMessage(_messages.textColorMessages.textColorTooltip);
|
|
164
|
-
var _getSelectedRowAndCol = (0, _uiColor.getSelectedRowAndColumnFromPalette)(palette, pluginState.color),
|
|
167
|
+
var _getSelectedRowAndCol = (0, _uiColor.getSelectedRowAndColumnFromPalette)(palette, pluginState.color, colorPickerColumns),
|
|
165
168
|
selectedRowIndex = _getSelectedRowAndCol.selectedRowIndex,
|
|
166
169
|
selectedColumnIndex = _getSelectedRowAndCol.selectedColumnIndex;
|
|
167
170
|
var reducedSpacing = this.props.toolbarType === _types.ToolbarType.FLOATING ? 'compact' : 'none';
|
|
@@ -224,9 +227,10 @@ var ToolbarTextColor = exports.ToolbarTextColor = /*#__PURE__*/function (_React$
|
|
|
224
227
|
})
|
|
225
228
|
}, (0, _react2.jsx)("div", {
|
|
226
229
|
"data-testid": "text-color-palette"
|
|
227
|
-
}, (0, _react2.jsx)(_uiColor.ColorPalette
|
|
228
|
-
|
|
229
|
-
|
|
230
|
+
}, (0, _react2.jsx)(_uiColor.ColorPalette, {
|
|
231
|
+
cols: colorPickerColumns
|
|
232
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
233
|
+
,
|
|
230
234
|
onClick: function onClick(color) {
|
|
231
235
|
var _pluginInjectionApi$a;
|
|
232
236
|
return _this2.changeTextColor(color, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, pluginState.disabled);
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { textColorPalette } from '@atlaskit/editor-common/ui-color';
|
|
2
|
+
import { textColorPalette, textColorPaletteNew } from '@atlaskit/editor-common/ui-color';
|
|
3
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
4
5
|
import { getActiveColor } from './utils/color';
|
|
5
6
|
import { DEFAULT_COLOR } from './utils/constants';
|
|
6
7
|
import { getDisabledState } from './utils/disabled';
|
|
7
8
|
function createInitialPluginState(editorState, pluginConfig) {
|
|
8
9
|
const defaultColor = (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.defaultColor) || DEFAULT_COLOR;
|
|
10
|
+
const paletteColors = expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) ? textColorPaletteNew : textColorPalette;
|
|
9
11
|
const palette = [{
|
|
10
12
|
value: defaultColor.color,
|
|
11
13
|
label: defaultColor.label,
|
|
12
14
|
border: "var(--ds-border, #0B120E24)"
|
|
13
|
-
}, ...
|
|
15
|
+
}, ...paletteColors];
|
|
14
16
|
const state = {
|
|
15
17
|
color: getActiveColor(editorState),
|
|
16
18
|
disabled: getDisabledState(editorState),
|
|
@@ -12,6 +12,7 @@ import { ColorPalette, useToolbarDropdownMenu } from '@atlaskit/editor-toolbar';
|
|
|
12
12
|
import Heading from '@atlaskit/heading';
|
|
13
13
|
import { Stack } from '@atlaskit/primitives/compiled';
|
|
14
14
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
|
+
const TEXT_COLOR_PICKER_COLUMNS = 10;
|
|
15
16
|
const styles = {
|
|
16
17
|
container: "_zulp12x7"
|
|
17
18
|
};
|
|
@@ -36,6 +37,10 @@ export function TextColorMenuItem({
|
|
|
36
37
|
} = useEditorToolbar();
|
|
37
38
|
const context = useToolbarDropdownMenu();
|
|
38
39
|
const closeMenu = context === null || context === void 0 ? void 0 : context.closeMenu;
|
|
40
|
+
const {
|
|
41
|
+
formatMessage
|
|
42
|
+
} = useIntl();
|
|
43
|
+
const isNewColorPaletteEnabled = expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true);
|
|
39
44
|
const handleTextColorChange = useCallback((color, event) => {
|
|
40
45
|
var _api$textColor, _api$textColor$action;
|
|
41
46
|
if (!(editorView !== null && editorView !== void 0 && editorView.state) || !(editorView !== null && editorView !== void 0 && editorView.dispatch)) {
|
|
@@ -43,22 +48,20 @@ export function TextColorMenuItem({
|
|
|
43
48
|
}
|
|
44
49
|
if (api !== null && api !== void 0 && (_api$textColor = api.textColor) !== null && _api$textColor !== void 0 && (_api$textColor$action = _api$textColor.actions) !== null && _api$textColor$action !== void 0 && _api$textColor$action.changeColor) {
|
|
45
50
|
api.textColor.actions.changeColor(color, getInputMethodFromParentKeys(parents))(editorView.state, editorView.dispatch);
|
|
46
|
-
if (!
|
|
51
|
+
if (!isNewColorPaletteEnabled) {
|
|
47
52
|
closeMenu === null || closeMenu === void 0 ? void 0 : closeMenu(event);
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
|
-
}, [editorView === null || editorView === void 0 ? void 0 : editorView.state, editorView === null || editorView === void 0 ? void 0 : editorView.dispatch, api === null || api === void 0 ? void 0 : api.textColor.actions, parents, closeMenu]);
|
|
51
|
-
const {
|
|
52
|
-
formatMessage
|
|
53
|
-
} = useIntl();
|
|
55
|
+
}, [editorView === null || editorView === void 0 ? void 0 : editorView.state, editorView === null || editorView === void 0 ? void 0 : editorView.dispatch, api === null || api === void 0 ? void 0 : api.textColor.actions, parents, closeMenu, isNewColorPaletteEnabled]);
|
|
54
56
|
return /*#__PURE__*/React.createElement(Stack, {
|
|
55
57
|
xcss: styles.container,
|
|
56
58
|
testId: "text-color-menu-item"
|
|
57
59
|
}, /*#__PURE__*/React.createElement(Heading, {
|
|
58
60
|
size: "xxsmall"
|
|
59
|
-
}, formatMessage(messages.textColorTooltip)), /*#__PURE__*/React.createElement(ColorPalette
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
}, formatMessage(messages.textColorTooltip)), /*#__PURE__*/React.createElement(ColorPalette, {
|
|
62
|
+
cols: isNewColorPaletteEnabled ? TEXT_COLOR_PICKER_COLUMNS : undefined
|
|
63
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
64
|
+
,
|
|
62
65
|
onClick: (color, _, event) => {
|
|
63
66
|
handleTextColorChange(color, event);
|
|
64
67
|
},
|
|
@@ -124,13 +124,16 @@ export class ToolbarTextColor extends React.Component {
|
|
|
124
124
|
pluginInjectionApi
|
|
125
125
|
} = this.props;
|
|
126
126
|
const palette = pluginState.palette;
|
|
127
|
+
const isNewColorPaletteEnabled = editorExperiment('platform_editor_lovability_text_bg_color', true);
|
|
128
|
+
const colorPickerColumns = isNewColorPaletteEnabled ? 10 : undefined;
|
|
127
129
|
let fitWidth;
|
|
128
130
|
if (document.body.clientWidth <= 740) {
|
|
129
131
|
// This was originally hard-coded, but moved here to a const
|
|
130
132
|
// My guess is it's based off (width of button * columns) + left/right padding
|
|
131
|
-
// 240 = (32 * 7) + (8 + 8)
|
|
133
|
+
// 7 cols: 240 = (32 * 7) + (8 + 8)
|
|
134
|
+
// 10 cols: 338 = (32 * 10) + (8 + 8)
|
|
132
135
|
// Not sure where the extra 2px comes from
|
|
133
|
-
fitWidth = 242;
|
|
136
|
+
fitWidth = isNewColorPaletteEnabled ? 338 : 242;
|
|
134
137
|
}
|
|
135
138
|
const selectedColor = this.getSelectedColor(pluginState);
|
|
136
139
|
// TODO: ED-26959 - This doesn't work, the label isn't translated
|
|
@@ -143,7 +146,7 @@ export class ToolbarTextColor extends React.Component {
|
|
|
143
146
|
const {
|
|
144
147
|
selectedRowIndex,
|
|
145
148
|
selectedColumnIndex
|
|
146
|
-
} = getSelectedRowAndColumnFromPalette(palette, pluginState.color);
|
|
149
|
+
} = getSelectedRowAndColumnFromPalette(palette, pluginState.color, colorPickerColumns);
|
|
147
150
|
const reducedSpacing = this.props.toolbarType === ToolbarType.FLOATING ? 'compact' : 'none';
|
|
148
151
|
return jsx("span", {
|
|
149
152
|
css:
|
|
@@ -204,9 +207,10 @@ export class ToolbarTextColor extends React.Component {
|
|
|
204
207
|
})
|
|
205
208
|
}, jsx("div", {
|
|
206
209
|
"data-testid": "text-color-palette"
|
|
207
|
-
}, jsx(ColorPalette
|
|
208
|
-
|
|
209
|
-
|
|
210
|
+
}, jsx(ColorPalette, {
|
|
211
|
+
cols: colorPickerColumns
|
|
212
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
213
|
+
,
|
|
210
214
|
onClick: color => {
|
|
211
215
|
var _pluginInjectionApi$a;
|
|
212
216
|
return this.changeTextColor(color, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, pluginState.disabled);
|
|
@@ -3,18 +3,20 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
3
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; }
|
|
4
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; }
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
|
-
import { textColorPalette } from '@atlaskit/editor-common/ui-color';
|
|
6
|
+
import { textColorPalette, textColorPaletteNew } from '@atlaskit/editor-common/ui-color';
|
|
7
7
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
8
9
|
import { getActiveColor } from './utils/color';
|
|
9
10
|
import { DEFAULT_COLOR } from './utils/constants';
|
|
10
11
|
import { getDisabledState } from './utils/disabled';
|
|
11
12
|
function createInitialPluginState(editorState, pluginConfig) {
|
|
12
13
|
var defaultColor = (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.defaultColor) || DEFAULT_COLOR;
|
|
14
|
+
var paletteColors = expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) ? textColorPaletteNew : textColorPalette;
|
|
13
15
|
var palette = [{
|
|
14
16
|
value: defaultColor.color,
|
|
15
17
|
label: defaultColor.label,
|
|
16
18
|
border: "var(--ds-border, #0B120E24)"
|
|
17
|
-
}].concat(_toConsumableArray(
|
|
19
|
+
}].concat(_toConsumableArray(paletteColors));
|
|
18
20
|
var state = {
|
|
19
21
|
color: getActiveColor(editorState),
|
|
20
22
|
disabled: getDisabledState(editorState),
|
|
@@ -12,6 +12,7 @@ import { ColorPalette, useToolbarDropdownMenu } from '@atlaskit/editor-toolbar';
|
|
|
12
12
|
import Heading from '@atlaskit/heading';
|
|
13
13
|
import { Stack } from '@atlaskit/primitives/compiled';
|
|
14
14
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
|
+
var TEXT_COLOR_PICKER_COLUMNS = 10;
|
|
15
16
|
var styles = {
|
|
16
17
|
container: "_zulp12x7"
|
|
17
18
|
};
|
|
@@ -33,6 +34,9 @@ export function TextColorMenuItem(_ref) {
|
|
|
33
34
|
editorView = _useEditorToolbar.editorView;
|
|
34
35
|
var context = useToolbarDropdownMenu();
|
|
35
36
|
var closeMenu = context === null || context === void 0 ? void 0 : context.closeMenu;
|
|
37
|
+
var _useIntl = useIntl(),
|
|
38
|
+
formatMessage = _useIntl.formatMessage;
|
|
39
|
+
var isNewColorPaletteEnabled = expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true);
|
|
36
40
|
var handleTextColorChange = useCallback(function (color, event) {
|
|
37
41
|
var _api$textColor;
|
|
38
42
|
if (!(editorView !== null && editorView !== void 0 && editorView.state) || !(editorView !== null && editorView !== void 0 && editorView.dispatch)) {
|
|
@@ -40,21 +44,20 @@ export function TextColorMenuItem(_ref) {
|
|
|
40
44
|
}
|
|
41
45
|
if (api !== null && api !== void 0 && (_api$textColor = api.textColor) !== null && _api$textColor !== void 0 && (_api$textColor = _api$textColor.actions) !== null && _api$textColor !== void 0 && _api$textColor.changeColor) {
|
|
42
46
|
api.textColor.actions.changeColor(color, getInputMethodFromParentKeys(parents))(editorView.state, editorView.dispatch);
|
|
43
|
-
if (!
|
|
47
|
+
if (!isNewColorPaletteEnabled) {
|
|
44
48
|
closeMenu === null || closeMenu === void 0 || closeMenu(event);
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
|
-
}, [editorView === null || editorView === void 0 ? void 0 : editorView.state, editorView === null || editorView === void 0 ? void 0 : editorView.dispatch, api === null || api === void 0 ? void 0 : api.textColor.actions, parents, closeMenu]);
|
|
48
|
-
var _useIntl = useIntl(),
|
|
49
|
-
formatMessage = _useIntl.formatMessage;
|
|
51
|
+
}, [editorView === null || editorView === void 0 ? void 0 : editorView.state, editorView === null || editorView === void 0 ? void 0 : editorView.dispatch, api === null || api === void 0 ? void 0 : api.textColor.actions, parents, closeMenu, isNewColorPaletteEnabled]);
|
|
50
52
|
return /*#__PURE__*/React.createElement(Stack, {
|
|
51
53
|
xcss: styles.container,
|
|
52
54
|
testId: "text-color-menu-item"
|
|
53
55
|
}, /*#__PURE__*/React.createElement(Heading, {
|
|
54
56
|
size: "xxsmall"
|
|
55
|
-
}, formatMessage(messages.textColorTooltip)), /*#__PURE__*/React.createElement(ColorPalette
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
}, formatMessage(messages.textColorTooltip)), /*#__PURE__*/React.createElement(ColorPalette, {
|
|
58
|
+
cols: isNewColorPaletteEnabled ? TEXT_COLOR_PICKER_COLUMNS : undefined
|
|
59
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
60
|
+
,
|
|
58
61
|
onClick: function onClick(color, _, event) {
|
|
59
62
|
handleTextColorChange(color, event);
|
|
60
63
|
},
|
|
@@ -139,13 +139,16 @@ export var ToolbarTextColor = /*#__PURE__*/function (_React$Component) {
|
|
|
139
139
|
disabled = _this$props.disabled,
|
|
140
140
|
pluginInjectionApi = _this$props.pluginInjectionApi;
|
|
141
141
|
var palette = pluginState.palette;
|
|
142
|
+
var isNewColorPaletteEnabled = editorExperiment('platform_editor_lovability_text_bg_color', true);
|
|
143
|
+
var colorPickerColumns = isNewColorPaletteEnabled ? 10 : undefined;
|
|
142
144
|
var fitWidth;
|
|
143
145
|
if (document.body.clientWidth <= 740) {
|
|
144
146
|
// This was originally hard-coded, but moved here to a const
|
|
145
147
|
// My guess is it's based off (width of button * columns) + left/right padding
|
|
146
|
-
// 240 = (32 * 7) + (8 + 8)
|
|
148
|
+
// 7 cols: 240 = (32 * 7) + (8 + 8)
|
|
149
|
+
// 10 cols: 338 = (32 * 10) + (8 + 8)
|
|
147
150
|
// Not sure where the extra 2px comes from
|
|
148
|
-
fitWidth = 242;
|
|
151
|
+
fitWidth = isNewColorPaletteEnabled ? 338 : 242;
|
|
149
152
|
}
|
|
150
153
|
var selectedColor = this.getSelectedColor(pluginState);
|
|
151
154
|
// TODO: ED-26959 - This doesn't work, the label isn't translated
|
|
@@ -157,7 +160,7 @@ export var ToolbarTextColor = /*#__PURE__*/function (_React$Component) {
|
|
|
157
160
|
selectedColorName: selectedColorPaletteItemLabelText
|
|
158
161
|
});
|
|
159
162
|
var tooltipTextColor = formatMessage(messages.textColorTooltip);
|
|
160
|
-
var _getSelectedRowAndCol = getSelectedRowAndColumnFromPalette(palette, pluginState.color),
|
|
163
|
+
var _getSelectedRowAndCol = getSelectedRowAndColumnFromPalette(palette, pluginState.color, colorPickerColumns),
|
|
161
164
|
selectedRowIndex = _getSelectedRowAndCol.selectedRowIndex,
|
|
162
165
|
selectedColumnIndex = _getSelectedRowAndCol.selectedColumnIndex;
|
|
163
166
|
var reducedSpacing = this.props.toolbarType === ToolbarType.FLOATING ? 'compact' : 'none';
|
|
@@ -220,9 +223,10 @@ export var ToolbarTextColor = /*#__PURE__*/function (_React$Component) {
|
|
|
220
223
|
})
|
|
221
224
|
}, jsx("div", {
|
|
222
225
|
"data-testid": "text-color-palette"
|
|
223
|
-
}, jsx(ColorPalette
|
|
224
|
-
|
|
225
|
-
|
|
226
|
+
}, jsx(ColorPalette, {
|
|
227
|
+
cols: colorPickerColumns
|
|
228
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
229
|
+
,
|
|
226
230
|
onClick: function onClick(color) {
|
|
227
231
|
var _pluginInjectionApi$a;
|
|
228
232
|
return _this2.changeTextColor(color, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, pluginState.disabled);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-color",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "Text color plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
],
|
|
22
22
|
"atlaskit:src": "src/index.ts",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atlaskit/adf-schema": "^55.
|
|
24
|
+
"@atlaskit/adf-schema": "^55.2.0",
|
|
25
25
|
"@atlaskit/button": "^24.0.0",
|
|
26
26
|
"@atlaskit/css": "^1.0.0",
|
|
27
|
-
"@atlaskit/editor-palette": "^3.
|
|
27
|
+
"@atlaskit/editor-palette": "^3.1.0",
|
|
28
28
|
"@atlaskit/editor-plugin-analytics": "^12.0.0",
|
|
29
|
-
"@atlaskit/editor-plugin-highlight": "^12.
|
|
29
|
+
"@atlaskit/editor-plugin-highlight": "^12.1.0",
|
|
30
30
|
"@atlaskit/editor-plugin-interaction": "^21.0.0",
|
|
31
31
|
"@atlaskit/editor-plugin-primary-toolbar": "^13.0.0",
|
|
32
32
|
"@atlaskit/editor-plugin-selection-toolbar": "^13.0.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": "^
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^107.1.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.
|
|
50
|
+
"@atlaskit/editor-common": "^116.3.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"
|