@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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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
|
+
## [5.1.8](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.1.7...@contentful/field-editor-reference@5.1.8) (2022-09-12)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **reference-editor:** re-introduce entity refetch when slide-in is closed ([#1233](https://github.com/contentful/field-editors/issues/1233)) ([7026521](https://github.com/contentful/field-editors/commit/7026521d3c1885dbe61acd9dfc7a1e091a036565))
|
|
11
|
+
|
|
12
|
+
## [5.1.7](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.1.6...@contentful/field-editor-reference@5.1.7) (2022-09-09)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @contentful/field-editor-reference
|
|
15
|
+
|
|
16
|
+
## [5.1.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.1.5...@contentful/field-editor-reference@5.1.6) (2022-09-07)
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
- **reference-editor:** accept pubsub messages from alias and non-alias environments ([#1227](https://github.com/contentful/field-editors/issues/1227)) ([2d7d93a](https://github.com/contentful/field-editors/commit/2d7d93a2d3aa089f7ecdfec48c53c7839856ba0d))
|
|
21
|
+
|
|
6
22
|
## [5.1.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.1.4...@contentful/field-editor-reference@5.1.5) (2022-09-06)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @contentful/field-editor-reference
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import changed from './changed_asset.json';
|
|
2
|
+
import created from './created_asset.json';
|
|
3
|
+
import empty from './empty_asset.json';
|
|
4
|
+
import invalid from './invalid_asset.json';
|
|
5
|
+
import published from './published_asset.json';
|
|
6
|
+
export { changed, empty, published, invalid, created };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import englishDefault from './english_default_locale.json';
|
|
2
|
+
import german from './german_locale.json';
|
|
3
|
+
declare const list: {
|
|
4
|
+
sys: {
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
total: number;
|
|
8
|
+
skip: number;
|
|
9
|
+
limit: number;
|
|
10
|
+
items: {
|
|
11
|
+
sys: {
|
|
12
|
+
id: string;
|
|
13
|
+
type: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
version: number;
|
|
17
|
+
space: {
|
|
18
|
+
sys: {
|
|
19
|
+
type: string;
|
|
20
|
+
linkType: string;
|
|
21
|
+
id: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
environment: {
|
|
25
|
+
sys: {
|
|
26
|
+
id: string;
|
|
27
|
+
type: string;
|
|
28
|
+
linkType: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
name: string;
|
|
33
|
+
code: string;
|
|
34
|
+
internal_code: string;
|
|
35
|
+
fallbackCode: null;
|
|
36
|
+
contentDeliveryApi: boolean;
|
|
37
|
+
contentManagementApi: boolean;
|
|
38
|
+
default: boolean;
|
|
39
|
+
optional: boolean;
|
|
40
|
+
}[];
|
|
41
|
+
};
|
|
42
|
+
export { englishDefault, german, list };
|
|
@@ -1967,13 +1967,13 @@ function _fetchContentfulEntry() {
|
|
|
1967
1967
|
_resourceId$split = resourceId.split('/'), spaceId = _resourceId$split[1], entryId = _resourceId$split[3];
|
|
1968
1968
|
environmentId = 'master';
|
|
1969
1969
|
_context3.next = 6;
|
|
1970
|
-
return Promise.all([fetch(['space', spaceId], function (
|
|
1971
|
-
var cmaClient =
|
|
1970
|
+
return Promise.all([fetch(['space', spaceId], function (_ref10) {
|
|
1971
|
+
var cmaClient = _ref10.cmaClient;
|
|
1972
1972
|
return cmaClient.space.get({
|
|
1973
1973
|
spaceId: spaceId
|
|
1974
1974
|
});
|
|
1975
|
-
}, options), fetch(['entry', spaceId, environmentId, entryId], function (
|
|
1976
|
-
var cmaClient =
|
|
1975
|
+
}, options), fetch(['entry', spaceId, environmentId, entryId], function (_ref11) {
|
|
1976
|
+
var cmaClient = _ref11.cmaClient;
|
|
1977
1977
|
return cmaClient.entry.get({
|
|
1978
1978
|
spaceId: spaceId,
|
|
1979
1979
|
environmentId: environmentId,
|
|
@@ -1987,15 +1987,15 @@ function _fetchContentfulEntry() {
|
|
|
1987
1987
|
entry = _yield$Promise$all[1];
|
|
1988
1988
|
contentTypeId = entry.sys.contentType.sys.id;
|
|
1989
1989
|
_context3.next = 12;
|
|
1990
|
-
return Promise.all([fetch(['contentType', spaceId, environmentId, contentTypeId], function (
|
|
1991
|
-
var cmaClient =
|
|
1990
|
+
return Promise.all([fetch(['contentType', spaceId, environmentId, contentTypeId], function (_ref12) {
|
|
1991
|
+
var cmaClient = _ref12.cmaClient;
|
|
1992
1992
|
return cmaClient.contentType.get({
|
|
1993
1993
|
contentTypeId: contentTypeId,
|
|
1994
1994
|
spaceId: spaceId,
|
|
1995
1995
|
environmentId: environmentId
|
|
1996
1996
|
});
|
|
1997
1997
|
}, options), fetch(['defaultLocale', spaceId, environmentId], /*#__PURE__*/function () {
|
|
1998
|
-
var
|
|
1998
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref13) {
|
|
1999
1999
|
var _locales$items$find;
|
|
2000
2000
|
|
|
2001
2001
|
var cmaClient, locales, defaultLocaleCode;
|
|
@@ -2003,7 +2003,7 @@ function _fetchContentfulEntry() {
|
|
|
2003
2003
|
while (1) {
|
|
2004
2004
|
switch (_context2.prev = _context2.next) {
|
|
2005
2005
|
case 0:
|
|
2006
|
-
cmaClient =
|
|
2006
|
+
cmaClient = _ref13.cmaClient;
|
|
2007
2007
|
_context2.next = 3;
|
|
2008
2008
|
return cmaClient.locale.getMany({
|
|
2009
2009
|
spaceId: spaceId,
|
|
@@ -2029,7 +2029,7 @@ function _fetchContentfulEntry() {
|
|
|
2029
2029
|
}));
|
|
2030
2030
|
|
|
2031
2031
|
return function (_x3) {
|
|
2032
|
-
return
|
|
2032
|
+
return _ref14.apply(this, arguments);
|
|
2033
2033
|
};
|
|
2034
2034
|
}(), options)]);
|
|
2035
2035
|
|
|
@@ -2059,6 +2059,9 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2059
2059
|
|
|
2060
2060
|
var currentSpaceId = props.sdk.ids.space;
|
|
2061
2061
|
var currentEnvironmentId = (_props$sdk$ids$enviro = props.sdk.ids.environmentAlias) != null ? _props$sdk$ids$enviro : props.sdk.ids.environment;
|
|
2062
|
+
var environmentIds = React.useMemo(function () {
|
|
2063
|
+
return [props.sdk.ids.environmentAlias, props.sdk.ids.environment];
|
|
2064
|
+
}, [props.sdk.ids.environmentAlias, props.sdk.ids.environment]);
|
|
2062
2065
|
var queryClient = reactQuery.useQueryClient();
|
|
2063
2066
|
var queryCache = queryClient.getQueryCache();
|
|
2064
2067
|
var entityChangeUnsubscribers = React.useRef({});
|
|
@@ -2213,20 +2216,40 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2213
2216
|
}, [fetch]);
|
|
2214
2217
|
var isSameSpaceEntityQueryKey = React.useCallback(function (queryKey) {
|
|
2215
2218
|
var isEntityKey = isEntityQueryKey(queryKey);
|
|
2216
|
-
var isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && queryKey[3]
|
|
2219
|
+
var isSameSpaceEntityKey = isEntityKey && queryKey[2] === currentSpaceId && environmentIds.includes(queryKey[3]);
|
|
2217
2220
|
return isSameSpaceEntityKey;
|
|
2218
|
-
}, [currentSpaceId,
|
|
2221
|
+
}, [currentSpaceId, environmentIds]); // @ts-expect-error ...
|
|
2219
2222
|
|
|
2220
2223
|
// @ts-expect-error ...
|
|
2221
2224
|
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
2225
|
+
var onSlideInNavigation = props.sdk.navigator.onSlideInNavigation;
|
|
2222
2226
|
React.useEffect(function () {
|
|
2227
|
+
function findSameSpaceQueries() {
|
|
2228
|
+
return queryCache.findAll({
|
|
2229
|
+
type: 'active',
|
|
2230
|
+
predicate: function predicate(query) {
|
|
2231
|
+
return isSameSpaceEntityQueryKey(query.queryKey);
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2223
2236
|
if (typeof onEntityChanged !== 'function') {
|
|
2224
|
-
return
|
|
2237
|
+
return onSlideInNavigation(function (_ref4) {
|
|
2238
|
+
var oldSlideLevel = _ref4.oldSlideLevel,
|
|
2239
|
+
newSlideLevel = _ref4.newSlideLevel;
|
|
2240
|
+
|
|
2241
|
+
if (oldSlideLevel > newSlideLevel) {
|
|
2242
|
+
findSameSpaceQueries().forEach(function (query) {
|
|
2243
|
+
// automatically refetches the query
|
|
2244
|
+
void queryClient.invalidateQueries(query.queryKey);
|
|
2245
|
+
});
|
|
2246
|
+
}
|
|
2247
|
+
});
|
|
2225
2248
|
}
|
|
2226
2249
|
|
|
2227
|
-
var subscribeQuery = function subscribeQuery(
|
|
2228
|
-
var queryKey =
|
|
2229
|
-
queryHash =
|
|
2250
|
+
var subscribeQuery = function subscribeQuery(_ref5) {
|
|
2251
|
+
var queryKey = _ref5.queryKey,
|
|
2252
|
+
queryHash = _ref5.queryHash;
|
|
2230
2253
|
var entityType = queryKey[0],
|
|
2231
2254
|
entityId = queryKey[1];
|
|
2232
2255
|
entityChangeUnsubscribers.current[queryHash] = onEntityChanged(entityType, entityId, function (data) {
|
|
@@ -2234,13 +2257,7 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2234
2257
|
});
|
|
2235
2258
|
};
|
|
2236
2259
|
|
|
2237
|
-
|
|
2238
|
-
type: 'active',
|
|
2239
|
-
predicate: function predicate(query) {
|
|
2240
|
-
return isSameSpaceEntityQueryKey(query.queryKey);
|
|
2241
|
-
}
|
|
2242
|
-
});
|
|
2243
|
-
queries.forEach(subscribeQuery);
|
|
2260
|
+
findSameSpaceQueries().forEach(subscribeQuery);
|
|
2244
2261
|
var unsubscribe = queryCache.subscribe(function (event) {
|
|
2245
2262
|
if (!event) {
|
|
2246
2263
|
return;
|
|
@@ -2273,30 +2290,35 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2273
2290
|
});
|
|
2274
2291
|
entityChangeUnsubscribers.current = {};
|
|
2275
2292
|
};
|
|
2276
|
-
}, [onEntityChanged, queryCache, isSameSpaceEntityQueryKey, queryClient]);
|
|
2293
|
+
}, [onEntityChanged, queryCache, isSameSpaceEntityQueryKey, queryClient, getEntity, onSlideInNavigation]);
|
|
2277
2294
|
return {
|
|
2295
|
+
ids: props.sdk.ids,
|
|
2278
2296
|
cmaClient: cmaClient,
|
|
2279
2297
|
fetch: fetch,
|
|
2280
2298
|
getResource: getResource,
|
|
2281
2299
|
getEntity: getEntity,
|
|
2282
|
-
ids: props.sdk.ids,
|
|
2283
2300
|
getEntityScheduledActions: getEntityScheduledActions
|
|
2284
2301
|
};
|
|
2285
|
-
}, function (_ref5) {
|
|
2286
|
-
var fetch = _ref5.fetch;
|
|
2287
|
-
return fetch;
|
|
2288
2302
|
}, function (_ref6) {
|
|
2289
|
-
var
|
|
2290
|
-
|
|
2291
|
-
|
|
2303
|
+
var fetch = _ref6.fetch;
|
|
2304
|
+
return fetch;
|
|
2305
|
+
}, function (_ref7) {
|
|
2306
|
+
var getResource = _ref7.getResource,
|
|
2307
|
+
getEntity = _ref7.getEntity,
|
|
2308
|
+
getEntityScheduledActions = _ref7.getEntityScheduledActions;
|
|
2292
2309
|
return {
|
|
2293
2310
|
getResource: getResource,
|
|
2294
2311
|
getEntity: getEntity,
|
|
2295
2312
|
getEntityScheduledActions: getEntityScheduledActions
|
|
2296
2313
|
};
|
|
2297
|
-
}, function (
|
|
2298
|
-
var
|
|
2299
|
-
|
|
2314
|
+
}, function (_ref8) {
|
|
2315
|
+
var _ids$environmentAlias;
|
|
2316
|
+
|
|
2317
|
+
var ids = _ref8.ids;
|
|
2318
|
+
return {
|
|
2319
|
+
environment: (_ids$environmentAlias = ids.environmentAlias) != null ? _ids$environmentAlias : ids.environment,
|
|
2320
|
+
space: ids.space
|
|
2321
|
+
};
|
|
2300
2322
|
}),
|
|
2301
2323
|
InternalServiceProvider = _constate[0],
|
|
2302
2324
|
useEntityLoader = _constate[2],
|
|
@@ -2349,9 +2371,9 @@ function useResource(resourceType, urn, options) {
|
|
|
2349
2371
|
};
|
|
2350
2372
|
}
|
|
2351
2373
|
|
|
2352
|
-
function EntityProvider(
|
|
2353
|
-
var children =
|
|
2354
|
-
props = _objectWithoutPropertiesLoose(
|
|
2374
|
+
function EntityProvider(_ref9) {
|
|
2375
|
+
var children = _ref9.children,
|
|
2376
|
+
props = _objectWithoutPropertiesLoose(_ref9, _excluded2);
|
|
2355
2377
|
|
|
2356
2378
|
var reactQueryClient = React.useMemo(function () {
|
|
2357
2379
|
var queryCache = new reactQuery.QueryCache();
|