@atlaskit/editor-common 96.1.0 → 96.1.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 (27) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/element-browser/components/ElementList/ElementList.js +31 -8
  3. package/dist/cjs/element-browser/components/StatelessElementBrowser.js +7 -2
  4. package/dist/cjs/element-browser/hooks/use-select-and-focus-on-arrow-navigation.js +102 -19
  5. package/dist/cjs/insert/index.js +19 -0
  6. package/dist/cjs/monitoring/error.js +1 -1
  7. package/dist/cjs/preset/core-plugin/index.js +1 -1
  8. package/dist/cjs/ui/DropList/index.js +1 -1
  9. package/dist/es2019/element-browser/components/ElementList/ElementList.js +31 -8
  10. package/dist/es2019/element-browser/components/StatelessElementBrowser.js +7 -2
  11. package/dist/es2019/element-browser/hooks/use-select-and-focus-on-arrow-navigation.js +97 -14
  12. package/dist/es2019/insert/index.js +18 -0
  13. package/dist/es2019/monitoring/error.js +1 -1
  14. package/dist/es2019/preset/core-plugin/index.js +1 -1
  15. package/dist/es2019/ui/DropList/index.js +1 -1
  16. package/dist/esm/element-browser/components/ElementList/ElementList.js +31 -8
  17. package/dist/esm/element-browser/components/StatelessElementBrowser.js +7 -2
  18. package/dist/esm/element-browser/hooks/use-select-and-focus-on-arrow-navigation.js +102 -20
  19. package/dist/esm/insert/index.js +18 -0
  20. package/dist/esm/monitoring/error.js +1 -1
  21. package/dist/esm/preset/core-plugin/index.js +1 -1
  22. package/dist/esm/ui/DropList/index.js +1 -1
  23. package/dist/types/element-browser/hooks/use-select-and-focus-on-arrow-navigation.d.ts +1 -1
  24. package/dist/types/insert/index.d.ts +6 -0
  25. package/dist/types-ts4.5/element-browser/hooks/use-select-and-focus-on-arrow-navigation.d.ts +1 -1
  26. package/dist/types-ts4.5/insert/index.d.ts +6 -0
  27. package/package.json +6 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 96.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#173737](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/173737)
