@contentful/field-editor-rich-text 0.23.0-next → 0.24.1-next
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/ContentfulEditorProvider.d.ts +2 -2
- package/dist/field-editor-rich-text.cjs.development.js +637 -150
- 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 +644 -157
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/plugins/EmbeddedEntityBlock/LinkedEntityBlock.d.ts +0 -2
- package/dist/plugins/EmbeddedEntityBlock/index.d.ts +3 -2
- package/dist/plugins/Paste/index.d.ts +2 -0
- package/dist/plugins/Paste/sanitizers/helpers.d.ts +5 -0
- package/dist/plugins/Paste/sanitizers/index.d.ts +2 -0
- package/dist/plugins/Paste/sanitizers/removeComments.d.ts +2 -0
- package/dist/plugins/Paste/sanitizers/sanitizeTables.d.ts +2 -0
- package/dist/plugins/Table/index.d.ts +159 -159
- package/dist/plugins/shared/EntityStatusIcon.d.ts +8 -0
- package/dist/plugins/shared/FetchingWrappedAssetCard.d.ts +0 -2
- package/dist/plugins/shared/FetchingWrappedEntryCard.d.ts +2 -4
- package/package.json +17 -16
|
@@ -25,6 +25,7 @@ var get = _interopDefault(require('lodash/get'));
|
|
|
25
25
|
var plateList = require('@udecode/plate-list');
|
|
26
26
|
var fieldEditorShared = require('@contentful/field-editor-shared');
|
|
27
27
|
var moment = _interopDefault(require('moment'));
|
|
28
|
+
var mimetype = _interopDefault(require('@contentful/mimetype'));
|
|
28
29
|
var plateTable = require('@udecode/plate-table');
|
|
29
30
|
var plateHtmlSerializer = require('@udecode/plate-html-serializer');
|
|
30
31
|
var plateParagraph = require('@udecode/plate-paragraph');
|
|
@@ -127,6 +128,44 @@ function _taggedTemplateLiteralLoose(strings, raw) {
|
|
|
127
128
|
return strings;
|
|
128
129
|
}
|
|
129
130
|
|
|
131
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
132
|
+
if (!o) return;
|
|
133
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
134
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
135
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
136
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
137
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function _arrayLikeToArray(arr, len) {
|
|
141
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
142
|
+
|
|
143
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
144
|
+
|
|
145
|
+
return arr2;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
149
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
150
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
151
|
+
|
|
152
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
153
|
+
if (it) o = it;
|
|
154
|
+
var i = 0;
|
|
155
|
+
return function () {
|
|
156
|
+
if (i >= o.length) return {
|
|
157
|
+
done: true
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
done: false,
|
|
161
|
+
value: o[i++]
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
167
|
+
}
|
|
168
|
+
|
|
130
169
|
var STYLE_EDITOR_BORDER = "1px solid " + tokens.gray400;
|
|
131
170
|
var styles = {
|
|
132
171
|
root: /*#__PURE__*/emotion.css({
|
|
@@ -511,9 +550,25 @@ function getContentfulEditorId(sdk) {
|
|
|
511
550
|
}
|
|
512
551
|
|
|
513
552
|
function useContentfulEditorHook(_ref) {
|
|
553
|
+
var _editor$selection;
|
|
554
|
+
|
|
514
555
|
var sdk = _ref.sdk;
|
|
515
556
|
var editorId = getContentfulEditorId(sdk);
|
|
516
557
|
var editor = plateCore.useStoreEditorRef(editorId);
|
|
558
|
+
|
|
559
|
+
var _React$useState = React.useState((_editor$selection = editor == null ? void 0 : editor.selection) != null ? _editor$selection : null),
|
|
560
|
+
selection = _React$useState[0],
|
|
561
|
+
setSelection = _React$useState[1];
|
|
562
|
+
|
|
563
|
+
React.useEffect(function () {
|
|
564
|
+
if (!(editor != null && editor.selection)) return;
|
|
565
|
+
setSelection(editor.selection);
|
|
566
|
+
}, [editor == null ? void 0 : editor.selection]);
|
|
567
|
+
|
|
568
|
+
if (editor && !(editor != null && editor.selection) && selection) {
|
|
569
|
+
editor.selection = selection;
|
|
570
|
+
}
|
|
571
|
+
|
|
517
572
|
return editor;
|
|
518
573
|
}
|
|
519
574
|
|
|
@@ -555,7 +610,8 @@ function withHrEvents(editor) {
|
|
|
555
610
|
function ToolbarHrButton(props) {
|
|
556
611
|
var editor = useContentfulEditor();
|
|
557
612
|
|
|
558
|
-
function handleOnClick() {
|
|
613
|
+
function handleOnClick(event) {
|
|
614
|
+
event.preventDefault();
|
|
559
615
|
if (!(editor != null && editor.selection)) return;
|
|
560
616
|
|
|
561
617
|
if (shouldUnwrapBlockquote(editor, Contentful.BLOCKS.HR)) {
|
|
@@ -584,7 +640,8 @@ function ToolbarHrButton(props) {
|
|
|
584
640
|
tooltipPlace: "bottom",
|
|
585
641
|
label: "HR",
|
|
586
642
|
disabled: props.isDisabled,
|
|
587
|
-
|
|
643
|
+
// @ts-expect-error
|
|
644
|
+
onMouseDown: handleOnClick,
|
|
588
645
|
testId: "hr-toolbar-button",
|
|
589
646
|
isActive: isBlockSelected(editor, Contentful.BLOCKS.HR)
|
|
590
647
|
});
|
|
@@ -782,19 +839,22 @@ function ToolbarHeadingButton(props) {
|
|
|
782
839
|
someHeadingsEnabled = _React$useMemo[1];
|
|
783
840
|
|
|
784
841
|
function handleOnSelectItem(type) {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
842
|
+
return function (event) {
|
|
843
|
+
event.preventDefault();
|
|
844
|
+
if (!(editor != null && editor.selection)) return;
|
|
845
|
+
setSelected(type);
|
|
846
|
+
setOpen(false);
|
|
788
847
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
848
|
+
if (shouldUnwrapBlockquote(editor, type)) {
|
|
849
|
+
unwrapFromRoot(editor);
|
|
850
|
+
}
|
|
792
851
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
852
|
+
plateCommon.toggleNodeType(editor, {
|
|
853
|
+
activeType: type,
|
|
854
|
+
inactiveType: type
|
|
855
|
+
});
|
|
856
|
+
Slate.ReactEditor.focus(editor);
|
|
857
|
+
};
|
|
798
858
|
}
|
|
799
859
|
|
|
800
860
|
if (!editor) return null;
|
|
@@ -818,9 +878,7 @@ function ToolbarHeadingButton(props) {
|
|
|
818
878
|
return nodeTypesByEnablement[nodeType] && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
819
879
|
key: nodeType,
|
|
820
880
|
isActive: selected === nodeType,
|
|
821
|
-
|
|
822
|
-
return handleOnSelectItem(nodeType);
|
|
823
|
-
},
|
|
881
|
+
onMouseDown: handleOnSelectItem(nodeType),
|
|
824
882
|
testId: "dropdown-option-" + nodeType,
|
|
825
883
|
isDisabled: props.isDisabled
|
|
826
884
|
}, /*#__PURE__*/React.createElement("span", {
|
|
@@ -969,7 +1027,8 @@ function withQuoteEvents(editor) {
|
|
|
969
1027
|
function ToolbarQuoteButton(props) {
|
|
970
1028
|
var editor = useContentfulEditor();
|
|
971
1029
|
|
|
972
|
-
function handleOnClick() {
|
|
1030
|
+
function handleOnClick(event) {
|
|
1031
|
+
event.preventDefault();
|
|
973
1032
|
if (!editor) return;
|
|
974
1033
|
createBlockQuote(editor);
|
|
975
1034
|
Slate.ReactEditor.focus(editor);
|
|
@@ -981,7 +1040,8 @@ function ToolbarQuoteButton(props) {
|
|
|
981
1040
|
tooltip: "Blockquote",
|
|
982
1041
|
tooltipPlace: "bottom",
|
|
983
1042
|
label: "Blockquote",
|
|
984
|
-
|
|
1043
|
+
// @ts-expect-error
|
|
1044
|
+
onMouseDown: handleOnClick,
|
|
985
1045
|
testId: "quote-toolbar-button",
|
|
986
1046
|
disabled: props.isDisabled,
|
|
987
1047
|
isActive: isBlockSelected(editor, Contentful.BLOCKS.QUOTE)
|
|
@@ -1013,16 +1073,19 @@ function ToolbarListButton(props) {
|
|
|
1013
1073
|
var editor = useContentfulEditor();
|
|
1014
1074
|
|
|
1015
1075
|
function handleClick(type) {
|
|
1016
|
-
|
|
1076
|
+
return function (event) {
|
|
1077
|
+
event.preventDefault();
|
|
1078
|
+
if (!(editor != null && editor.selection)) return;
|
|
1017
1079
|
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1080
|
+
if (shouldUnwrapBlockquote(editor, type)) {
|
|
1081
|
+
unwrapFromRoot(editor);
|
|
1082
|
+
}
|
|
1021
1083
|
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1084
|
+
plateList.toggleList(editor, {
|
|
1085
|
+
type: type
|
|
1086
|
+
});
|
|
1087
|
+
Slate.ReactEditor.focus(editor);
|
|
1088
|
+
};
|
|
1026
1089
|
}
|
|
1027
1090
|
|
|
1028
1091
|
if (!editor) return null;
|
|
@@ -1032,9 +1095,8 @@ function ToolbarListButton(props) {
|
|
|
1032
1095
|
tooltipPlace: "bottom",
|
|
1033
1096
|
label: "UL",
|
|
1034
1097
|
testId: "ul-toolbar-button",
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
},
|
|
1098
|
+
// @ts-expect-error
|
|
1099
|
+
onMouseDown: handleClick(Contentful.BLOCKS.UL_LIST),
|
|
1038
1100
|
isActive: isBlockSelected(editor, Contentful.BLOCKS.UL_LIST),
|
|
1039
1101
|
disabled: props.isDisabled
|
|
1040
1102
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.OL_LIST) && /*#__PURE__*/React.createElement(forma36ReactComponents.EditorToolbarButton, {
|
|
@@ -1043,9 +1105,8 @@ function ToolbarListButton(props) {
|
|
|
1043
1105
|
tooltipPlace: "bottom",
|
|
1044
1106
|
label: "OL",
|
|
1045
1107
|
testId: "ol-toolbar-button",
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
},
|
|
1108
|
+
// @ts-expect-error
|
|
1109
|
+
onMouseDown: handleClick(Contentful.BLOCKS.OL_LIST),
|
|
1049
1110
|
isActive: isBlockSelected(editor, Contentful.BLOCKS.OL_LIST),
|
|
1050
1111
|
disabled: props.isDisabled
|
|
1051
1112
|
}));
|
|
@@ -1079,7 +1140,8 @@ var _withBoldOptions;
|
|
|
1079
1140
|
function ToolbarBoldButton(props) {
|
|
1080
1141
|
var editor = useContentfulEditor();
|
|
1081
1142
|
|
|
1082
|
-
function handleClick() {
|
|
1143
|
+
function handleClick(event) {
|
|
1144
|
+
event.preventDefault();
|
|
1083
1145
|
if (!(editor != null && editor.selection)) return;
|
|
1084
1146
|
plateCommon.toggleMark(editor, Contentful.MARKS.BOLD);
|
|
1085
1147
|
Slate.ReactEditor.focus(editor);
|
|
@@ -1092,7 +1154,8 @@ function ToolbarBoldButton(props) {
|
|
|
1092
1154
|
tooltipPlace: "bottom",
|
|
1093
1155
|
label: "Bold",
|
|
1094
1156
|
testId: "bold-toolbar-button",
|
|
1095
|
-
|
|
1157
|
+
// @ts-expect-error
|
|
1158
|
+
onMouseDown: handleClick,
|
|
1096
1159
|
isActive: plateCommon.isMarkActive(editor, Contentful.MARKS.BOLD),
|
|
1097
1160
|
disabled: props.isDisabled
|
|
1098
1161
|
});
|
|
@@ -1140,7 +1203,8 @@ var _withCodeOptions;
|
|
|
1140
1203
|
function ToolbarCodeButton(props) {
|
|
1141
1204
|
var editor = useContentfulEditor();
|
|
1142
1205
|
|
|
1143
|
-
function handleClick() {
|
|
1206
|
+
function handleClick(event) {
|
|
1207
|
+
event.preventDefault();
|
|
1144
1208
|
if (!(editor != null && editor.selection)) return;
|
|
1145
1209
|
plateCommon.toggleMark(editor, Contentful.MARKS.CODE);
|
|
1146
1210
|
Slate.ReactEditor.focus(editor);
|
|
@@ -1153,7 +1217,8 @@ function ToolbarCodeButton(props) {
|
|
|
1153
1217
|
tooltipPlace: "bottom",
|
|
1154
1218
|
label: "Code",
|
|
1155
1219
|
testId: "code-toolbar-button",
|
|
1156
|
-
|
|
1220
|
+
// @ts-expect-error
|
|
1221
|
+
onMouseDown: handleClick,
|
|
1157
1222
|
isActive: plateCommon.isMarkActive(editor, Contentful.MARKS.CODE),
|
|
1158
1223
|
disabled: props.isDisabled
|
|
1159
1224
|
});
|
|
@@ -1194,7 +1259,8 @@ var _withItalicOptions;
|
|
|
1194
1259
|
function ToolbarItalicButton(props) {
|
|
1195
1260
|
var editor = useContentfulEditor();
|
|
1196
1261
|
|
|
1197
|
-
function handleClick() {
|
|
1262
|
+
function handleClick(event) {
|
|
1263
|
+
event.preventDefault();
|
|
1198
1264
|
if (!(editor != null && editor.selection)) return;
|
|
1199
1265
|
plateCommon.toggleMark(editor, Contentful.MARKS.ITALIC);
|
|
1200
1266
|
Slate.ReactEditor.focus(editor);
|
|
@@ -1207,7 +1273,8 @@ function ToolbarItalicButton(props) {
|
|
|
1207
1273
|
tooltipPlace: "bottom",
|
|
1208
1274
|
label: "Italic",
|
|
1209
1275
|
testId: "italic-toolbar-button",
|
|
1210
|
-
|
|
1276
|
+
// @ts-expect-error
|
|
1277
|
+
onMouseDown: handleClick,
|
|
1211
1278
|
isActive: plateCommon.isMarkActive(editor, Contentful.MARKS.ITALIC),
|
|
1212
1279
|
disabled: props.isDisabled
|
|
1213
1280
|
});
|
|
@@ -1247,7 +1314,8 @@ var _withUnderlineOptions;
|
|
|
1247
1314
|
function ToolbarUnderlineButton(props) {
|
|
1248
1315
|
var editor = useContentfulEditor();
|
|
1249
1316
|
|
|
1250
|
-
function handleClick() {
|
|
1317
|
+
function handleClick(event) {
|
|
1318
|
+
event.preventDefault();
|
|
1251
1319
|
if (!(editor != null && editor.selection)) return;
|
|
1252
1320
|
plateCommon.toggleMark(editor, Contentful.MARKS.UNDERLINE);
|
|
1253
1321
|
Slate.ReactEditor.focus(editor);
|
|
@@ -1260,7 +1328,8 @@ function ToolbarUnderlineButton(props) {
|
|
|
1260
1328
|
tooltipPlace: "bottom",
|
|
1261
1329
|
label: "Underline",
|
|
1262
1330
|
testId: "underline-toolbar-button",
|
|
1263
|
-
|
|
1331
|
+
// @ts-expect-error
|
|
1332
|
+
onMouseDown: handleClick,
|
|
1264
1333
|
isActive: plateCommon.isMarkActive(editor, Contentful.MARKS.UNDERLINE),
|
|
1265
1334
|
disabled: props.isDisabled
|
|
1266
1335
|
});
|
|
@@ -2285,26 +2354,97 @@ function EntryAssetTooltip(_ref) {
|
|
|
2285
2354
|
})));
|
|
2286
2355
|
}
|
|
2287
2356
|
|
|
2357
|
+
var styles$a = {
|
|
2358
|
+
scheduleIcon: /*#__PURE__*/emotion.css({
|
|
2359
|
+
marginRight: tokens.spacing2Xs
|
|
2360
|
+
})
|
|
2361
|
+
};
|
|
2362
|
+
function EntityStatusIcon(_ref) {
|
|
2363
|
+
var entity = _ref.entity,
|
|
2364
|
+
entityType = _ref.entityType;
|
|
2365
|
+
|
|
2366
|
+
var _useEntities = fieldEditorReference.useEntities(),
|
|
2367
|
+
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
|
|
2368
|
+
|
|
2369
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.ScheduledIconWithTooltip, {
|
|
2370
|
+
getEntityScheduledActions: loadEntityScheduledActions,
|
|
2371
|
+
entityType: entityType,
|
|
2372
|
+
entityId: entity.sys.id
|
|
2373
|
+
}, /*#__PURE__*/React.createElement(forma36ReactComponents.Icon, {
|
|
2374
|
+
className: styles$a.scheduleIcon,
|
|
2375
|
+
icon: "Clock",
|
|
2376
|
+
size: "small",
|
|
2377
|
+
color: "muted",
|
|
2378
|
+
testId: "schedule-icon"
|
|
2379
|
+
}));
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
var styles$b = {
|
|
2383
|
+
entryCard: /*#__PURE__*/emotion.css({
|
|
2384
|
+
cursor: 'pointer'
|
|
2385
|
+
})
|
|
2386
|
+
};
|
|
2387
|
+
|
|
2388
|
+
function EntryThumbnail(_ref) {
|
|
2389
|
+
var file = _ref.file;
|
|
2390
|
+
if (!fieldEditorShared.isValidImage(file)) return null;
|
|
2391
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.AssetThumbnail, {
|
|
2392
|
+
file: file
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
function EntryDropdownMenu(_ref2) {
|
|
2397
|
+
var onEdit = _ref2.onEdit,
|
|
2398
|
+
onRemove = _ref2.onRemove,
|
|
2399
|
+
isDisabled = _ref2.isDisabled;
|
|
2400
|
+
return /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownList, null, /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2401
|
+
isTitle: true
|
|
2402
|
+
}, "Actions"), /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2403
|
+
onClick: onEdit,
|
|
2404
|
+
testId: "card-action-edit"
|
|
2405
|
+
}, "Edit"), /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2406
|
+
onClick: onRemove,
|
|
2407
|
+
isDisabled: isDisabled,
|
|
2408
|
+
testId: "card-action-remove"
|
|
2409
|
+
}, "Remove"));
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2288
2412
|
function FetchingWrappedEntryCard(props) {
|
|
2289
2413
|
var _useEntities = fieldEditorReference.useEntities(),
|
|
2290
2414
|
getOrLoadEntry = _useEntities.getOrLoadEntry,
|
|
2291
|
-
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
|
|
2292
2415
|
entries = _useEntities.entries;
|
|
2293
2416
|
|
|
2294
|
-
React.
|
|
2295
|
-
|
|
2296
|
-
|
|
2417
|
+
var _React$useState = React.useState(null),
|
|
2418
|
+
file = _React$useState[0],
|
|
2419
|
+
setFile = _React$useState[1];
|
|
2297
2420
|
|
|
2298
2421
|
var entry = entries[props.entryId];
|
|
2422
|
+
var contentType = React.useMemo(function () {
|
|
2423
|
+
return props.sdk.space.getCachedContentTypes().find(function (contentType) {
|
|
2424
|
+
return contentType.sys.id === (entry == null ? void 0 : entry.sys.contentType.sys.id);
|
|
2425
|
+
});
|
|
2426
|
+
}, [props.sdk, entry]);
|
|
2427
|
+
var defaultLocaleCode = props.sdk.locales["default"];
|
|
2299
2428
|
React.useEffect(function () {
|
|
2300
2429
|
if (!entry) return;
|
|
2301
|
-
|
|
2302
|
-
|
|
2430
|
+
fieldEditorShared.entityHelpers.getEntryImage({
|
|
2431
|
+
entry: entry,
|
|
2432
|
+
contentType: contentType,
|
|
2433
|
+
localeCode: props.locale,
|
|
2434
|
+
defaultLocaleCode: defaultLocaleCode
|
|
2435
|
+
}, props.sdk.space.getAsset).then(setFile)["catch"](function () {
|
|
2436
|
+
return setFile(null);
|
|
2437
|
+
});
|
|
2438
|
+
}, [entry, contentType, props.locale, defaultLocaleCode, props.sdk, file]);
|
|
2439
|
+
React.useEffect(function () {
|
|
2440
|
+
getOrLoadEntry(props.entryId);
|
|
2441
|
+
}, [props.entryId]); // eslint-disable-line
|
|
2303
2442
|
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2443
|
+
function renderDropdown() {
|
|
2444
|
+
if (!props.onEdit || !props.onRemove) return undefined;
|
|
2445
|
+
return /*#__PURE__*/React.createElement(EntryDropdownMenu, {
|
|
2307
2446
|
isDisabled: props.isDisabled,
|
|
2447
|
+
onEdit: props.onEdit,
|
|
2308
2448
|
onRemove: props.onRemove
|
|
2309
2449
|
});
|
|
2310
2450
|
}
|
|
@@ -2316,49 +2456,149 @@ function FetchingWrappedEntryCard(props) {
|
|
|
2316
2456
|
});
|
|
2317
2457
|
}
|
|
2318
2458
|
|
|
2319
|
-
|
|
2320
|
-
return
|
|
2459
|
+
if (entry === 'failed') {
|
|
2460
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.MissingEntityCard, {
|
|
2461
|
+
entityType: "Entry",
|
|
2462
|
+
isDisabled: props.isDisabled,
|
|
2463
|
+
onRemove: props.onRemove
|
|
2464
|
+
});
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
var entryStatus = entry ? fieldEditorShared.entityHelpers.getEntryStatus(entry.sys) : undefined;
|
|
2468
|
+
|
|
2469
|
+
if (entryStatus === 'deleted') {
|
|
2470
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.MissingEntityCard, {
|
|
2471
|
+
entityType: "Entry",
|
|
2472
|
+
isDisabled: props.isDisabled,
|
|
2473
|
+
onRemove: props.onRemove
|
|
2474
|
+
});
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
var title = fieldEditorShared.entityHelpers.getEntryTitle({
|
|
2478
|
+
entry: entry,
|
|
2479
|
+
contentType: contentType,
|
|
2480
|
+
localeCode: props.locale,
|
|
2481
|
+
defaultLocaleCode: defaultLocaleCode,
|
|
2482
|
+
defaultTitle: 'Untitled'
|
|
2321
2483
|
});
|
|
2322
|
-
|
|
2484
|
+
var description = fieldEditorShared.entityHelpers.getEntityDescription({
|
|
2485
|
+
entity: entry,
|
|
2323
2486
|
contentType: contentType,
|
|
2324
|
-
defaultLocaleCode: props.sdk.locales["default"],
|
|
2325
|
-
entry: entry,
|
|
2326
|
-
entryUrl: props.getEntryUrl && props.getEntryUrl(entry.sys.id),
|
|
2327
|
-
getAsset: props.sdk.space.getAsset,
|
|
2328
|
-
getEntityScheduledActions: loadEntityScheduledActions,
|
|
2329
|
-
isClickable: false,
|
|
2330
|
-
isDisabled: props.isDisabled,
|
|
2331
|
-
isSelected: props.isSelected,
|
|
2332
2487
|
localeCode: props.locale,
|
|
2333
|
-
|
|
2334
|
-
|
|
2488
|
+
defaultLocaleCode: defaultLocaleCode
|
|
2489
|
+
});
|
|
2490
|
+
return /*#__PURE__*/React.createElement(forma36ReactComponents.EntryCard, {
|
|
2491
|
+
contentType: contentType == null ? void 0 : contentType.name,
|
|
2492
|
+
title: title,
|
|
2493
|
+
description: description,
|
|
2335
2494
|
size: "default",
|
|
2336
|
-
|
|
2495
|
+
selected: props.isSelected,
|
|
2496
|
+
status: entryStatus,
|
|
2497
|
+
className: styles$b.entryCard,
|
|
2498
|
+
thumbnailElement: file ? /*#__PURE__*/React.createElement(EntryThumbnail, {
|
|
2499
|
+
file: file
|
|
2500
|
+
}) : null,
|
|
2501
|
+
statusIcon: /*#__PURE__*/React.createElement(EntityStatusIcon, {
|
|
2502
|
+
entityType: "Entry",
|
|
2503
|
+
entity: entry
|
|
2504
|
+
}),
|
|
2505
|
+
dropdownListElements: renderDropdown()
|
|
2337
2506
|
});
|
|
2338
2507
|
}
|
|
2339
2508
|
|
|
2509
|
+
var styles$c = {
|
|
2510
|
+
assetCard: /*#__PURE__*/emotion.css({
|
|
2511
|
+
cursor: 'pointer'
|
|
2512
|
+
}),
|
|
2513
|
+
cardDropdown: /*#__PURE__*/emotion.css({
|
|
2514
|
+
width: '300px'
|
|
2515
|
+
}),
|
|
2516
|
+
truncated: /*#__PURE__*/emotion.css({
|
|
2517
|
+
overflow: 'hidden',
|
|
2518
|
+
whiteSpace: 'nowrap',
|
|
2519
|
+
textOverflow: 'ellipsis'
|
|
2520
|
+
})
|
|
2521
|
+
};
|
|
2522
|
+
|
|
2523
|
+
function AssetDropdownMenu(_ref) {
|
|
2524
|
+
var onEdit = _ref.onEdit,
|
|
2525
|
+
onRemove = _ref.onRemove,
|
|
2526
|
+
isDisabled = _ref.isDisabled,
|
|
2527
|
+
entityFile = _ref.entityFile;
|
|
2528
|
+
var fileName = entityFile.fileName,
|
|
2529
|
+
mimeType = entityFile.contentType,
|
|
2530
|
+
details = entityFile.details;
|
|
2531
|
+
var fileSize = details.size,
|
|
2532
|
+
image = details.image;
|
|
2533
|
+
|
|
2534
|
+
function downloadAsset() {
|
|
2535
|
+
if (!entityFile) return;
|
|
2536
|
+
window.open(entityFile.url, '_blank', 'noopener,noreferrer');
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownList, null, /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2540
|
+
isTitle: true
|
|
2541
|
+
}, "Actions"), onEdit && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2542
|
+
onClick: onEdit,
|
|
2543
|
+
testId: "card-action-edit"
|
|
2544
|
+
}, "Edit"), entityFile && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2545
|
+
onClick: downloadAsset,
|
|
2546
|
+
testId: "card-action-download"
|
|
2547
|
+
}, "Download"), onRemove && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2548
|
+
onClick: onRemove,
|
|
2549
|
+
isDisabled: isDisabled,
|
|
2550
|
+
testId: "card-action-remove"
|
|
2551
|
+
}, "Remove")), /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownList, {
|
|
2552
|
+
border: "top"
|
|
2553
|
+
}, /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2554
|
+
isTitle: true
|
|
2555
|
+
}, "File info"), fileName && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, null, /*#__PURE__*/React.createElement("div", {
|
|
2556
|
+
className: styles$c.truncated
|
|
2557
|
+
}, fileName)), mimeType && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, null, /*#__PURE__*/React.createElement("div", null, mimeType)), fileSize && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, null, fieldEditorShared.shortenStorageUnit(fileSize, 'B')), image && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, null, image.width + " \xD7 " + image.height)));
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2340
2560
|
function FetchingWrappedAssetCard(props) {
|
|
2341
2561
|
var _useEntities = fieldEditorReference.useEntities(),
|
|
2342
2562
|
getOrLoadAsset = _useEntities.getOrLoadAsset,
|
|
2343
|
-
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
|
|
2344
2563
|
assets = _useEntities.assets;
|
|
2345
2564
|
|
|
2565
|
+
var asset = assets[props.assetId];
|
|
2566
|
+
var defaultLocaleCode = props.sdk.locales["default"];
|
|
2567
|
+
var entityFile = asset != null && asset.fields.file ? asset.fields.file[props.locale] || asset.fields.file[defaultLocaleCode] : undefined;
|
|
2346
2568
|
React.useEffect(function () {
|
|
2347
2569
|
getOrLoadAsset(props.assetId);
|
|
2348
2570
|
}, [props.assetId]); // eslint-disable-line
|
|
2349
2571
|
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
}, [asset]); // eslint-disable-line
|
|
2572
|
+
function getAssetSrc() {
|
|
2573
|
+
if (!(entityFile != null && entityFile.url)) return '';
|
|
2574
|
+
return entityFile.url + "?h=300";
|
|
2575
|
+
}
|
|
2355
2576
|
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2577
|
+
function getFileType() {
|
|
2578
|
+
var groupToIconMap = {
|
|
2579
|
+
image: 'image',
|
|
2580
|
+
video: 'video',
|
|
2581
|
+
audio: 'audio',
|
|
2582
|
+
richtext: 'richtext',
|
|
2583
|
+
presentation: 'presentation',
|
|
2584
|
+
spreadsheet: 'spreadsheet',
|
|
2585
|
+
pdfdocument: 'pdf',
|
|
2586
|
+
archive: 'archive',
|
|
2587
|
+
plaintext: 'plaintext',
|
|
2588
|
+
code: 'code',
|
|
2589
|
+
markup: 'markup'
|
|
2590
|
+
};
|
|
2591
|
+
var archive = groupToIconMap['archive'];
|
|
2592
|
+
|
|
2593
|
+
if (!entityFile) {
|
|
2594
|
+
return archive;
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
var groupName = mimetype.getGroupLabel({
|
|
2598
|
+
type: entityFile.contentType,
|
|
2599
|
+
fallbackFileName: entityFile.fileName
|
|
2361
2600
|
});
|
|
2601
|
+
return groupToIconMap[groupName] || archive;
|
|
2362
2602
|
}
|
|
2363
2603
|
|
|
2364
2604
|
if (asset === undefined) {
|
|
@@ -2371,20 +2611,49 @@ function FetchingWrappedAssetCard(props) {
|
|
|
2371
2611
|
});
|
|
2372
2612
|
}
|
|
2373
2613
|
|
|
2374
|
-
|
|
2614
|
+
if (asset === 'failed') {
|
|
2615
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.MissingEntityCard, {
|
|
2616
|
+
entityType: "Asset",
|
|
2617
|
+
isDisabled: props.isDisabled,
|
|
2618
|
+
onRemove: props.onRemove
|
|
2619
|
+
});
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
var status = asset ? fieldEditorShared.entityHelpers.getEntryStatus(asset.sys) : undefined;
|
|
2623
|
+
|
|
2624
|
+
if (status === 'deleted') {
|
|
2625
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.MissingEntityCard, {
|
|
2626
|
+
entityType: "Asset",
|
|
2627
|
+
asSquare: true,
|
|
2628
|
+
isDisabled: props.isDisabled,
|
|
2629
|
+
onRemove: props.onRemove
|
|
2630
|
+
});
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
var entityTitle = fieldEditorShared.entityHelpers.getAssetTitle({
|
|
2375
2634
|
asset: asset,
|
|
2376
|
-
defaultLocaleCode: props.sdk.locales["default"],
|
|
2377
|
-
// @ts-expect-error
|
|
2378
|
-
getAsset: props.sdk.space.getAsset,
|
|
2379
|
-
getAssetUrl: props.getAssetUrl,
|
|
2380
|
-
getEntityScheduledActions: loadEntityScheduledActions,
|
|
2381
|
-
isClickable: false,
|
|
2382
|
-
isDisabled: props.isDisabled,
|
|
2383
|
-
isSelected: props.isSelected,
|
|
2384
2635
|
localeCode: props.locale,
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2636
|
+
defaultLocaleCode: defaultLocaleCode,
|
|
2637
|
+
defaultTitle: 'Untitled'
|
|
2638
|
+
});
|
|
2639
|
+
return /*#__PURE__*/React.createElement(forma36ReactComponents.AssetCard, {
|
|
2640
|
+
title: entityTitle,
|
|
2641
|
+
selected: props.isSelected,
|
|
2642
|
+
size: "default",
|
|
2643
|
+
src: getAssetSrc(),
|
|
2644
|
+
type: getFileType(),
|
|
2645
|
+
status: status,
|
|
2646
|
+
statusIcon: /*#__PURE__*/React.createElement(EntityStatusIcon, {
|
|
2647
|
+
entityType: "Asset",
|
|
2648
|
+
entity: asset
|
|
2649
|
+
}),
|
|
2650
|
+
className: styles$c.assetCard,
|
|
2651
|
+
dropdownListElements: entityFile && /*#__PURE__*/React.createElement(AssetDropdownMenu, {
|
|
2652
|
+
onEdit: props.onEdit,
|
|
2653
|
+
onRemove: props.onRemove,
|
|
2654
|
+
isDisabled: props.isDisabled,
|
|
2655
|
+
entityFile: entityFile
|
|
2656
|
+
})
|
|
2388
2657
|
});
|
|
2389
2658
|
}
|
|
2390
2659
|
|
|
@@ -2428,7 +2697,7 @@ function getLinkedContentTypeIdsForNodeType(field, nodeType) {
|
|
|
2428
2697
|
}
|
|
2429
2698
|
|
|
2430
2699
|
var _templateObject$3, _SYS_LINK_TYPES, _LINK_TYPE_SELECTION_;
|
|
2431
|
-
var styles$
|
|
2700
|
+
var styles$d = {
|
|
2432
2701
|
removeSelectionLabel: /*#__PURE__*/emotion.css(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-left: ", ";\n "])), tokens.spacingS)
|
|
2433
2702
|
};
|
|
2434
2703
|
var SYS_LINK_TYPES = (_SYS_LINK_TYPES = {}, _SYS_LINK_TYPES[Contentful.INLINES.ENTRY_HYPERLINK] = 'Entry', _SYS_LINK_TYPES[Contentful.INLINES.ASSET_HYPERLINK] = 'Asset', _SYS_LINK_TYPES);
|
|
@@ -2616,7 +2885,7 @@ function HyperlinkModal(props) {
|
|
|
2616
2885
|
htmlFor: ""
|
|
2617
2886
|
}, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(forma36ReactComponents.TextLink, {
|
|
2618
2887
|
onClick: resetLinkEntity,
|
|
2619
|
-
className: styles$
|
|
2888
|
+
className: styles$d.removeSelectionLabel
|
|
2620
2889
|
}, "Remove selection"), /*#__PURE__*/React.createElement("div", null, linkType === Contentful.INLINES.ENTRY_HYPERLINK && /*#__PURE__*/React.createElement(FetchingWrappedEntryCard, {
|
|
2621
2890
|
sdk: props.sdk,
|
|
2622
2891
|
locale: props.sdk.field.locale,
|
|
@@ -2731,7 +3000,7 @@ function _addOrEditLink() {
|
|
|
2731
3000
|
}
|
|
2732
3001
|
|
|
2733
3002
|
var _withHyperlinkOptions;
|
|
2734
|
-
var styles$
|
|
3003
|
+
var styles$e = {
|
|
2735
3004
|
hyperlinkWrapper: /*#__PURE__*/emotion.css({
|
|
2736
3005
|
display: 'inline',
|
|
2737
3006
|
position: 'static',
|
|
@@ -2815,7 +3084,7 @@ function createHyperlinkPlugin(sdk) {
|
|
|
2815
3084
|
sys: {
|
|
2816
3085
|
id: element.getAttribute('data-link-id'),
|
|
2817
3086
|
linkType: element.getAttribute('data-link-type'),
|
|
2818
|
-
|
|
3087
|
+
type: 'Link'
|
|
2819
3088
|
}
|
|
2820
3089
|
}
|
|
2821
3090
|
}
|
|
@@ -2832,7 +3101,7 @@ function createHyperlinkPlugin(sdk) {
|
|
|
2832
3101
|
sys: {
|
|
2833
3102
|
id: element.getAttribute('data-link-id'),
|
|
2834
3103
|
linkType: element.getAttribute('data-link-type'),
|
|
2835
|
-
|
|
3104
|
+
type: 'Link'
|
|
2836
3105
|
}
|
|
2837
3106
|
}
|
|
2838
3107
|
}
|
|
@@ -2910,14 +3179,14 @@ function UrlHyperlink(props) {
|
|
|
2910
3179
|
|
|
2911
3180
|
return /*#__PURE__*/React.createElement(forma36ReactComponents.Tooltip, {
|
|
2912
3181
|
content: uri,
|
|
2913
|
-
targetWrapperClassName: styles$
|
|
3182
|
+
targetWrapperClassName: styles$e.hyperlinkWrapper,
|
|
2914
3183
|
place: "bottom",
|
|
2915
3184
|
maxWidth: "auto"
|
|
2916
3185
|
}, /*#__PURE__*/React.createElement(forma36ReactComponents.TextLink, {
|
|
2917
3186
|
href: uri,
|
|
2918
3187
|
rel: "noopener noreferrer",
|
|
2919
3188
|
onClick: handleClick,
|
|
2920
|
-
className: styles$
|
|
3189
|
+
className: styles$e.hyperlink
|
|
2921
3190
|
}, props.children));
|
|
2922
3191
|
}
|
|
2923
3192
|
|
|
@@ -2966,14 +3235,14 @@ function EntityHyperlink(props) {
|
|
|
2966
3235
|
type: target.sys.linkType,
|
|
2967
3236
|
sdk: sdk
|
|
2968
3237
|
}),
|
|
2969
|
-
targetWrapperClassName: styles$
|
|
3238
|
+
targetWrapperClassName: styles$e.hyperlinkWrapper,
|
|
2970
3239
|
place: "bottom",
|
|
2971
3240
|
maxWidth: "auto"
|
|
2972
3241
|
}, /*#__PURE__*/React.createElement(forma36ReactComponents.TextLink, {
|
|
2973
3242
|
href: "javascript:void(0)",
|
|
2974
3243
|
rel: "noopener noreferrer",
|
|
2975
3244
|
onClick: handleClick,
|
|
2976
|
-
className: styles$
|
|
3245
|
+
className: styles$e.hyperlink,
|
|
2977
3246
|
"data-link-type": target.sys.linkType,
|
|
2978
3247
|
"data-link-id": target.sys.id
|
|
2979
3248
|
}, props.children));
|
|
@@ -3027,7 +3296,8 @@ function ToolbarHyperlinkButton(props) {
|
|
|
3027
3296
|
tooltipPlace: "bottom",
|
|
3028
3297
|
label: "Hyperlink",
|
|
3029
3298
|
testId: "hyperlink-toolbar-button",
|
|
3030
|
-
|
|
3299
|
+
// @ts-expect-error
|
|
3300
|
+
onMouseDown: handleClick,
|
|
3031
3301
|
isActive: isActive,
|
|
3032
3302
|
disabled: props.isDisabled
|
|
3033
3303
|
});
|
|
@@ -3245,7 +3515,7 @@ var setHeader = function setHeader(editor, enable) {
|
|
|
3245
3515
|
});
|
|
3246
3516
|
};
|
|
3247
3517
|
|
|
3248
|
-
var styles$
|
|
3518
|
+
var styles$f = {
|
|
3249
3519
|
topRight: /*#__PURE__*/emotion.css({
|
|
3250
3520
|
position: 'absolute',
|
|
3251
3521
|
top: tokens.spacingXs,
|
|
@@ -3323,7 +3593,7 @@ var TableActions = function TableActions() {
|
|
|
3323
3593
|
};
|
|
3324
3594
|
}, [editor, isHeaderEnabled, close, onViewportAction]);
|
|
3325
3595
|
return /*#__PURE__*/React__default.createElement(forma36ReactComponents.Dropdown, {
|
|
3326
|
-
className: styles$
|
|
3596
|
+
className: styles$f.topRight,
|
|
3327
3597
|
position: "left",
|
|
3328
3598
|
isOpen: isOpen,
|
|
3329
3599
|
onClose: close,
|
|
@@ -3363,27 +3633,27 @@ var TableActions = function TableActions() {
|
|
|
3363
3633
|
};
|
|
3364
3634
|
|
|
3365
3635
|
var _templateObject$4, _templateObject2$3, _templateObject3$3, _templateObject4$1, _styles$1, _withTableOptions;
|
|
3366
|
-
var styles$
|
|
3636
|
+
var styles$g = (_styles$1 = {}, _styles$1[Contentful.BLOCKS.TABLE] = /*#__PURE__*/emotion.css(_templateObject$4 || (_templateObject$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-bottom: 1.5em;\n border-collapse: collapse;\n border-radius: 5px;\n border-style: hidden;\n box-shadow: 0 0 0 1px ", ";\n width: 100%;\n table-layout: fixed;\n overflow: hidden;\n "])), tokens.gray400), _styles$1[Contentful.BLOCKS.TABLE_ROW] = /*#__PURE__*/emotion.css(_templateObject2$3 || (_templateObject2$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 1px solid ", ";\n &:hover td {\n background-color: transparent !important;\n }\n "])), tokens.gray400), _styles$1[Contentful.BLOCKS.TABLE_HEADER_CELL] = /*#__PURE__*/emotion.css(_templateObject3$3 || (_templateObject3$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background-color: ", ";\n border: 1px solid ", ";\n padding: 10px 12px;\n font-weight: ", ";\n text-align: left;\n min-width: 48px;\n position: relative;\n div:last-child {\n margin-bottom: 0;\n }\n "])), tokens.gray200, tokens.gray400, tokens.fontWeightMedium), _styles$1[Contentful.BLOCKS.TABLE_CELL] = /*#__PURE__*/emotion.css(_templateObject4$1 || (_templateObject4$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 1px solid ", ";\n padding: 10px 12px;\n min-width: 48px;\n position: relative;\n div:last-child {\n margin-bottom: 0;\n }\n "])), tokens.gray400), _styles$1);
|
|
3367
3637
|
var Table = function Table(props) {
|
|
3368
3638
|
return /*#__PURE__*/React.createElement("table", Object.assign({}, props.attributes, {
|
|
3369
|
-
className: styles$
|
|
3639
|
+
className: styles$g[Contentful.BLOCKS.TABLE]
|
|
3370
3640
|
}), /*#__PURE__*/React.createElement("tbody", null, props.children));
|
|
3371
3641
|
};
|
|
3372
3642
|
var TR = function TR(props) {
|
|
3373
3643
|
return /*#__PURE__*/React.createElement("tr", Object.assign({}, props.attributes, {
|
|
3374
|
-
className: styles$
|
|
3644
|
+
className: styles$g[Contentful.BLOCKS.TABLE_ROW]
|
|
3375
3645
|
}), props.children);
|
|
3376
3646
|
};
|
|
3377
3647
|
var TH = function TH(props) {
|
|
3378
3648
|
var isSelected = Slate.useSelected();
|
|
3379
3649
|
return /*#__PURE__*/React.createElement("th", Object.assign({}, props.attributes, props.element.data, {
|
|
3380
|
-
className: styles$
|
|
3650
|
+
className: styles$g[Contentful.BLOCKS.TABLE_HEADER_CELL]
|
|
3381
3651
|
}), isSelected && /*#__PURE__*/React.createElement(TableActions, null), props.children);
|
|
3382
3652
|
};
|
|
3383
3653
|
var TD = function TD(props) {
|
|
3384
3654
|
var isSelected = Slate.useSelected();
|
|
3385
3655
|
return /*#__PURE__*/React.createElement("td", Object.assign({}, props.attributes, props.element.data, {
|
|
3386
|
-
className: styles$
|
|
3656
|
+
className: styles$g[Contentful.BLOCKS.TABLE_CELL]
|
|
3387
3657
|
}), isSelected && /*#__PURE__*/React.createElement(TableActions, null), props.children);
|
|
3388
3658
|
};
|
|
3389
3659
|
var withTableOptions = (_withTableOptions = {}, _withTableOptions[plateTable.ELEMENT_TABLE] = {
|
|
@@ -3416,7 +3686,8 @@ function addTableTrackingEvents(editor, _ref) {
|
|
|
3416
3686
|
|
|
3417
3687
|
if (hasTables(markupAfter)) {
|
|
3418
3688
|
onViewportAction('paste', {
|
|
3419
|
-
tablePasted: true
|
|
3689
|
+
tablePasted: true,
|
|
3690
|
+
hasHeadersOutsideFirstRow: hasHeadersOutsideFirstRow(markupAfter)
|
|
3420
3691
|
});
|
|
3421
3692
|
}
|
|
3422
3693
|
}, 1);
|
|
@@ -3424,6 +3695,40 @@ function addTableTrackingEvents(editor, _ref) {
|
|
|
3424
3695
|
};
|
|
3425
3696
|
}
|
|
3426
3697
|
|
|
3698
|
+
function addTableNormalization(editor) {
|
|
3699
|
+
var normalizeNode = editor.normalizeNode;
|
|
3700
|
+
|
|
3701
|
+
editor.normalizeNode = function (entry) {
|
|
3702
|
+
var node = entry[0],
|
|
3703
|
+
path = entry[1]; // TODO: This should be enforced by sanitizeSlateDoc() but the internal
|
|
3704
|
+
// editor value can be different.
|
|
3705
|
+
// cf. https://github.com/ianstormtaylor/slate/issues/2206
|
|
3706
|
+
|
|
3707
|
+
var cellTypes = [Contentful.BLOCKS.TABLE_CELL, Contentful.BLOCKS.TABLE_HEADER_CELL];
|
|
3708
|
+
|
|
3709
|
+
if (slate.Element.isElement(node) && cellTypes.includes(node.type)) {
|
|
3710
|
+
for (var _iterator = _createForOfIteratorHelperLoose(slate.Node.children(editor, path)), _step; !(_step = _iterator()).done;) {
|
|
3711
|
+
var _step$value = _step.value,
|
|
3712
|
+
child = _step$value[0],
|
|
3713
|
+
childPath = _step$value[1];
|
|
3714
|
+
|
|
3715
|
+
if (slate.Text.isText(child)) {
|
|
3716
|
+
var paragraph = {
|
|
3717
|
+
type: Contentful.BLOCKS.PARAGRAPH,
|
|
3718
|
+
data: {},
|
|
3719
|
+
children: []
|
|
3720
|
+
};
|
|
3721
|
+
slate.Transforms.wrapNodes(editor, paragraph, {
|
|
3722
|
+
at: childPath
|
|
3723
|
+
});
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3727
|
+
|
|
3728
|
+
normalizeNode(entry);
|
|
3729
|
+
};
|
|
3730
|
+
}
|
|
3731
|
+
|
|
3427
3732
|
function hasTables(nodes) {
|
|
3428
3733
|
return nodes.some(function (_ref2) {
|
|
3429
3734
|
var type = _ref2.type;
|
|
@@ -3431,16 +3736,62 @@ function hasTables(nodes) {
|
|
|
3431
3736
|
});
|
|
3432
3737
|
}
|
|
3433
3738
|
|
|
3739
|
+
var isTableHeaderCell = function isTableHeaderCell(_ref3) {
|
|
3740
|
+
var type = _ref3.type;
|
|
3741
|
+
return type === Contentful.BLOCKS.TABLE_HEADER_CELL;
|
|
3742
|
+
};
|
|
3743
|
+
|
|
3744
|
+
function hasHeadersOutsideFirstRow(nodes) {
|
|
3745
|
+
return nodes.filter(function (_ref4) {
|
|
3746
|
+
var type = _ref4.type;
|
|
3747
|
+
return type === Contentful.BLOCKS.TABLE;
|
|
3748
|
+
}).flatMap(function (_ref5) {
|
|
3749
|
+
var children = _ref5.children;
|
|
3750
|
+
return children.slice(1);
|
|
3751
|
+
}).some(function (_ref6) {
|
|
3752
|
+
var children = _ref6.children;
|
|
3753
|
+
return children.some(isTableHeaderCell);
|
|
3754
|
+
});
|
|
3755
|
+
}
|
|
3756
|
+
|
|
3434
3757
|
function createWithTableEvents(tracking) {
|
|
3435
3758
|
return function withTableEvents(editor) {
|
|
3436
3759
|
addTableTrackingEvents(editor, tracking);
|
|
3760
|
+
addTableNormalization(editor);
|
|
3437
3761
|
return plateTable.getTableOnKeyDown()(editor);
|
|
3438
3762
|
};
|
|
3439
3763
|
}
|
|
3440
3764
|
|
|
3441
3765
|
var createTablePlugin = function createTablePlugin(tracking) {
|
|
3442
3766
|
return _extends({}, plateTable.createTablePlugin(), {
|
|
3443
|
-
onKeyDown: createWithTableEvents(tracking)
|
|
3767
|
+
onKeyDown: createWithTableEvents(tracking),
|
|
3768
|
+
withOverrides: function withOverrides(editor) {
|
|
3769
|
+
var insertFragment = editor.insertFragment;
|
|
3770
|
+
|
|
3771
|
+
editor.insertFragment = function (fragments) {
|
|
3772
|
+
// We need to make sure we have a new, empty and clean paragraph in order to paste tables as-is due to how Slate behaves
|
|
3773
|
+
// More info: https://github.com/ianstormtaylor/slate/pull/4489 and https://github.com/ianstormtaylor/slate/issues/4542
|
|
3774
|
+
var fragmentHasTable = fragments.some(function (fragment) {
|
|
3775
|
+
return fragment.type === Contentful.BLOCKS.TABLE;
|
|
3776
|
+
});
|
|
3777
|
+
|
|
3778
|
+
if (fragmentHasTable) {
|
|
3779
|
+
var emptyParagraph = {
|
|
3780
|
+
type: Contentful.BLOCKS.PARAGRAPH,
|
|
3781
|
+
children: [{
|
|
3782
|
+
text: ''
|
|
3783
|
+
}],
|
|
3784
|
+
data: {},
|
|
3785
|
+
isVoid: false
|
|
3786
|
+
};
|
|
3787
|
+
slate.Transforms.insertNodes(editor, emptyParagraph);
|
|
3788
|
+
}
|
|
3789
|
+
|
|
3790
|
+
insertFragment(fragments);
|
|
3791
|
+
};
|
|
3792
|
+
|
|
3793
|
+
return editor;
|
|
3794
|
+
}
|
|
3444
3795
|
});
|
|
3445
3796
|
};
|
|
3446
3797
|
function ToolbarTableButton(props) {
|
|
@@ -3492,7 +3843,8 @@ function ToolbarTableButton(props) {
|
|
|
3492
3843
|
tooltipPlace: "bottom",
|
|
3493
3844
|
label: "Table",
|
|
3494
3845
|
testId: "table-toolbar-button",
|
|
3495
|
-
|
|
3846
|
+
// @ts-expect-error
|
|
3847
|
+
onMouseDown: handleClick,
|
|
3496
3848
|
// TODO: active state looks off since the button will be disabled. Do we still need it?
|
|
3497
3849
|
isActive: isActive,
|
|
3498
3850
|
disabled: props.isDisabled
|
|
@@ -3522,7 +3874,7 @@ function EmbeddedEntityDropdownButton(_ref) {
|
|
|
3522
3874
|
}, /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownList, null, children));
|
|
3523
3875
|
}
|
|
3524
3876
|
|
|
3525
|
-
var styles$
|
|
3877
|
+
var styles$h = {
|
|
3526
3878
|
root: /*#__PURE__*/emotion.css({
|
|
3527
3879
|
marginBottom: '1.25rem'
|
|
3528
3880
|
})
|
|
@@ -3530,8 +3882,7 @@ var styles$e = {
|
|
|
3530
3882
|
function LinkedEntityBlock(props) {
|
|
3531
3883
|
var attributes = props.attributes,
|
|
3532
3884
|
children = props.children,
|
|
3533
|
-
element = props.element
|
|
3534
|
-
onEntityFetchComplete = props.onEntityFetchComplete;
|
|
3885
|
+
element = props.element;
|
|
3535
3886
|
var isSelected = Slate.useSelected();
|
|
3536
3887
|
var editor = useContentfulEditor();
|
|
3537
3888
|
var sdk = useSdkContext();
|
|
@@ -3556,7 +3907,7 @@ function LinkedEntityBlock(props) {
|
|
|
3556
3907
|
};
|
|
3557
3908
|
|
|
3558
3909
|
return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
|
|
3559
|
-
className: styles$
|
|
3910
|
+
className: styles$h.root,
|
|
3560
3911
|
"data-entity-type": entityType,
|
|
3561
3912
|
"data-entity-id": entityId
|
|
3562
3913
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -3568,12 +3919,7 @@ function LinkedEntityBlock(props) {
|
|
|
3568
3919
|
isDisabled: isDisabled,
|
|
3569
3920
|
isSelected: isSelected,
|
|
3570
3921
|
onRemove: handleRemoveClick,
|
|
3571
|
-
onEdit: handleEditClick
|
|
3572
|
-
getEntryUrl: function getEntryUrl() {
|
|
3573
|
-
var getEntryUrl = sdk.parameters.instance.getEntryUrl;
|
|
3574
|
-
return typeof getEntryUrl === 'function' ? getEntryUrl(entityId) : '';
|
|
3575
|
-
},
|
|
3576
|
-
onEntityFetchComplete: onEntityFetchComplete
|
|
3922
|
+
onEdit: handleEditClick
|
|
3577
3923
|
}), entityType === 'Asset' && /*#__PURE__*/React__default.createElement(FetchingWrappedAssetCard, {
|
|
3578
3924
|
sdk: sdk,
|
|
3579
3925
|
assetId: entityId,
|
|
@@ -3581,12 +3927,7 @@ function LinkedEntityBlock(props) {
|
|
|
3581
3927
|
isDisabled: isDisabled,
|
|
3582
3928
|
isSelected: isSelected,
|
|
3583
3929
|
onRemove: handleRemoveClick,
|
|
3584
|
-
onEdit: handleEditClick
|
|
3585
|
-
getAssetUrl: function getAssetUrl() {
|
|
3586
|
-
var getAssetUrl = sdk.parameters.instance.getAssetUrl;
|
|
3587
|
-
return typeof getAssetUrl === 'function' ? getAssetUrl(entityId) : '';
|
|
3588
|
-
},
|
|
3589
|
-
onEntityFetchComplete: onEntityFetchComplete
|
|
3930
|
+
onEdit: handleEditClick
|
|
3590
3931
|
})), children);
|
|
3591
3932
|
}
|
|
3592
3933
|
|
|
@@ -3726,7 +4067,7 @@ function insertBlock(editor, nodeType, entity) {
|
|
|
3726
4067
|
Slate.ReactEditor.focus(editor);
|
|
3727
4068
|
}
|
|
3728
4069
|
|
|
3729
|
-
var styles$
|
|
4070
|
+
var styles$i = {
|
|
3730
4071
|
icon: /*#__PURE__*/emotion.css({
|
|
3731
4072
|
marginRight: '10px'
|
|
3732
4073
|
})
|
|
@@ -3741,16 +4082,17 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
|
|
|
3741
4082
|
var sdk = useSdkContext();
|
|
3742
4083
|
|
|
3743
4084
|
var handleClick = /*#__PURE__*/function () {
|
|
3744
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
4085
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(event) {
|
|
3745
4086
|
return runtime_1.wrap(function _callee$(_context) {
|
|
3746
4087
|
while (1) {
|
|
3747
4088
|
switch (_context.prev = _context.next) {
|
|
3748
4089
|
case 0:
|
|
4090
|
+
event.preventDefault();
|
|
3749
4091
|
onClose();
|
|
3750
|
-
_context.next =
|
|
4092
|
+
_context.next = 4;
|
|
3751
4093
|
return selectEntityAndInsert(nodeType, sdk, editor, logAction || noop);
|
|
3752
4094
|
|
|
3753
|
-
case
|
|
4095
|
+
case 4:
|
|
3754
4096
|
case "end":
|
|
3755
4097
|
return _context.stop();
|
|
3756
4098
|
}
|
|
@@ -3758,7 +4100,7 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
|
|
|
3758
4100
|
}, _callee);
|
|
3759
4101
|
}));
|
|
3760
4102
|
|
|
3761
|
-
return function handleClick() {
|
|
4103
|
+
return function handleClick(_x) {
|
|
3762
4104
|
return _ref2.apply(this, arguments);
|
|
3763
4105
|
};
|
|
3764
4106
|
}();
|
|
@@ -3769,21 +4111,22 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
|
|
|
3769
4111
|
disabled: isDisabled,
|
|
3770
4112
|
className: baseClass + "-button",
|
|
3771
4113
|
size: "small",
|
|
3772
|
-
|
|
4114
|
+
// @ts-expect-error
|
|
4115
|
+
onMouseDown: handleClick,
|
|
3773
4116
|
icon: type === 'Asset' ? 'Asset' : 'EmbeddedEntryBlock',
|
|
3774
4117
|
buttonType: "muted",
|
|
3775
4118
|
testId: "toolbar-toggle-" + nodeType
|
|
3776
4119
|
}, "Embed " + type.toLowerCase()) : /*#__PURE__*/React__default.createElement(forma36ReactComponents.DropdownListItem, {
|
|
3777
4120
|
isDisabled: isDisabled,
|
|
3778
4121
|
className: baseClass + "-list-item",
|
|
3779
|
-
|
|
4122
|
+
onMouseDown: handleClick,
|
|
3780
4123
|
testId: "toolbar-toggle-" + nodeType
|
|
3781
4124
|
}, /*#__PURE__*/React__default.createElement(forma36ReactComponents.Flex, {
|
|
3782
4125
|
alignItems: "center",
|
|
3783
4126
|
flexDirection: "row"
|
|
3784
4127
|
}, /*#__PURE__*/React__default.createElement(forma36ReactComponents.Icon, {
|
|
3785
4128
|
icon: type === 'Asset' ? 'Asset' : 'EmbeddedEntryBlock',
|
|
3786
|
-
className: "rich-text__embedded-entry-list-icon " + styles$
|
|
4129
|
+
className: "rich-text__embedded-entry-list-icon " + styles$i.icon,
|
|
3787
4130
|
color: "secondary"
|
|
3788
4131
|
}), /*#__PURE__*/React__default.createElement("span", null, type)));
|
|
3789
4132
|
}
|
|
@@ -3826,6 +4169,7 @@ var createEmbeddedEntityPlugin = function createEmbeddedEntityPlugin(nodeType) {
|
|
|
3826
4169
|
if (!isBlock) return;
|
|
3827
4170
|
return {
|
|
3828
4171
|
type: nodeType,
|
|
4172
|
+
isVoid: true,
|
|
3829
4173
|
data: {
|
|
3830
4174
|
target: {
|
|
3831
4175
|
sys: {
|
|
@@ -3908,7 +4252,7 @@ function getWithEmbeddedEntityEvents(nodeType, sdk) {
|
|
|
3908
4252
|
|
|
3909
4253
|
var getEntryTitle = fieldEditorShared.entityHelpers.getEntryTitle,
|
|
3910
4254
|
getEntryStatus = fieldEditorShared.entityHelpers.getEntryStatus;
|
|
3911
|
-
var styles$
|
|
4255
|
+
var styles$j = {
|
|
3912
4256
|
scheduledIcon: /*#__PURE__*/emotion.css({
|
|
3913
4257
|
verticalAlign: 'text-bottom',
|
|
3914
4258
|
marginRight: tokens.spacing2Xs
|
|
@@ -3986,7 +4330,7 @@ function FetchingWrappedInlineEntryCard(props) {
|
|
|
3986
4330
|
entityType: "Entry",
|
|
3987
4331
|
entityId: entry.sys.id
|
|
3988
4332
|
}, /*#__PURE__*/React__default.createElement(forma36ReactComponents.Icon, {
|
|
3989
|
-
className: styles$
|
|
4333
|
+
className: styles$j.scheduledIcon,
|
|
3990
4334
|
icon: "Clock",
|
|
3991
4335
|
color: "muted",
|
|
3992
4336
|
testId: "scheduled-icon"
|
|
@@ -4012,7 +4356,7 @@ function createInlineEntryNode(id) {
|
|
|
4012
4356
|
}
|
|
4013
4357
|
|
|
4014
4358
|
var _withEmbeddedEntityIn;
|
|
4015
|
-
var styles$
|
|
4359
|
+
var styles$k = {
|
|
4016
4360
|
icon: /*#__PURE__*/emotion.css({
|
|
4017
4361
|
marginRight: '10px'
|
|
4018
4362
|
}),
|
|
@@ -4050,7 +4394,7 @@ function EmbeddedEntityInline(props) {
|
|
|
4050
4394
|
}
|
|
4051
4395
|
|
|
4052
4396
|
return /*#__PURE__*/React.createElement("span", Object.assign({}, props.attributes, {
|
|
4053
|
-
className: styles$
|
|
4397
|
+
className: styles$k.root,
|
|
4054
4398
|
"data-embedded-entity-inline-id": entryId
|
|
4055
4399
|
}), /*#__PURE__*/React.createElement("span", {
|
|
4056
4400
|
contentEditable: false
|
|
@@ -4168,7 +4512,7 @@ function ToolbarEmbeddedEntityInlineButton(props) {
|
|
|
4168
4512
|
}, /*#__PURE__*/React.createElement(forma36ReactComponents.Icon, {
|
|
4169
4513
|
icon: "EmbeddedEntryInline",
|
|
4170
4514
|
color: "secondary",
|
|
4171
|
-
className: "rich-text__embedded-entry-list-icon " + styles$
|
|
4515
|
+
className: "rich-text__embedded-entry-list-icon " + styles$k.icon
|
|
4172
4516
|
}), /*#__PURE__*/React.createElement("span", null, "Inline entry")));
|
|
4173
4517
|
}
|
|
4174
4518
|
function createEmbeddedEntityInlinePlugin(sdk) {
|
|
@@ -4288,7 +4632,7 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
|
|
|
4288
4632
|
}, actions);
|
|
4289
4633
|
};
|
|
4290
4634
|
|
|
4291
|
-
var styles$
|
|
4635
|
+
var styles$l = {
|
|
4292
4636
|
embedActionsWrapper: /*#__PURE__*/emotion.css({
|
|
4293
4637
|
display: ['-webkit-box', '-ms-flexbox', 'flex'],
|
|
4294
4638
|
webkitAlignSelf: 'flex-start',
|
|
@@ -4318,7 +4662,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
4318
4662
|
return /*#__PURE__*/React__default.createElement(forma36ReactComponents.EditorToolbar, {
|
|
4319
4663
|
testId: "toolbar"
|
|
4320
4664
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
4321
|
-
className: styles$
|
|
4665
|
+
className: styles$l.formattingOptionsWrapper
|
|
4322
4666
|
}, /*#__PURE__*/React__default.createElement(ToolbarHeadingButton, {
|
|
4323
4667
|
isDisabled: isDisabled || !canInsertBlocks
|
|
4324
4668
|
}), validationInfo.isAnyMarkEnabled && /*#__PURE__*/React__default.createElement(forma36ReactComponents.EditorToolbarDivider, null), isMarkEnabled(sdk.field, Contentful.MARKS.BOLD) && /*#__PURE__*/React__default.createElement(ToolbarBoldButton, {
|
|
@@ -4340,7 +4684,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
4340
4684
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.TABLE) && /*#__PURE__*/React__default.createElement(ToolbarTableButton, {
|
|
4341
4685
|
isDisabled: isDisabled || !canInsertBlocks
|
|
4342
4686
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
4343
|
-
className: styles$
|
|
4687
|
+
className: styles$l.embedActionsWrapper
|
|
4344
4688
|
}, /*#__PURE__*/React__default.createElement(EmbedEntityWidget, {
|
|
4345
4689
|
isDisabled: isDisabled,
|
|
4346
4690
|
canInsertBlocks: canInsertBlocks
|
|
@@ -4365,7 +4709,7 @@ function getValidationInfo(field) {
|
|
|
4365
4709
|
}
|
|
4366
4710
|
|
|
4367
4711
|
var _templateObject$5;
|
|
4368
|
-
var styles$
|
|
4712
|
+
var styles$m = {
|
|
4369
4713
|
nativeSticky: /*#__PURE__*/emotion.css(_templateObject$5 || (_templateObject$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: -webkit-sticky;\n position: sticky;\n top: -1px;\n z-index: 2;\n "])))
|
|
4370
4714
|
};
|
|
4371
4715
|
|
|
@@ -4373,15 +4717,158 @@ var StickyToolbarWrapper = function StickyToolbarWrapper(_ref) {
|
|
|
4373
4717
|
var isDisabled = _ref.isDisabled,
|
|
4374
4718
|
children = _ref.children;
|
|
4375
4719
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
4376
|
-
className: isDisabled ? '' : styles$
|
|
4720
|
+
className: isDisabled ? '' : styles$m.nativeSticky
|
|
4377
4721
|
}, children);
|
|
4378
4722
|
};
|
|
4379
4723
|
|
|
4724
|
+
var removeChildNodes = function removeChildNodes(node, predicate) {
|
|
4725
|
+
return Array.from(node.childNodes).filter(predicate).forEach(function (table) {
|
|
4726
|
+
return node.removeChild(table);
|
|
4727
|
+
});
|
|
4728
|
+
};
|
|
4729
|
+
|
|
4730
|
+
var removeChildNodesUsingPredicate = function removeChildNodesUsingPredicate(predicate) {
|
|
4731
|
+
return function (nodeList) {
|
|
4732
|
+
var nodes = Array.from(nodeList);
|
|
4733
|
+
|
|
4734
|
+
while (nodes.length > 0) {
|
|
4735
|
+
var node = nodes.pop();
|
|
4736
|
+
removeChildNodes(node, predicate);
|
|
4737
|
+
|
|
4738
|
+
for (var _i = 0, _Array$from = Array.from(node.childNodes); _i < _Array$from.length; _i++) {
|
|
4739
|
+
var childNode = _Array$from[_i];
|
|
4740
|
+
nodes.push(childNode);
|
|
4741
|
+
}
|
|
4742
|
+
}
|
|
4743
|
+
|
|
4744
|
+
return nodes;
|
|
4745
|
+
};
|
|
4746
|
+
};
|
|
4747
|
+
|
|
4748
|
+
var isComment = function isComment(node) {
|
|
4749
|
+
return node.nodeType === Node.COMMENT_NODE;
|
|
4750
|
+
};
|
|
4751
|
+
|
|
4752
|
+
var removeCommentChildren = /*#__PURE__*/removeChildNodesUsingPredicate(isComment);
|
|
4753
|
+
var removeComments = function removeComments(_ref) {
|
|
4754
|
+
var doc = _ref[0],
|
|
4755
|
+
editor = _ref[1];
|
|
4756
|
+
removeCommentChildren(doc.childNodes);
|
|
4757
|
+
return [doc, editor];
|
|
4758
|
+
};
|
|
4759
|
+
|
|
4760
|
+
var TAG_NAME_TABLE = 'TABLE';
|
|
4761
|
+
var TAG_NAME_TABLE_CAPTION = 'CAPTION';
|
|
4762
|
+
var DISALLOWED_TABLE_CHILD_ELEMENTS = [TAG_NAME_TABLE, TAG_NAME_TABLE_CAPTION];
|
|
4763
|
+
|
|
4764
|
+
var isHTMLElement = function isHTMLElement(node) {
|
|
4765
|
+
return node.nodeType === Node.ELEMENT_NODE;
|
|
4766
|
+
};
|
|
4767
|
+
|
|
4768
|
+
var isTableElement = function isTableElement(node) {
|
|
4769
|
+
return isHTMLElement(node) && node.tagName === TAG_NAME_TABLE;
|
|
4770
|
+
};
|
|
4771
|
+
|
|
4772
|
+
var isDisallowedTableChildElement = function isDisallowedTableChildElement(node) {
|
|
4773
|
+
return isHTMLElement(node) && DISALLOWED_TABLE_CHILD_ELEMENTS.includes(node.tagName);
|
|
4774
|
+
};
|
|
4775
|
+
|
|
4776
|
+
var removeDisallowedTableChildElements = /*#__PURE__*/removeChildNodesUsingPredicate(isDisallowedTableChildElement);
|
|
4777
|
+
|
|
4778
|
+
var removeTableGrandchildren = function removeTableGrandchildren(nodeList) {
|
|
4779
|
+
var nodes = Array.from(nodeList);
|
|
4780
|
+
|
|
4781
|
+
while (nodes.length > 0) {
|
|
4782
|
+
var node = nodes.pop();
|
|
4783
|
+
|
|
4784
|
+
if (isTableElement(node)) {
|
|
4785
|
+
removeDisallowedTableChildElements(node.childNodes);
|
|
4786
|
+
continue;
|
|
4787
|
+
}
|
|
4788
|
+
|
|
4789
|
+
for (var _i = 0, _Array$from = Array.from(node.childNodes); _i < _Array$from.length; _i++) {
|
|
4790
|
+
var childNode = _Array$from[_i];
|
|
4791
|
+
nodes.push(childNode);
|
|
4792
|
+
}
|
|
4793
|
+
}
|
|
4794
|
+
|
|
4795
|
+
return nodes;
|
|
4796
|
+
};
|
|
4797
|
+
|
|
4798
|
+
var sanitizeTables = function sanitizeTables(_ref) {
|
|
4799
|
+
var doc = _ref[0],
|
|
4800
|
+
editor = _ref[1];
|
|
4801
|
+
|
|
4802
|
+
var _getNodeEntryFromSele = getNodeEntryFromSelection(editor, Contentful.BLOCKS.TABLE),
|
|
4803
|
+
node = _getNodeEntryFromSele[0];
|
|
4804
|
+
|
|
4805
|
+
var isTableInCurrentSelection = !!node;
|
|
4806
|
+
|
|
4807
|
+
if (isTableInCurrentSelection) {
|
|
4808
|
+
removeDisallowedTableChildElements(doc.childNodes);
|
|
4809
|
+
} else {
|
|
4810
|
+
removeTableGrandchildren(doc.childNodes);
|
|
4811
|
+
}
|
|
4812
|
+
|
|
4813
|
+
return [doc, editor];
|
|
4814
|
+
};
|
|
4815
|
+
|
|
4816
|
+
|
|
4817
|
+
|
|
4818
|
+
var sanitizers = {
|
|
4819
|
+
__proto__: null,
|
|
4820
|
+
removeComments: removeComments,
|
|
4821
|
+
sanitizeTables: sanitizeTables
|
|
4822
|
+
};
|
|
4823
|
+
|
|
4824
|
+
var MIME_TYPE_HTML = 'text/html'; // TODO: Upgrade tslib so we can just flow(...sanitizers);
|
|
4825
|
+
|
|
4826
|
+
var sanitizeDocument = /*#__PURE__*/flow.apply(undefined, /*#__PURE__*/Object.values(sanitizers));
|
|
4827
|
+
|
|
4828
|
+
var sanitizeHtml = function sanitizeHtml(html, editor) {
|
|
4829
|
+
var doc = new DOMParser().parseFromString(html, MIME_TYPE_HTML);
|
|
4830
|
+
|
|
4831
|
+
var _sanitizeDocument = sanitizeDocument([doc, editor]),
|
|
4832
|
+
sanitizedDoc = _sanitizeDocument[0];
|
|
4833
|
+
|
|
4834
|
+
var sanitizedData = new XMLSerializer().serializeToString(sanitizedDoc);
|
|
4835
|
+
return sanitizedData;
|
|
4836
|
+
};
|
|
4837
|
+
|
|
4838
|
+
var htmlToDataTransfer = function htmlToDataTransfer(html) {
|
|
4839
|
+
var data = new DataTransfer();
|
|
4840
|
+
data.setData(MIME_TYPE_HTML, html);
|
|
4841
|
+
return data;
|
|
4842
|
+
};
|
|
4843
|
+
|
|
4844
|
+
function withPasteHandling(editor) {
|
|
4845
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4846
|
+
return function (_event) {
|
|
4847
|
+
var insertData = editor.insertData;
|
|
4848
|
+
|
|
4849
|
+
editor.insertData = function (data) {
|
|
4850
|
+
var html = data.getData(MIME_TYPE_HTML);
|
|
4851
|
+
|
|
4852
|
+
if (html) {
|
|
4853
|
+
var sanitized = sanitizeHtml(html, editor);
|
|
4854
|
+
var newData = htmlToDataTransfer(sanitized);
|
|
4855
|
+
insertData(newData);
|
|
4856
|
+
}
|
|
4857
|
+
};
|
|
4858
|
+
};
|
|
4859
|
+
}
|
|
4860
|
+
|
|
4861
|
+
var createPastePlugin = function createPastePlugin() {
|
|
4862
|
+
return {
|
|
4863
|
+
onKeyDown: withPasteHandling
|
|
4864
|
+
};
|
|
4865
|
+
};
|
|
4866
|
+
|
|
4380
4867
|
var _templateObject$6, _styles$2, _withParagraphOptions;
|
|
4381
|
-
var styles$
|
|
4868
|
+
var styles$n = (_styles$2 = {}, _styles$2[Contentful.BLOCKS.PARAGRAPH] = /*#__PURE__*/emotion.css(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: ", ";\n margin-bottom: 1.5em;\n "])), tokens.lineHeightDefault), _styles$2);
|
|
4382
4869
|
function Paragraph(props) {
|
|
4383
4870
|
return /*#__PURE__*/React.createElement("div", Object.assign({}, props.attributes, {
|
|
4384
|
-
className: styles$
|
|
4871
|
+
className: styles$n[Contentful.BLOCKS.PARAGRAPH]
|
|
4385
4872
|
}), props.children);
|
|
4386
4873
|
}
|
|
4387
4874
|
function createParagraphPlugin() {
|
|
@@ -4397,9 +4884,8 @@ function createParagraphPlugin() {
|
|
|
4397
4884
|
type: Contentful.BLOCKS.PARAGRAPH,
|
|
4398
4885
|
deserialize: function deserialize(element) {
|
|
4399
4886
|
var isParagraphText = element.nodeName === 'P';
|
|
4400
|
-
var isDivText = element.nodeName === 'DIV' && !element.getAttribute('data-entity-type');
|
|
4401
4887
|
var isNotEmpty = element.textContent !== '';
|
|
4402
|
-
var isText =
|
|
4888
|
+
var isText = isParagraphText && isNotEmpty;
|
|
4403
4889
|
if (!isText) return;
|
|
4404
4890
|
return {
|
|
4405
4891
|
type: Contentful.BLOCKS.PARAGRAPH
|
|
@@ -4560,7 +5046,8 @@ var _excluded = ["sdk", "isInitiallyDisabled", "onAction"];
|
|
|
4560
5046
|
|
|
4561
5047
|
var getPlugins = function getPlugins(sdk, tracking) {
|
|
4562
5048
|
var plugins = [// Core
|
|
4563
|
-
plateCore.createReactPlugin(), plateCore.createHistoryPlugin(), //
|
|
5049
|
+
plateCore.createReactPlugin(), plateCore.createHistoryPlugin(), // Behavior
|
|
5050
|
+
createPastePlugin(), // Global shortcuts
|
|
4564
5051
|
createNewLinePlugin(), createInsertBeforeFirstVoidBlockPlugin(), // Block Elements
|
|
4565
5052
|
createParagraphPlugin(), plateList.createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(tracking), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
|
|
4566
5053
|
createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
|
|
@@ -4633,8 +5120,6 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
4633
5120
|
sdk: sdk
|
|
4634
5121
|
}, /*#__PURE__*/React__default.createElement(SdkProvider, {
|
|
4635
5122
|
sdk: sdk
|
|
4636
|
-
}, /*#__PURE__*/React__default.createElement(ContentfulEditorProvider, {
|
|
4637
|
-
sdk: sdk
|
|
4638
5123
|
}, /*#__PURE__*/React__default.createElement(TrackingProvider, {
|
|
4639
5124
|
onAction: onAction || noop
|
|
4640
5125
|
}, /*#__PURE__*/React__default.createElement(fieldEditorShared.FieldConnector, {
|
|
@@ -4648,15 +5133,17 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
4648
5133
|
disabled = _ref.disabled,
|
|
4649
5134
|
setValue = _ref.setValue,
|
|
4650
5135
|
externalReset = _ref.externalReset;
|
|
4651
|
-
return /*#__PURE__*/React__default.createElement(
|
|
5136
|
+
return /*#__PURE__*/React__default.createElement(ContentfulEditorProvider, {
|
|
5137
|
+
sdk: sdk
|
|
5138
|
+
}, /*#__PURE__*/React__default.createElement(ConnectedRichTextEditor, Object.assign({}, otherProps, {
|
|
4652
5139
|
key: "rich-text-editor-" + externalReset,
|
|
4653
5140
|
value: lastRemoteValue,
|
|
4654
5141
|
sdk: sdk,
|
|
4655
5142
|
onAction: onAction || noop,
|
|
4656
5143
|
isDisabled: disabled,
|
|
4657
5144
|
onChange: setValue
|
|
4658
|
-
}));
|
|
4659
|
-
}))))
|
|
5145
|
+
})));
|
|
5146
|
+
}))));
|
|
4660
5147
|
};
|
|
4661
5148
|
|
|
4662
5149
|
var LINK_TYPES$1 = {
|