@contentful/field-editor-reference 5.5.3 → 5.5.4
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 +4 -0
- package/dist/field-editor-reference.cjs.development.js +13 -8
- 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 +13 -8
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/dist/resources/useResourceLinkActions.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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.5.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.5.3...@contentful/field-editor-reference@5.5.4) (2022-12-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @contentful/field-editor-reference
|
|
9
|
+
|
|
6
10
|
## [5.5.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.5.2...@contentful/field-editor-reference@5.5.3) (2022-12-08)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @contentful/field-editor-reference
|
|
@@ -4044,32 +4044,37 @@ function ResourceCard(props) {
|
|
|
4044
4044
|
})));
|
|
4045
4045
|
}
|
|
4046
4046
|
|
|
4047
|
-
var toLinkItem = function toLinkItem(entry) {
|
|
4047
|
+
var toLinkItem = function toLinkItem(entry, apiUrl) {
|
|
4048
|
+
var _entry$sys$urn;
|
|
4049
|
+
|
|
4048
4050
|
return {
|
|
4049
4051
|
sys: {
|
|
4050
4052
|
type: 'ResourceLink',
|
|
4051
4053
|
linkType: 'Contentful:Entry',
|
|
4052
|
-
urn: entry.sys.urn
|
|
4054
|
+
urn: (_entry$sys$urn = entry.sys.urn) != null ? _entry$sys$urn : "crn:" + apiUrl + ":::content:spaces/" + entry.sys.space.sys.id + "/entries/" + entry.sys.id
|
|
4053
4055
|
}
|
|
4054
4056
|
};
|
|
4055
4057
|
};
|
|
4056
4058
|
|
|
4057
|
-
var getUpdatedValue = function getUpdatedValue(field, entries) {
|
|
4059
|
+
var getUpdatedValue = function getUpdatedValue(field, entries, apiUrl) {
|
|
4058
4060
|
var multiple = field.type === 'Array';
|
|
4059
4061
|
|
|
4060
4062
|
if (multiple) {
|
|
4061
|
-
var linkItems = entries.map(
|
|
4063
|
+
var linkItems = entries.map(function (entry) {
|
|
4064
|
+
return toLinkItem(entry, apiUrl);
|
|
4065
|
+
});
|
|
4062
4066
|
var prevValue = field.getValue() || [];
|
|
4063
4067
|
return [].concat(prevValue, linkItems);
|
|
4064
4068
|
} else {
|
|
4065
|
-
return toLinkItem(entries[0]);
|
|
4069
|
+
return toLinkItem(entries[0], apiUrl);
|
|
4066
4070
|
}
|
|
4067
4071
|
};
|
|
4068
4072
|
|
|
4069
4073
|
function useResourceLinkActions(_ref) {
|
|
4070
4074
|
var dialogs = _ref.dialogs,
|
|
4071
4075
|
field = _ref.field,
|
|
4072
|
-
onAfterLink = _ref.onAfterLink
|
|
4076
|
+
onAfterLink = _ref.onAfterLink,
|
|
4077
|
+
apiUrl = _ref.apiUrl;
|
|
4073
4078
|
var handleAfterLink = React.useCallback(function (entries) {
|
|
4074
4079
|
if (!onAfterLink) {
|
|
4075
4080
|
return;
|
|
@@ -4079,11 +4084,11 @@ function useResourceLinkActions(_ref) {
|
|
|
4079
4084
|
}, [onAfterLink]);
|
|
4080
4085
|
var onLinkedExisting = React.useMemo(function () {
|
|
4081
4086
|
return function (entries) {
|
|
4082
|
-
var updatedValue = getUpdatedValue(field, entries);
|
|
4087
|
+
var updatedValue = getUpdatedValue(field, entries, apiUrl);
|
|
4083
4088
|
field.setValue(updatedValue);
|
|
4084
4089
|
handleAfterLink(entries);
|
|
4085
4090
|
};
|
|
4086
|
-
}, [field, handleAfterLink]);
|
|
4091
|
+
}, [field, handleAfterLink, apiUrl]);
|
|
4087
4092
|
var multiple = field.type === 'Array';
|
|
4088
4093
|
var onLinkExisting = React.useMemo(function () {
|
|
4089
4094
|
var promptSelection = multiple ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|