@contentful/field-editor-rich-text 2.0.0-next.36 → 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.
- package/dist/field-editor-rich-text.cjs.development.js +27 -43
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +27 -43
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/plugins/Hyperlink/HyperlinkModal.d.ts +1 -0
- package/dist/test-utils/jsx.d.ts +1 -1
- package/package.json +3 -3
|
@@ -451,7 +451,7 @@ function moveToTheNextLine(editor) {
|
|
|
451
451
|
function moveToTheNextChar(editor) {
|
|
452
452
|
Transforms.move(editor, {
|
|
453
453
|
distance: 1,
|
|
454
|
-
unit: '
|
|
454
|
+
unit: 'offset'
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
function insertEmptyParagraph(editor, options) {
|
|
@@ -725,7 +725,6 @@ function renderActions(props) {
|
|
|
725
725
|
key: "section-title"
|
|
726
726
|
}, "Actions"), onEdit ? /*#__PURE__*/createElement(Menu.Item, {
|
|
727
727
|
key: "edit",
|
|
728
|
-
disabled: isDisabled,
|
|
729
728
|
onClick: onEdit,
|
|
730
729
|
testId: "card-action-edit"
|
|
731
730
|
}, "Edit") : null, entityFile ? /*#__PURE__*/createElement(Menu.Item, {
|
|
@@ -928,7 +927,6 @@ function FetchingWrappedEntryCard(props) {
|
|
|
928
927
|
if (!props.onEdit || !props.onRemove) return undefined;
|
|
929
928
|
return [props.onEdit ? /*#__PURE__*/createElement(MenuItem, {
|
|
930
929
|
key: "edit",
|
|
931
|
-
disabled: props.isDisabled,
|
|
932
930
|
testId: "card-action-edit",
|
|
933
931
|
onClick: function onClick() {
|
|
934
932
|
props.onEdit && props.onEdit();
|
|
@@ -1012,7 +1010,8 @@ var styles$3 = {
|
|
|
1012
1010
|
// The next 2 properties ensure Entity card won't be aligned above
|
|
1013
1011
|
// a list item marker (i.e. bullet)
|
|
1014
1012
|
display: 'inline-block',
|
|
1015
|
-
verticalAlign: 'text-top'
|
|
1013
|
+
verticalAlign: 'text-top',
|
|
1014
|
+
width: '100%'
|
|
1016
1015
|
})
|
|
1017
1016
|
};
|
|
1018
1017
|
function LinkedEntityBlock(props) {
|
|
@@ -2241,8 +2240,7 @@ function FetchingWrappedInlineEntryCard(props) {
|
|
|
2241
2240
|
status: status,
|
|
2242
2241
|
actions: [/*#__PURE__*/React__default.createElement(MenuItem, {
|
|
2243
2242
|
key: "edit",
|
|
2244
|
-
onClick: props.onEdit
|
|
2245
|
-
disabled: props.isDisabled
|
|
2243
|
+
onClick: props.onEdit
|
|
2246
2244
|
}, "Edit"), /*#__PURE__*/React__default.createElement(MenuItem, {
|
|
2247
2245
|
key: "remove",
|
|
2248
2246
|
onClick: props.onRemove,
|
|
@@ -3098,7 +3096,8 @@ function HyperlinkModal(props) {
|
|
|
3098
3096
|
onChange: function onChange(event) {
|
|
3099
3097
|
return setLinkType(event.target.value);
|
|
3100
3098
|
},
|
|
3101
|
-
testId: "link-type-input"
|
|
3099
|
+
testId: "link-type-input",
|
|
3100
|
+
isDisabled: props.readonly
|
|
3102
3101
|
}, enabledLinkTypes.map(function (nodeType) {
|
|
3103
3102
|
return /*#__PURE__*/createElement(Select.Option, {
|
|
3104
3103
|
key: nodeType,
|
|
@@ -3114,11 +3113,12 @@ function HyperlinkModal(props) {
|
|
|
3114
3113
|
setLinkEntity(null);
|
|
3115
3114
|
setLinkTarget(event.target.value);
|
|
3116
3115
|
},
|
|
3117
|
-
testId: "link-target-input"
|
|
3116
|
+
testId: "link-target-input",
|
|
3117
|
+
isDisabled: props.readonly
|
|
3118
3118
|
}), /*#__PURE__*/createElement(FormControl.HelpText, null, "A protocol may be required, e.g. https://")), linkType !== INLINES.HYPERLINK && /*#__PURE__*/createElement("div", null, /*#__PURE__*/createElement(FormLabel, {
|
|
3119
3119
|
isRequired: true,
|
|
3120
3120
|
htmlFor: ""
|
|
3121
|
-
}, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(TextLink, {
|
|
3121
|
+
}, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? /*#__PURE__*/createElement(Fragment, null, !props.readonly && /*#__PURE__*/createElement(TextLink, {
|
|
3122
3122
|
testId: "entity-selection-link",
|
|
3123
3123
|
onClick: resetLinkEntity,
|
|
3124
3124
|
className: styles$b.removeSelectionLabel
|
|
@@ -3152,7 +3152,7 @@ function HyperlinkModal(props) {
|
|
|
3152
3152
|
type: "submit",
|
|
3153
3153
|
variant: "positive",
|
|
3154
3154
|
size: "small",
|
|
3155
|
-
isDisabled: !isLinkComplete(),
|
|
3155
|
+
isDisabled: props.readonly || !isLinkComplete(),
|
|
3156
3156
|
onClick: handleOnSubmit,
|
|
3157
3157
|
testId: "confirm-cta"
|
|
3158
3158
|
}, props.linkType ? 'Update' : 'Insert'))));
|
|
@@ -3165,22 +3165,23 @@ function _addOrEditLink() {
|
|
|
3165
3165
|
_addOrEditLink = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(editor, sdk, logAction, targetPath) {
|
|
3166
3166
|
var _target$sys$linkType;
|
|
3167
3167
|
|
|
3168
|
-
var selectionBeforeBlur, linkType, linkText, linkTarget, linkEntity, _getNodeEntryFromSele, node, path, selectionAfterFocus, currentLinkText, isEditing, data, text, url, type, target;
|
|
3168
|
+
var isReadOnly, selectionBeforeBlur, linkType, linkText, linkTarget, linkEntity, _getNodeEntryFromSele, node, path, selectionAfterFocus, currentLinkText, isEditing, data, text, url, type, target;
|
|
3169
3169
|
|
|
3170
3170
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
3171
3171
|
while (1) {
|
|
3172
3172
|
switch (_context3.prev = _context3.next) {
|
|
3173
3173
|
case 0:
|
|
3174
|
+
isReadOnly = ReactEditor.isReadOnly(editor);
|
|
3174
3175
|
selectionBeforeBlur = editor.selection ? _extends({}, editor.selection) : undefined;
|
|
3175
3176
|
|
|
3176
3177
|
if (!(!targetPath && !selectionBeforeBlur)) {
|
|
3177
|
-
_context3.next =
|
|
3178
|
+
_context3.next = 4;
|
|
3178
3179
|
break;
|
|
3179
3180
|
}
|
|
3180
3181
|
|
|
3181
3182
|
return _context3.abrupt("return");
|
|
3182
3183
|
|
|
3183
|
-
case
|
|
3184
|
+
case 4:
|
|
3184
3185
|
_getNodeEntryFromSele = getNodeEntryFromSelection(editor, LINK_TYPES, targetPath), node = _getNodeEntryFromSele[0], path = _getNodeEntryFromSele[1];
|
|
3185
3186
|
|
|
3186
3187
|
if (node && path) {
|
|
@@ -3194,7 +3195,7 @@ function _addOrEditLink() {
|
|
|
3194
3195
|
currentLinkText = linkText || (editor.selection ? Editor.string(editor, editor.selection) : '');
|
|
3195
3196
|
isEditing = Boolean(node && path);
|
|
3196
3197
|
logAction(isEditing ? 'openEditHyperlinkDialog' : 'openCreateHyperlinkDialog');
|
|
3197
|
-
_context3.next =
|
|
3198
|
+
_context3.next = 12;
|
|
3198
3199
|
return ModalDialogLauncher.openDialog({
|
|
3199
3200
|
title: isEditing ? 'Edit hyperlink' : 'Insert hyperlink',
|
|
3200
3201
|
width: 'large',
|
|
@@ -3209,16 +3210,17 @@ function _addOrEditLink() {
|
|
|
3209
3210
|
linkType: linkType,
|
|
3210
3211
|
linkEntity: linkEntity,
|
|
3211
3212
|
onClose: onClose,
|
|
3212
|
-
sdk: sdk
|
|
3213
|
+
sdk: sdk,
|
|
3214
|
+
readonly: isReadOnly
|
|
3213
3215
|
});
|
|
3214
3216
|
});
|
|
3215
3217
|
|
|
3216
|
-
case
|
|
3218
|
+
case 12:
|
|
3217
3219
|
data = _context3.sent;
|
|
3218
3220
|
Transforms.select(editor, selectionAfterFocus);
|
|
3219
3221
|
|
|
3220
3222
|
if (data) {
|
|
3221
|
-
_context3.next =
|
|
3223
|
+
_context3.next = 18;
|
|
3222
3224
|
break;
|
|
3223
3225
|
}
|
|
3224
3226
|
|
|
@@ -3226,7 +3228,7 @@ function _addOrEditLink() {
|
|
|
3226
3228
|
logAction(isEditing ? 'cancelEditHyperlinkDialog' : 'cancelCreateHyperlinkDialog');
|
|
3227
3229
|
return _context3.abrupt("return");
|
|
3228
3230
|
|
|
3229
|
-
case
|
|
3231
|
+
case 18:
|
|
3230
3232
|
text = data.linkText, url = data.linkTarget, type = data.linkType, target = data.linkEntity;
|
|
3231
3233
|
Editor.withoutNormalizing(editor, function () {
|
|
3232
3234
|
insertLink(editor, {
|
|
@@ -3243,7 +3245,7 @@ function _addOrEditLink() {
|
|
|
3243
3245
|
});
|
|
3244
3246
|
focus(editor);
|
|
3245
3247
|
|
|
3246
|
-
case
|
|
3248
|
+
case 22:
|
|
3247
3249
|
case "end":
|
|
3248
3250
|
return _context3.stop();
|
|
3249
3251
|
}
|
|
@@ -3482,7 +3484,6 @@ var styles$c = {
|
|
|
3482
3484
|
|
|
3483
3485
|
function EntityHyperlink(props) {
|
|
3484
3486
|
var editor = useContentfulEditor();
|
|
3485
|
-
var isReadOnly = useReadOnly();
|
|
3486
3487
|
var sdk = useSdkContext();
|
|
3487
3488
|
var target = props.element.data.target;
|
|
3488
3489
|
var onEntityFetchComplete = props.onEntityFetchComplete;
|
|
@@ -3512,7 +3513,6 @@ function EntityHyperlink(props) {
|
|
|
3512
3513
|
}, /*#__PURE__*/createElement(TextLink, {
|
|
3513
3514
|
as: "a",
|
|
3514
3515
|
onClick: handleClick,
|
|
3515
|
-
isDisabled: isReadOnly,
|
|
3516
3516
|
className: styles$c.hyperlink,
|
|
3517
3517
|
"data-link-type": target.sys.linkType,
|
|
3518
3518
|
"data-link-id": target.sys.id
|
|
@@ -3521,7 +3521,6 @@ function EntityHyperlink(props) {
|
|
|
3521
3521
|
|
|
3522
3522
|
function UrlHyperlink(props) {
|
|
3523
3523
|
var editor = useContentfulEditor();
|
|
3524
|
-
var isReadOnly = useReadOnly();
|
|
3525
3524
|
var sdk = useSdkContext();
|
|
3526
3525
|
var uri = props.element.data.uri;
|
|
3527
3526
|
|
|
@@ -3546,7 +3545,6 @@ function UrlHyperlink(props) {
|
|
|
3546
3545
|
href: uri,
|
|
3547
3546
|
rel: "noopener noreferrer",
|
|
3548
3547
|
onClick: handleClick,
|
|
3549
|
-
isDisabled: isReadOnly,
|
|
3550
3548
|
className: styles$c.hyperlink
|
|
3551
3549
|
}, props.children));
|
|
3552
3550
|
}
|
|
@@ -6882,7 +6880,8 @@ var styles$j = {
|
|
|
6882
6880
|
}
|
|
6883
6881
|
}),
|
|
6884
6882
|
disabled: /*#__PURE__*/css({
|
|
6885
|
-
background: tokens.gray100
|
|
6883
|
+
background: tokens.gray100,
|
|
6884
|
+
cursor: 'not-allowed'
|
|
6886
6885
|
})
|
|
6887
6886
|
};
|
|
6888
6887
|
|
|
@@ -6927,26 +6926,11 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
|
|
|
6927
6926
|
return setEmbedDropdownOpen(!isEmbedDropdownOpen);
|
|
6928
6927
|
};
|
|
6929
6928
|
|
|
6930
|
-
var _useState2 = useState(false),
|
|
6931
|
-
canAccessAssets = _useState2[0],
|
|
6932
|
-
setCanAccessAssets = _useState2[1];
|
|
6933
|
-
|
|
6934
|
-
React__default.useEffect(function () {
|
|
6935
|
-
var subscribed = true;
|
|
6936
|
-
sdk.access.can('read', 'Asset').then(function (can) {
|
|
6937
|
-
if (!subscribed) {
|
|
6938
|
-
return;
|
|
6939
|
-
}
|
|
6940
|
-
|
|
6941
|
-
setCanAccessAssets(can);
|
|
6942
|
-
});
|
|
6943
|
-
return function () {
|
|
6944
|
-
subscribed = false;
|
|
6945
|
-
};
|
|
6946
|
-
}, [sdk]);
|
|
6947
6929
|
var inlineEntryEmbedEnabled = isNodeTypeEnabled(sdk.field, INLINES.EMBEDDED_ENTRY);
|
|
6948
|
-
var blockEntryEmbedEnabled = isNodeTypeEnabled(sdk.field, BLOCKS.EMBEDDED_ENTRY) && canInsertBlocks;
|
|
6949
|
-
|
|
6930
|
+
var blockEntryEmbedEnabled = isNodeTypeEnabled(sdk.field, BLOCKS.EMBEDDED_ENTRY) && canInsertBlocks; // Removed access check following https://contentful.atlassian.net/browse/DANTE-486
|
|
6931
|
+
// TODO: refine permissions check in order to account for tags in rules and then readd access.can('read', 'Asset')
|
|
6932
|
+
|
|
6933
|
+
var blockAssetEmbedEnabled = isNodeTypeEnabled(sdk.field, BLOCKS.EMBEDDED_ASSET) && canInsertBlocks;
|
|
6950
6934
|
var numEnabledEmbeds = [inlineEntryEmbedEnabled, blockEntryEmbedEnabled, blockAssetEmbedEnabled].filter(Boolean).length;
|
|
6951
6935
|
var shouldDisplayDropdown = numEnabledEmbeds > 1 || isDisabled; // Avoids UI glitching when switching back and forth between
|
|
6952
6936
|
// different layouts
|