@atlaskit/editor-common 96.1.0 → 96.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +26 -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/extensibility/ExtensionComponent.js +29 -18
  6. package/dist/cjs/insert/index.js +19 -0
  7. package/dist/cjs/monitoring/error.js +1 -1
  8. package/dist/cjs/preset/core-plugin/index.js +1 -1
  9. package/dist/cjs/ui/DropList/index.js +1 -1
  10. package/dist/es2019/element-browser/components/ElementList/ElementList.js +31 -8
  11. package/dist/es2019/element-browser/components/StatelessElementBrowser.js +7 -2
  12. package/dist/es2019/element-browser/hooks/use-select-and-focus-on-arrow-navigation.js +97 -14
  13. package/dist/es2019/extensibility/ExtensionComponent.js +30 -19
  14. package/dist/es2019/insert/index.js +18 -0
  15. package/dist/es2019/monitoring/error.js +1 -1
  16. package/dist/es2019/preset/core-plugin/index.js +1 -1
  17. package/dist/es2019/ui/DropList/index.js +1 -1
  18. package/dist/esm/element-browser/components/ElementList/ElementList.js +31 -8
  19. package/dist/esm/element-browser/components/StatelessElementBrowser.js +7 -2
  20. package/dist/esm/element-browser/hooks/use-select-and-focus-on-arrow-navigation.js +102 -20
  21. package/dist/esm/extensibility/ExtensionComponent.js +30 -19
  22. package/dist/esm/insert/index.js +18 -0
  23. package/dist/esm/monitoring/error.js +1 -1
  24. package/dist/esm/preset/core-plugin/index.js +1 -1
  25. package/dist/esm/ui/DropList/index.js +1 -1
  26. package/dist/types/element-browser/hooks/use-select-and-focus-on-arrow-navigation.d.ts +1 -1
  27. package/dist/types/insert/index.d.ts +6 -0
  28. package/dist/types-ts4.5/element-browser/hooks/use-select-and-focus-on-arrow-navigation.d.ts +1 -1
  29. package/dist/types-ts4.5/insert/index.d.ts +6 -0
  30. package/package.json +6 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 96.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#168049](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/168049)
