@atlaskit/editor-common 71.0.3 → 72.0.1

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.
Files changed (148) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/dist/cjs/analytics/types/enums.js +20 -1
  3. package/dist/cjs/i18n/index.js +13 -5
  4. package/dist/cjs/i18n/languages.js +42 -0
  5. package/dist/cjs/keymaps/index.js +56 -6
  6. package/dist/cjs/styles/index.js +8 -2
  7. package/dist/cjs/styles/shared/annotation.js +9 -14
  8. package/dist/cjs/styles/shared/block-marks.js +1 -1
  9. package/dist/cjs/styles/shared/blockquote.js +1 -3
  10. package/dist/cjs/styles/shared/code-block.js +13 -16
  11. package/dist/cjs/styles/shared/code-mark.js +2 -4
  12. package/dist/cjs/styles/shared/lists.js +55 -4
  13. package/dist/cjs/styles/shared/panel.js +29 -39
  14. package/dist/cjs/styles/shared/rule.js +2 -4
  15. package/dist/cjs/styles/shared/shadow.js +1 -1
  16. package/dist/cjs/styles/shared/table.js +24 -26
  17. package/dist/cjs/types/next-editor-plugin.js +5 -0
  18. package/dist/cjs/ui/Caption/index.js +2 -4
  19. package/dist/cjs/ui/DropList/index.js +5 -7
  20. package/dist/cjs/ui/Emoji/index.js +11 -2
  21. package/dist/cjs/ui/Expand/index.js +17 -19
  22. package/dist/cjs/ui/Messages/index.js +3 -5
  23. package/dist/cjs/ui/Popup/index.js +72 -2
  24. package/dist/cjs/ui/Popup/utils.js +13 -6
  25. package/dist/cjs/ui/UnsupportedBlock/index.js +3 -5
  26. package/dist/cjs/ui/UnsupportedInline/index.js +3 -5
  27. package/dist/cjs/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +138 -0
  28. package/dist/cjs/ui-color/ColorPalette/index.js +20 -2
  29. package/dist/cjs/ui-menu/DropdownMenu/index.js +12 -12
  30. package/dist/cjs/ui-menu/ToolbarButton/index.js +3 -1
  31. package/dist/cjs/utils/analytics.js +1 -38
  32. package/dist/cjs/utils/builder.js +44 -0
  33. package/dist/cjs/utils/compareNodes.js +86 -33
  34. package/dist/cjs/utils/index.js +47 -1
  35. package/dist/cjs/utils/list.js +47 -0
  36. package/dist/cjs/utils/plugin-state-factory.js +9 -9
  37. package/dist/cjs/utils/referentiality.js +281 -2
  38. package/dist/cjs/utils/track-unsupported-content.js +19 -20
  39. package/dist/cjs/utils/validate-using-spec.js +8 -2
  40. package/dist/cjs/version.json +1 -1
  41. package/dist/es2019/analytics/types/enums.js +20 -1
  42. package/dist/es2019/i18n/index.js +4 -3
  43. package/dist/es2019/i18n/languages.js +34 -0
  44. package/dist/es2019/keymaps/index.js +48 -2
  45. package/dist/es2019/styles/index.js +1 -1
  46. package/dist/es2019/styles/shared/annotation.js +9 -13
  47. package/dist/es2019/styles/shared/block-marks.js +8 -1
  48. package/dist/es2019/styles/shared/blockquote.js +1 -2
  49. package/dist/es2019/styles/shared/code-block.js +18 -18
  50. package/dist/es2019/styles/shared/code-mark.js +2 -3
  51. package/dist/es2019/styles/shared/lists.js +44 -2
  52. package/dist/es2019/styles/shared/panel.js +29 -37
  53. package/dist/es2019/styles/shared/rule.js +2 -3
  54. package/dist/es2019/styles/shared/shadow.js +20 -6
  55. package/dist/es2019/styles/shared/table.js +24 -26
  56. package/dist/es2019/types/next-editor-plugin.js +1 -0
  57. package/dist/es2019/ui/Caption/index.js +2 -3
  58. package/dist/es2019/ui/DropList/index.js +5 -6
  59. package/dist/es2019/ui/Emoji/index.js +11 -2
  60. package/dist/es2019/ui/Expand/index.js +17 -18
  61. package/dist/es2019/ui/Messages/index.js +3 -4
  62. package/dist/es2019/ui/Popup/index.js +68 -2
  63. package/dist/es2019/ui/Popup/utils.js +13 -6
  64. package/dist/es2019/ui/UnsupportedBlock/index.js +3 -4
  65. package/dist/es2019/ui/UnsupportedInline/index.js +3 -4
  66. package/dist/es2019/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +120 -0
  67. package/dist/es2019/ui-color/ColorPalette/index.js +29 -13
  68. package/dist/es2019/ui-menu/DropdownMenu/index.js +13 -12
  69. package/dist/es2019/ui-menu/ToolbarButton/index.js +3 -1
  70. package/dist/es2019/utils/analytics.js +0 -33
  71. package/dist/es2019/utils/builder.js +16 -0
  72. package/dist/es2019/utils/compareNodes.js +79 -28
  73. package/dist/es2019/utils/index.js +4 -2
  74. package/dist/es2019/utils/list.js +31 -0
  75. package/dist/es2019/utils/plugin-state-factory.js +9 -9
  76. package/dist/es2019/utils/referentiality.js +240 -0
  77. package/dist/es2019/utils/track-unsupported-content.js +20 -16
  78. package/dist/es2019/utils/validate-using-spec.js +8 -2
  79. package/dist/es2019/version.json +1 -1
  80. package/dist/esm/analytics/types/enums.js +20 -1
  81. package/dist/esm/i18n/index.js +4 -3
  82. package/dist/esm/i18n/languages.js +34 -0
  83. package/dist/esm/keymaps/index.js +49 -2
  84. package/dist/esm/styles/index.js +1 -1
  85. package/dist/esm/styles/shared/annotation.js +9 -13
  86. package/dist/esm/styles/shared/block-marks.js +1 -1
  87. package/dist/esm/styles/shared/blockquote.js +1 -2
  88. package/dist/esm/styles/shared/code-block.js +13 -15
  89. package/dist/esm/styles/shared/code-mark.js +2 -3
  90. package/dist/esm/styles/shared/lists.js +49 -2
  91. package/dist/esm/styles/shared/panel.js +29 -37
  92. package/dist/esm/styles/shared/rule.js +2 -3
  93. package/dist/esm/styles/shared/shadow.js +1 -2
  94. package/dist/esm/styles/shared/table.js +24 -26
  95. package/dist/esm/types/next-editor-plugin.js +1 -0
  96. package/dist/esm/ui/Caption/index.js +2 -3
  97. package/dist/esm/ui/DropList/index.js +5 -6
  98. package/dist/esm/ui/Emoji/index.js +11 -2
  99. package/dist/esm/ui/Expand/index.js +17 -18
  100. package/dist/esm/ui/Messages/index.js +3 -4
  101. package/dist/esm/ui/Popup/index.js +73 -2
  102. package/dist/esm/ui/Popup/utils.js +13 -6
  103. package/dist/esm/ui/UnsupportedBlock/index.js +2 -3
  104. package/dist/esm/ui/UnsupportedInline/index.js +2 -3
  105. package/dist/esm/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +124 -0
  106. package/dist/esm/ui-color/ColorPalette/index.js +19 -3
  107. package/dist/esm/ui-menu/DropdownMenu/index.js +12 -11
  108. package/dist/esm/ui-menu/ToolbarButton/index.js +3 -1
  109. package/dist/esm/utils/analytics.js +0 -33
  110. package/dist/esm/utils/builder.js +30 -0
  111. package/dist/esm/utils/compareNodes.js +83 -32
  112. package/dist/esm/utils/index.js +4 -2
  113. package/dist/esm/utils/list.js +31 -0
  114. package/dist/esm/utils/plugin-state-factory.js +9 -9
  115. package/dist/esm/utils/referentiality.js +269 -0
  116. package/dist/esm/utils/track-unsupported-content.js +19 -20
  117. package/dist/esm/utils/validate-using-spec.js +8 -2
  118. package/dist/esm/version.json +1 -1
  119. package/dist/types/analytics/types/enums.d.ts +23 -4
  120. package/dist/types/collab/types.d.ts +1 -1
  121. package/dist/types/i18n/index.d.ts +4 -3
  122. package/dist/types/i18n/languages.d.ts +35 -0
  123. package/dist/types/keymaps/index.d.ts +1 -0
  124. package/dist/types/styles/index.d.ts +1 -1
  125. package/dist/types/styles/shared/lists.d.ts +3 -1
  126. package/dist/types/types/collab.d.ts +1 -1
  127. package/dist/types/types/copy-button.d.ts +4 -0
  128. package/dist/types/types/feature-flags.d.ts +30 -25
  129. package/dist/types/types/floating-toolbar.d.ts +26 -1
  130. package/dist/types/types/index.d.ts +2 -1
  131. package/dist/types/types/next-editor-plugin.d.ts +61 -0
  132. package/dist/types/ui/Emoji/index.d.ts +2 -0
  133. package/dist/types/ui/Popup/index.d.ts +19 -0
  134. package/dist/types/ui/Popup/utils.d.ts +3 -3
  135. package/dist/types/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.d.ts +214 -0
  136. package/dist/types/ui-color/ColorPalette/index.d.ts +7 -0
  137. package/dist/types/ui-menu/DropdownMenu/types.d.ts +1 -0
  138. package/dist/types/ui-menu/ToolbarButton/index.d.ts +3 -1
  139. package/dist/types/utils/analytics.d.ts +1 -21
  140. package/dist/types/utils/builder.d.ts +8 -0
  141. package/dist/types/utils/compareNodes.d.ts +16 -0
  142. package/dist/types/utils/index.d.ts +3 -1
  143. package/dist/types/utils/list.d.ts +10 -0
  144. package/dist/types/utils/plugin-state-factory.d.ts +1 -1
  145. package/dist/types/utils/referentiality.d.ts +4 -0
  146. package/dist/types/utils/track-unsupported-content.d.ts +14 -2
  147. package/package.json +15 -12
  148. package/report.api.md +1 -1
