@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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.3.10](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.3.9...@contentful/field-editor-reference@4.3.10) (2022-06-22)
7
+
8
+ **Note:** Version bump only for package @contentful/field-editor-reference
9
+
10
+ ## [4.3.9](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.3.8...@contentful/field-editor-reference@4.3.9) (2022-06-21)
11
+
12
+ **Note:** Version bump only for package @contentful/field-editor-reference
13
+
14
+ ## [4.3.8](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.3.7...@contentful/field-editor-reference@4.3.8) (2022-06-15)
15
+
16
+ ### Bug Fixes
17
+
18
+ - don't register onClick callbacks when isClickable is false ([#1163](https://github.com/contentful/field-editors/issues/1163)) ([fe6fc6b](https://github.com/contentful/field-editors/commit/fe6fc6b872acfde3b097c626d2eef81a7cc24193))
19
+
6
20
  ## [4.3.7](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@4.3.6...@contentful/field-editor-reference@4.3.7) (2022-06-07)
7
21
 
8
22
  ### Bug Fixes
@@ -1548,7 +1548,8 @@ function useLinkActionsProps(props) {
1548
1548
  slide: slide,
1549
1549
  index: index
1550
1550
  });
1551
- }, [entityType, props.onCreate, props.onAction]);
1551
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1552
+ [entityType, props.onCreate, props.onAction]);
1552
1553
  var onLinkedExisting = React.useCallback(function (entities, index) {
1553
1554
  if (index === void 0) {
1554
1555
  index = itemsLength;
@@ -1565,7 +1566,8 @@ function useLinkActionsProps(props) {
1565
1566
  index: index === undefined ? undefined : index + i
1566
1567
  });
1567
1568
  });
