@contentful/field-editor-reference 4.3.7 → 4.3.10

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.
@@ -1541,7 +1541,8 @@ function useLinkActionsProps(props) {
1541
1541
  slide: slide,
1542
1542
  index: index
1543
1543
  });
1544
- }, [entityType, props.onCreate, props.onAction]);
1544
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1545
+ [entityType, props.onCreate, props.onAction]);
1545
1546
  var onLinkedExisting = useCallback(function (entities, index) {
1546
1547
  if (index === void 0) {
1547
1548
  index = itemsLength;
@@ -1558,7 +1559,8 @@ function useLinkActionsProps(props) {
1558
1559
  index: index === undefined ? undefined : index + i
1559
1560
  });
1560
1561
  });
1561
- }, [entityType, props.onLink, props.onAction]);
1562
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1563
+ [entityType, props.onLink, props.onAction]);
1562
1564
  var onCreate = useCallback( /*#__PURE__*/function () {
1563
1565
  var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(contentTypeId, index) {
1564
1566
  var _yield$createEntity, entity, slide;
@@ -1680,7 +1682,7 @@ function useLinkActionsProps(props) {
1680
1682
  return function onLinkSeveralExisting(_x4) {
1681
1683
  return _ref3.apply(this, arguments);
1682
1684
  };
1683
- }(); // FIXME: The memoization might rerun every time due to the always changing callback identities above
1685
+ }(); // FIXME: The memoization might rerun every time due to the always changing callback identities above
1684
1686
 
1685
1687
 
1686
1688
  return useMemo(function () {
@@ -1700,7 +1702,9 @@ function useLinkActionsProps(props) {
1700
1702
  onLinkedExisting: onLinkedExisting,
1701
1703
  itemsLength: itemsLength
1702
1704
  };
1703
- }, [entityType, canLinkMultiple, isDisabled, isEmpty, isFull, editorPermissions.canCreateEntity, editorPermissions.canLinkEntity, actionLabels, editorPermissions.creatableContentTypes.map(function (ct) {
1705
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1706
+ [entityType, canLinkMultiple, isDisabled, isEmpty, isFull, editorPermissions.canCreateEntity, editorPermissions.canLinkEntity, actionLabels, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1707
+ editorPermissions.creatableContentTypes.map(function (ct) {
1704
1708
  return ct.sys.id;
1705
1709
  }).join(':'), onCreate, onLinkExisting, onLinkSeveralExisting, onCreated, onLinkedExisting, itemsLength]);
1706
1710
  }
@@ -1714,7 +1718,7 @@ function LinkEntityActions(_ref4) {
1714
1718
  return renderLinkActions(props);
1715
1719
  }
1716
1720
 
1717
- // eslint-disable-next-line no-restricted-imports
1721
+ // eslint-disable-next-line -- TODO: describe this disable no-restricted-imports
1718
1722
  /**
1719
1723
  * @param {Date|string} date A valid constructor argument for moment()
1720
1724
  * @param {boolean=} short Render only Today/Tomorrow/Yesterday if valid. Defaults to false
@@ -1794,7 +1798,7 @@ var ScheduledIconWithTooltip = function ScheduledIconWithTooltip(_ref) {
1794
1798
  });
1795
1799
  }); // This should only be ever called once. Following the eslint hint to add used
1796
1800
  // dependencies will cause page freeze (infinite loop)
1797
- // eslint-disable-next-line
1801
+ // eslint-disable-next-line -- TODO: describe this disable
1798
1802
  }, []);
1799
1803
 
1800
1804
  if (status.type === 'loading' || status.type === 'error') {
@@ -1990,7 +1994,7 @@ function useEntitiesStore(props) {
1990
1994
  }
1991
1995
  });
1992
1996
  }
1993
- });
1997
+ }); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1994
1998
  }, [props.sdk, state.assets, state.entries]);
1995
1999
  return _extends({
1996
2000
  getOrLoadEntry: getOrLoadEntry,
@@ -2172,7 +2176,7 @@ function useContentTypePermissions(props) {
2172
2176
  return _checkContentTypeAccess.apply(this, arguments);
2173
2177
  }
2174
2178
 
2175
- void checkContentTypeAccess();
2179
+ void checkContentTypeAccess(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2176
2180
  }, [availableContentTypes]);
2177
2181
  return {
2178
2182
  creatableContentTypes: creatableContentTypes,
@@ -2184,7 +2188,7 @@ function useContentTypePermissions(props) {
2184
2188
  function fromFieldValidations(field) {
2185
2189
  var _field$items$validati, _field$items, _linkContentTypeValid, _linkMimetypeGroupVal;
2186
2190
 
2187
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2191
+ // eslint-disable-next-line -- TODO: describe this disable @typescript-eslint/no-explicit-any
2188
2192
  var validations = [].concat(field.validations, (_field$items$validati = (_field$items = field.items) == null ? void 0 : _field$items.validations) != null ? _field$items$validati : []);
2189
2193
  var linkContentTypeValidations = validations.find(function (v) {
2190
2194
  return 'linkContentType' in v;
@@ -2312,7 +2316,7 @@ function useEditorPermissions(props) {
2312
2316
  return _checkCreateAccess.apply(this, arguments);
2313
2317
  }
2314
2318
 
2315
- void checkCreateAccess();
2319
+ void checkCreateAccess(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2316
2320
  }, [entityType, parameters.instance, creatableContentTypes]);
2317
2321
  useEffect(function () {
2318
2322
  if (parameters.instance.showLinkEntityAction === false) {
@@ -2374,7 +2378,7 @@ function useEditorPermissions(props) {
2374
2378
  return _checkLinkAccess.apply(this, arguments);
2375
2379
  }
2376
2380
 
2377
- void checkLinkAccess();
2381
+ void checkLinkAccess(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2378
2382
  }, [entityType, parameters.instance, readableContentTypes]);
2379
2383
  return {
2380
2384
  canCreateEntity: canCreateEntity,
@@ -2418,7 +2422,8 @@ function Editor(props) {
2418
2422
 
2419
2423
  var customCardRenderer = useCallback(function (cardProps, _, renderDefaultCard) {
2420
2424
  return props.renderCustomCard ? props.renderCustomCard(cardProps, linkActionsProps, renderDefaultCard) : false;
2421
- }, [linkActionsProps]);
2425
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2426
+ [linkActionsProps]);
2422
2427
 
2423
2428
  if (!props.entityId) {
2424
2429
  return createElement(LinkEntityActions, Object.assign({
@@ -2561,12 +2566,15 @@ function WrappedEntryCard(props) {
2561
2566
  }, "Move to bottom") : null].filter(function (item) {
2562
2567
  return item;
2563
2568
  }) : [],
2564
- onClick: function onClick(e) {
2569
+ onClick: // Providing an onClick handler messes up with some rich text
2570
+ // features e.g. pressing ENTER on a card to add a new paragraph
2571
+ // underneath. It's crucial not to pass a custom handler when
2572
+ // isClickable is disabled which in the case of RT it's.
2573
+ props.isClickable ? function (e) {
2565
2574
  e.preventDefault();
2566
- if (!props.isClickable) return;
2567
2575
  if (props.onClick) return props.onClick(e);
2568
2576
  props.onEdit && props.onEdit();
2569
- }
2577
+ } : undefined
2570
2578
  });
2571
2579
  }
2572
2580
  WrappedEntryCard.defaultProps = defaultProps;
@@ -2634,7 +2642,7 @@ function FetchingWrappedEntryCard(props) {
2634
2642
  entries = _useEntities.entries;
2635
2643
 
2636
2644
  useEffect(function () {
2637
- getOrLoadEntry(props.entryId);
2645
+ getOrLoadEntry(props.entryId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2638
2646
  }, [props.entryId]);
2639
2647
  var size = props.viewType === 'link' ? 'small' : 'default';
2640
2648
  var entry = entries[props.entryId];
@@ -2692,7 +2700,8 @@ function FetchingWrappedEntryCard(props) {
2692
2700
  type: 'rendered',
2693
2701
  entity: 'Entry'
2694
2702
  });
2695
- }
2703
+ } // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2704
+
2696
2705
  }, [entry]);
2697
2706
  return useMemo(function () {
2698
2707
  if (entry === 'failed') {
@@ -2766,7 +2775,7 @@ function FetchingWrappedEntryCard(props) {
2766
2775
  }
2767
2776
  }
2768
2777
 
2769
- return renderDefaultCard();
2778
+ return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2770
2779
  }, [props, entityKey]);
2771
2780
  }
2772
2781
 
@@ -2865,7 +2874,8 @@ function Editor$1(props) {
2865
2874
  }));
2866
2875
  var customCardRenderer = useCallback(function (cardProps, _, renderDefaultCard) {
2867
2876
  return props.renderCustomCard ? props.renderCustomCard(cardProps, linkActionsProps, renderDefaultCard) : false;
2868
- }, [linkActionsProps]);
2877
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2878
+ [linkActionsProps]);
2869
2879
  return createElement(Fragment, null, props.children(_extends({}, props, {
2870
2880
  onSortStart: onSortStart,
2871
2881
  onSortEnd: onSortEnd,
@@ -3036,7 +3046,7 @@ var styles$3 = {
3036
3046
  };
3037
3047
  var defaultProps$1 = {
3038
3048
  isClickable: true
3039
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
3049
+ }; // eslint-disable-next-line -- TODO: describe this disable @typescript-eslint/no-explicit-any
3040
3050
 
3041
3051
  function getFileType(file) {
3042
3052
  if (!file) {
@@ -3097,11 +3107,14 @@ var WrappedAssetCard = function WrappedAssetCard(props) {
3097
3107
  testId: "schedule-icon"
3098
3108
  })),
3099
3109
  src: entityFile && entityFile.url ? size === 'small' ? entityFile.url + "?w=150&h=150&fit=thumb" : entityFile.url + "?h=300" : '',
3100
- onClick: function onClick(e) {
3110
+ onClick: // Providing an onClick handler messes up with some rich text
3111
+ // features e.g. pressing ENTER on a card to add a new paragraph
3112
+ // underneath. It's crucial not to pass a custom handler when
3113
+ // isClickable is disabled which in the case of RT it's.
3114
+ isClickable ? function (e) {
3101
3115
  e.preventDefault();
3102
- if (!isClickable) return;
3103
3116
  onEdit && onEdit();
3104
- },
3117
+ } : undefined,
3105
3118
  dragHandleRender: props.renderDragHandle,
3106
3119
  withDragHandle: !!props.renderDragHandle,
3107
3120
  actions: [].concat(renderActions({
@@ -3194,7 +3207,7 @@ function FetchingWrappedAssetCard(props) {
3194
3207
  assets = _useEntities.assets;
3195
3208
 
3196
3209
  useEffect(function () {
3197
- getOrLoadAsset(props.assetId);
3210
+ getOrLoadAsset(props.assetId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3198
3211
  }, [props.assetId]);
3199
3212
  var asset = assets[props.assetId];
3200
3213
  var entityKey = asset === 'failed' ? 'failed' : asset === undefined ? 'undefined' : ":" + asset.sys.id + ":" + asset.sys.version;
@@ -3204,7 +3217,8 @@ function FetchingWrappedAssetCard(props) {
3204
3217
  type: 'rendered',
3205
3218
  entity: 'Asset'
3206
3219
  });
3207
- }
3220
+ } // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3221
+
3208
3222
  }, [asset]);
3209
3223
 
3210
3224
  var onEdit = /*#__PURE__*/function () {
@@ -3336,7 +3350,7 @@ function FetchingWrappedAssetCard(props) {
3336
3350
  }
3337
3351
  }
3338
3352
 
3339
- return renderDefaultCard();
3353
+ return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3340
3354
  }, [props, entityKey]);
3341
3355
  }
3342
3356