@@ -15,6 +15,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
15
15
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
16
 
17
17
  import React from 'react';
18
+ import createFocusTrap from 'focus-trap';
18
19
  import rafSchedule from 'raf-schd';
19
20
  import { createPortal } from 'react-dom';
20
21
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
@@ -44,6 +45,8 @@ var Popup = /*#__PURE__*/function (_React$Component) {
44
45
  validPosition: true
45
46
  });
46
47
 
48
+ _defineProperty(_assertThisInitialized(_this), "popupRef", /*#__PURE__*/React.createRef());
49
+
47
50
  _defineProperty(_assertThisInitialized(_this), "placement", ['', '']);
48
51
 
49
52
  _defineProperty(_assertThisInitialized(_this), "handleRef", function (popup) {
@@ -66,6 +69,25 @@ var Popup = /*#__PURE__*/function (_React$Component) {
66
69
  _this.scheduledUpdatePosition(_this.props);
67
70
  }) : undefined);
68
71
 
72
+ _defineProperty(_assertThisInitialized(_this), "initFocusTrap", rafSchedule(function () {
73
+ var popup = _this.popupRef.current;
74
+
75
+ if (!popup) {
76
+ return;
77
+ }
78
+
79
+ var trapConfig = {
80
+ clickOutsideDeactivates: true,
81
+ escapeDeactivates: true,
82
+ initialFocus: popup,
83
+ fallbackFocus: popup,
84
+ returnFocusOnDeactivate: false
85
+ };
86
+ _this.focusTrap = createFocusTrap(popup, trapConfig);
87
+
88
+ _this.focusTrap.activate();
89
+ }));
90
+
69
91
  return _this;