1568
- }, [entityType, props.onLink, props.onAction]);
1569
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1570
+ [entityType, props.onLink, props.onAction]);
1569
1571
  var onCreate = React.useCallback( /*#__PURE__*/function () {
1570
1572
  var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(contentTypeId, index) {
1571
1573
  var _yield$createEntity, entity, slide;
@@ -1687,7 +1689,7 @@ function useLinkActionsProps(props) {
1687
1689
  return function onLinkSeveralExisting(_x4) {
1688
1690
  return _ref3.apply(this, arguments);
1689
1691
  };
1690
- }(); // FIXME: The memoization might rerun every time due to the always changing callback identities above
1692
+ }(); // FIXME: The memoization might rerun every time due to the always changing callback identities above
1691
1693
 
1692
1694
 
1693
1695
  return React.useMemo(function () {
@@ -1707,7 +1709,9 @@ function useLinkActionsProps(props) {
1707
1709
  onLinkedExisting: onLinkedExisting,
1708
1710
  itemsLength: itemsLength
1709
1711
  };
1710
- }, [entityType, canLinkMultiple, isDisabled, isEmpty, isFull, editorPermissions.canCreateEntity, editorPermissions.canLinkEntity, actionLabels, editorPermissions.creatableContentTypes.map(function (ct) {
1712
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1713
+ [entityType, canLinkMultiple, isDisabled, isEmpty, isFull, editorPermissions.canCreateEntity, editorPermissions.canLinkEntity, actionLabels, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
1714
+ editorPermissions.creatableContentTypes.map(function (ct) {
1711
1715
  return ct.sys.id;
1712
1716
  }).join(':'), onCreate, onLinkExisting, onLinkSeveralExisting, onCreated, onLinkedExisting, itemsLength]);
1713
1717
  }
@@ -1721,7 +1725,7 @@ function LinkEntityActions(_ref4) {
1721
1725
  return renderLinkActions(props);
1722
1726
  }
1723
1727
 
1724
- // eslint-disable-next-line no-restricted-imports
1728
+ // eslint-disable-next-line -- TODO: describe this disable no-restricted-imports
1725
1729
  /**
1726
1730
  * @param {Date|string} date A valid constructor argument for moment()
1727
1731
  * @param {boolean=} short Render only Today/Tomorrow/Yesterday if valid. Defaults to false
@@ -1801,7 +1805,7 @@ var ScheduledIconWithTooltip = function ScheduledIconWithTooltip(_ref) {
1801
1805
  });
1802
1806
  }); // This should only be ever called once. Following the eslint hint to add used
1803
1807
  // dependencies will cause page freeze (infinite loop)
1804
- // eslint-disable-next-line
1808
+ // eslint-disable-next-line -- TODO: describe this disable
1805
1809
  }, []);
1806
1810
 
1807
1811
  if (status.type === 'loading' || status.type === 'error') {
@@ -1997,7 +2001,7 @@ function useEntitiesStore(props) {
1997
2001
  }
1998
2002
  });
1999
2003
  }
2000
- });
2004
+ }); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2001
2005
  }, [props.sdk, state.assets, state.entries]);
2002
2006
  return _extends({
2003
2007
  getOrLoadEntry: getOrLoadEntry,
@@ -2179,7 +2183,7 @@ function useContentTypePermissions(props) {
2179
2183
  return _checkContentTypeAccess.apply(this, arguments);
2180
2184
  }
2181
2185
 
2182
- void checkContentTypeAccess();
2186
+ void checkContentTypeAccess(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2183
2187
  }, [availableContentTypes]);
2184
2188
  return {
2185
2189
  creatableContentTypes: creatableContentTypes,
@@ -2191,7 +2195,7 @@ function useContentTypePermissions(props) {
2191
2195
  function fromFieldValidations(field) {
2192
2196
  var _field$items$validati, _field$items, _linkContentTypeValid, _linkMimetypeGroupVal;
2193
2197
 
2194
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2198
+ // eslint-disable-next-line -- TODO: describe this disable @typescript-eslint/no-explicit-any
2195
2199
  var validations = [].concat(field.validations, (_field$items$validati = (_field$items = field.items) == null ? void 0 : _field$items.validations) != null ? _field$items$validati : []);
2196
2200
  var linkContentTypeValidations = validations.find(function (v) {
2197
2201
  return 'linkContentType' in v;
@@ -2319,7 +2323,7 @@ function useEditorPermissions(props) {
2319
2323
  return _checkCreateAccess.apply(this, arguments);
2320
2324
  }
2321
2325
 
2322
- void checkCreateAccess();
2326
+ void checkCreateAccess(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2323
2327
  }, [entityType, parameters.instance, creatableContentTypes]);
2324
2328
  React.useEffect(function () {
2325
2329
  if (parameters.instance.showLinkEntityAction === false) {
@@ -2381,7 +2385,7 @@ function useEditorPermissions(props) {
2381
2385
  return _checkLinkAccess.apply(this, arguments);
2382
2386
  }
2383
2387
 
2384
- void checkLinkAccess();
2388
+ void checkLinkAccess(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2385
2389
  }, [entityType, parameters.instance, readableContentTypes]);
2386
2390
  return {
2387
2391
  canCreateEntity: canCreateEntity,
@@ -2425,7 +2429,8 @@ function Editor(props) {
2425
2429
 
2426
2430
  var customCardRenderer = React.useCallback(function (cardProps, _, renderDefaultCard) {
2427
2431
  return props.renderCustomCard ? props.renderCustomCard(cardProps, linkActionsProps, renderDefaultCard) : false;
2428
- }, [linkActionsProps]);
2432
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2433
+ [linkActionsProps]);
2429
2434
 
2430
2435
  if (!props.entityId) {
2431
2436
  return React.createElement(LinkEntityActions, Object.assign({
@@ -2568,12 +2573,15 @@ function WrappedEntryCard(props) {
2568
2573
  }, "Move to bottom") : null].filter(function (item) {
2569
2574
  return item;
2570
2575
  }) : [],
2571
- onClick: function onClick(e) {
2576
+ onClick: // Providing an onClick handler messes up with some rich text
2577
+ // features e.g. pressing ENTER on a card to add a new paragraph
2578
+ // underneath. It's crucial not to pass a custom handler when
2579
+ // isClickable is disabled which in the case of RT it's.
2580
+ props.isClickable ? function (e) {
2572
2581
  e.preventDefault();
2573
- if (!props.isClickable) return;
2574
2582
  if (props.onClick) return props.onClick(e);
2575
2583
  props.onEdit && props.onEdit();
2576
- }
2584
+ } : undefined
2577
2585
  });
2578
2586
  }
2579
2587
  WrappedEntryCard.defaultProps = defaultProps;
@@ -2641,7 +2649,7 @@ function FetchingWrappedEntryCard(props) {
2641
2649
  entries = _useEntities.entries;
2642
2650
 
2643
2651
  React.useEffect(function () {
2644
- getOrLoadEntry(props.entryId);
2652
+ getOrLoadEntry(props.entryId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2645
2653
  }, [props.entryId]);
2646
2654
  var size = props.viewType === 'link' ? 'small' : 'default';
2647
2655
  var entry = entries[props.entryId];
@@ -2699,7 +2707,8 @@ function FetchingWrappedEntryCard(props) {
2699
2707
  type: 'rendered',
2700
2708
  entity: 'Entry'
2701
2709
  });
2702
- }
2710
+ } // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2711
+
2703
2712
  }, [entry]);
2704
2713
  return React.useMemo(function () {
2705
2714
  if (entry === 'failed') {
@@ -2773,7 +2782,7 @@ function FetchingWrappedEntryCard(props) {
2773
2782
  }
2774
2783
  }
2775
2784
 
2776
- return renderDefaultCard();
2785
+ return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2777
2786
  }, [props, entityKey]);
2778
2787
  }
2779
2788
 
@@ -2872,7 +2881,8 @@ function Editor$1(props) {
2872
2881
  }));
2873
2882
  var customCardRenderer = React.useCallback(function (cardProps, _, renderDefaultCard) {
2874
2883
  return props.renderCustomCard ? props.renderCustomCard(cardProps, linkActionsProps, renderDefaultCard) : false;
2875
- }, [linkActionsProps]);
2884
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
2885
+ [linkActionsProps]);
2876
2886
  return React.createElement(React.Fragment, null, props.children(_extends({}, props, {
2877
2887
  onSortStart: onSortStart,
2878
2888
  onSortEnd: onSortEnd,
@@ -3043,7 +3053,7 @@ var styles$3 = {
3043
3053
  };
3044
3054
  var defaultProps$1 = {
3045
3055
  isClickable: true
3046
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
3056
+ }; // eslint-disable-next-line -- TODO: describe this disable @typescript-eslint/no-explicit-any
3047
3057
 
3048
3058
  function getFileType(file) {
3049
3059
  if (!file) {
@@ -3104,11 +3114,14 @@ var WrappedAssetCard = function WrappedAssetCard(props) {
3104
3114
  testId: "schedule-icon"
3105
3115
  })),
3106
3116
  src: entityFile && entityFile.url ? size === 'small' ? entityFile.url + "?w=150&h=150&fit=thumb" : entityFile.url + "?h=300" : '',
3107
- onClick: function onClick(e) {
3117
+ onClick: // Providing an onClick handler messes up with some rich text
3118
+ // features e.g. pressing ENTER on a card to add a new paragraph
3119
+ // underneath. It's crucial not to pass a custom handler when
3120
+ // isClickable is disabled which in the case of RT it's.
3121
+ isClickable ? function (e) {
3108
3122
  e.preventDefault();
3109
- if (!isClickable) return;
3110
3123
  onEdit && onEdit();
3111
- },
3124
+ } : undefined,
3112
3125
  dragHandleRender: props.renderDragHandle,
3113
3126
  withDragHandle: !!props.renderDragHandle,
3114
3127
  actions: [].concat(renderActions({
@@ -3201,7 +3214,7 @@ function FetchingWrappedAssetCard(props) {
3201
3214
  assets = _useEntities.assets;
3202
3215
 
3203
3216
  React.useEffect(function () {
3204
- getOrLoadAsset(props.assetId);
3217
+ getOrLoadAsset(props.assetId); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3205
3218
  }, [props.assetId]);
3206
3219
  var asset = assets[props.assetId];
3207
3220
  var entityKey = asset === 'failed' ? 'failed' : asset === undefined ? 'undefined' : ":" + asset.sys.id + ":" + asset.sys.version;
@@ -3211,7 +3224,8 @@ function FetchingWrappedAssetCard(props) {
3211
3224
  type: 'rendered',
3212
3225
  entity: 'Asset'
3213
3226
  });
3214
- }
3227
+ } // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3228
+
3215
3229
  }, [asset]);
3216
3230
 
3217
3231
  var onEdit = /*#__PURE__*/function () {
@@ -3343,7 +3357,7 @@ function FetchingWrappedAssetCard(props) {
3343
3357
  }
3344
3358
  }
3345
3359
 
3346
- return renderDefaultCard();
3360
+ return renderDefaultCard(); // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: Evaluate the dependencies
3347
3361
  }, [props, entityKey]);
3348
3362
  }
3349
3363