@atlaskit/editor-plugin-highlight 3.0.3 → 3.0.4

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,14 @@
1
1
  # @atlaskit/editor-plugin-highlight
2
2
 
3
+ ## 3.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#185643](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/185643)
8
+ [`5954e6c1fbac5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5954e6c1fbac5) -
9
+ [ux] [ED-28432] Add orange highlight color and reorder color swatches
10
+ - Updated dependencies
11
+
3
12
  ## 3.0.3
4
13
 
5
14
  ### Patch Changes
@@ -8,6 +8,7 @@ var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _keymaps = require("@atlaskit/editor-common/keymaps");
9
9
  var _preset = require("@atlaskit/editor-common/preset");
10
10
  var _uiColor = require("@atlaskit/editor-common/ui-color");
11
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
11
12
  var _changeColor = require("../editor-commands/change-color");
12
13
  var _palette = require("../editor-commands/palette");
13
14
  function keymapPlugin(_ref) {
@@ -24,19 +25,23 @@ function keymapPlugin(_ref) {
24
25
  inputMethod: _analytics.INPUT_METHOD.SHORTCUT
25
26
  }), list);
26
27
  var analyticsApi = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
27
- // NOTE: This will work with fallback until we clean up `editor_text_highlight_orange_to_yellow`
28
- var color = _uiColor.highlightColorPalette.find(function (_ref2) {
28
+ var color = (0, _expValEquals.expValEquals)('platform_editor_add_orange_highlight_color', 'cohort', 'test') ? _uiColor.highlightColorPaletteNext.find(function (_ref2) {
29
29
  var label = _ref2.label;
30
30
  return label === 'Yellow';
31
+ }) : _uiColor.highlightColorPalette.find(function (_ref3) {
32
+ var label = _ref3.label;
33
+ return label === 'Yellow';
31
34
  }) || {
32
35
  value: '#fedec8'
33
36
  };
34
- (0, _keymaps.bindKeymapWithCommand)(
35
- // Ignored via go/ees005
36
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
37
- _keymaps.applyYellowHighlight.common, (0, _preset.editorCommandToPMCommand)((0, _changeColor.changeColor)(analyticsApi)({
38
- color: color.value,
39
- inputMethod: _analytics.INPUT_METHOD.SHORTCUT
40
- })), list);
37
+ if (color) {
38
+ (0, _keymaps.bindKeymapWithCommand)(
39
+ // Ignored via go/ees005
40
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
41
+ _keymaps.applyYellowHighlight.common, (0, _preset.editorCommandToPMCommand)((0, _changeColor.changeColor)(analyticsApi)({
42
+ color: color.value,
43
+ inputMethod: _analytics.INPUT_METHOD.SHORTCUT
44
+ })), list);
45
+ }
41
46
  return (0, _keymaps.keymap)(list);
42
47
  }
@@ -11,8 +11,10 @@ var _uiColor = require("@atlaskit/editor-common/ui-color");
11
11
  var _uiMenu = require("@atlaskit/editor-common/ui-menu");
12
12
  var _editorPalette = require("@atlaskit/editor-palette");
13
13
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
14
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
14
15
  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; }
15
16
  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; }
17
+ var HIGHLIGHT_COLOR_PICKER_COLUMNS = 8;
16
18
  var PaletteDropdown = exports.PaletteDropdown = function PaletteDropdown(props) {
17
19
  var popupsMountPoint = props.popupsMountPoint,
18
20
  popupsBoundariesElement = props.popupsBoundariesElement,
@@ -24,21 +26,26 @@ var PaletteDropdown = exports.PaletteDropdown = function PaletteDropdown(props)
24
26
  isOpenedByKeyboard = props.isOpenedByKeyboard,
25
27
  handleClickOutside = props.handleClickOutside,
26
28
  handleEscapeKeydown = props.handleEscapeKeydown;
29
+ var isOrangeHighlightEnabled = (0, _expValEquals.expValEquals)('platform_editor_add_orange_highlight_color', 'cohort', 'test');
27
30
 
28
31
  // pixels, used to determine where to horizontally position the dropdown when space is limited
29
32
  // this should reflect the width of the dropdown when fully populated with colors, including translations due to layering
30
- var fitWidth = 242;
31
- var colorPalette = _uiColor.highlightColorPalette;
32
- colorPalette = _uiColor.highlightColorPalette.map(function (item) {
33
- if (item.label === 'Orange') {
34
- return _objectSpread(_objectSpread({}, item), {}, {
35
- label: 'Yellow',
36
- message: _uiColor.colorPaletteMessages.yellow
37
- });
38
- }
39
- return item;
40
- });
41
- var _getSelectedRowAndCol = (0, _uiColor.getSelectedRowAndColumnFromPalette)(colorPalette, activeColor),
33
+ var fitWidth = isOrangeHighlightEnabled ? 274 : 242;
34
+ var colorPalette;
35
+ if (isOrangeHighlightEnabled) {
36
+ colorPalette = _uiColor.highlightColorPaletteNext;
37
+ } else {
38
+ colorPalette = _uiColor.highlightColorPalette.map(function (item) {
39
+ if (item.label === 'Orange') {
40
+ return _objectSpread(_objectSpread({}, item), {}, {
41
+ label: 'Yellow',
42
+ message: _uiColor.colorPaletteMessages.yellow
43
+ });
44
+ }
45
+ return item;
46
+ });
47
+ }
48
+ var _getSelectedRowAndCol = (0, _uiColor.getSelectedRowAndColumnFromPalette)(colorPalette, activeColor, isOrangeHighlightEnabled ? HIGHLIGHT_COLOR_PICKER_COLUMNS : undefined),
42
49
  selectedRowIndex = _getSelectedRowAndCol.selectedRowIndex,
43
50
  selectedColumnIndex = _getSelectedRowAndCol.selectedColumnIndex;
44
51
  return /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownContainer, {
@@ -62,6 +69,7 @@ var PaletteDropdown = exports.PaletteDropdown = function PaletteDropdown(props)
62
69
  }, /*#__PURE__*/_react.default.createElement("div", {
63
70
  "data-testid": "highlight-color-palette"
64
71
  }, /*#__PURE__*/_react.default.createElement(_uiColor.ColorPalette, {
72
+ cols: isOrangeHighlightEnabled ? HIGHLIGHT_COLOR_PICKER_COLUMNS : undefined,
65
73
  onClick: onColorChange,
66
74
  selectedColor: activeColor,
67
75
  paletteOptions: {
@@ -1,7 +1,8 @@
1
1
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { bindKeymapWithCommand, keymap, toggleHighlightPalette, applyYellowHighlight } from '@atlaskit/editor-common/keymaps';
3
3
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
4
- import { highlightColorPalette } from '@atlaskit/editor-common/ui-color';
4
+ import { highlightColorPalette, highlightColorPaletteNext } from '@atlaskit/editor-common/ui-color';
5
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
6
  import { changeColor } from '../editor-commands/change-color';
6
7
  import { togglePalette } from '../editor-commands/palette';
7
8
  export function keymapPlugin({
@@ -19,18 +20,21 @@ export function keymapPlugin({
19
20
  inputMethod: INPUT_METHOD.SHORTCUT
20
21
  }), list);
21
22
  const analyticsApi = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
22
- // NOTE: This will work with fallback until we clean up `editor_text_highlight_orange_to_yellow`
23
- const color = highlightColorPalette.find(({
23
+ const color = expValEquals('platform_editor_add_orange_highlight_color', 'cohort', 'test') ? highlightColorPaletteNext.find(({
24
+ label
25
+ }) => label === 'Yellow') : highlightColorPalette.find(({
24
26
  label
25
27
  }) => label === 'Yellow') || {
26
28
  value: '#fedec8'
27
29
  };
28
- bindKeymapWithCommand(
29
- // Ignored via go/ees005
30
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
31
- applyYellowHighlight.common, editorCommandToPMCommand(changeColor(analyticsApi)({
32
- color: color.value,
33
- inputMethod: INPUT_METHOD.SHORTCUT
34
- })), list);
30
+ if (color) {
31
+ bindKeymapWithCommand(
32
+ // Ignored via go/ees005
33
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
34
+ applyYellowHighlight.common, editorCommandToPMCommand(changeColor(analyticsApi)({
35
+ color: color.value,
36
+ inputMethod: INPUT_METHOD.SHORTCUT
37
+ })), list);
38
+ }
35
39
  return keymap(list);
36
40
  }
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
- import { ColorPalette, colorPaletteMessages, getSelectedRowAndColumnFromPalette, highlightColorPalette } from '@atlaskit/editor-common/ui-color';
2
+ import { ColorPalette, colorPaletteMessages, getSelectedRowAndColumnFromPalette, highlightColorPalette, highlightColorPaletteNext } from '@atlaskit/editor-common/ui-color';
3
3
  import { ArrowKeyNavigationType, DropdownContainer as Dropdown } from '@atlaskit/editor-common/ui-menu';
4
4
  import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
5
5
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
6
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
+ const HIGHLIGHT_COLOR_PICKER_COLUMNS = 8;
6
8
  export const PaletteDropdown = props => {
7
9
  const {
8
10
  popupsMountPoint,
@@ -16,25 +18,30 @@ export const PaletteDropdown = props => {
16
18
  handleClickOutside,
17
19
  handleEscapeKeydown
18
20
  } = props;
21
+ const isOrangeHighlightEnabled = expValEquals('platform_editor_add_orange_highlight_color', 'cohort', 'test');
19
22
 
20
23
  // pixels, used to determine where to horizontally position the dropdown when space is limited
21
24
  // this should reflect the width of the dropdown when fully populated with colors, including translations due to layering
22
- const fitWidth = 242;
23
- let colorPalette = highlightColorPalette;
24
- colorPalette = highlightColorPalette.map(item => {
25
- if (item.label === 'Orange') {
26
- return {
27
- ...item,
28
- label: 'Yellow',
29
- message: colorPaletteMessages.yellow
30
- };
31
- }
32
- return item;
33
- });
25
+ const fitWidth = isOrangeHighlightEnabled ? 274 : 242;
26
+ let colorPalette;
27
+ if (isOrangeHighlightEnabled) {
28
+ colorPalette = highlightColorPaletteNext;
29
+ } else {
30
+ colorPalette = highlightColorPalette.map(item => {
31
+ if (item.label === 'Orange') {
32
+ return {
33
+ ...item,
34
+ label: 'Yellow',
35
+ message: colorPaletteMessages.yellow
36
+ };
37
+ }
38
+ return item;
39
+ });
40
+ }
34
41
  const {
35
42
  selectedRowIndex,
36
43
  selectedColumnIndex
37
- } = getSelectedRowAndColumnFromPalette(colorPalette, activeColor);
44
+ } = getSelectedRowAndColumnFromPalette(colorPalette, activeColor, isOrangeHighlightEnabled ? HIGHLIGHT_COLOR_PICKER_COLUMNS : undefined);
38
45
  return /*#__PURE__*/React.createElement(Dropdown, {
39
46
  mountTo: popupsMountPoint,
40
47
  boundariesElement: popupsBoundariesElement,
@@ -56,6 +63,7 @@ export const PaletteDropdown = props => {
56
63
  }, /*#__PURE__*/React.createElement("div", {
57
64
  "data-testid": "highlight-color-palette"
58
65
  }, /*#__PURE__*/React.createElement(ColorPalette, {
66
+ cols: isOrangeHighlightEnabled ? HIGHLIGHT_COLOR_PICKER_COLUMNS : undefined,
59
67
  onClick: onColorChange,
60
68
  selectedColor: activeColor,
61
69
  paletteOptions: {
@@ -1,7 +1,8 @@
1
1
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { bindKeymapWithCommand, keymap, toggleHighlightPalette, applyYellowHighlight } from '@atlaskit/editor-common/keymaps';
3
3
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
4
- import { highlightColorPalette } from '@atlaskit/editor-common/ui-color';
4
+ import { highlightColorPalette, highlightColorPaletteNext } from '@atlaskit/editor-common/ui-color';
5
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
6
  import { changeColor } from '../editor-commands/change-color';
6
7
  import { togglePalette } from '../editor-commands/palette';
7
8
  export function keymapPlugin(_ref) {
@@ -18,19 +19,23 @@ export function keymapPlugin(_ref) {
18
19
  inputMethod: INPUT_METHOD.SHORTCUT
19
20
  }), list);
20
21
  var analyticsApi = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
21
- // NOTE: This will work with fallback until we clean up `editor_text_highlight_orange_to_yellow`
22
- var color = highlightColorPalette.find(function (_ref2) {
22
+ var color = expValEquals('platform_editor_add_orange_highlight_color', 'cohort', 'test') ? highlightColorPaletteNext.find(function (_ref2) {
23
23
  var label = _ref2.label;
24
24
  return label === 'Yellow';
25
+ }) : highlightColorPalette.find(function (_ref3) {
26
+ var label = _ref3.label;
27
+ return label === 'Yellow';
25
28
  }) || {
26
29
  value: '#fedec8'
27
30
  };
28
- bindKeymapWithCommand(
29
- // Ignored via go/ees005
30
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
31
- applyYellowHighlight.common, editorCommandToPMCommand(changeColor(analyticsApi)({
32
- color: color.value,
33
- inputMethod: INPUT_METHOD.SHORTCUT
34
- })), list);
31
+ if (color) {
32
+ bindKeymapWithCommand(
33
+ // Ignored via go/ees005
34
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
35
+ applyYellowHighlight.common, editorCommandToPMCommand(changeColor(analyticsApi)({
36
+ color: color.value,
37
+ inputMethod: INPUT_METHOD.SHORTCUT
38
+ })), list);
39
+ }
35
40
  return keymap(list);
36
41
  }
@@ -2,10 +2,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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
3
  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
4
  import React from 'react';
5
- import { ColorPalette, colorPaletteMessages, getSelectedRowAndColumnFromPalette, highlightColorPalette } from '@atlaskit/editor-common/ui-color';
5
+ import { ColorPalette, colorPaletteMessages, getSelectedRowAndColumnFromPalette, highlightColorPalette, highlightColorPaletteNext } from '@atlaskit/editor-common/ui-color';
6
6
  import { ArrowKeyNavigationType, DropdownContainer as Dropdown } from '@atlaskit/editor-common/ui-menu';
7
7
  import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
8
8
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
9
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
+ var HIGHLIGHT_COLOR_PICKER_COLUMNS = 8;
9
11
  export var PaletteDropdown = function PaletteDropdown(props) {
10
12
  var popupsMountPoint = props.popupsMountPoint,
11
13
  popupsBoundariesElement = props.popupsBoundariesElement,
@@ -17,21 +19,26 @@ export var PaletteDropdown = function PaletteDropdown(props) {
17
19
  isOpenedByKeyboard = props.isOpenedByKeyboard,
18
20
  handleClickOutside = props.handleClickOutside,
19
21
  handleEscapeKeydown = props.handleEscapeKeydown;
22
+ var isOrangeHighlightEnabled = expValEquals('platform_editor_add_orange_highlight_color', 'cohort', 'test');
20
23
 
21
24
  // pixels, used to determine where to horizontally position the dropdown when space is limited
22
25
  // this should reflect the width of the dropdown when fully populated with colors, including translations due to layering
23
- var fitWidth = 242;
24
- var colorPalette = highlightColorPalette;
25
- colorPalette = highlightColorPalette.map(function (item) {
26
- if (item.label === 'Orange') {
27
- return _objectSpread(_objectSpread({}, item), {}, {
28
- label: 'Yellow',
29
- message: colorPaletteMessages.yellow
30
- });
31
- }
32
- return item;
33
- });
34
- var _getSelectedRowAndCol = getSelectedRowAndColumnFromPalette(colorPalette, activeColor),
26
+ var fitWidth = isOrangeHighlightEnabled ? 274 : 242;
27
+ var colorPalette;
28
+ if (isOrangeHighlightEnabled) {
29
+ colorPalette = highlightColorPaletteNext;
30
+ } else {
31
+ colorPalette = highlightColorPalette.map(function (item) {
32
+ if (item.label === 'Orange') {
33
+ return _objectSpread(_objectSpread({}, item), {}, {
34
+ label: 'Yellow',
35
+ message: colorPaletteMessages.yellow
36
+ });
37
+ }
38
+ return item;
39
+ });
40
+ }
41
+ var _getSelectedRowAndCol = getSelectedRowAndColumnFromPalette(colorPalette, activeColor, isOrangeHighlightEnabled ? HIGHLIGHT_COLOR_PICKER_COLUMNS : undefined),
35
42
  selectedRowIndex = _getSelectedRowAndCol.selectedRowIndex,
36
43
  selectedColumnIndex = _getSelectedRowAndCol.selectedColumnIndex;
37
44
  return /*#__PURE__*/React.createElement(Dropdown, {
@@ -55,6 +62,7 @@ export var PaletteDropdown = function PaletteDropdown(props) {
55
62
  }, /*#__PURE__*/React.createElement("div", {
56
63
  "data-testid": "highlight-color-palette"
57
64
  }, /*#__PURE__*/React.createElement(ColorPalette, {
65
+ cols: isOrangeHighlightEnabled ? HIGHLIGHT_COLOR_PICKER_COLUMNS : undefined,
58
66
  onClick: onColorChange,
59
67
  selectedColor: activeColor,
60
68
  paletteOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-highlight",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "Highlight plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  ".": "./src/index.ts"
36
36
  },
37
37
  "dependencies": {
38
- "@atlaskit/adf-schema": "^49.0.5",
38
+ "@atlaskit/adf-schema": "^49.0.6",
39
39
  "@atlaskit/editor-palette": "^2.1.0",
40
40
  "@atlaskit/editor-plugin-analytics": "^3.0.0",
41
41
  "@atlaskit/editor-plugin-primary-toolbar": "^4.0.0",
@@ -47,13 +47,13 @@
47
47
  "@atlaskit/icon": "^27.3.0",
48
48
  "@atlaskit/platform-feature-flags": "^1.1.0",
49
49
  "@atlaskit/primitives": "^14.10.0",
50
- "@atlaskit/tmp-editor-statsig": "^9.3.0",
51
- "@atlaskit/tokens": "^5.4.0",
50
+ "@atlaskit/tmp-editor-statsig": "^9.6.0",
51
+ "@atlaskit/tokens": "^5.5.0",
52
52
  "@babel/runtime": "^7.0.0",
53
53
  "@emotion/react": "^11.7.1"
54
54
  },
55
55
  "peerDependencies": {
56
- "@atlaskit/editor-common": "^107.7.0",
56
+ "@atlaskit/editor-common": "^107.8.0",
57
57
  "react": "^18.2.0",
58
58
  "react-intl-next": "npm:react-intl@^5.18.1"
59
59
  },