8
+ [`965f739a481f5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/965f739a481f5) -
9
+ [ux] Items are disabled in the plus menu while offline. This affects arrow navigation in the plus
10
+ menu and element browser
11
+ - [#173404](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/173404)
12
+ [`e5dc6a590c2e9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e5dc6a590c2e9) -
13
+ fixed import path to resolve build error
14
+ - [#170241](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/170241)
15
+ [`05530abbeb871`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/05530abbeb871) -
16
+ [ux] [ED-25804] [ED-25147] Make sure that Editor AI cannot insert tables nested more than two
17
+ times into the Editor
18
+ - Updated dependencies
19
+
3
20
  ## 96.1.0
4
21
 
5
22
  ### Minor Changes
@@ -545,7 +545,8 @@ function ElementItem(_ref10) {
545
545
  var icon = item.icon,
546
546
  title = item.title,
547
547
  description = item.description,
548
- keyshortcut = item.keyshortcut;
548
+ keyshortcut = item.keyshortcut,
549
+ isDisabled = item.isDisabled;
549
550
  return (0, _react2.jsx)(_tooltip.default, {
550
551
  content: description,
551
552
  testId: "element-item-tooltip-".concat(index)
@@ -559,7 +560,8 @@ function ElementItem(_ref10) {
559
560
  "aria-describedby": title,
560
561
  ref: ref,
561
562
  testId: "element-item-".concat(index),
562
- id: "searched-item-".concat(index)
563
+ id: "searched-item-".concat(index),
564
+ isDisabled: isDisabled
563
565
  }, (0, _react2.jsx)(ItemContent
564
566
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
565
567
  , {
@@ -567,7 +569,8 @@ function ElementItem(_ref10) {
567
569
  tabIndex: 0,
568
570
  title: title,
569
571
  description: description,
570
- keyshortcut: keyshortcut
572
+ keyshortcut: keyshortcut,
573
+ isDisabled: isDisabled
571
574
  })));
572
575
  }
573
576
 
@@ -586,7 +589,8 @@ var ElementBefore = /*#__PURE__*/(0, _react.memo)(function (_ref11) {
586
589
  var ItemContent = /*#__PURE__*/(0, _react.memo)(function (_ref12) {
587
590
  var title = _ref12.title,
588
591
  description = _ref12.description,
589
- keyshortcut = _ref12.keyshortcut;
592
+ keyshortcut = _ref12.keyshortcut,
593
+ isDisabled = _ref12.isDisabled;
590
594
  if ((0, _platformFeatureFlags.fg)('platform_editor_typography_ugc')) {
591
595
  return (
592
596
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -600,13 +604,14 @@ var ItemContent = /*#__PURE__*/(0, _react.memo)(function (_ref12) {
600
604
  }, (0, _react2.jsx)("div", {
601
605
  css: itemTitleWrapper
602
606
  }, (0, _react2.jsx)(_primitives.Text, {
607
+ color: isDisabled ? 'color.text.disabled' : undefined,
603
608
  maxLines: 1
604
609
  }, title), (0, _react2.jsx)("div", {
605
610
  css: itemAfter
606
611
  }, keyshortcut && (0, _react2.jsx)("div", {
607
612
  css: _shortcut.shortcutStyle
608
613
  }, keyshortcut))), description && (0, _react2.jsx)(_primitives.Text, {
609
- color: "color.text.subtle",
614
+ color: isDisabled ? 'color.text.disabled' : 'color.text.subtle',
610
615
  size: "small",
611
616
  maxLines: 2
612
617
  }, description))))
@@ -622,13 +627,15 @@ var ItemContent = /*#__PURE__*/(0, _react.memo)(function (_ref12) {
622
627
  }, (0, _react2.jsx)("div", {
623
628
  css: itemTitleWrapper
624
629
  }, (0, _react2.jsx)("p", {
625
- css: itemTitle
630
+ css: isDisabled ? itemTitleDisabled : itemTitle
626
631
  }, title), (0, _react2.jsx)("div", {
627
632
  css: itemAfter
628
633
  }, keyshortcut && (0, _react2.jsx)("div", {
629
634
  css: _shortcut.shortcutStyle
630
- }, keyshortcut))), description && (0, _react2.jsx)("p", {
631
- css: itemDescription
635
+ }, keyshortcut))), description &&
636
+ // eslint-disable-next-line @atlaskit/design-system/use-primitives-text
637
+ (0, _react2.jsx)("p", {
638
+ css: isDisabled ? itemDescriptionDisabled : itemDescription
632
639
  }, description)))
633
640
  );
634
641
  }
@@ -708,6 +715,15 @@ var itemDescription = (0, _react2.css)(multilineStyle, {
708
715
  color: "var(--ds-text-subtle, #44546F)",
709
716
  marginTop: "var(--ds-space-025, 2px)"
710
717
  });
718
+
719
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
720
+ var itemDescriptionDisabled = (0, _react2.css)(multilineStyle, {
721
+ overflow: 'hidden',
722
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
723
+ fontSize: (0, _editorSharedStyles.relativeFontSizeToBase16)(11.67),
724
+ color: "var(--ds-text-disabled, #091E424F)",
725
+ marginTop: "var(--ds-space-025, 2px)"
726
+ });
711
727
  var itemText = (0, _react2.css)({
712
728
  width: 'inherit',
713
729
  whiteSpace: 'initial'
@@ -722,6 +738,13 @@ var itemTitle = (0, _react2.css)({
722
738
  whiteSpace: 'nowrap',
723
739
  textOverflow: 'ellipsis'
724
740
  });
741
+ var itemTitleDisabled = (0, _react2.css)({
742
+ width: '100%',
743
+ overflow: 'hidden',
744
+ whiteSpace: 'nowrap',
745
+ textOverflow: 'ellipsis',
746
+ color: "var(--ds-text-disabled, #091E424F)"
747
+ });
725
748
  var itemAfter = (0, _react2.css)({
726
749
  flex: '0 0 auto',
727
750
  paddingTop: "var(--ds-space-025, 2px)",
@@ -157,7 +157,11 @@ function StatelessElementBrowser(props) {
157
157
  // After user pick some category the category should stay focused.
158
158
  isFocusSearch = !categoryBeenChosen.current || !isEmptySearchTerm;
159
159
  }
160
- var _useSelectAndFocusOnA = (0, _useSelectAndFocusOnArrowNavigation.default)(items.length - 1, columnCount, !!viewMoreItem, isFocusSearch),
160
+ var itemIsDisabled = (0, _react.useCallback)(function (index) {
161
+ var _items$index$isDisabl, _items$index;
162
+ return (_items$index$isDisabl = (_items$index = items[index]) === null || _items$index === void 0 ? void 0 : _items$index.isDisabled) !== null && _items$index$isDisabl !== void 0 ? _items$index$isDisabl : false;
163
+ }, [items]);
164
+ var _useSelectAndFocusOnA = (0, _useSelectAndFocusOnArrowNavigation.default)(items.length - 1, columnCount, !!viewMoreItem, itemIsDisabled, isFocusSearch),
161
165
  selectedItemIndex = _useSelectAndFocusOnA.selectedItemIndex,
162
166
  focusedItemIndex = _useSelectAndFocusOnA.focusedItemIndex,
163
167
  setFocusedItemIndex = _useSelectAndFocusOnA.setFocusedItemIndex,
@@ -197,6 +201,7 @@ function StatelessElementBrowser(props) {
197
201
  */
198
202
  var selectedItem = selectedItemIndex !== undefined ? items[selectedItemIndex] : null;
199
203
  var onItemsEnterTabKeyPress = (0, _react.useCallback)(function (e) {
204
+ var _selectedItem$isDisab;
200
205
  if (e.key !== 'Enter' && (e.key !== 'Tab' || !showCategories)) {
201
206
  return;
202
207
  }
@@ -206,7 +211,7 @@ function StatelessElementBrowser(props) {
206
211
  e.preventDefault();
207
212
  return;
208
213
  }
209
- if (onInsertItem && selectedItem != null) {
214
+ if (onInsertItem && selectedItem != null && !((_selectedItem$isDisab = selectedItem.isDisabled) !== null && _selectedItem$isDisab !== void 0 ? _selectedItem$isDisab : false)) {
210
215
  onInsertItem(selectedItem);
211
216
  }
212
217
  e.preventDefault();
@@ -8,6 +8,7 @@ exports.ensureSafeIndex = exports.default = exports.ACTIONS = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _react = require("react");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  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; }
12
13
  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; }
13
14
  /**
@@ -83,12 +84,27 @@ var moveReducer = function moveReducer(state, action) {
83
84
  selectedItemIndex: canFocusViewMore ? undefined : listSize
84
85
  });
85
86
  } else {
86
- return _objectSpread(_objectSpread({}, state), {}, {
87
- focusOnSearch: false,
88
- focusOnViewMore: false,
89
- focusedItemIndex: 0,
90
- selectedItemIndex: 0
91
- });
87
+ if ((0, _platformFeatureFlags.fg)('platform_editor_is_disabled_state_element_browser')) {
88
+ var _action$payload$step;
89
+ var _newIndex = action.payload.positions ? action.payload.positions - ((_action$payload$step = action.payload.step) !== null && _action$payload$step !== void 0 ? _action$payload$step : 1) : 0;
90
+ var _safeIndex = ensureSafeIndex(_newIndex, state.listSize);
91
+ var isLastItemFocused = _newIndex > listSize;
92
+ var focusOnSearch = isLastItemFocused && !canFocusViewMore;
93
+ var focusOnViewMore = isLastItemFocused && !!canFocusViewMore;
94
+ return _objectSpread(_objectSpread({}, state), {}, {
95
+ focusOnSearch: focusOnSearch,
96
+ focusOnViewMore: focusOnViewMore,
97
+ focusedItemIndex: _safeIndex,
98
+ selectedItemIndex: _safeIndex
99
+ });
100
+ } else {
101
+ return _objectSpread(_objectSpread({}, state), {}, {
102
+ focusOnSearch: false,
103
+ focusOnViewMore: false,
104
+ focusedItemIndex: 0,
105
+ selectedItemIndex: 0
106
+ });
107
+ }
92
108
  }
93
109
  }
94
110
  if (state.focusOnViewMore) {
@@ -118,17 +134,17 @@ var moveReducer = function moveReducer(state, action) {
118
134
  // row then newIndex will be greater than listSize when
119
135
  // down arrow key is pressed.
120
136
  // Or when last item is focused and down or right arrow key is pressed.
121
- var isLastItemFocused = newIndex > listSize;
122
- var focusOnSearch = isLastItemFocused && !canFocusViewMore;
123
- var focusOnViewMore = isLastItemFocused && !!canFocusViewMore;
137
+ var _isLastItemFocused = newIndex > listSize;
138
+ var _focusOnSearch = _isLastItemFocused && !canFocusViewMore;
139
+ var _focusOnViewMore = _isLastItemFocused && !!canFocusViewMore;
124
140
  // if search is focused, then select first item.
125
141
  // otherwise if view more is focused then select item should be undefined.
126
- var selectedItemIndex = focusOnSearch ? 0 : focusOnViewMore ? undefined : safeIndex;
142
+ var selectedItemIndex = _focusOnSearch ? 0 : _focusOnViewMore ? undefined : safeIndex;
127
143
  return _objectSpread(_objectSpread({}, state), {}, {
128
- focusOnSearch: focusOnSearch,
129
- focusOnViewMore: focusOnViewMore,
144
+ focusOnSearch: _focusOnSearch,
145
+ focusOnViewMore: _focusOnViewMore,
130
146
  selectedItemIndex: selectedItemIndex,
131
- focusedItemIndex: isLastItemFocused ? undefined : safeIndex
147
+ focusedItemIndex: _isLastItemFocused ? undefined : safeIndex
132
148
  });
133
149
  }
134
150
 
@@ -171,7 +187,40 @@ var getInitialState = function getInitialState(listSize, canFocusViewMore) {
171
187
  });
172
188
  };
173
189
  };
174
- function useSelectAndFocusOnArrowNavigation(listSize, step, canFocusViewMore, isFocusSearch) {
190
+
191
+ // Get the offset forwards - skip items that are disabled
192
+ var skipForwardOffsetToSafeItem = function skipForwardOffsetToSafeItem(currentIndex, listSize, stepSize, itemIsDisabled) {
193
+ if (currentIndex === undefined) {
194
+ return undefined;
195
+ }
196
+ // Iterate through the list starting from the next item
197
+ for (var offset = 1; currentIndex + offset * stepSize <= listSize; offset++) {
198
+ if (!itemIsDisabled(currentIndex + offset * stepSize)) {
199
+ return offset * stepSize;
200
+ }
201
+ }
202
+
203
+ // Move to the last place if possible
204
+ return listSize - currentIndex + 1;
205
+ };
206
+
207
+ // Get the offset backwards - skip items that are disabled
208
+ var skipBackwardOffsetToSafeItem = function skipBackwardOffsetToSafeItem(currentIndex, stepSize, itemIsDisabled) {
209
+ if (currentIndex === undefined) {
210
+ return undefined;
211
+ }
212
+
213
+ // Iterate backwards starting from the previous item
214
+ for (var offset = 1; currentIndex - offset * stepSize >= -1; offset++) {
215
+ if (!itemIsDisabled(currentIndex - offset * stepSize) || currentIndex - offset * stepSize === -1) {
216
+ return offset * stepSize;
217
+ }
218
+ }
219
+
220
+ // Move to search if no available index
221
+ return currentIndex + 1;
222
+ };
223
+ function useSelectAndFocusOnArrowNavigation(listSize, step, canFocusViewMore, itemIsDisabled, isFocusSearch) {
175
224
  var _useReducer = (0, _react.useReducer)(reducer, initialState, getInitialState(listSize, canFocusViewMore)),
176
225
  _useReducer2 = (0, _slicedToArray2.default)(_useReducer, 2),
177
226
  state = _useReducer2[0],
@@ -271,15 +320,49 @@ function useSelectAndFocusOnArrowNavigation(listSize, step, canFocusViewMore, is
271
320
  e.stopPropagation();
272
321
  return setFocusOnSearch();
273
322
  case 'ArrowRight':
274
- return move(e, +1);
323
+ {
324
+ if ((0, _platformFeatureFlags.fg)('platform_editor_is_disabled_state_element_browser')) {
325
+ var _skipForwardOffsetToS;
326
+ var itemIndex = focusOnSearch ? -1 : selectedItemIndex;
327
+ var nextItem = (_skipForwardOffsetToS = skipForwardOffsetToSafeItem(itemIndex, listSize, 1, itemIsDisabled)) !== null && _skipForwardOffsetToS !== void 0 ? _skipForwardOffsetToS : 1;
328
+ return move(e, nextItem);
329
+ } else {
330
+ return move(e, +1);
331
+ }
332
+ }
275
333
  case 'ArrowLeft':
276
- return move(e, -1);
334
+ {
335
+ if ((0, _platformFeatureFlags.fg)('platform_editor_is_disabled_state_element_browser')) {
336
+ var _skipBackwardOffsetTo;
337
+ var _nextItem = (_skipBackwardOffsetTo = skipBackwardOffsetToSafeItem(selectedItemIndex, 1, itemIsDisabled)) !== null && _skipBackwardOffsetTo !== void 0 ? _skipBackwardOffsetTo : 1;
338
+ return move(e, -_nextItem);
339
+ } else {
340
+ return move(e, -1);
341
+ }
342
+ }
277
343
  case 'ArrowDown':
278
- return move(e, +step);
344
+ {
345
+ if ((0, _platformFeatureFlags.fg)('platform_editor_is_disabled_state_element_browser')) {
346
+ var _skipForwardOffsetToS2;
347
+ var _itemIndex = focusOnSearch ? -step : selectedItemIndex;
348
+ var _nextItem2 = (_skipForwardOffsetToS2 = skipForwardOffsetToSafeItem(_itemIndex, listSize, step, itemIsDisabled)) !== null && _skipForwardOffsetToS2 !== void 0 ? _skipForwardOffsetToS2 : step;
349
+ return move(e, +_nextItem2, step);
350
+ } else {
351
+ return move(e, +step);
352
+ }
353
+ }
279
354
  case 'ArrowUp':
280
- return move(e, -step, step);
355
+ {
356
+ if ((0, _platformFeatureFlags.fg)('platform_editor_is_disabled_state_element_browser')) {
357
+ var _skipBackwardOffsetTo2;
358
+ var _nextItem3 = (_skipBackwardOffsetTo2 = skipBackwardOffsetToSafeItem(selectedItemIndex, step, itemIsDisabled)) !== null && _skipBackwardOffsetTo2 !== void 0 ? _skipBackwardOffsetTo2 : step;
359
+ return move(e, Math.min(-_nextItem3, -step), step);
360
+ } else {
361
+ return move(e, -step, step);
362
+ }
363
+ }
281
364
  }
282
- }, [focusOnSearch, setFocusOnSearch, move, step]);
365
+ }, [focusOnSearch, setFocusOnSearch, move, selectedItemIndex, itemIsDisabled, listSize, step]);
283
366
  (0, _react.useEffect)(function () {
284
367
  // To reset selection when user filters
285
368
  reset(listSize);
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.LookDirection = void 0;
8
8
  exports.contentAllowedInCodeBlock = contentAllowedInCodeBlock;
9
+ exports.fragmentContainsNodeType = fragmentContainsNodeType;
9
10
  exports.shouldSplitSelectedNodeOnNodeInsertion = exports.safeInsert = exports.normaliseNestedLayout = exports.insertSelectedItem = void 0;
10
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
12
  var _model = require("@atlaskit/editor-prosemirror/model");
@@ -311,6 +312,24 @@ function contentAllowedInCodeBlock(state) {
311
312
  return isAllowedChild;
312
313
  }
313
314
 
315
+ /**
316
+ * Check if a fragment contains a particular node by iterating through all the nodes in the fragment.
317
+ * If the node type is found will stop looking and return true.
318
+ * If the node type is not found, it will return false.
319
+ */
320
+ function fragmentContainsNodeType(fragment, nodeType) {
321
+ var doesContainNodeType = false;
322
+ fragment.descendants(function (node) {
323
+ if (node.type === nodeType) {
324
+ doesContainNodeType = true;
325
+ // Stop looking
326
+ return false;
327
+ }
328
+ return true;
329
+ });
330
+ return doesContainNodeType;
331
+ }
332
+
314
333
  // For platform_editor_element_level_templates experiment only
315
334
  // clean up ticket ED-24873
316
335
  var insertTemplateFragment = function insertTemplateFragment(_ref3) {
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
18
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
19
19
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
20
- var packageVersion = "96.1.0";
20
+ var packageVersion = "96.1.1";
21
21
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
22
22
  // Remove URL as it has UGC
23
23
  // TODO: Sanitise the URL instead of just removing it
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.corePlugin = void 0;
7
- var _processRawValue = require("../../../src/utils/processRawValue");
7
+ var _processRawValue = require("../../utils/processRawValue");
8
8
  var _editorCommands = require("../editor-commands");
9
9
  var _requestDocument = require("./requestDocument");
10
10
  /**
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
24
24
  * @jsx jsx
25
25
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "96.1.0";
27
+ var packageVersion = "96.1.1";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -530,7 +530,8 @@ export function ElementItem({
530
530
  icon,
531
531
  title,
532
532
  description,
533
- keyshortcut
533
+ keyshortcut,
534
+ isDisabled
534
535
  } = item;
535
536
  return jsx(Tooltip, {
536
537
  content: description,
@@ -545,7 +546,8 @@ export function ElementItem({
545
546
  "aria-describedby": title,
546
547
  ref: ref,
547
548
  testId: `element-item-${index}`,
548
- id: `searched-item-${index}`
549
+ id: `searched-item-${index}`,
550
+ isDisabled: isDisabled
549
551
  }, jsx(ItemContent
550
552
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
551
553
  , {
@@ -553,7 +555,8 @@ export function ElementItem({
553
555
  tabIndex: 0,
554
556
  title: title,
555
557
  description: description,
556
- keyshortcut: keyshortcut
558
+ keyshortcut: keyshortcut,
559
+ isDisabled: isDisabled
557
560
  })));
558
561
  }
559
562
 
@@ -571,7 +574,8 @@ const ElementBefore = /*#__PURE__*/memo(({
571
574
  const ItemContent = /*#__PURE__*/memo(({
572
575
  title,
573
576
  description,
574
- keyshortcut
577
+ keyshortcut,
578
+ isDisabled
575
579
  }) => {
576
580
  if (fg('platform_editor_typography_ugc')) {
577
581
  return (
@@ -586,13 +590,14 @@ const ItemContent = /*#__PURE__*/memo(({
586
590
  }, jsx("div", {
587
591
  css: itemTitleWrapper
588
592
  }, jsx(Text, {
593
+ color: isDisabled ? 'color.text.disabled' : undefined,
589
594
  maxLines: 1
590
595
  }, title), jsx("div", {
591
596
  css: itemAfter
592
597
  }, keyshortcut && jsx("div", {
593
598
  css: shortcutStyle
594
599
  }, keyshortcut))), description && jsx(Text, {
595
- color: "color.text.subtle",
600
+ color: isDisabled ? 'color.text.disabled' : 'color.text.subtle',
596
601
  size: "small",
597
602
  maxLines: 2
598
603
  }, description))))
@@ -608,13 +613,15 @@ const ItemContent = /*#__PURE__*/memo(({
608
613
  }, jsx("div", {
609
614
  css: itemTitleWrapper
610
615
  }, jsx("p", {
611
- css: itemTitle
616
+ css: isDisabled ? itemTitleDisabled : itemTitle
612
617
  }, title), jsx("div", {
613
618
  css: itemAfter
614
619
  }, keyshortcut && jsx("div", {
615
620
  css: shortcutStyle
616
- }, keyshortcut))), description && jsx("p", {
617
- css: itemDescription
621
+ }, keyshortcut))), description &&
622
+ // eslint-disable-next-line @atlaskit/design-system/use-primitives-text
623
+ jsx("p", {
624
+ css: isDisabled ? itemDescriptionDisabled : itemDescription
618
625
  }, description)))
619
626
  );
620
627
  }
@@ -694,6 +701,15 @@ const itemDescription = css(multilineStyle, {
694
701
  color: "var(--ds-text-subtle, #44546F)",
695
702
  marginTop: "var(--ds-space-025, 2px)"
696
703
  });
704
+
705
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
706
+ const itemDescriptionDisabled = css(multilineStyle, {
707
+ overflow: 'hidden',
708
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
709
+ fontSize: relativeFontSizeToBase16(11.67),
710
+ color: "var(--ds-text-disabled, #091E424F)",
711
+ marginTop: "var(--ds-space-025, 2px)"
712
+ });
697
713
  const itemText = css({
698
714
  width: 'inherit',
699
715
  whiteSpace: 'initial'
@@ -708,6 +724,13 @@ const itemTitle = css({
708
724
  whiteSpace: 'nowrap',
709
725
  textOverflow: 'ellipsis'
710
726
  });
727
+ const itemTitleDisabled = css({
728
+ width: '100%',
729
+ overflow: 'hidden',
730
+ whiteSpace: 'nowrap',
731
+ textOverflow: 'ellipsis',
732
+ color: "var(--ds-text-disabled, #091E424F)"
733
+ });
711
734
  const itemAfter = css({
712
735
  flex: '0 0 auto',
713
736
  paddingTop: "var(--ds-space-025, 2px)",
@@ -145,6 +145,10 @@ function StatelessElementBrowser(props) {
145
145
  // After user pick some category the category should stay focused.
146
146
  isFocusSearch = !categoryBeenChosen.current || !isEmptySearchTerm;
147
147
  }
148
+ const itemIsDisabled = useCallback(index => {
149
+ var _items$index$isDisabl, _items$index;
150
+ return (_items$index$isDisabl = (_items$index = items[index]) === null || _items$index === void 0 ? void 0 : _items$index.isDisabled) !== null && _items$index$isDisabl !== void 0 ? _items$index$isDisabl : false;
151
+ }, [items]);
148
152
  const {
149
153
  selectedItemIndex,
150
154
  focusedItemIndex,
@@ -155,7 +159,7 @@ function StatelessElementBrowser(props) {
155
159
  focusOnViewMore,
156
160
  onKeyDown,
157
161
  setFocusOnSearch
158
- } = useSelectAndFocusOnArrowNavigation(items.length - 1, columnCount, !!viewMoreItem, isFocusSearch);
162
+ } = useSelectAndFocusOnArrowNavigation(items.length - 1, columnCount, !!viewMoreItem, itemIsDisabled, isFocusSearch);
159
163
  useEffect(() => {
160
164
  fireAnalyticsEvent(props.createAnalyticsEvent)({
161
165
  payload: {
@@ -186,6 +190,7 @@ function StatelessElementBrowser(props) {
186
190
  */
187
191
  const selectedItem = selectedItemIndex !== undefined ? items[selectedItemIndex] : null;
188
192
  const onItemsEnterTabKeyPress = useCallback(e => {
193
+ var _selectedItem$isDisab;
189
194
  if (e.key !== 'Enter' && (e.key !== 'Tab' || !showCategories)) {
190
195
  return;
191
196
  }
@@ -195,7 +200,7 @@ function StatelessElementBrowser(props) {
195
200
  e.preventDefault();
196
201
  return;
197
202
  }
198
- if (onInsertItem && selectedItem != null) {
203
+ if (onInsertItem && selectedItem != null && !((_selectedItem$isDisab = selectedItem.isDisabled) !== null && _selectedItem$isDisab !== void 0 ? _selectedItem$isDisab : false)) {
199
204
  onInsertItem(selectedItem);
200
205
  }
201
206
  e.preventDefault();
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useEffect, useReducer, useRef } from 'react';
2
-
2
+ import { fg } from '@atlaskit/platform-feature-flags';
3
3
  /**
4
4
  * a custom hook that handles keyboard navigation for Arrow keys based on a
5
5
  * given listSize, and a step (for up and down arrows).
@@ -81,13 +81,29 @@ const moveReducer = (state, action) => {
81
81
  selectedItemIndex: canFocusViewMore ? undefined : listSize
82
82
  };
83
83
  } else {
84
- return {
85
- ...state,
86
- focusOnSearch: false,
87
- focusOnViewMore: false,
88
- focusedItemIndex: 0,
89
- selectedItemIndex: 0
90
- };
84
+ if (fg('platform_editor_is_disabled_state_element_browser')) {
85
+ var _action$payload$step;
86
+ const newIndex = action.payload.positions ? action.payload.positions - ((_action$payload$step = action.payload.step) !== null && _action$payload$step !== void 0 ? _action$payload$step : 1) : 0;
87
+ const safeIndex = ensureSafeIndex(newIndex, state.listSize);
88
+ const isLastItemFocused = newIndex > listSize;
89
+ const focusOnSearch = isLastItemFocused && !canFocusViewMore;
90
+ const focusOnViewMore = isLastItemFocused && !!canFocusViewMore;
91
+ return {
92
+ ...state,
93
+ focusOnSearch: focusOnSearch,
94
+ focusOnViewMore: focusOnViewMore,
95
+ focusedItemIndex: safeIndex,
96
+ selectedItemIndex: safeIndex
97
+ };
98
+ } else {
99
+ return {
100
+ ...state,
101
+ focusOnSearch: false,
102
+ focusOnViewMore: false,
103
+ focusedItemIndex: 0,
104
+ selectedItemIndex: 0
105
+ };
106
+ }
91
107
  }
92
108
  }
93
109
  if (state.focusOnViewMore) {
@@ -172,7 +188,40 @@ const getInitialState = (listSize, canFocusViewMore) => initialState => ({
172
188
  listSize,
173
189
  canFocusViewMore
174
190
  });
175
- function useSelectAndFocusOnArrowNavigation(listSize, step, canFocusViewMore, isFocusSearch) {
191
+
192
+ // Get the offset forwards - skip items that are disabled
193
+ const skipForwardOffsetToSafeItem = (currentIndex, listSize, stepSize, itemIsDisabled) => {
194
+ if (currentIndex === undefined) {
195
+ return undefined;
196
+ }
197
+ // Iterate through the list starting from the next item
198
+ for (let offset = 1; currentIndex + offset * stepSize <= listSize; offset++) {
199
+ if (!itemIsDisabled(currentIndex + offset * stepSize)) {
200
+ return offset * stepSize;
201
+ }
202
+ }
203
+
204
+ // Move to the last place if possible
205
+ return listSize - currentIndex + 1;
206
+ };
207
+
208
+ // Get the offset backwards - skip items that are disabled
209
+ const skipBackwardOffsetToSafeItem = (currentIndex, stepSize, itemIsDisabled) => {
210
+ if (currentIndex === undefined) {
211
+ return undefined;
212
+ }
213
+
214
+ // Iterate backwards starting from the previous item
215
+ for (let offset = 1; currentIndex - offset * stepSize >= -1; offset++) {
216
+ if (!itemIsDisabled(currentIndex - offset * stepSize) || currentIndex - offset * stepSize === -1) {
217
+ return offset * stepSize;
218
+ }
219
+ }
220
+
221
+ // Move to search if no available index
222
+ return currentIndex + 1;
223
+ };
224
+ function useSelectAndFocusOnArrowNavigation(listSize, step, canFocusViewMore, itemIsDisabled, isFocusSearch) {
176
225
  const [state, dispatch] = useReducer(reducer, initialState, getInitialState(listSize, canFocusViewMore));
177
226
  useEffect(() => {
178
227
  dispatch({
@@ -272,15 +321,49 @@ function useSelectAndFocusOnArrowNavigation(listSize, step, canFocusViewMore, is
272
321
  e.stopPropagation();
273
322
  return setFocusOnSearch();
274
323
  case 'ArrowRight':
275
- return move(e, +1);
324
+ {
325
+ if (fg('platform_editor_is_disabled_state_element_browser')) {
326
+ var _skipForwardOffsetToS;
327
+ const itemIndex = focusOnSearch ? -1 : selectedItemIndex;
328
+ const nextItem = (_skipForwardOffsetToS = skipForwardOffsetToSafeItem(itemIndex, listSize, 1, itemIsDisabled)) !== null && _skipForwardOffsetToS !== void 0 ? _skipForwardOffsetToS : 1;
329
+ return move(e, nextItem);
330
+ } else {
331
+ return move(e, +1);
332
+ }
333
+ }
276
334
  case 'ArrowLeft':
277
- return move(e, -1);
335
+ {
336
+ if (fg('platform_editor_is_disabled_state_element_browser')) {
337
+ var _skipBackwardOffsetTo;
338
+ const nextItem = (_skipBackwardOffsetTo = skipBackwardOffsetToSafeItem(selectedItemIndex, 1, itemIsDisabled)) !== null && _skipBackwardOffsetTo !== void 0 ? _skipBackwardOffsetTo : 1;
339
+ return move(e, -nextItem);
340
+ } else {
341
+ return move(e, -1);
342
+ }
343
+ }
278
344
  case 'ArrowDown':
279
- return move(e, +step);
345
+ {
346
+ if (fg('platform_editor_is_disabled_state_element_browser')) {
347
+ var _skipForwardOffsetToS2;
348
+ const itemIndex = focusOnSearch ? -step : selectedItemIndex;
349
+ const nextItem = (_skipForwardOffsetToS2 = skipForwardOffsetToSafeItem(itemIndex, listSize, step, itemIsDisabled)) !== null && _skipForwardOffsetToS2 !== void 0 ? _skipForwardOffsetToS2 : step;
350
+ return move(e, +nextItem, step);
351
+ } else {
352
+ return move(e, +step);
353
+ }
354
+ }
280
355
  case 'ArrowUp':
281
- return move(e, -step, step);
356
+ {
357
+ if (fg('platform_editor_is_disabled_state_element_browser')) {
358
+ var _skipBackwardOffsetTo2;
359
+ const nextItem = (_skipBackwardOffsetTo2 = skipBackwardOffsetToSafeItem(selectedItemIndex, step, itemIsDisabled)) !== null && _skipBackwardOffsetTo2 !== void 0 ? _skipBackwardOffsetTo2 : step;
360
+ return move(e, Math.min(-nextItem, -step), step);
361
+ } else {
362
+ return move(e, -step, step);
363
+ }
364
+ }
282
365
  }
283
- }, [focusOnSearch, setFocusOnSearch, move, step]);
366
+ }, [focusOnSearch, setFocusOnSearch, move, selectedItemIndex, itemIsDisabled, listSize, step]);
284
367
  useEffect(() => {
285
368
  // To reset selection when user filters
286
369
  reset(listSize);
@@ -305,6 +305,24 @@ export function contentAllowedInCodeBlock(state) {
305
305
  return isAllowedChild;
306
306
  }
307
307
 
308
+ /**
309
+ * Check if a fragment contains a particular node by iterating through all the nodes in the fragment.
310
+ * If the node type is found will stop looking and return true.
311
+ * If the node type is not found, it will return false.
312
+ */
313
+ export function fragmentContainsNodeType(fragment, nodeType) {
314
+ let doesContainNodeType = false;
315
+ fragment.descendants(node => {
316
+ if (node.type === nodeType) {
317
+ doesContainNodeType = true;
318
+ // Stop looking
319
+ return false;
320
+ }
321
+ return true;
322
+ });
323
+ return doesContainNodeType;
324
+ }
325
+
308
326
  // For platform_editor_element_level_templates experiment only
309
327
  // clean up ticket ED-24873
310
328
  const insertTemplateFragment = ({
@@ -1,7 +1,7 @@
1
1
  import { isFedRamp } from './environment';
2
2
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
3
3
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
4
- const packageVersion = "96.1.0";
4
+ const packageVersion = "96.1.1";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // TODO: Sanitise the URL instead of just removing it
@@ -1,4 +1,4 @@
1
- import { processRawFragmentValue, processRawValue } from '../../../src/utils/processRawValue';
1
+ import { processRawFragmentValue, processRawValue } from '../../utils/processRawValue';
2
2
  import { editorCommandToPMCommand } from '../editor-commands';
3
3
  import { scheduleDocumentRequest } from './requestDocument';
4
4
 
@@ -13,7 +13,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
13
13
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import Layer from '../Layer';
15
15
  const packageName = "@atlaskit/editor-common";
16
- const packageVersion = "96.1.0";
16
+ const packageVersion = "96.1.1";
17
17
  const halfFocusRing = 1;
18
18
  const dropOffset = '0, 8';
19
19
  class DropList extends Component {
@@ -535,7 +535,8 @@ export function ElementItem(_ref10) {
535
535
  var icon = item.icon,
536
536
  title = item.title,
537
537
  description = item.description,
538
- keyshortcut = item.keyshortcut;
538
+ keyshortcut = item.keyshortcut,
539
+ isDisabled = item.isDisabled;
539
540
  return jsx(Tooltip, {
540
541
  content: description,
541
542
  testId: "element-item-tooltip-".concat(index)
@@ -549,7 +550,8 @@ export function ElementItem(_ref10) {
549
550
  "aria-describedby": title,
550
551
  ref: ref,
551
552
  testId: "element-item-".concat(index),
552
- id: "searched-item-".concat(index)
553
+ id: "searched-item-".concat(index),
554
+ isDisabled: isDisabled
553
555
  }, jsx(ItemContent
554
556
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
555
557
  , {
@@ -557,7 +559,8 @@ export function ElementItem(_ref10) {
557
559
  tabIndex: 0,
558
560
  title: title,
559
561
  description: description,
560
- keyshortcut: keyshortcut
562
+ keyshortcut: keyshortcut,
563
+ isDisabled: isDisabled
561
564
  })));
562
565
  }
563
566
 
@@ -576,7 +579,8 @@ var ElementBefore = /*#__PURE__*/memo(function (_ref11) {
576
579
  var ItemContent = /*#__PURE__*/memo(function (_ref12) {
577
580
  var title = _ref12.title,
578
581
  description = _ref12.description,
579
- keyshortcut = _ref12.keyshortcut;
582
+ keyshortcut = _ref12.keyshortcut,
583
+ isDisabled = _ref12.isDisabled;
580
584
  if (fg('platform_editor_typography_ugc')) {
581
585
  return (
582
586
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -590,13 +594,14 @@ var ItemContent = /*#__PURE__*/memo(function (_ref12) {
590
594
  }, jsx("div", {
591
595
  css: itemTitleWrapper
592
596
  }, jsx(Text, {
597
+ color: isDisabled ? 'color.text.disabled' : undefined,
593
598
  maxLines: 1
594
599
  }, title), jsx("div", {
595
600
  css: itemAfter
596
601
  }, keyshortcut && jsx("div", {
597
602
  css: shortcutStyle
598
603
  }, keyshortcut))), description && jsx(Text, {
599
- color: "color.text.subtle",
604
+ color: isDisabled ? 'color.text.disabled' : 'color.text.subtle',
600
605
  size: "small",
601
606
  maxLines: 2
602
607
  }, description))))
@@ -612,13 +617,15 @@ var ItemContent = /*#__PURE__*/memo(function (_ref12) {
612
617
  }, jsx("div", {
613
618
  css: itemTitleWrapper
614
619
  }, jsx("p", {
615
- css: itemTitle
620
+ css: isDisabled ? itemTitleDisabled : itemTitle
616
621
  }, title), jsx("div", {
617
622
  css: itemAfter
618
623
  }, keyshortcut && jsx("div", {
619
624
  css: shortcutStyle
620
- }, keyshortcut))), description && jsx("p", {
621
- css: itemDescription
625
+ }, keyshortcut))), description &&
626
+ // eslint-disable-next-line @atlaskit/design-system/use-primitives-text
627
+ jsx("p", {
628
+ css: isDisabled ? itemDescriptionDisabled : itemDescription
622
629
  }, description)))
623
630
  );
624
631
  }
@@ -698,6 +705,15 @@ var itemDescription = css(multilineStyle, {
698
705
  color: "var(--ds-text-subtle, #44546F)",
699
706
  marginTop: "var(--ds-space-025, 2px)"
700
707
  });
708
+
709
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
710
+ var itemDescriptionDisabled = css(multilineStyle, {
711
+ overflow: 'hidden',
712
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
713
+ fontSize: relativeFontSizeToBase16(11.67),
714
+ color: "var(--ds-text-disabled, #091E424F)",
715
+ marginTop: "var(--ds-space-025, 2px)"
716
+ });
701
717
  var itemText = css({
702
718
  width: 'inherit',
703
719
  whiteSpace: 'initial'
@@ -712,6 +728,13 @@ var itemTitle = css({
712
728
  whiteSpace: 'nowrap',
713
729
  textOverflow: 'ellipsis'
714
730
  });
731
+ var itemTitleDisabled = css({
732
+ width: '100%',
733
+ overflow: 'hidden',
734
+ whiteSpace: 'nowrap',
735
+ textOverflow: 'ellipsis',
736
+ color: "var(--ds-text-disabled, #091E424F)"
737
+ });
715
738
  var itemAfter = css({
716
739
  flex: '0 0 auto',
717
740
  paddingTop: "var(--ds-space-025, 2px)",
@@ -146,7 +146,11 @@ function StatelessElementBrowser(props) {
146
146
  // After user pick some category the category should stay focused.
147
147
  isFocusSearch = !categoryBeenChosen.current || !isEmptySearchTerm;
148
148
  }
149
- var _useSelectAndFocusOnA = useSelectAndFocusOnArrowNavigation(items.length - 1, columnCount, !!viewMoreItem, isFocusSearch),
149
+ var itemIsDisabled = useCallback(function (index) {
150
+ var _items$index$isDisabl, _items$index;
151
+ return (_items$index$isDisabl = (_items$index = items[index]) === null || _items$index === void 0 ? void 0 : _items$index.isDisabled) !== null && _items$index$isDisabl !== void 0 ? _items$index$isDisabl : false;
152
+ }, [items]);
153
+ var _useSelectAndFocusOnA = useSelectAndFocusOnArrowNavigation(items.length - 1, columnCount, !!viewMoreItem, itemIsDisabled, isFocusSearch),
150
154
  selectedItemIndex = _useSelectAndFocusOnA.selectedItemIndex,
151
155
  focusedItemIndex = _useSelectAndFocusOnA.focusedItemIndex,
152
156
  setFocusedItemIndex = _useSelectAndFocusOnA.setFocusedItemIndex,
@@ -186,6 +190,7 @@ function StatelessElementBrowser(props) {
186
190
  */
187
191
  var selectedItem = selectedItemIndex !== undefined ? items[selectedItemIndex] : null;
188
192
  var onItemsEnterTabKeyPress = useCallback(function (e) {
193
+ var _selectedItem$isDisab;
189
194
  if (e.key !== 'Enter' && (e.key !== 'Tab' || !showCategories)) {
190
195
  return;
191
196
  }
@@ -195,7 +200,7 @@ function StatelessElementBrowser(props) {
195
200
  e.preventDefault();
196
201
  return;
197
202
  }
198
- if (onInsertItem && selectedItem != null) {
203
+ if (onInsertItem && selectedItem != null && !((_selectedItem$isDisab = selectedItem.isDisabled) !== null && _selectedItem$isDisab !== void 0 ? _selectedItem$isDisab : false)) {
199
204
  onInsertItem(selectedItem);
200
205
  }
201
206
  e.preventDefault();
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
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 { useCallback, useEffect, useReducer, useRef } from 'react';
6
-
6
+ import { fg } from '@atlaskit/platform-feature-flags';
7
7
  /**
8
8
  * a custom hook that handles keyboard navigation for Arrow keys based on a
9
9
  * given listSize, and a step (for up and down arrows).
@@ -78,12 +78,27 @@ var moveReducer = function moveReducer(state, action) {
78
78
  selectedItemIndex: canFocusViewMore ? undefined : listSize
79
79
  });
80
80
  } else {
81
- return _objectSpread(_objectSpread({}, state), {}, {
82
- focusOnSearch: false,
83
- focusOnViewMore: false,
84
- focusedItemIndex: 0,
85
- selectedItemIndex: 0
86
- });
81
+ if (fg('platform_editor_is_disabled_state_element_browser')) {
82
+ var _action$payload$step;
83
+ var _newIndex = action.payload.positions ? action.payload.positions - ((_action$payload$step = action.payload.step) !== null && _action$payload$step !== void 0 ? _action$payload$step : 1) : 0;
84
+ var _safeIndex = ensureSafeIndex(_newIndex, state.listSize);
85
+ var isLastItemFocused = _newIndex > listSize;
86
+ var focusOnSearch = isLastItemFocused && !canFocusViewMore;
87
+ var focusOnViewMore = isLastItemFocused && !!canFocusViewMore;
88
+ return _objectSpread(_objectSpread({}, state), {}, {
89
+ focusOnSearch: focusOnSearch,
90
+ focusOnViewMore: focusOnViewMore,
91
+ focusedItemIndex: _safeIndex,
92
+ selectedItemIndex: _safeIndex
93
+ });
94
+ } else {
95
+ return _objectSpread(_objectSpread({}, state), {}, {
96
+ focusOnSearch: false,
97
+ focusOnViewMore: false,
98
+ focusedItemIndex: 0,
99
+ selectedItemIndex: 0
100
+ });
101
+ }
87
102
  }
88
103
  }
89
104
  if (state.focusOnViewMore) {
@@ -113,17 +128,17 @@ var moveReducer = function moveReducer(state, action) {
113
128
  // row then newIndex will be greater than listSize when
114
129
  // down arrow key is pressed.
115
130
  // Or when last item is focused and down or right arrow key is pressed.
116
- var isLastItemFocused = newIndex > listSize;
117
- var focusOnSearch = isLastItemFocused && !canFocusViewMore;
118
- var focusOnViewMore = isLastItemFocused && !!canFocusViewMore;
131
+ var _isLastItemFocused = newIndex > listSize;
132
+ var _focusOnSearch = _isLastItemFocused && !canFocusViewMore;
133
+ var _focusOnViewMore = _isLastItemFocused && !!canFocusViewMore;
119
134
  // if search is focused, then select first item.
120
135
  // otherwise if view more is focused then select item should be undefined.
121
- var selectedItemIndex = focusOnSearch ? 0 : focusOnViewMore ? undefined : safeIndex;
136
+ var selectedItemIndex = _focusOnSearch ? 0 : _focusOnViewMore ? undefined : safeIndex;
122
137
  return _objectSpread(_objectSpread({}, state), {}, {
123
- focusOnSearch: focusOnSearch,
124
- focusOnViewMore: focusOnViewMore,
138
+ focusOnSearch: _focusOnSearch,
139
+ focusOnViewMore: _focusOnViewMore,
125
140
  selectedItemIndex: selectedItemIndex,
126
- focusedItemIndex: isLastItemFocused ? undefined : safeIndex
141
+ focusedItemIndex: _isLastItemFocused ? undefined : safeIndex
127
142
  });
128
143
  }
129
144
 
@@ -166,7 +181,40 @@ var getInitialState = function getInitialState(listSize, canFocusViewMore) {
166
181
  });
167
182
  };
168
183
  };
169
- function useSelectAndFocusOnArrowNavigation(listSize, step, canFocusViewMore, isFocusSearch) {
184
+
185
+ // Get the offset forwards - skip items that are disabled
186
+ var skipForwardOffsetToSafeItem = function skipForwardOffsetToSafeItem(currentIndex, listSize, stepSize, itemIsDisabled) {
187
+ if (currentIndex === undefined) {
188
+ return undefined;
189
+ }
190
+ // Iterate through the list starting from the next item
191
+ for (var offset = 1; currentIndex + offset * stepSize <= listSize; offset++) {
192
+ if (!itemIsDisabled(currentIndex + offset * stepSize)) {
193
+ return offset * stepSize;
194
+ }
195
+ }
196
+
197
+ // Move to the last place if possible
198
+ return listSize - currentIndex + 1;
199
+ };
200
+
201
+ // Get the offset backwards - skip items that are disabled
202
+ var skipBackwardOffsetToSafeItem = function skipBackwardOffsetToSafeItem(currentIndex, stepSize, itemIsDisabled) {
203
+ if (currentIndex === undefined) {
204
+ return undefined;
205
+ }
206
+
207
+ // Iterate backwards starting from the previous item
208
+ for (var offset = 1; currentIndex - offset * stepSize >= -1; offset++) {
209
+ if (!itemIsDisabled(currentIndex - offset * stepSize) || currentIndex - offset * stepSize === -1) {
210
+ return offset * stepSize;
211
+ }
212
+ }
213
+
214
+ // Move to search if no available index
215
+ return currentIndex + 1;
216
+ };
217
+ function useSelectAndFocusOnArrowNavigation(listSize, step, canFocusViewMore, itemIsDisabled, isFocusSearch) {
170
218
  var _useReducer = useReducer(reducer, initialState, getInitialState(listSize, canFocusViewMore)),
171
219
  _useReducer2 = _slicedToArray(_useReducer, 2),
172
220
  state = _useReducer2[0],
@@ -266,15 +314,49 @@ function useSelectAndFocusOnArrowNavigation(listSize, step, canFocusViewMore, is
266
314
  e.stopPropagation();
267
315
  return setFocusOnSearch();
268
316
  case 'ArrowRight':
269
- return move(e, +1);
317
+ {
318
+ if (fg('platform_editor_is_disabled_state_element_browser')) {
319
+ var _skipForwardOffsetToS;
320
+ var itemIndex = focusOnSearch ? -1 : selectedItemIndex;
321
+ var nextItem = (_skipForwardOffsetToS = skipForwardOffsetToSafeItem(itemIndex, listSize, 1, itemIsDisabled)) !== null && _skipForwardOffsetToS !== void 0 ? _skipForwardOffsetToS : 1;
322
+ return move(e, nextItem);
323
+ } else {
324
+ return move(e, +1);
325
+ }
326
+ }
270
327
  case 'ArrowLeft':
271
- return move(e, -1);
328
+ {
329
+ if (fg('platform_editor_is_disabled_state_element_browser')) {
330
+ var _skipBackwardOffsetTo;
331
+ var _nextItem = (_skipBackwardOffsetTo = skipBackwardOffsetToSafeItem(selectedItemIndex, 1, itemIsDisabled)) !== null && _skipBackwardOffsetTo !== void 0 ? _skipBackwardOffsetTo : 1;
332
+ return move(e, -_nextItem);
333
+ } else {
334
+ return move(e, -1);
335
+ }
336
+ }
272
337
  case 'ArrowDown':
273
- return move(e, +step);
338
+ {
339
+ if (fg('platform_editor_is_disabled_state_element_browser')) {
340
+ var _skipForwardOffsetToS2;
341
+ var _itemIndex = focusOnSearch ? -step : selectedItemIndex;
342
+ var _nextItem2 = (_skipForwardOffsetToS2 = skipForwardOffsetToSafeItem(_itemIndex, listSize, step, itemIsDisabled)) !== null && _skipForwardOffsetToS2 !== void 0 ? _skipForwardOffsetToS2 : step;
343
+ return move(e, +_nextItem2, step);
344
+ } else {
345
+ return move(e, +step);
346
+ }
347
+ }
274
348
  case 'ArrowUp':
275
- return move(e, -step, step);
349
+ {
350
+ if (fg('platform_editor_is_disabled_state_element_browser')) {
351
+ var _skipBackwardOffsetTo2;
352
+ var _nextItem3 = (_skipBackwardOffsetTo2 = skipBackwardOffsetToSafeItem(selectedItemIndex, step, itemIsDisabled)) !== null && _skipBackwardOffsetTo2 !== void 0 ? _skipBackwardOffsetTo2 : step;
353
+ return move(e, Math.min(-_nextItem3, -step), step);
354
+ } else {
355
+ return move(e, -step, step);
356
+ }
357
+ }
276
358
  }
277
- }, [focusOnSearch, setFocusOnSearch, move, step]);
359
+ }, [focusOnSearch, setFocusOnSearch, move, selectedItemIndex, itemIsDisabled, listSize, step]);
278
360
  useEffect(function () {
279
361
  // To reset selection when user filters
280
362
  reset(listSize);
@@ -302,6 +302,24 @@ export function contentAllowedInCodeBlock(state) {
302
302
  return isAllowedChild;
303
303
  }
304
304
 
305
+ /**
306
+ * Check if a fragment contains a particular node by iterating through all the nodes in the fragment.
307
+ * If the node type is found will stop looking and return true.
308
+ * If the node type is not found, it will return false.
309
+ */
310
+ export function fragmentContainsNodeType(fragment, nodeType) {
311
+ var doesContainNodeType = false;
312
+ fragment.descendants(function (node) {
313
+ if (node.type === nodeType) {
314
+ doesContainNodeType = true;
315
+ // Stop looking
316
+ return false;
317
+ }
318
+ return true;
319
+ });
320
+ return doesContainNodeType;
321
+ }
322
+
305
323
  // For platform_editor_element_level_templates experiment only
306
324
  // clean up ticket ED-24873
307
325
  var insertTemplateFragment = function insertTemplateFragment(_ref3) {
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { isFedRamp } from './environment';
8
8
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
9
9
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
10
- var packageVersion = "96.1.0";
10
+ var packageVersion = "96.1.1";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // TODO: Sanitise the URL instead of just removing it
@@ -1,4 +1,4 @@
1
- import { processRawFragmentValue, processRawValue } from '../../../src/utils/processRawValue';
1
+ import { processRawFragmentValue, processRawValue } from '../../utils/processRawValue';
2
2
  import { editorCommandToPMCommand } from '../editor-commands';
3
3
  import { scheduleDocumentRequest } from './requestDocument';
4
4
 
@@ -21,7 +21,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
21
21
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "96.1.0";
24
+ var packageVersion = "96.1.1";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var DropList = /*#__PURE__*/function (_Component) {
@@ -70,6 +70,6 @@ export type useSelectAndFocusReturnType = {
70
70
  setFocusedCategoryIndex: (index?: number) => void;
71
71
  setFocusOnSearch: () => void;
72
72
  };
73
- declare function useSelectAndFocusOnArrowNavigation(listSize: number, step: number, canFocusViewMore: boolean, isFocusSearch?: boolean): useSelectAndFocusReturnType;
73
+ declare function useSelectAndFocusOnArrowNavigation(listSize: number, step: number, canFocusViewMore: boolean, itemIsDisabled: (index: number) => boolean, isFocusSearch?: boolean): useSelectAndFocusReturnType;
74
74
  export declare const ensureSafeIndex: (index: number, listSize: number) => number;
75
75
  export default useSelectAndFocusOnArrowNavigation;
@@ -30,3 +30,9 @@ export declare const shouldSplitSelectedNodeOnNodeInsertion: ({ parentNodeType,
30
30
  * as we extract their text content.
31
31
  */
32
32
  export declare function contentAllowedInCodeBlock(state: EditorState): boolean;
33
+ /**
34
+ * Check if a fragment contains a particular node by iterating through all the nodes in the fragment.
35
+ * If the node type is found will stop looking and return true.
36
+ * If the node type is not found, it will return false.
37
+ */
38
+ export declare function fragmentContainsNodeType(fragment: Fragment, nodeType: NodeType): boolean;
@@ -70,6 +70,6 @@ export type useSelectAndFocusReturnType = {
70
70
  setFocusedCategoryIndex: (index?: number) => void;
71
71
  setFocusOnSearch: () => void;
72
72
  };
73
- declare function useSelectAndFocusOnArrowNavigation(listSize: number, step: number, canFocusViewMore: boolean, isFocusSearch?: boolean): useSelectAndFocusReturnType;
73
+ declare function useSelectAndFocusOnArrowNavigation(listSize: number, step: number, canFocusViewMore: boolean, itemIsDisabled: (index: number) => boolean, isFocusSearch?: boolean): useSelectAndFocusReturnType;
74
74
  export declare const ensureSafeIndex: (index: number, listSize: number) => number;
75
75
  export default useSelectAndFocusOnArrowNavigation;
@@ -30,3 +30,9 @@ export declare const shouldSplitSelectedNodeOnNodeInsertion: ({ parentNodeType,
30
30
  * as we extract their text content.
31
31
  */
32
32
  export declare function contentAllowedInCodeBlock(state: EditorState): boolean;
33
+ /**
34
+ * Check if a fragment contains a particular node by iterating through all the nodes in the fragment.
35
+ * If the node type is found will stop looking and return true.
36
+ * If the node type is not found, it will return false.
37
+ */
38
+ export declare function fragmentContainsNodeType(fragment: Fragment, nodeType: NodeType): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "96.1.0",
3
+ "version": "96.1.1",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -152,8 +152,8 @@
152
152
  "@atlaskit/smart-user-picker": "^6.11.0",
153
153
  "@atlaskit/spinner": "^16.3.0",
154
154
  "@atlaskit/task-decision": "^17.11.0",
155
- "@atlaskit/textfield": "^6.6.0",
156
- "@atlaskit/tmp-editor-statsig": "^2.22.0",
155
+ "@atlaskit/textfield": "^6.7.0",
156
+ "@atlaskit/tmp-editor-statsig": "^2.23.0",
157
157
  "@atlaskit/tokens": "^2.4.0",
158
158
  "@atlaskit/tooltip": "^18.9.0",
159
159
  "@atlaskit/width-detector": "^4.3.0",
@@ -261,6 +261,9 @@
261
261
  "platform_editor_react18_extension_component_v2": {
262
262
  "type": "boolean"
263
263
  },
264
+ "platform_editor_is_disabled_state_element_browser": {
265
+ "type": "boolean"
266
+ },
264
267
  "platform-datasources-enable-two-way-sync": {
265
268
  "type": "boolean"
266
269
  },