@contentful/field-editor-reference 5.1.7 → 5.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.
@@ -1960,13 +1960,13 @@ function _fetchContentfulEntry() {
1960
1960
  _resourceId$split = resourceId.split('/'), spaceId = _resourceId$split[1], entryId = _resourceId$split[3];
1961
1961
  environmentId = 'master';
1962
1962
  _context3.next = 6;
1963
- return Promise.all([fetch(['space', spaceId], function (_ref9) {
1964
- var cmaClient = _ref9.cmaClient;
1963
+ return Promise.all([fetch(['space', spaceId], function (_ref10) {
1964
+ var cmaClient = _ref10.cmaClient;
1965
1965
  return cmaClient.space.get({
1966
1966
  spaceId: spaceId
1967
1967
  });
1968
- }, options), fetch(['entry', spaceId, environmentId, entryId], function (_ref10) {
1969
- var cmaClient = _ref10.cmaClient;
1968
+ }, options), fetch(['entry', spaceId, environmentId, entryId], function (_ref11) {
1969
+ var cmaClient = _ref11.cmaClient;
1970
1970
  return cmaClient.entry.get({
1971
1971
  spaceId: spaceId,
1972
1972
  environmentId: environmentId,
@@ -1980,15 +1980,15 @@ function _fetchContentfulEntry() {
1980
1980
  entry = _yield$Promise$all[1];
1981
1981
  contentTypeId = entry.sys.contentType.sys.id;
1982
1982
  _context3.next = 12;
1983
- return Promise.all([fetch(['contentType', spaceId, environmentId, contentTypeId], function (_ref11) {
1984
- var cmaClient = _ref11.cmaClient;
1983
+ return Promise.all([fetch(['contentType', spaceId, environmentId, contentTypeId], function (_ref12) {
1984
+ var cmaClient = _ref12.cmaClient;
1985
1985
  return cmaClient.contentType.get({
1986
1986
  contentTypeId: contentTypeId,
1987
1987
  spaceId: spaceId,
1988
1988
  environmentId: environmentId
1989
1989
  });
1990
1990
  }, options), fetch(['defaultLocale', spaceId, environmentId], /*#__PURE__*/function () {
1991
- var _ref13 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref12) {
1991
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref13) {
1992
1992
  var _locales$items$find;
1993
1993
 
1994
1994
  var cmaClient, locales, defaultLocaleCode;
@@ -1996,7 +1996,7 @@ function _fetchContentfulEntry() {
1996
1996
  while (1) {
1997
1997
  switch (_context2.prev = _context2.next) {
1998
1998
  case 0:
1999
- cmaClient = _ref12.cmaClient;
1999
+ cmaClient = _ref13.cmaClient;
2000
2000
  _context2.next = 3;
2001
2001
  return cmaClient.locale.getMany({
2002
2002
  spaceId: spaceId,
@@ -2022,7 +2022,7 @@ function _fetchContentfulEntry() {
2022
2022
  }));
2023
2023
 
2024
2024
  return function (_x3) {
2025
- return _ref13.apply(this, arguments);
2025
+ return _ref14.apply(this, arguments);
2026
2026
  };
2027
2027
  }(), options)]);
2028
2028
 
@@ -2215,14 +2215,34 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
2215
2215
 
2216
2216
  // @ts-expect-error ...
2217
2217
  var onEntityChanged = props.sdk.space.onEntityChanged;
2218
+ var onSlideInNavigation = props.sdk.navigator.onSlideInNavigation;
2218
2219
  useEffect(function () {
2220
+ function findSameSpaceQueries() {
2221
+ return queryCache.findAll({
2222
+ type: 'active',
2223
+ predicate: function predicate(query) {
2224
+ return isSameSpaceEntityQueryKey(query.queryKey);
2225
+ }
2226
+ });
2227
+ }
2228
+
2219
2229
  if (typeof onEntityChanged !== 'function') {
2220
- return;
2230
+ return onSlideInNavigation(function (_ref4) {
2231
+ var oldSlideLevel = _ref4.oldSlideLevel,
2232
+ newSlideLevel = _ref4.newSlideLevel;
2233
+
2234
+ if (oldSlideLevel > newSlideLevel) {
2235
+ findSameSpaceQueries().forEach(function (query) {
2236
+ // automatically refetches the query
2237
+ void queryClient.invalidateQueries(query.queryKey);
2238
+ });
2239
+ }
2240
+ });
2221
2241
  }
2222
2242
 
2223
- var subscribeQuery = function subscribeQuery(_ref4) {
2224
- var queryKey = _ref4.queryKey,
2225
- queryHash = _ref4.queryHash;
2243
+ var subscribeQuery = function subscribeQuery(_ref5) {
2244
+ var queryKey = _ref5.queryKey,
2245
+ queryHash = _ref5.queryHash;
2226
2246
  var entityType = queryKey[0],
2227
2247
  entityId = queryKey[1];
2228
2248
  entityChangeUnsubscribers.current[queryHash] = onEntityChanged(entityType, entityId, function (data) {
@@ -2230,13 +2250,7 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
2230
2250
  });
2231
2251
  };
2232
2252
 
2233
- var queries = queryCache.findAll({
2234
- type: 'active',
2235
- predicate: function predicate(query) {
2236
- return isSameSpaceEntityQueryKey(query.queryKey);
2237
- }
2238
- });
2239
- queries.forEach(subscribeQuery);
2253
+ findSameSpaceQueries().forEach(subscribeQuery);
2240
2254
  var unsubscribe = queryCache.subscribe(function (event) {
2241
2255
  if (!event) {
2242
2256
  return;
@@ -2269,7 +2283,7 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
2269
2283
  });
2270
2284
  entityChangeUnsubscribers.current = {};
2271
2285
  };
2272
- }, [onEntityChanged, queryCache, isSameSpaceEntityQueryKey, queryClient]);
2286
+ }, [onEntityChanged, queryCache, isSameSpaceEntityQueryKey, queryClient, getEntity, onSlideInNavigation]);
2273
2287
  return {
2274
2288
  ids: props.sdk.ids,
2275
2289
  cmaClient: cmaClient,
@@ -2278,22 +2292,22 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
2278
2292
  getEntity: getEntity,
2279
2293
  getEntityScheduledActions: getEntityScheduledActions
2280
2294
  };
2281
- }, function (_ref5) {
2282
- var fetch = _ref5.fetch;
2283
- return fetch;
2284
2295
  }, function (_ref6) {
2285
- var getResource = _ref6.getResource,
2286
- getEntity = _ref6.getEntity,
2287
- getEntityScheduledActions = _ref6.getEntityScheduledActions;
2296
+ var fetch = _ref6.fetch;
2297
+ return fetch;
2298
+ }, function (_ref7) {
2299
+ var getResource = _ref7.getResource,
2300
+ getEntity = _ref7.getEntity,
2301
+ getEntityScheduledActions = _ref7.getEntityScheduledActions;
2288
2302
  return {
2289
2303
  getResource: getResource,
2290
2304
  getEntity: getEntity,
2291
2305
  getEntityScheduledActions: getEntityScheduledActions
2292
2306
  };
2293
- }, function (_ref7) {
2307
+ }, function (_ref8) {
2294
2308
  var _ids$environmentAlias;
2295
2309
 
2296
- var ids = _ref7.ids;
2310
+ var ids = _ref8.ids;
2297
2311
  return {
2298
2312
  environment: (_ids$environmentAlias = ids.environmentAlias) != null ? _ids$environmentAlias : ids.environment,
2299
2313
  space: ids.space
@@ -2350,9 +2364,9 @@ function useResource(resourceType, urn, options) {
2350
2364
  };
2351
2365
  }
2352
2366
 
2353
- function EntityProvider(_ref8) {
2354
- var children = _ref8.children,
2355
- props = _objectWithoutPropertiesLoose(_ref8, _excluded2);
2367
+ function EntityProvider(_ref9) {
2368
+ var children = _ref9.children,
2369
+ props = _objectWithoutPropertiesLoose(_ref9, _excluded2);
2356
2370
 
2357
2371
  var reactQueryClient = useMemo(function () {
2358
2372
  var queryCache = new QueryCache();
@@ -2963,12 +2977,16 @@ function WrappedEntryCard(props) {
2963
2977
  onClick: function onClick() {
2964
2978
  props.onRemove && props.onRemove();
2965
2979
  }
2966
- }, "Remove") : null, props.hasCardMoveActions && (props.onMoveTop || props.onMoveBottom) ? createElement(MenuDivider, null) : null, props.hasCardMoveActions && props.onMoveTop ? createElement(MenuItem, {
2980
+ }, "Remove") : null, props.hasCardMoveActions && (props.onMoveTop || props.onMoveBottom) ? createElement(MenuDivider, {
2981
+ key: "divider"
2982
+ }) : null, props.hasCardMoveActions && props.onMoveTop ? createElement(MenuItem, {
2983
+ key: "move-top",
2967
2984
  onClick: function onClick() {
2968
2985
  return props.onMoveTop && props.onMoveTop();
2969
2986
  },
2970
2987
  testId: "move-top"
2971
2988
  }, "Move to top") : null, props.hasCardMoveActions && props.onMoveBottom ? createElement(MenuItem, {
2989
+ key: "move-bottom",
2972
2990
  onClick: function onClick() {
2973
2991
  return props.onMoveBottom && props.onMoveBottom();
2974
2992
  },