@contentful/field-editor-rich-text 2.3.6 → 2.3.7
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 +6 -0
- package/dist/field-editor-rich-text.cjs.development.js +31 -4
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +32 -5
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/plugins/shared/useStableCallback.d.ts +6 -0
- package/package.json +2 -2
- package/dist/plugins/EmbeddedEntityBlock/FetchingWrappedAssetCard.d.ts +0 -15
- package/dist/plugins/EmbeddedEntityBlock/FetchingWrappedEntryCard.d.ts +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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
|
+
## [2.3.7](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@2.3.6...@contentful/field-editor-rich-text@2.3.7) (2022-07-19)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **rich-text:** avoid unnecessary render of reference cards ([#1189](https://github.com/contentful/field-editors/issues/1189)) ([b253014](https://github.com/contentful/field-editors/commit/b2530144857ea9b82259c6fbae02875f0692a62a))
|
|
11
|
+
|
|
6
12
|
## [2.3.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@2.3.5...@contentful/field-editor-rich-text@2.3.6) (2022-07-19)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @contentful/field-editor-rich-text
|
|
@@ -2186,6 +2186,27 @@ function useFetchedEntity(_ref) {
|
|
|
2186
2186
|
return entity;
|
|
2187
2187
|
}
|
|
2188
2188
|
|
|
2189
|
+
/**
|
|
2190
|
+
* A userland implementation of useEvent RFC
|
|
2191
|
+
*
|
|
2192
|
+
* See: https://github.com/reactjs/rfcs/pull/220
|
|
2193
|
+
*/
|
|
2194
|
+
|
|
2195
|
+
var useStableCallback = function useStableCallback(callback) {
|
|
2196
|
+
var callbackRef = React.useRef(callback); // Makes sure the callbackRef points to the latest `callback` props
|
|
2197
|
+
// The useLayoutEffect is here for concurrent safety. It has the
|
|
2198
|
+
// disadvantage of not being able to use the result callback during
|
|
2199
|
+
// the render but that's Ok.
|
|
2200
|
+
|
|
2201
|
+
React.useLayoutEffect(function () {
|
|
2202
|
+
callbackRef.current = callback;
|
|
2203
|
+
}); // The stable callback that won't change
|
|
2204
|
+
|
|
2205
|
+
return React.useCallback(function () {
|
|
2206
|
+
return callbackRef.current.apply(callbackRef, arguments);
|
|
2207
|
+
}, []);
|
|
2208
|
+
};
|
|
2209
|
+
|
|
2189
2210
|
var InternalAssetCard = /*#__PURE__*/React.memo(function (props) {
|
|
2190
2211
|
if (props.asset === undefined) {
|
|
2191
2212
|
return /*#__PURE__*/React.createElement(f36Components.AssetCard, {
|
|
@@ -2221,8 +2242,11 @@ function FetchingWrappedAssetCard(props) {
|
|
|
2221
2242
|
assetId = props.assetId;
|
|
2222
2243
|
|
|
2223
2244
|
var _useEntities = fieldEditorReference.useEntities(),
|
|
2224
|
-
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
|
|
2245
|
+
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions; // FIXME: remove when useEntities() has been refactored to avoid
|
|
2246
|
+
// unnecessary re-rendering
|
|
2225
2247
|
|
|
2248
|
+
|
|
2249
|
+
var stableLoadEntityScheduledActions = useStableCallback(loadEntityScheduledActions);
|
|
2226
2250
|
var asset = useFetchedEntity({
|
|
2227
2251
|
type: 'Asset',
|
|
2228
2252
|
id: assetId,
|
|
@@ -2233,7 +2257,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
2233
2257
|
sdk: props.sdk,
|
|
2234
2258
|
isDisabled: props.isDisabled,
|
|
2235
2259
|
isSelected: props.isSelected,
|
|
2236
|
-
loadEntityScheduledActions:
|
|
2260
|
+
loadEntityScheduledActions: stableLoadEntityScheduledActions,
|
|
2237
2261
|
locale: props.locale,
|
|
2238
2262
|
onEdit: props.onEdit,
|
|
2239
2263
|
onRemove: props.onRemove
|
|
@@ -2283,8 +2307,11 @@ var FetchingWrappedEntryCard = function FetchingWrappedEntryCard(props) {
|
|
|
2283
2307
|
onEntityFetchComplete = props.onEntityFetchComplete;
|
|
2284
2308
|
|
|
2285
2309
|
var _useEntities = fieldEditorReference.useEntities(),
|
|
2286
|
-
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
|
|
2310
|
+
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions; // FIXME: remove when useEntities() has been refactored to avoid
|
|
2311
|
+
// unnecessary re-rendering
|
|
2312
|
+
|
|
2287
2313
|
|
|
2314
|
+
var stableLoadEntityScheduledActions = useStableCallback(loadEntityScheduledActions);
|
|
2288
2315
|
var entry = useFetchedEntity({
|
|
2289
2316
|
type: 'Entry',
|
|
2290
2317
|
id: entryId,
|
|
@@ -2298,7 +2325,7 @@ var FetchingWrappedEntryCard = function FetchingWrappedEntryCard(props) {
|
|
|
2298
2325
|
isSelected: props.isSelected,
|
|
2299
2326
|
onEdit: props.onEdit,
|
|
2300
2327
|
onRemove: props.onRemove,
|
|
2301
|
-
loadEntityScheduledActions:
|
|
2328
|
+
loadEntityScheduledActions: stableLoadEntityScheduledActions
|
|
2302
2329
|
});
|
|
2303
2330
|
};
|
|
2304
2331
|
|