70
92
  }
71
93
 
@@ -88,13 +110,14 @@ var Popup = /*#__PURE__*/function (_React$Component) {
88
110
  stick = props.stick,
89
111
  forcePlacement = props.forcePlacement,
90
112
  allowOutOfBounds = props.allowOutOfBounds,
91
- rect = props.rect;
113
+ rect = props.rect,
114
+ preventOverflow = props.preventOverflow;
92
115
 
93
116
  if (!target || !popup) {
94
117
  return {};
95
118
  }
96
119
 
97
- var placement = calculatePlacement(target, boundariesElement || document.body, fitWidth, fitHeight, alignX, alignY, forcePlacement);
120
+ var placement = calculatePlacement(target, boundariesElement || document.body, fitWidth, fitHeight, alignX, alignY, forcePlacement, preventOverflow);
98
121
 
99
122
  if (onPlacementChanged && this.placement.join('') !== placement.join('')) {
100
123
  onPlacementChanged(placement);
@@ -156,6 +179,7 @@ var Popup = /*#__PURE__*/function (_React$Component) {
156
179
  }, {
157
180
  key: "initPopup",
158
181
  value: function initPopup(popup) {
182
+ this.popupRef.current = popup;
159
183
  var target = this.props.target;
160
184
  var overflowScrollParent = findOverflowScrollParent(popup);
161
185
 
@@ -179,6 +203,10 @@ var Popup = /*#__PURE__*/function (_React$Component) {
179
203
  */
180
204
 
181
205
  this.scheduledUpdatePosition(this.props);
206
+
207
+ if (this.props.focusTrap) {
208
+ this.initFocusTrap();
209
+ }
182
210
  }
183
211
  }, {
184
212
  key: "UNSAFE_componentWillReceiveProps",
@@ -187,6 +215,48 @@ var Popup = /*#__PURE__*/function (_React$Component) {
187
215
  // get rendered and we end up with a wrong position
188
216
  this.scheduledUpdatePosition(newProps);
189
217
  }
218
+ }, {
219
+ key: "destroyFocusTrap",
220
+ value:
221
+ /**
222
+ * Cancels the initialisation of the focus trap if it has not yet occured
223
+ * Deactivates the focus trap if it exists
224
+ */
225
+ function destroyFocusTrap() {
226
+ var _this$focusTrap;
227
+
228
+ this.initFocusTrap.cancel();
229
+ (_this$focusTrap = this.focusTrap) === null || _this$focusTrap === void 0 ? void 0 : _this$focusTrap.deactivate();
230
+ }
231
+ /**
232
+ * Handle pausing, unpausing, and initialising (if not yet initialised) of the focus trap
233
+ */
234
+
235
+ }, {
236
+ key: "handleChangedFocusTrapProp",
237
+ value: function handleChangedFocusTrapProp(prevProps) {
238
+ if (prevProps.focusTrap !== this.props.focusTrap) {
239
+ // If currently set to disable, then pause the trap if it exists
240
+ if (!this.props.focusTrap) {
241
+ var _this$focusTrap2;
242
+
243
+ return (_this$focusTrap2 = this.focusTrap) === null || _this$focusTrap2 === void 0 ? void 0 : _this$focusTrap2.pause();
244
+ } // If set to enabled and trap already exists, unpause
245
+
246
+
247
+ if (this.focusTrap) {
248
+ this.focusTrap.unpause();
249
+ } // Else initialise the focus trap
250
+
251
+
252
+ return this.initFocusTrap();
253
+ }
254
+ }
255
+ }, {
256
+ key: "componentDidUpdate",
257
+ value: function componentDidUpdate(prevProps) {
258
+ this.handleChangedFocusTrapProp(prevProps);
259
+ }
190
260
  }, {
191
261
  key: "componentDidMount",
192
262
  value: function componentDidMount() {
@@ -222,6 +292,7 @@ var Popup = /*#__PURE__*/function (_React$Component) {
222
292
  }
223
293
 
224
294
  this.scheduledUpdatePosition.cancel();
295
+ this.destroyFocusTrap();
225
296
  }
226
297
  }, {
227
298
  key: "renderPopup",
@@ -15,7 +15,7 @@ export function isTextNode(elem) {
15
15
  * Decides if given fitHeight fits below or above the target taking boundaries into account.
16
16
  */
17
17
 
18
- export function getVerticalPlacement(target, boundariesElement, fitHeight, alignY, forcePlacement) {
18
+ export function getVerticalPlacement(target, boundariesElement, fitHeight, alignY, forcePlacement, preventOverflow) {
19
19
  if (forcePlacement && alignY) {
20
20
  return alignY;
21
21
  }
@@ -37,7 +37,13 @@ export function getVerticalPlacement(target, boundariesElement, fitHeight, align
37
37
  targetHeight = _target$getBoundingCl.height;
38
38
 
39
39
  var spaceAbove = targetTop - (boundariesTop - boundariesElement.scrollTop);
40
- var spaceBelow = boundariesTop + boundariesHeight - (targetTop + targetHeight);
40
+ var spaceBelow = boundariesTop + boundariesHeight - (targetTop + targetHeight); // Force vertical placement to bottom if the space above doesn't accomodate the fitHeight
41
+
42
+ if (preventOverflow) {
43
+ if (spaceAbove <= fitHeight) {
44
+ return 'bottom';
45
+ }
46
+ }
41
47
 
42
48
  if (spaceBelow >= fitHeight || spaceBelow >= spaceAbove) {
43
49
  return 'bottom';
@@ -49,8 +55,9 @@ export function getVerticalPlacement(target, boundariesElement, fitHeight, align
49
55
  * Decides if given fitWidth fits to the left or to the right of the target taking boundaries into account.
50
56
  */
51
57
 
52
- export function getHorizontalPlacement(target, boundariesElement, fitWidth, alignX, forcePlacement) {
53
- if (forcePlacement && alignX) {
58
+ export function getHorizontalPlacement(target, boundariesElement, fitWidth, alignX, forcePlacement, preventOverflow) {
59
+ // force placement unless preventOverflow is enabled
60
+ if (forcePlacement && alignX && !preventOverflow) {
54
61
  return alignX;
55
62
  }
56
63
 
@@ -81,8 +88,8 @@ export function getHorizontalPlacement(target, boundariesElement, fitWidth, alig
81
88
 
82
89
  return 'right';
83
90
  }
84
- export function calculatePlacement(target, boundariesElement, fitWidth, fitHeight, alignX, alignY, forcePlacement) {
85
- return [getVerticalPlacement(target, boundariesElement, fitHeight, alignY, forcePlacement), getHorizontalPlacement(target, boundariesElement, fitWidth, alignX, forcePlacement)];
91
+ export function calculatePlacement(target, boundariesElement, fitWidth, fitHeight, alignX, alignY, forcePlacement, preventOverflow) {
92
+ return [getVerticalPlacement(target, boundariesElement, fitHeight, alignY, forcePlacement, preventOverflow), getHorizontalPlacement(target, boundariesElement, fitWidth, alignX, forcePlacement, preventOverflow)];
86
93
  }
87
94
 
88
95
  var calculateHorizontalPlacement = function calculateHorizontalPlacement(_ref) {
@@ -10,13 +10,12 @@ import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
10
10
  import QuestionsIcon from '@atlaskit/icon/glyph/question-circle';
11
11
  import { N30, N50 } from '@atlaskit/theme/colors';
12
12
  import { borderRadius, fontSize } from '@atlaskit/theme/constants';
13
- import { token } from '@atlaskit/tokens';
14
13
  import Tooltip from '@atlaskit/tooltip';
14
+ import { ACTION_SUBJECT_ID } from '../../analytics';
15
15
  import { unsupportedContentMessages } from '../../messages/unsupportedContent';
16
- import { ACTION_SUBJECT_ID } from '../../utils/analytics';
17
16
  import { trackUnsupportedContentTooltipDisplayedFor } from '../../utils/track-unsupported-content';
18
17
  import { getUnsupportedContent } from '../unsupported-content-helper';
19
- var blockNodeStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: ", ";\n border: 1px dashed ", ";\n border-radius: ", "px;\n box-sizing: border-box;\n cursor: default;\n display: flex;\n font-size: ", ";\n margin: 10px 0;\n min-height: 24px;\n padding: 10px;\n text-align: center;\n vertical-align: text-bottom;\n min-width: 120px;\n align-items: center;\n justify-content: center;\n"])), token('color.background.disabled', N30), token('color.border.disabled', N50), borderRadius(), relativeFontSizeToBase16(fontSize()));
18
+ var blockNodeStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: ", ";\n border: 1px dashed ", ";\n border-radius: ", "px;\n box-sizing: border-box;\n cursor: default;\n display: flex;\n font-size: ", ";\n margin: 10px 0;\n min-height: 24px;\n padding: 10px;\n text-align: center;\n vertical-align: text-bottom;\n min-width: 120px;\n align-items: center;\n justify-content: center;\n"])), "var(--ds-background-disabled, ".concat(N30, ")"), "var(--ds-border-disabled, ".concat(N50, ")"), borderRadius(), relativeFontSizeToBase16(fontSize()));
20
19
 
21
20
  var UnsupportedBlockNode = function UnsupportedBlockNode(_ref) {
22
21
  var node = _ref.node,
@@ -10,13 +10,12 @@ import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
10
10
  import QuestionsIcon from '@atlaskit/icon/glyph/question-circle';
11
11
  import { N30, N50 } from '@atlaskit/theme/colors';
12
12
  import { borderRadius, fontSize } from '@atlaskit/theme/constants';
13
- import { token } from '@atlaskit/tokens';
14
13
  import Tooltip from '@atlaskit/tooltip';
14
+ import { ACTION_SUBJECT_ID } from '../../analytics';
15
15
  import { unsupportedContentMessages } from '../../messages/unsupportedContent';
16
- import { ACTION_SUBJECT_ID } from '../../utils/analytics';
17
16
  import { trackUnsupportedContentTooltipDisplayedFor } from '../../utils/track-unsupported-content';
18
17
  import { getUnsupportedContent } from '../unsupported-content-helper';
19
- var inlineNodeStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n align-items: center;\n background: ", ";\n border: 1px dashed ", ";\n border-radius: ", "px;\n box-sizing: border-box;\n cursor: default;\n display: inline-flex;\n font-size: ", ";\n margin: 0 2px;\n min-height: 24px;\n padding: 0 10px;\n vertical-align: middle;\n white-space: nowrap;\n"])), token('color.background.disabled', N30), token('color.border.disabled', N50), borderRadius(), relativeFontSizeToBase16(fontSize()));
18
+ var inlineNodeStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n align-items: center;\n background: ", ";\n border: 1px dashed ", ";\n border-radius: ", "px;\n box-sizing: border-box;\n cursor: default;\n display: inline-flex;\n font-size: ", ";\n margin: 0 2px;\n min-height: 24px;\n padding: 0 10px;\n vertical-align: middle;\n white-space: nowrap;\n"])), "var(--ds-background-disabled, ".concat(N30, ")"), "var(--ds-border-disabled, ".concat(N50, ")"), borderRadius(), relativeFontSizeToBase16(fontSize()));
20
19
 
21
20
  var UnsupportedInlineNode = function UnsupportedInlineNode(_ref) {
22
21
  var node = _ref.node,
@@ -0,0 +1,124 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
7
+ import { defineMessages } from 'react-intl-next'; // These messages are only to be used when useSomewhatSemanticTextColorNames feature flag is true.
8
+ // They are used only in Jira and are part of work for https://product-fabric.atlassian.net/wiki/spaces/EUXQ/pages/3365994869/EXTERNAL+MAKE+PP+COMMIT-5058+Enable+dark+mode+usage+of+text+colors+in+UGC+and+non+custom+panels+in+Jira
9
+
10
+ export var newLightPalette = defineMessages({
11
+ '#FFFFFF': {
12
+ id: 'fabric.theme.white',
13
+ defaultMessage: 'White',
14
+ description: 'Name of a color'
15
+ },
16
+ '#B3D4FF': {
17
+ id: 'fabric.theme.subtle-blue',
18
+ defaultMessage: 'Subtle blue',
19
+ description: 'Name of a color'
20
+ },
21
+ '#B3F5FF': {
22
+ id: 'fabric.theme.subtle-teal',
23
+ defaultMessage: 'Subtle teal',
24
+ description: 'Name of a color'
25
+ },
26
+ '#ABF5D1': {
27
+ id: 'fabric.theme.subtle-green',
28
+ defaultMessage: 'Subtle green',
29
+ description: 'Name of a color'
30
+ },
31
+ '#FFF0B3': {
32
+ id: 'fabric.theme.subtle-yellow',
33
+ defaultMessage: 'Subtle yellow',
34
+ description: 'Name of a color'
35
+ },
36
+ '#FFBDAD': {
37
+ id: 'fabric.theme.subtle-red',
38
+ defaultMessage: 'Subtle red',
39
+ description: 'Name of a color'
40
+ },
41
+ '#EAE6FF': {
42
+ id: 'fabric.theme.subtle-purple',
43
+ defaultMessage: 'Subtle purple',
44
+ description: 'Name of a color'
45
+ },
46
+ '#97A0AF': {
47
+ id: 'fabric.theme.gray',
48
+ defaultMessage: 'Gray',
49
+ description: 'Name of a color'
50
+ },
51
+ '#4C9AFF': {
52
+ id: 'fabric.theme.blue',
53
+ defaultMessage: 'Blue',
54
+ description: 'Name of a color'
55
+ },
56
+ '#00B8D9': {
57
+ id: 'fabric.theme.teal',
58
+ defaultMessage: 'Teal',
59
+ description: 'Name of a color'
60
+ },
61
+ '#36B37E': {
62
+ id: 'fabric.theme.green',
63
+ defaultMessage: 'Green',
64
+ description: 'Name of a color'
65
+ },
66
+ '#FFC400': {
67
+ id: 'fabric.theme.yellow',
68
+ defaultMessage: 'Yellow',
69
+ description: 'Name of a color'
70
+ },
71
+ '#FF5630': {
72
+ id: 'fabric.theme.red',
73
+ defaultMessage: 'Red',
74
+ description: 'Name of a color'
75
+ },
76
+ '#FF991F': {
77
+ id: 'fabric.theme.bold-orange',
78
+ defaultMessage: 'Bold orange',
79
+ description: 'Name of a color.'
80
+ },
81
+ '#6554C0': {
82
+ id: 'fabric.theme.purple',
83
+ defaultMessage: 'Purple',
84
+ description: 'Name of a color'
85
+ },
86
+ '#0747A6': {
87
+ id: 'fabric.theme.bold-blue',
88
+ defaultMessage: 'Bold blue',
89
+ description: 'Name of a color'
90
+ },
91
+ '#008DA6': {
92
+ id: 'fabric.theme.bold-teal',
93
+ defaultMessage: 'Bold teal',
94
+ description: 'Name of a color'
95
+ },
96
+ '#006644': {
97
+ id: 'fabric.theme.bold-green',
98
+ defaultMessage: 'Bold green',
99
+ description: 'Name of a color'
100
+ },
101
+ '#BF2600': {
102
+ id: 'fabric.theme.bold-red',
103
+ defaultMessage: 'Bold red',
104
+ description: 'Name of a color'
105
+ },
106
+ '#403294': {
107
+ id: 'fabric.theme.bold-purple',
108
+ defaultMessage: 'Bold purple',
109
+ description: 'Name of a color'
110
+ },
111
+ '#172B4D': {
112
+ id: 'fabric.theme.default',
113
+ defaultMessage: 'Default',
114
+ description: 'Name of a color'
115
+ }
116
+ });
117
+ var darkModeWhite = defineMessages({
118
+ '#FFFFFF': {
119
+ id: 'fabric.theme.dark-gray',
120
+ defaultMessage: 'Dark gray',
121
+ description: 'Name of a color'
122
+ }
123
+ });
124
+ export var newDarkPalette = _objectSpread(_objectSpread({}, newLightPalette), darkModeWhite);
@@ -4,8 +4,10 @@ import { jsx } from '@emotion/react';
4
4
  import chromatism from 'chromatism';
5
5
  import { injectIntl } from 'react-intl-next';
6
6
  import { N0, N500 } from '@atlaskit/theme/colors';
7
- import { token } from '@atlaskit/tokens';
7
+ import { useThemeObserver } from '@atlaskit/tokens';
8
8
  import Color from './Color';
9
+ import getColorMessage from './Palettes/getColorMessage';
10
+ import { newDarkPalette, newLightPalette } from './Palettes/paletteMessagesTokenModeNames';
9
11
  import { colorPaletteWrapper } from './styles';
10
12
 
11
13
  /**
@@ -29,7 +31,7 @@ function getCheckMarkColor(color, textPalette) {
29
31
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
30
32
 
31
33
 
32
- return contrastColor === N0 ? token('color.icon.inverse', N0) : token('color.icon', N500);
34
+ return contrastColor === N0 ? "var(--ds-icon-inverse, ".concat(N0, ")") : "var(--ds-icon, ".concat(N500, ")");
33
35
  }
34
36
 
35
37
  var ColorPalette = function ColorPalette(props) {
@@ -41,7 +43,10 @@ var ColorPalette = function ColorPalette(props) {
41
43
  className = props.className,
42
44
  formatMessage = props.intl.formatMessage,
43
45
  _props$textPalette = props.textPalette,
44
- textPalette = _props$textPalette === void 0 ? false : _props$textPalette;
46
+ textPalette = _props$textPalette === void 0 ? false : _props$textPalette,
47
+ _props$useSomewhatSem = props.useSomewhatSemanticTextColorNames,
48
+ useSomewhatSemanticTextColorNames = _props$useSomewhatSem === void 0 ? false : _props$useSomewhatSem;
49
+ var tokenTheme = useThemeObserver();
45
50
  var colorsPerRow = React.useMemo(function () {
46
51
  return palette.reduce(function (resultArray, item, index) {
47
52
  var chunkIndex = Math.floor(index / cols);
@@ -62,6 +67,17 @@ var ColorPalette = function ColorPalette(props) {
62
67
  label = _ref.label,
63
68
  border = _ref.border,
64
69
  message = _ref.message;
70
+
71
+ if (textPalette === true && useSomewhatSemanticTextColorNames) {
72
+ if (tokenTheme === 'dark') {
73
+ message = getColorMessage(newDarkPalette, value.toUpperCase());
74
+ }
75
+
76
+ if (tokenTheme === 'light') {
77
+ message = getColorMessage(newLightPalette, value.toUpperCase());
78
+ }
79
+ }
80
+
65
81
  return jsx(Color, {
66
82
  key: value,
67
83
  value: value,
@@ -23,14 +23,13 @@ import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
23
23
  import { CustomItem, MenuGroup } from '@atlaskit/menu';
24
24
  import { B100, DN600, DN80, N70, N900 } from '@atlaskit/theme/colors';
25
25
  import { themed } from '@atlaskit/theme/components';
26
- import { token } from '@atlaskit/tokens';
27
26
  import Tooltip from '@atlaskit/tooltip';
28
27
  import { withReactEditorViewOuterListeners } from '../../ui-react';
29
28
  import DropList from '../../ui/DropList';
30
29
  import Popup from '../../ui/Popup';
31
30
  import { MenuArrowKeyNavigationProvider } from '../MenuArrowKeyNavigationProvider';
32
31
  var wrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* tooltip in ToolbarButton is display:block */\n & > div > div {\n display: flex;\n }\n"])));
33
- var focusedMenuItemStyle = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n box-shadow: inset 0px 0px 0px 2px ", ";\n outline: none;\n"])), token('color.border.focused', B100));
32
+ var focusedMenuItemStyle = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n box-shadow: inset 0px 0px 0px 2px ", ";\n outline: none;\n"])), "var(--ds-border-focused, ".concat(B100, ")"));
34
33
 
35
34
  var buttonStyles = function buttonStyles(isActive) {
36
35
  return function (theme) {
@@ -38,20 +37,20 @@ var buttonStyles = function buttonStyles(isActive) {
38
37
  /**
39
38
  * Hack for item to imitate old dropdown-menu selected styles
40
39
  */
41
- return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n > span,\n > span:hover,\n > span:active {\n background: ", ";\n color: ", ";\n }\n :focus > span[aria-disabled='false'] {\n ", ";\n }\n :focus-visible,\n :focus-visible > span[aria-disabled='false'] {\n outline: none;\n }\n "])), token('color.background.selected', '#6c798f'), token('color.text', '#fff'), focusedMenuItemStyle);
40
+ return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n > span,\n > span:hover,\n > span:active {\n background: ", ";\n color: ", ";\n }\n :focus > span[aria-disabled='false'] {\n ", ";\n }\n :focus-visible,\n :focus-visible > span[aria-disabled='false'] {\n outline: none;\n }\n "])), "var(--ds-background-selected, #6c798f)", "var(--ds-text, #fff)", focusedMenuItemStyle);
42
41
  } else {
43
42
  return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n > span:hover[aria-disabled='false'] {\n color: ", ";\n background-color: ", ";\n }\n > span:active[aria-disabled='false'] {\n background-color: ", ";\n }\n > span[aria-disabled='true'] {\n color: ", ";\n }\n :focus > span[aria-disabled='false'] {\n ", ";\n }\n :focus-visible,\n :focus-visible > span[aria-disabled='false'] {\n outline: none;\n }\n "])), themed({
44
- light: token('color.text', N900),
45
- dark: token('color.text', DN600)
43
+ light: "var(--ds-text, ".concat(N900, ")"),
44
+ dark: "var(--ds-text, ".concat(DN600, ")")
46
45
  })(theme), themed({
47
- light: token('color.background.neutral.subtle.hovered', 'rgb(244, 245, 247)'),
48
- dark: token('color.background.neutral.subtle.hovered', 'rgb(59, 71, 92)')
46
+ light: "var(--ds-background-neutral-subtle-hovered, rgb(244, 245, 247))",
47
+ dark: "var(--ds-background-neutral-subtle-hovered, rgb(59, 71, 92))"
49
48
  })(theme), themed({
50
- light: token('color.background.neutral.subtle.pressed', 'rgb(179, 212, 255)'),
51
- dark: token('color.background.neutral.subtle.pressed', 'rgb(179, 212, 255)')
49
+ light: "var(--ds-background-neutral-subtle-pressed, rgb(179, 212, 255))",
50
+ dark: "var(--ds-background-neutral-subtle-pressed, rgb(179, 212, 255))"
52
51
  })(theme), themed({
53
- light: token('color.text.disabled', N70),
54
- dark: token('color.text.disabled', DN80)
52
+ light: "var(--ds-text-disabled, ".concat(N70, ")"),
53
+ dark: "var(--ds-text-disabled, ".concat(DN80, ")")
55
54
  })(theme), focusedMenuItemStyle); // The deafut focus-visible style is removed to ensure consistency across browsers
56
55
  }
57
56
  };
@@ -243,6 +242,7 @@ function DropdownMenuItem(_ref) {
243
242
  }, jsx(CustomItem, {
244
243
  item: item,
245
244
  key: (_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : String(item.content),
245
+ testId: "dropdown-item__".concat(String(item.content)),
246
246
  role: shouldUseDefaultRole ? 'button' : 'menuitem',
247
247
  iconBefore: item.elemBefore,
248
248
  iconAfter: item.elemAfter,
@@ -254,6 +254,7 @@ function DropdownMenuItem(_ref) {
254
254
  },
255
255
  "aria-label": item['aria-label'] || String(item.content),
256
256
  "aria-pressed": shouldUseDefaultRole ? item.isActive : undefined,
257
+ "aria-keyshortcuts": item['aria-keyshortcuts'],
257
258
  onMouseDown: function onMouseDown(e) {
258
259
  e.preventDefault();
259
260
  },
@@ -38,6 +38,7 @@ var ToolbarButton = /*#__PURE__*/React.forwardRef(function (props, ref) {
38
38
  ariaHasPopup = props['aria-haspopup'],
39
39
  ariaExpanded = props['aria-expanded'],
40
40
  ariaPressed = props['aria-pressed'],
41
+ ariaKeyShortcuts = props['aria-keyshortcuts'],
41
42
  onClick = props.onClick,
42
43
  onItemClick = props.onItemClick;
43
44
  var handleClick = useCallback(function (event, analyticsEvent) {
@@ -83,7 +84,8 @@ var ToolbarButton = /*#__PURE__*/React.forwardRef(function (props, ref) {
83
84
  "aria-expanded": ariaExpanded,
84
85
  "aria-haspopup": ariaHasPopup,
85
86
  "aria-label": ariaLabel,
86
- "aria-pressed": ariaPressed
87
+ "aria-pressed": ariaPressed,
88
+ "aria-keyshortcuts": ariaKeyShortcuts
87
89
  }, children);
88
90
 
89
91
  if (!title) {
@@ -37,37 +37,4 @@ export var SEVERITY;
37
37
  })(SEVERITY || (SEVERITY = {}));
38
38
 
39
39
  export { UNSUPPORTED_CONTENT_LEVEL_SEVERITY, getUnsupportedContentLevelData, UNSUPPORTED_CONTENT_LEVEL_SEVERITY_THRESHOLD_DEFAULTS } from './unsupportedContent/get-unsupported-content-level-data';
40
- export var EVENT_TYPE;
41
-
42
- (function (EVENT_TYPE) {
43
- EVENT_TYPE["TRACK"] = "track";
44
- EVENT_TYPE["UI"] = "ui";
45
- })(EVENT_TYPE || (EVENT_TYPE = {}));
46
-
47
- export var ACTION;
48
-
49
- (function (ACTION) {
50
- ACTION["UNSUPPORTED_CONTENT_ENCOUNTERED"] = "unsupportedContentEncountered";
51
- ACTION["UNSUPPORTED_TOOLTIP_VIEWED"] = "viewed";
52
- })(ACTION || (ACTION = {}));
53
-
54
- export var ACTION_SUBJECT;
55
-
56
- (function (ACTION_SUBJECT) {
57
- ACTION_SUBJECT["DOCUMENT"] = "document";
58
- ACTION_SUBJECT["TOOLTIP"] = "tooltip";
59
- })(ACTION_SUBJECT || (ACTION_SUBJECT = {}));
60
-
61
- export var ACTION_SUBJECT_ID;
62
-
63
- (function (ACTION_SUBJECT_ID) {
64
- ACTION_SUBJECT_ID["UNSUPPORTED_BLOCK"] = "unsupportedBlock";
65
- ACTION_SUBJECT_ID["UNSUPPORTED_INLINE"] = "unsupportedInline";
66
- ACTION_SUBJECT_ID["UNSUPPORTED_MARK"] = "unsupportedMark";
67
- ACTION_SUBJECT_ID["UNSUPPORTED_ERROR"] = "unsupportedUnhandled";
68
- ACTION_SUBJECT_ID["UNSUPPORTED_NODE_ATTRIBUTE"] = "unsupportedNodeAttribute";
69
- ACTION_SUBJECT_ID["ON_UNSUPPORTED_INLINE"] = "onUnsupportedInline";
70
- ACTION_SUBJECT_ID["ON_UNSUPPORTED_BLOCK"] = "onUnsupportedBlock";
71
- })(ACTION_SUBJECT_ID || (ACTION_SUBJECT_ID = {}));
72
-
73
40
  export var analyticsEventKey = 'EDITOR_ANALYTICS_EVENT';
@@ -0,0 +1,30 @@
1
+ import _construct from "@babel/runtime/helpers/construct";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/createClass";
5
+ export var Builder = /*#__PURE__*/function () {
6
+ function Builder() {
7
+ _classCallCheck(this, Builder);
8
+
9
+ for (var _len = arguments.length, more = new Array(_len), _key = 0; _key < _len; _key++) {
10
+ more[_key] = arguments[_key];
11
+ }
12
+
13
+ this.data = [].concat(more) || [];
14
+ }
15
+
16
+ _createClass(Builder, [{
17
+ key: "add",
18
+ value: function add(nextOrTuple) {
19
+ return _construct(Builder, [
20
+ /**
21
+ * re-cast this to NewPlugin as we've done all the type
22
+ * safety, dependency checking, narrowing, during
23
+ * `SafePresetCheck & VerifyPluginDependencies`
24
+ */
25
+ nextOrTuple].concat(_toConsumableArray(this.data)));
26
+ }
27
+ }]);
28
+
29
+ return Builder;
30
+ }();