@contentful/field-editor-reference 5.1.5 → 5.1.8
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 +16 -0
- package/dist/__fixtures__/FakeSdk.d.ts +1 -1
- package/dist/__fixtures__/asset/index.d.ts +6 -0
- package/dist/__fixtures__/content-type/index.d.ts +2 -0
- package/dist/__fixtures__/entry/index.d.ts +5 -0
- package/dist/__fixtures__/fixtures.d.ts +6 -0
- package/dist/__fixtures__/locale/index.d.ts +42 -0
- package/dist/__fixtures__/space/index.d.ts +2 -0
- package/dist/field-editor-reference.cjs.development.js +58 -36
- package/dist/field-editor-reference.cjs.development.js.map +1 -1
- package/dist/field-editor-reference.cjs.production.min.js +1 -1
- package/dist/field-editor-reference.cjs.production.min.js.map +1 -1
- package/dist/field-editor-reference.esm.js +58 -36
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/package.json +3 -3
|
@@ -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 (
|
|
1964
|
-
var 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 (
|
|
1969
|
-
var 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 (
|
|
1984
|
-
var 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
|
|
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 =
|
|
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
|
|
2025
|
+
return _ref14.apply(this, arguments);
|
|
2026
2026
|
};
|
|
2027
2027
|
}(), options)]);
|
|
2028
2028
|
|
|
@@ -2052,6 +2052,9 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2052
2052
|
|
|
2053
2053
|
var currentSpaceId = props.sdk.ids.space;
|
|
2054
2054
|
var currentEnvironmentId = (_props$sdk$ids$enviro = props.sdk.ids.environmentAlias) != null ? _props$sdk$ids$enviro : props.sdk.ids.environment;
|
|
2055
|
+
var environmentIds = useMemo(function () {
|
|
2056
|
+
return [props.sdk.ids.environmentAlias, props.sdk.ids.environment];
|
|
2057
|
+
}, [props.sdk.ids.environmentAlias, props.sdk.ids.environment]);
|
|
2055
2058
|
var queryClient = useQueryClient();
|
|
2056
2059
|
var queryCache = queryClient.getQueryCache();
|
|
2057
2060
|
var entityChangeUnsubscribers = useRef({});
|
|
@@ -2206,20 +2209,40 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2206
2209
|
}, [fetch]);
|
|
2207
2210
|
var isSameSpaceEntityQueryKey = useCallback(function (queryKey) {
|
|
2208
2211
|
var isEntityKey = isEntityQueryKey(queryKey);
|
|
2209
|
-
var isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && queryKey[3]
|
|
2212
|
+
var isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && environmentIds.includes(queryKey[3]);
|
|
2210
2213
|
return isSameSpaceEntityKey;
|
|
2211
|
-
}, [currentSpaceId,
|
|
2214
|
+
}, [currentSpaceId, environmentIds]); // @ts-expect-error ...
|
|
2212
2215
|
|
|
2213
2216
|
// @ts-expect-error ...
|
|
2214
2217
|
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
2218
|
+
var onSlideInNavigation = props.sdk.navigator.onSlideInNavigation;
|
|
2215
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
|
+
|
|
2216
2229
|
if (typeof onEntityChanged !== 'function') {
|
|
2217
|
-
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
|
+
});
|
|
2218
2241
|
}
|
|
2219
2242
|
|
|
2220
|
-
var subscribeQuery = function subscribeQuery(
|
|
2221
|
-
var queryKey =
|
|
2222
|
-
queryHash =
|
|
2243
|
+
var subscribeQuery = function subscribeQuery(_ref5) {
|
|
2244
|
+
var queryKey = _ref5.queryKey,
|
|
2245
|
+
queryHash = _ref5.queryHash;
|
|
2223
2246
|
var entityType = queryKey[0],
|
|
2224
2247
|
entityId = queryKey[1];
|
|
2225
2248
|
entityChangeUnsubscribers.current[queryHash] = onEntityChanged(entityType, entityId, function (data) {
|
|
@@ -2227,13 +2250,7 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2227
2250
|
});
|
|
2228
2251
|
};
|
|
2229
2252
|
|
|
2230
|
-
|
|
2231
|
-
type: 'active',
|
|
2232
|
-
predicate: function predicate(query) {
|
|
2233
|
-
return isSameSpaceEntityQueryKey(query.queryKey);
|
|
2234
|
-
}
|
|
2235
|
-
});
|
|
2236
|
-
queries.forEach(subscribeQuery);
|
|
2253
|
+
findSameSpaceQueries().forEach(subscribeQuery);
|
|
2237
2254
|
var unsubscribe = queryCache.subscribe(function (event) {
|
|
2238
2255
|
if (!event) {
|
|
2239
2256
|
return;
|
|
@@ -2266,30 +2283,35 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2266
2283
|
});
|
|
2267
2284
|
entityChangeUnsubscribers.current = {};
|
|
2268
2285
|
};
|
|
2269
|
-
}, [onEntityChanged, queryCache, isSameSpaceEntityQueryKey, queryClient]);
|
|
2286
|
+
}, [onEntityChanged, queryCache, isSameSpaceEntityQueryKey, queryClient, getEntity, onSlideInNavigation]);
|
|
2270
2287
|
return {
|
|
2288
|
+
ids: props.sdk.ids,
|
|
2271
2289
|
cmaClient: cmaClient,
|
|
2272
2290
|
fetch: fetch,
|
|
2273
2291
|
getResource: getResource,
|
|
2274
2292
|
getEntity: getEntity,
|
|
2275
|
-
ids: props.sdk.ids,
|
|
2276
2293
|
getEntityScheduledActions: getEntityScheduledActions
|
|
2277
2294
|
};
|
|
2278
|
-
}, function (_ref5) {
|
|
2279
|
-
var fetch = _ref5.fetch;
|
|
2280
|
-
return fetch;
|
|
2281
2295
|
}, function (_ref6) {
|
|
2282
|
-
var
|
|
2283
|
-
|
|
2284
|
-
|
|
2296
|
+
var fetch = _ref6.fetch;
|
|
2297
|
+
return fetch;
|
|
2298
|
+
}, function (_ref7) {
|
|
2299
|
+
var getResource = _ref7.getResource,
|
|
2300
|
+
getEntity = _ref7.getEntity,
|
|
2301
|
+
getEntityScheduledActions = _ref7.getEntityScheduledActions;
|
|
2285
2302
|
return {
|
|
2286
2303
|
getResource: getResource,
|
|
2287
2304
|
getEntity: getEntity,
|
|
2288
2305
|
getEntityScheduledActions: getEntityScheduledActions
|
|
2289
2306
|
};
|
|
2290
|
-
}, function (
|
|
2291
|
-
var
|
|
2292
|
-
|
|
2307
|
+
}, function (_ref8) {
|
|
2308
|
+
var _ids$environmentAlias;
|
|
2309
|
+
|
|
2310
|
+
var ids = _ref8.ids;
|
|
2311
|
+
return {
|
|
2312
|
+
environment: (_ids$environmentAlias = ids.environmentAlias) != null ? _ids$environmentAlias : ids.environment,
|
|
2313
|
+
space: ids.space
|
|
2314
|
+
};
|
|
2293
2315
|
}),
|
|
2294
2316
|
InternalServiceProvider = _constate[0],
|
|
2295
2317
|
useEntityLoader = _constate[2],
|
|
@@ -2342,9 +2364,9 @@ function useResource(resourceType, urn, options) {
|
|
|
2342
2364
|
};
|
|
2343
2365
|
}
|
|
2344
2366
|
|
|
2345
|
-
function EntityProvider(
|
|
2346
|
-
var children =
|
|
2347
|
-
props = _objectWithoutPropertiesLoose(
|
|
2367
|
+
function EntityProvider(_ref9) {
|
|
2368
|
+
var children = _ref9.children,
|
|
2369
|
+
props = _objectWithoutPropertiesLoose(_ref9, _excluded2);
|
|
2348
2370
|
|
|
2349
2371
|
var reactQueryClient = useMemo(function () {
|
|
2350
2372
|
var queryCache = new QueryCache();
|