8
+ [`f0b76d1c73ba0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f0b76d1c73ba0) -
9
+ [ux] Utilizing the new extension plugin's \_\_rendererExtensionOptions option to be able to render
10
+ renderer view of bodied extensions on toggle in editor
11
+
12
+ ## 96.1.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [#173737](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/173737)
17
+ [`965f739a481f5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/965f739a481f5) -
18
+ [ux] Items are disabled in the plus menu while offline. This affects arrow navigation in the plus
19
+ menu and element browser
20
+ - [#173404](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/173404)
21
+ [`e5dc6a590c2e9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e5dc6a590c2e9) -
22
+ fixed import path to resolve build error
23
+ - [#170241](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/170241)
24
+ [`05530abbeb871`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/05530abbeb871) -
25
+ [ux] [ED-25804] [ED-25147] Make sure that Editor AI cannot insert tables nested more than two
26
+ times into the Editor
27
+ - Updated dependencies
28
+
3
29
  ## 96.1.0
4
30
 
5
31
  ### 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);
@@ -49,6 +49,13 @@ var isEmptyBodiedMacro = function isEmptyBodiedMacro(node) {
49
49
  var isEmptyWithNoContent = !firstGrandChildNode && node.childCount === 1;
50
50
  return isEmptyWithPlacholder || isEmptyWithNoContent;
51
51
  };
52
+ var getBodiedExtensionContent = function getBodiedExtensionContent(node) {
53
+ var bodiedExtensionContent = [];
54
+ node.content.forEach(function (childNode) {
55
+ bodiedExtensionContent.push((0, _utils.nodeToJSON)(childNode));
56
+ });
57
+ return !!bodiedExtensionContent.length ? bodiedExtensionContent : node.attrs.text;
58
+ };
52
59
  var ExtensionComponentOld = exports.ExtensionComponentOld = /*#__PURE__*/function (_Component) {
53
60
  (0, _inherits2.default)(ExtensionComponentOld, _Component);
54
61
  var _super = _createSuper(ExtensionComponentOld);
@@ -134,7 +141,8 @@ var ExtensionComponentOld = exports.ExtensionComponentOld = /*#__PURE__*/functio
134
141
  var _pmNode$marks;
135
142
  var _this$props = _this.props,
136
143
  extensionHandlers = _this$props.extensionHandlers,
137
- editorView = _this$props.editorView;
144
+ editorView = _this$props.editorView,
145
+ rendererExtensionHandlers = _this$props.rendererExtensionHandlers;
138
146
  var showBodiedExtensionRendererView = _this.state.showBodiedExtensionRendererView; // State will only be true if the gate is on and meets requirements
139
147
  var _pmNode$attrs = pmNode.attrs,
140
148
  extensionType = _pmNode$attrs.extensionType,
@@ -148,22 +156,23 @@ var ExtensionComponentOld = exports.ExtensionComponentOld = /*#__PURE__*/functio
148
156
  var fragmentLocalId = pmNode === null || pmNode === void 0 || (_pmNode$marks = pmNode.marks) === null || _pmNode$marks === void 0 || (_pmNode$marks = _pmNode$marks.find(function (m) {
149
157
  return m.type.name === 'fragment';
150
158
  })) === null || _pmNode$marks === void 0 || (_pmNode$marks = _pmNode$marks.attrs) === null || _pmNode$marks === void 0 ? void 0 : _pmNode$marks.localId;
151
- var nodeContent = [];
152
- if (isBodiedExtension) {
153
- var _pmNode$content;
154
- pmNode === null || pmNode === void 0 || (_pmNode$content = pmNode.content) === null || _pmNode$content === void 0 || _pmNode$content.forEach(function (childNode) {
155
- nodeContent.push(childNode);
156
- });
157
- }
159
+ var content = isBodiedExtension ? getBodiedExtensionContent(pmNode) : text;
158
160
  var node = {
159
161
  type: pmNode.type.name,
160
162
  extensionType: extensionType,
161
163
  extensionKey: extensionKey,
162
164
  parameters: parameters,
163
- content: isBodiedExtension ? nodeContent.length ? nodeContent : text : text,
165
+ content: content,
164
166
  localId: pmNode.attrs.localId,
165
167
  fragmentLocalId: fragmentLocalId
166
168
  };
169
+ if (isBodiedExtension) {
170
+ var rendererExtensionHandler = rendererExtensionHandlers === null || rendererExtensionHandlers === void 0 ? void 0 : rendererExtensionHandlers[extensionType];
171
+ if (!rendererExtensionHandler) {
172
+ return null;
173
+ }
174
+ return (0, _utils.getExtensionRenderer)(rendererExtensionHandler)(node, (0, _utils.toJSON)(editorView.state.doc));
175
+ }
167
176
  var result;
168
177
  if (extensionHandlers && extensionHandlers[extensionType]) {
169
178
  var render = (0, _utils.getExtensionRenderer)(extensionHandlers[extensionType]);
@@ -431,7 +440,8 @@ var ExtensionComponentInner = /*#__PURE__*/function (_Component2) {
431
440
  var _this2$props = _this2.props,
432
441
  extensionHandlers = _this2$props.extensionHandlers,
433
442
  editorView = _this2$props.editorView,
434
- showBodiedExtensionRendererView = _this2$props.showBodiedExtensionRendererView;
443
+ showBodiedExtensionRendererView = _this2$props.showBodiedExtensionRendererView,
444
+ rendererExtensionHandlers = _this2$props.rendererExtensionHandlers;
435
445
  var _pmNode$attrs2 = pmNode.attrs,
436
446
  extensionType = _pmNode$attrs2.extensionType,
437
447
  extensionKey = _pmNode$attrs2.extensionKey,
@@ -444,22 +454,23 @@ var ExtensionComponentInner = /*#__PURE__*/function (_Component2) {
444
454
  var fragmentLocalId = pmNode === null || pmNode === void 0 || (_pmNode$marks2 = pmNode.marks) === null || _pmNode$marks2 === void 0 || (_pmNode$marks2 = _pmNode$marks2.find(function (m) {
445
455
  return m.type.name === 'fragment';
446
456
  })) === null || _pmNode$marks2 === void 0 || (_pmNode$marks2 = _pmNode$marks2.attrs) === null || _pmNode$marks2 === void 0 ? void 0 : _pmNode$marks2.localId;
447
- var nodeContent = [];
448
- if (isBodiedExtension) {
449
- var _pmNode$content2;
450
- pmNode === null || pmNode === void 0 || (_pmNode$content2 = pmNode.content) === null || _pmNode$content2 === void 0 || _pmNode$content2.forEach(function (childNode) {
451
- nodeContent.push(childNode);
452
- });
453
- }
457
+ var content = isBodiedExtension ? getBodiedExtensionContent(pmNode) : text;
454
458
  var node = {
455
459
  type: pmNode.type.name,
456
460
  extensionType: extensionType,
457
461
  extensionKey: extensionKey,
458
462
  parameters: parameters,
459
- content: isBodiedExtension ? nodeContent.length ? nodeContent : text : text,
463
+ content: content,
460
464
  localId: pmNode.attrs.localId,
461
465
  fragmentLocalId: fragmentLocalId
462
466
  };
467
+ if (isBodiedExtension) {
468
+ var rendererExtensionHandler = rendererExtensionHandlers === null || rendererExtensionHandlers === void 0 ? void 0 : rendererExtensionHandlers[extensionType];
469
+ if (!rendererExtensionHandler) {
470
+ return null;
471
+ }
472
+ return (0, _utils.getExtensionRenderer)(rendererExtensionHandler)(node, (0, _utils.toJSON)(editorView.state.doc));
473
+ }
463
474
  var result;
464
475
  if (extensionHandlers && extensionHandlers[extensionType]) {
465
476
  var render = (0, _utils.getExtensionRenderer)(extensionHandlers[extensionType]);
@@ -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.2.0";
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.2.0";
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();