@contentful/field-editor-rich-text 2.0.0-next.38 → 2.0.0-next.39

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.
@@ -732,7 +732,6 @@ function renderActions(props) {
732
732
  key: "section-title"
733
733
  }, "Actions"), onEdit ? /*#__PURE__*/React.createElement(f36Components.Menu.Item, {
734
734
  key: "edit",
735
- disabled: isDisabled,
736
735
  onClick: onEdit,
737
736
  testId: "card-action-edit"
738
737
  }, "Edit") : null, entityFile ? /*#__PURE__*/React.createElement(f36Components.Menu.Item, {
@@ -935,7 +934,6 @@ function FetchingWrappedEntryCard(props) {
935
934
  if (!props.onEdit || !props.onRemove) return undefined;
936
935
  return [props.onEdit ? /*#__PURE__*/React.createElement(f36Components.MenuItem, {
937
936
  key: "edit",
938
- disabled: props.isDisabled,
939
937
  testId: "card-action-edit",
940
938
  onClick: function onClick() {
941
939
  props.onEdit && props.onEdit();
@@ -1019,7 +1017,8 @@ var styles$3 = {
1019
1017
  // The next 2 properties ensure Entity card won't be aligned above
1020
1018
  // a list item marker (i.e. bullet)
1021
1019
  display: 'inline-block',
1022
- verticalAlign: 'text-top'
1020
+ verticalAlign: 'text-top',
1021
+ width: '100%'
1023
1022
  })
1024
1023
  };
1025
1024
  function LinkedEntityBlock(props) {
@@ -2248,8 +2247,7 @@ function FetchingWrappedInlineEntryCard(props) {
2248
2247
  status: status,
2249
2248
  actions: [/*#__PURE__*/React__default.createElement(f36Components.MenuItem, {
2250
2249
  key: "edit",
2251
- onClick: props.onEdit,
2252
- disabled: props.isDisabled
2250
+ onClick: props.onEdit
2253
2251
  }, "Edit"), /*#__PURE__*/React__default.createElement(f36Components.MenuItem, {
2254
2252
  key: "remove",
2255
2253
  onClick: props.onRemove,
@@ -3105,7 +3103,8 @@ function HyperlinkModal(props) {
3105
3103
  onChange: function onChange(event) {
3106
3104
  return setLinkType(event.target.value);
3107
3105
  },
3108
- testId: "link-type-input"
3106
+ testId: "link-type-input",
3107
+ isDisabled: props.readonly
3109
3108
  }, enabledLinkTypes.map(function (nodeType) {
3110
3109
  return /*#__PURE__*/React.createElement(f36Components.Select.Option, {
3111
3110
  key: nodeType,
@@ -3121,11 +3120,12 @@ function HyperlinkModal(props) {
3121
3120
  setLinkEntity(null);
3122
3121
  setLinkTarget(event.target.value);
3123
3122
  },
3124
- testId: "link-target-input"
3123
+ testId: "link-target-input",
3124
+ isDisabled: props.readonly
3125
3125
  }), /*#__PURE__*/React.createElement(f36Components.FormControl.HelpText, null, "A protocol may be required, e.g. https://")), linkType !== Contentful.INLINES.HYPERLINK && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(f36Components.FormLabel, {
3126
3126
  isRequired: true,
3127
3127
  htmlFor: ""
3128
- }, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(f36Components.TextLink, {
3128
+ }, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? /*#__PURE__*/React.createElement(React.Fragment, null, !props.readonly && /*#__PURE__*/React.createElement(f36Components.TextLink, {
3129
3129
  testId: "entity-selection-link",
3130
3130
  onClick: resetLinkEntity,
3131
3131
  className: styles$b.removeSelectionLabel
@@ -3159,7 +3159,7 @@ function HyperlinkModal(props) {
3159
3159
  type: "submit",
3160
3160
  variant: "positive",
3161
3161
  size: "small",
3162
- isDisabled: !isLinkComplete(),
3162
+ isDisabled: props.readonly || !isLinkComplete(),
3163
3163
  onClick: handleOnSubmit,
3164
3164
  testId: "confirm-cta"
3165
3165
  }, props.linkType ? 'Update' : 'Insert'))));
@@ -3172,22 +3172,23 @@ function _addOrEditLink() {
3172
3172
  _addOrEditLink = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(editor, sdk, logAction, targetPath) {
3173
3173
  var _target$sys$linkType;
3174
3174
 
3175
- var selectionBeforeBlur, linkType, linkText, linkTarget, linkEntity, _getNodeEntryFromSele, node, path, selectionAfterFocus, currentLinkText, isEditing, data, text, url, type, target;
3175
+ var isReadOnly, selectionBeforeBlur, linkType, linkText, linkTarget, linkEntity, _getNodeEntryFromSele, node, path, selectionAfterFocus, currentLinkText, isEditing, data, text, url, type, target;
3176
3176
 
3177
3177
  return runtime_1.wrap(function _callee3$(_context3) {
3178
3178
  while (1) {
3179
3179
  switch (_context3.prev = _context3.next) {
3180
3180
  case 0:
3181
+ isReadOnly = Slate.ReactEditor.isReadOnly(editor);
3181
3182
  selectionBeforeBlur = editor.selection ? _extends({}, editor.selection) : undefined;
3182
3183
 
3183
3184
  if (!(!targetPath && !selectionBeforeBlur)) {
3184
- _context3.next = 3;
3185
+ _context3.next = 4;
3185
3186
  break;
3186
3187
  }
3187
3188
 
3188
3189
  return _context3.abrupt("return");
3189
3190
 
3190
- case 3:
3191
+ case 4:
3191
3192
  _getNodeEntryFromSele = getNodeEntryFromSelection(editor, LINK_TYPES, targetPath), node = _getNodeEntryFromSele[0], path = _getNodeEntryFromSele[1];
3192
3193
 
3193
3194
  if (node && path) {
@@ -3201,7 +3202,7 @@ function _addOrEditLink() {
3201
3202
  currentLinkText = linkText || (editor.selection ? slate.Editor.string(editor, editor.selection) : '');
3202
3203
  isEditing = Boolean(node && path);
3203
3204
  logAction(isEditing ? 'openEditHyperlinkDialog' : 'openCreateHyperlinkDialog');
3204
- _context3.next = 11;
3205
+ _context3.next = 12;
3205
3206
  return fieldEditorShared.ModalDialogLauncher.openDialog({
3206
3207
  title: isEditing ? 'Edit hyperlink' : 'Insert hyperlink',
3207
3208
  width: 'large',
@@ -3216,16 +3217,17 @@ function _addOrEditLink() {
3216
3217
  linkType: linkType,
3217
3218
  linkEntity: linkEntity,
3218
3219
  onClose: onClose,
3219
- sdk: sdk
3220
+ sdk: sdk,
3221
+ readonly: isReadOnly
3220
3222
  });
3221
3223
  });
3222
3224
 
3223
- case 11:
3225
+ case 12:
3224
3226
  data = _context3.sent;
3225
3227
  slate.Transforms.select(editor, selectionAfterFocus);
3226
3228
 
3227
3229
  if (data) {
3228
- _context3.next = 17;
3230
+ _context3.next = 18;
3229
3231
  break;
3230
3232
  }
3231
3233
 
@@ -3233,7 +3235,7 @@ function _addOrEditLink() {
3233
3235
  logAction(isEditing ? 'cancelEditHyperlinkDialog' : 'cancelCreateHyperlinkDialog');
3234
3236
  return _context3.abrupt("return");
3235
3237
 
3236
- case 17:
3238
+ case 18:
3237
3239
  text = data.linkText, url = data.linkTarget, type = data.linkType, target = data.linkEntity;
3238
3240
  slate.Editor.withoutNormalizing(editor, function () {
3239
3241
  insertLink(editor, {
@@ -3250,7 +3252,7 @@ function _addOrEditLink() {
3250
3252
  });
3251
3253
  focus(editor);
3252
3254
 
3253
- case 21:
3255
+ case 22:
3254
3256
  case "end":
3255
3257
  return _context3.stop();
3256
3258
  }
@@ -3489,7 +3491,6 @@ var styles$c = {
3489
3491
 
3490
3492
  function EntityHyperlink(props) {
3491
3493
  var editor = useContentfulEditor();
3492
- var isReadOnly = Slate.useReadOnly();
3493
3494
  var sdk = useSdkContext();
3494
3495
  var target = props.element.data.target;
3495
3496
  var onEntityFetchComplete = props.onEntityFetchComplete;
@@ -3519,7 +3520,6 @@ function EntityHyperlink(props) {
3519
3520
  }, /*#__PURE__*/React.createElement(f36Components.TextLink, {
3520
3521
  as: "a",
3521
3522
  onClick: handleClick,
3522
- isDisabled: isReadOnly,
3523
3523
  className: styles$c.hyperlink,
3524
3524
  "data-link-type": target.sys.linkType,
3525
3525
  "data-link-id": target.sys.id
@@ -3528,7 +3528,6 @@ function EntityHyperlink(props) {
3528
3528
 
3529
3529
  function UrlHyperlink(props) {
3530
3530
  var editor = useContentfulEditor();
3531
- var isReadOnly = Slate.useReadOnly();
3532
3531
  var sdk = useSdkContext();
3533
3532
  var uri = props.element.data.uri;
3534
3533
 
@@ -3553,7 +3552,6 @@ function UrlHyperlink(props) {
3553
3552
  href: uri,
3554
3553
  rel: "noopener noreferrer",
3555
3554
  onClick: handleClick,
3556
- isDisabled: isReadOnly,
3557
3555
  className: styles$c.hyperlink
3558
3556
  }, props.children));
3559
3557
  }
@@ -6889,7 +6887,8 @@ var styles$j = {
6889
6887
  }
6890
6888
  }),
6891
6889
  disabled: /*#__PURE__*/emotion.css({
6892
- background: tokens.gray100
6890
+ background: tokens.gray100,
6891
+ cursor: 'not-allowed'
6893
6892
  })
6894
6893
  };
6895
6894