@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.
@@ -4037,32 +4037,37 @@ function ResourceCard(props) {
4037
4037
  })));
4038
4038
  }
4039
4039
 
4040
- var toLinkItem = function toLinkItem(entry) {
4040
+ var toLinkItem = function toLinkItem(entry, apiUrl) {
4041
+ var _entry$sys$urn;
4042
+
4041
4043
  return {
4042
4044
  sys: {
4043
4045
  type: 'ResourceLink',
4044
4046
  linkType: 'Contentful:Entry',
4045
- urn: entry.sys.urn
4047
+ urn: (_entry$sys$urn = entry.sys.urn) != null ? _entry$sys$urn : "crn:" + apiUrl + ":::content:spaces/" + entry.sys.space.sys.id + "/entries/" + entry.sys.id
4046
4048
  }
4047
4049
  };
4048
4050
  };
4049
4051
 
4050
- var getUpdatedValue = function getUpdatedValue(field, entries) {
4052
+ var getUpdatedValue = function getUpdatedValue(field, entries, apiUrl) {
4051
4053
  var multiple = field.type === 'Array';
4052
4054
 
4053
4055
  if (multiple) {
4054
- var linkItems = entries.map(toLinkItem);
4056
+ var linkItems = entries.map(function (entry) {
4057
+ return toLinkItem(entry, apiUrl);
4058
+ });
4055
4059
  var prevValue = field.getValue() || [];
4056
4060
  return [].concat(prevValue, linkItems);
4057
4061
  } else {
4058
- return toLinkItem(entries[0]);
4062
+ return toLinkItem(entries[0], apiUrl);
4059
4063
  }
4060
4064
  };
4061
4065
 
4062
4066
  function useResourceLinkActions(_ref) {
4063
4067
  var dialogs = _ref.dialogs,
4064
4068
  field = _ref.field,
4065
- onAfterLink = _ref.onAfterLink;
4069
+ onAfterLink = _ref.onAfterLink,
4070
+ apiUrl = _ref.apiUrl;
4066
4071
  var handleAfterLink = useCallback(function (entries) {
4067
4072
  if (!onAfterLink) {
4068
4073
  return;
@@ -4072,11 +4077,11 @@ function useResourceLinkActions(_ref) {
4072
4077
  }, [onAfterLink]);
4073
4078
  var onLinkedExisting = useMemo(function () {
4074
4079
  return function (entries) {
4075
- var updatedValue = getUpdatedValue(field, entries);
4080
+ var updatedValue = getUpdatedValue(field, entries, apiUrl);
4076
4081
  field.setValue(updatedValue);
4077
4082
  handleAfterLink(entries);
4078
4083
  };
4079
- }, [field, handleAfterLink]);
4084
+ }, [field, handleAfterLink, apiUrl]);
4080
4085
  var multiple = field.type === 'Array';
4081
4086
  var onLinkExisting = useMemo(function () {
4082
4087
  var promptSelection = multiple ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {