@contentful/field-editor-rich-text 0.23.1-next → 0.25.0-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 +667 -149
- 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 +676 -158
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/plugins/EmbeddedEntityBlock/LinkedEntityBlock.d.ts +0 -2
- package/dist/plugins/List/index.d.ts +1 -0
- 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 +10 -9
|
@@ -25,7 +25,9 @@ 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');
|
|
30
|
+
var richTextPlainTextRenderer = require('@contentful/rich-text-plain-text-renderer');
|
|
29
31
|
var plateHtmlSerializer = require('@udecode/plate-html-serializer');
|
|
30
32
|
var plateParagraph = require('@udecode/plate-paragraph');
|
|
31
33
|
var plateBreak = require('@udecode/plate-break');
|
|
@@ -127,6 +129,44 @@ function _taggedTemplateLiteralLoose(strings, raw) {
|
|
|
127
129
|
return strings;
|
|
128
130
|
}
|
|
129
131
|
|
|
132
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
133
|
+
if (!o) return;
|
|
134
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
135
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
136
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
137
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
138
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function _arrayLikeToArray(arr, len) {
|
|
142
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
143
|
+
|
|
144
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
145
|
+
|
|
146
|
+
return arr2;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
150
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
151
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
152
|
+
|
|
153
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
154
|
+
if (it) o = it;
|
|
155
|
+
var i = 0;
|
|
156
|
+
return function () {
|
|
157
|
+
if (i >= o.length) return {
|
|
158
|
+
done: true
|
|
159
|
+
};
|
|
160
|
+
return {
|
|
161
|
+
done: false,
|
|
162
|
+
value: o[i++]
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
168
|
+
}
|
|
169
|
+
|
|
130
170
|
var STYLE_EDITOR_BORDER = "1px solid " + tokens.gray400;
|
|
131
171
|
var styles = {
|
|
132
172
|
root: /*#__PURE__*/emotion.css({
|
|
@@ -511,9 +551,25 @@ function getContentfulEditorId(sdk) {
|
|
|
511
551
|
}
|
|
512
552
|
|
|
513
553
|
function useContentfulEditorHook(_ref) {
|
|
554
|
+
var _editor$selection;
|
|
555
|
+
|
|
514
556
|
var sdk = _ref.sdk;
|
|
515
557
|
var editorId = getContentfulEditorId(sdk);
|
|
516
558
|
var editor = plateCore.useStoreEditorRef(editorId);
|
|
559
|
+
|
|
560
|
+
var _React$useState = React.useState((_editor$selection = editor == null ? void 0 : editor.selection) != null ? _editor$selection : null),
|
|
561
|
+
selection = _React$useState[0],
|
|
562
|
+
setSelection = _React$useState[1];
|
|
563
|
+
|
|
564
|
+
React.useEffect(function () {
|
|
565
|
+
if (!(editor != null && editor.selection)) return;
|
|
566
|
+
setSelection(editor.selection);
|
|
567
|
+
}, [editor == null ? void 0 : editor.selection]);
|
|
568
|
+
|
|
569
|
+
if (editor && !(editor != null && editor.selection) && selection) {
|
|
570
|
+
editor.selection = selection;
|
|
571
|
+
}
|
|
572
|
+
|
|
517
573
|
return editor;
|
|
518
574
|
}
|
|
519
575
|
|
|
@@ -555,7 +611,8 @@ function withHrEvents(editor) {
|
|
|
555
611
|
function ToolbarHrButton(props) {
|
|
556
612
|
var editor = useContentfulEditor();
|
|
557
613
|
|
|
558
|
-
function handleOnClick() {
|
|
614
|
+
function handleOnClick(event) {
|
|
615
|
+
event.preventDefault();
|
|
559
616
|
if (!(editor != null && editor.selection)) return;
|
|
560
617
|
|
|
561
618
|
if (shouldUnwrapBlockquote(editor, Contentful.BLOCKS.HR)) {
|
|
@@ -584,7 +641,8 @@ function ToolbarHrButton(props) {
|
|
|
584
641
|
tooltipPlace: "bottom",
|
|
585
642
|
label: "HR",
|
|
586
643
|
disabled: props.isDisabled,
|
|
587
|
-
|
|
644
|
+
// @ts-expect-error
|
|
645
|
+
onMouseDown: handleOnClick,
|
|
588
646
|
testId: "hr-toolbar-button",
|
|
589
647
|
isActive: isBlockSelected(editor, Contentful.BLOCKS.HR)
|
|
590
648
|
});
|
|
@@ -782,19 +840,22 @@ function ToolbarHeadingButton(props) {
|
|
|
782
840
|
someHeadingsEnabled = _React$useMemo[1];
|
|
783
841
|
|
|
784
842
|
function handleOnSelectItem(type) {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
843
|
+
return function (event) {
|
|
844
|
+
event.preventDefault();
|
|
845
|
+
if (!(editor != null && editor.selection)) return;
|
|
846
|
+
setSelected(type);
|
|
847
|
+
setOpen(false);
|
|
788
848
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
849
|
+
if (shouldUnwrapBlockquote(editor, type)) {
|
|
850
|
+
unwrapFromRoot(editor);
|
|
851
|
+
}
|
|
792
852
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
853
|
+
plateCommon.toggleNodeType(editor, {
|
|
854
|
+
activeType: type,
|
|
855
|
+
inactiveType: type
|
|
856
|
+
});
|
|
857
|
+
Slate.ReactEditor.focus(editor);
|
|
858
|
+
};
|
|
798
859
|
}
|
|
799
860
|
|
|
800
861
|
if (!editor) return null;
|
|
@@ -818,9 +879,7 @@ function ToolbarHeadingButton(props) {
|
|
|
818
879
|
return nodeTypesByEnablement[nodeType] && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
819
880
|
key: nodeType,
|
|
820
881
|
isActive: selected === nodeType,
|
|
821
|
-
|
|
822
|
-
return handleOnSelectItem(nodeType);
|
|
823
|
-
},
|
|
882
|
+
onMouseDown: handleOnSelectItem(nodeType),
|
|
824
883
|
testId: "dropdown-option-" + nodeType,
|
|
825
884
|
isDisabled: props.isDisabled
|
|
826
885
|
}, /*#__PURE__*/React.createElement("span", {
|
|
@@ -969,7 +1028,8 @@ function withQuoteEvents(editor) {
|
|
|
969
1028
|
function ToolbarQuoteButton(props) {
|
|
970
1029
|
var editor = useContentfulEditor();
|
|
971
1030
|
|
|
972
|
-
function handleOnClick() {
|
|
1031
|
+
function handleOnClick(event) {
|
|
1032
|
+
event.preventDefault();
|
|
973
1033
|
if (!editor) return;
|
|
974
1034
|
createBlockQuote(editor);
|
|
975
1035
|
Slate.ReactEditor.focus(editor);
|
|
@@ -981,7 +1041,8 @@ function ToolbarQuoteButton(props) {
|
|
|
981
1041
|
tooltip: "Blockquote",
|
|
982
1042
|
tooltipPlace: "bottom",
|
|
983
1043
|
label: "Blockquote",
|
|
984
|
-
|
|
1044
|
+
// @ts-expect-error
|
|
1045
|
+
onMouseDown: handleOnClick,
|
|
985
1046
|
testId: "quote-toolbar-button",
|
|
986
1047
|
disabled: props.isDisabled,
|
|
987
1048
|
isActive: isBlockSelected(editor, Contentful.BLOCKS.QUOTE)
|
|
@@ -1013,16 +1074,19 @@ function ToolbarListButton(props) {
|
|
|
1013
1074
|
var editor = useContentfulEditor();
|
|
1014
1075
|
|
|
1015
1076
|
function handleClick(type) {
|
|
1016
|
-
|
|
1077
|
+
return function (event) {
|
|
1078
|
+
event.preventDefault();
|
|
1079
|
+
if (!(editor != null && editor.selection)) return;
|
|
1017
1080
|
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1081
|
+
if (shouldUnwrapBlockquote(editor, type)) {
|
|
1082
|
+
unwrapFromRoot(editor);
|
|
1083
|
+
}
|
|
1021
1084
|
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1085
|
+
plateList.toggleList(editor, {
|
|
1086
|
+
type: type
|
|
1087
|
+
});
|
|
1088
|
+
Slate.ReactEditor.focus(editor);
|
|
1089
|
+
};
|
|
1026
1090
|
}
|
|
1027
1091
|
|
|
1028
1092
|
if (!editor) return null;
|
|
@@ -1032,9 +1096,8 @@ function ToolbarListButton(props) {
|
|
|
1032
1096
|
tooltipPlace: "bottom",
|
|
1033
1097
|
label: "UL",
|
|
1034
1098
|
testId: "ul-toolbar-button",
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
},
|
|
1099
|
+
// @ts-expect-error
|
|
1100
|
+
onMouseDown: handleClick(Contentful.BLOCKS.UL_LIST),
|
|
1038
1101
|
isActive: isBlockSelected(editor, Contentful.BLOCKS.UL_LIST),
|
|
1039
1102
|
disabled: props.isDisabled
|
|
1040
1103
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.OL_LIST) && /*#__PURE__*/React.createElement(forma36ReactComponents.EditorToolbarButton, {
|
|
@@ -1043,9 +1106,8 @@ function ToolbarListButton(props) {
|
|
|
1043
1106
|
tooltipPlace: "bottom",
|
|
1044
1107
|
label: "OL",
|
|
1045
1108
|
testId: "ol-toolbar-button",
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
},
|
|
1109
|
+
// @ts-expect-error
|
|
1110
|
+
onMouseDown: handleClick(Contentful.BLOCKS.OL_LIST),
|
|
1049
1111
|
isActive: isBlockSelected(editor, Contentful.BLOCKS.OL_LIST),
|
|
1050
1112
|
disabled: props.isDisabled
|
|
1051
1113
|
}));
|
|
@@ -1074,12 +1136,18 @@ var withListOptions = (_withListOptions = {}, _withListOptions[plateList.ELEMENT
|
|
|
1074
1136
|
type: Contentful.BLOCKS.OL_LIST,
|
|
1075
1137
|
component: OL
|
|
1076
1138
|
}, _withListOptions);
|
|
1139
|
+
var createListPlugin = function createListPlugin() {
|
|
1140
|
+
return plateList.createListPlugin({
|
|
1141
|
+
validLiChildrenTypes: Contentful.LIST_ITEM_BLOCKS
|
|
1142
|
+
});
|
|
1143
|
+
};
|
|
1077
1144
|
|
|
1078
1145
|
var _withBoldOptions;
|
|
1079
1146
|
function ToolbarBoldButton(props) {
|
|
1080
1147
|
var editor = useContentfulEditor();
|
|
1081
1148
|
|
|
1082
|
-
function handleClick() {
|
|
1149
|
+
function handleClick(event) {
|
|
1150
|
+
event.preventDefault();
|
|
1083
1151
|
if (!(editor != null && editor.selection)) return;
|
|
1084
1152
|
plateCommon.toggleMark(editor, Contentful.MARKS.BOLD);
|
|
1085
1153
|
Slate.ReactEditor.focus(editor);
|
|
@@ -1092,7 +1160,8 @@ function ToolbarBoldButton(props) {
|
|
|
1092
1160
|
tooltipPlace: "bottom",
|
|
1093
1161
|
label: "Bold",
|
|
1094
1162
|
testId: "bold-toolbar-button",
|
|
1095
|
-
|
|
1163
|
+
// @ts-expect-error
|
|
1164
|
+
onMouseDown: handleClick,
|
|
1096
1165
|
isActive: plateCommon.isMarkActive(editor, Contentful.MARKS.BOLD),
|
|
1097
1166
|
disabled: props.isDisabled
|
|
1098
1167
|
});
|
|
@@ -1140,7 +1209,8 @@ var _withCodeOptions;
|
|
|
1140
1209
|
function ToolbarCodeButton(props) {
|
|
1141
1210
|
var editor = useContentfulEditor();
|
|
1142
1211
|
|
|
1143
|
-
function handleClick() {
|
|
1212
|
+
function handleClick(event) {
|
|
1213
|
+
event.preventDefault();
|
|
1144
1214
|
if (!(editor != null && editor.selection)) return;
|
|
1145
1215
|
plateCommon.toggleMark(editor, Contentful.MARKS.CODE);
|
|
1146
1216
|
Slate.ReactEditor.focus(editor);
|
|
@@ -1153,7 +1223,8 @@ function ToolbarCodeButton(props) {
|
|
|
1153
1223
|
tooltipPlace: "bottom",
|
|
1154
1224
|
label: "Code",
|
|
1155
1225
|
testId: "code-toolbar-button",
|
|
1156
|
-
|
|
1226
|
+
// @ts-expect-error
|
|
1227
|
+
onMouseDown: handleClick,
|
|
1157
1228
|
isActive: plateCommon.isMarkActive(editor, Contentful.MARKS.CODE),
|
|
1158
1229
|
disabled: props.isDisabled
|
|
1159
1230
|
});
|
|
@@ -1194,7 +1265,8 @@ var _withItalicOptions;
|
|
|
1194
1265
|
function ToolbarItalicButton(props) {
|
|
1195
1266
|
var editor = useContentfulEditor();
|
|
1196
1267
|
|
|
1197
|
-
function handleClick() {
|
|
1268
|
+
function handleClick(event) {
|
|
1269
|
+
event.preventDefault();
|
|
1198
1270
|
if (!(editor != null && editor.selection)) return;
|
|
1199
1271
|
plateCommon.toggleMark(editor, Contentful.MARKS.ITALIC);
|
|
1200
1272
|
Slate.ReactEditor.focus(editor);
|
|
@@ -1207,7 +1279,8 @@ function ToolbarItalicButton(props) {
|
|
|
1207
1279
|
tooltipPlace: "bottom",
|
|
1208
1280
|
label: "Italic",
|
|
1209
1281
|
testId: "italic-toolbar-button",
|
|
1210
|
-
|
|
1282
|
+
// @ts-expect-error
|
|
1283
|
+
onMouseDown: handleClick,
|
|
1211
1284
|
isActive: plateCommon.isMarkActive(editor, Contentful.MARKS.ITALIC),
|
|
1212
1285
|
disabled: props.isDisabled
|
|
1213
1286
|
});
|
|
@@ -1247,7 +1320,8 @@ var _withUnderlineOptions;
|
|
|
1247
1320
|
function ToolbarUnderlineButton(props) {
|
|
1248
1321
|
var editor = useContentfulEditor();
|
|
1249
1322
|
|
|
1250
|
-
function handleClick() {
|
|
1323
|
+
function handleClick(event) {
|
|
1324
|
+
event.preventDefault();
|
|
1251
1325
|
if (!(editor != null && editor.selection)) return;
|
|
1252
1326
|
plateCommon.toggleMark(editor, Contentful.MARKS.UNDERLINE);
|
|
1253
1327
|
Slate.ReactEditor.focus(editor);
|
|
@@ -1260,7 +1334,8 @@ function ToolbarUnderlineButton(props) {
|
|
|
1260
1334
|
tooltipPlace: "bottom",
|
|
1261
1335
|
label: "Underline",
|
|
1262
1336
|
testId: "underline-toolbar-button",
|
|
1263
|
-
|
|
1337
|
+
// @ts-expect-error
|
|
1338
|
+
onMouseDown: handleClick,
|
|
1264
1339
|
isActive: plateCommon.isMarkActive(editor, Contentful.MARKS.UNDERLINE),
|
|
1265
1340
|
disabled: props.isDisabled
|
|
1266
1341
|
});
|
|
@@ -2285,26 +2360,97 @@ function EntryAssetTooltip(_ref) {
|
|
|
2285
2360
|
})));
|
|
2286
2361
|
}
|
|
2287
2362
|
|
|
2363
|
+
var styles$a = {
|
|
2364
|
+
scheduleIcon: /*#__PURE__*/emotion.css({
|
|
2365
|
+
marginRight: tokens.spacing2Xs
|
|
2366
|
+
})
|
|
2367
|
+
};
|
|
2368
|
+
function EntityStatusIcon(_ref) {
|
|
2369
|
+
var entity = _ref.entity,
|
|
2370
|
+
entityType = _ref.entityType;
|
|
2371
|
+
|
|
2372
|
+
var _useEntities = fieldEditorReference.useEntities(),
|
|
2373
|
+
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
|
|
2374
|
+
|
|
2375
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.ScheduledIconWithTooltip, {
|
|
2376
|
+
getEntityScheduledActions: loadEntityScheduledActions,
|
|
2377
|
+
entityType: entityType,
|
|
2378
|
+
entityId: entity.sys.id
|
|
2379
|
+
}, /*#__PURE__*/React.createElement(forma36ReactComponents.Icon, {
|
|
2380
|
+
className: styles$a.scheduleIcon,
|
|
2381
|
+
icon: "Clock",
|
|
2382
|
+
size: "small",
|
|
2383
|
+
color: "muted",
|
|
2384
|
+
testId: "schedule-icon"
|
|
2385
|
+
}));
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
var styles$b = {
|
|
2389
|
+
entryCard: /*#__PURE__*/emotion.css({
|
|
2390
|
+
cursor: 'pointer'
|
|
2391
|
+
})
|
|
2392
|
+
};
|
|
2393
|
+
|
|
2394
|
+
function EntryThumbnail(_ref) {
|
|
2395
|
+
var file = _ref.file;
|
|
2396
|
+
if (!fieldEditorShared.isValidImage(file)) return null;
|
|
2397
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.AssetThumbnail, {
|
|
2398
|
+
file: file
|
|
2399
|
+
});
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
function EntryDropdownMenu(_ref2) {
|
|
2403
|
+
var onEdit = _ref2.onEdit,
|
|
2404
|
+
onRemove = _ref2.onRemove,
|
|
2405
|
+
isDisabled = _ref2.isDisabled;
|
|
2406
|
+
return /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownList, null, /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2407
|
+
isTitle: true
|
|
2408
|
+
}, "Actions"), /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2409
|
+
onClick: onEdit,
|
|
2410
|
+
testId: "card-action-edit"
|
|
2411
|
+
}, "Edit"), /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2412
|
+
onClick: onRemove,
|
|
2413
|
+
isDisabled: isDisabled,
|
|
2414
|
+
testId: "card-action-remove"
|
|
2415
|
+
}, "Remove"));
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2288
2418
|
function FetchingWrappedEntryCard(props) {
|
|
2289
2419
|
var _useEntities = fieldEditorReference.useEntities(),
|
|
2290
2420
|
getOrLoadEntry = _useEntities.getOrLoadEntry,
|
|
2291
|
-
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
|
|
2292
2421
|
entries = _useEntities.entries;
|
|
2293
2422
|
|
|
2294
|
-
React.
|
|
2295
|
-
|
|
2296
|
-
|
|
2423
|
+
var _React$useState = React.useState(null),
|
|
2424
|
+
file = _React$useState[0],
|
|
2425
|
+
setFile = _React$useState[1];
|
|
2297
2426
|
|
|
2298
2427
|
var entry = entries[props.entryId];
|
|
2428
|
+
var contentType = React.useMemo(function () {
|
|
2429
|
+
return props.sdk.space.getCachedContentTypes().find(function (contentType) {
|
|
2430
|
+
return contentType.sys.id === (entry == null ? void 0 : entry.sys.contentType.sys.id);
|
|
2431
|
+
});
|
|
2432
|
+
}, [props.sdk, entry]);
|
|
2433
|
+
var defaultLocaleCode = props.sdk.locales["default"];
|
|
2299
2434
|
React.useEffect(function () {
|
|
2300
2435
|
if (!entry) return;
|
|
2301
|
-
|
|
2302
|
-
|
|
2436
|
+
fieldEditorShared.entityHelpers.getEntryImage({
|
|
2437
|
+
entry: entry,
|
|
2438
|
+
contentType: contentType,
|
|
2439
|
+
localeCode: props.locale,
|
|
2440
|
+
defaultLocaleCode: defaultLocaleCode
|
|
2441
|
+
}, props.sdk.space.getAsset).then(setFile)["catch"](function () {
|
|
2442
|
+
return setFile(null);
|
|
2443
|
+
});
|
|
2444
|
+
}, [entry, contentType, props.locale, defaultLocaleCode, props.sdk, file]);
|
|
2445
|
+
React.useEffect(function () {
|
|
2446
|
+
getOrLoadEntry(props.entryId);
|
|
2447
|
+
}, [props.entryId]); // eslint-disable-line
|
|
2303
2448
|
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2449
|
+
function renderDropdown() {
|
|
2450
|
+
if (!props.onEdit || !props.onRemove) return undefined;
|
|
2451
|
+
return /*#__PURE__*/React.createElement(EntryDropdownMenu, {
|
|
2307
2452
|
isDisabled: props.isDisabled,
|
|
2453
|
+
onEdit: props.onEdit,
|
|
2308
2454
|
onRemove: props.onRemove
|
|
2309
2455
|
});
|
|
2310
2456
|
}
|
|
@@ -2316,49 +2462,149 @@ function FetchingWrappedEntryCard(props) {
|
|
|
2316
2462
|
});
|
|
2317
2463
|
}
|
|
2318
2464
|
|
|
2319
|
-
|
|
2320
|
-
return
|
|
2465
|
+
if (entry === 'failed') {
|
|
2466
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.MissingEntityCard, {
|
|
2467
|
+
entityType: "Entry",
|
|
2468
|
+
isDisabled: props.isDisabled,
|
|
2469
|
+
onRemove: props.onRemove
|
|
2470
|
+
});
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
var entryStatus = entry ? fieldEditorShared.entityHelpers.getEntryStatus(entry.sys) : undefined;
|
|
2474
|
+
|
|
2475
|
+
if (entryStatus === 'deleted') {
|
|
2476
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.MissingEntityCard, {
|
|
2477
|
+
entityType: "Entry",
|
|
2478
|
+
isDisabled: props.isDisabled,
|
|
2479
|
+
onRemove: props.onRemove
|
|
2480
|
+
});
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2483
|
+
var title = fieldEditorShared.entityHelpers.getEntryTitle({
|
|
2484
|
+
entry: entry,
|
|
2485
|
+
contentType: contentType,
|
|
2486
|
+
localeCode: props.locale,
|
|
2487
|
+
defaultLocaleCode: defaultLocaleCode,
|
|
2488
|
+
defaultTitle: 'Untitled'
|
|
2321
2489
|
});
|
|
2322
|
-
|
|
2490
|
+
var description = fieldEditorShared.entityHelpers.getEntityDescription({
|
|
2491
|
+
entity: entry,
|
|
2323
2492
|
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
2493
|
localeCode: props.locale,
|
|
2333
|
-
|
|
2334
|
-
|
|
2494
|
+
defaultLocaleCode: defaultLocaleCode
|
|
2495
|
+
});
|
|
2496
|
+
return /*#__PURE__*/React.createElement(forma36ReactComponents.EntryCard, {
|
|
2497
|
+
contentType: contentType == null ? void 0 : contentType.name,
|
|
2498
|
+
title: title,
|
|
2499
|
+
description: description,
|
|
2335
2500
|
size: "default",
|
|
2336
|
-
|
|
2501
|
+
selected: props.isSelected,
|
|
2502
|
+
status: entryStatus,
|
|
2503
|
+
className: styles$b.entryCard,
|
|
2504
|
+
thumbnailElement: file ? /*#__PURE__*/React.createElement(EntryThumbnail, {
|
|
2505
|
+
file: file
|
|
2506
|
+
}) : null,
|
|
2507
|
+
statusIcon: /*#__PURE__*/React.createElement(EntityStatusIcon, {
|
|
2508
|
+
entityType: "Entry",
|
|
2509
|
+
entity: entry
|
|
2510
|
+
}),
|
|
2511
|
+
dropdownListElements: renderDropdown()
|
|
2337
2512
|
});
|
|
2338
2513
|
}
|
|
2339
2514
|
|
|
2515
|
+
var styles$c = {
|
|
2516
|
+
assetCard: /*#__PURE__*/emotion.css({
|
|
2517
|
+
cursor: 'pointer'
|
|
2518
|
+
}),
|
|
2519
|
+
cardDropdown: /*#__PURE__*/emotion.css({
|
|
2520
|
+
width: '300px'
|
|
2521
|
+
}),
|
|
2522
|
+
truncated: /*#__PURE__*/emotion.css({
|
|
2523
|
+
overflow: 'hidden',
|
|
2524
|
+
whiteSpace: 'nowrap',
|
|
2525
|
+
textOverflow: 'ellipsis'
|
|
2526
|
+
})
|
|
2527
|
+
};
|
|
2528
|
+
|
|
2529
|
+
function AssetDropdownMenu(_ref) {
|
|
2530
|
+
var onEdit = _ref.onEdit,
|
|
2531
|
+
onRemove = _ref.onRemove,
|
|
2532
|
+
isDisabled = _ref.isDisabled,
|
|
2533
|
+
entityFile = _ref.entityFile;
|
|
2534
|
+
var fileName = entityFile.fileName,
|
|
2535
|
+
mimeType = entityFile.contentType,
|
|
2536
|
+
details = entityFile.details;
|
|
2537
|
+
var fileSize = details.size,
|
|
2538
|
+
image = details.image;
|
|
2539
|
+
|
|
2540
|
+
function downloadAsset() {
|
|
2541
|
+
if (!entityFile) return;
|
|
2542
|
+
window.open(entityFile.url, '_blank', 'noopener,noreferrer');
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownList, null, /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2546
|
+
isTitle: true
|
|
2547
|
+
}, "Actions"), onEdit && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2548
|
+
onClick: onEdit,
|
|
2549
|
+
testId: "card-action-edit"
|
|
2550
|
+
}, "Edit"), entityFile && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2551
|
+
onClick: downloadAsset,
|
|
2552
|
+
testId: "card-action-download"
|
|
2553
|
+
}, "Download"), onRemove && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2554
|
+
onClick: onRemove,
|
|
2555
|
+
isDisabled: isDisabled,
|
|
2556
|
+
testId: "card-action-remove"
|
|
2557
|
+
}, "Remove")), /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownList, {
|
|
2558
|
+
border: "top"
|
|
2559
|
+
}, /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, {
|
|
2560
|
+
isTitle: true
|
|
2561
|
+
}, "File info"), fileName && /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownListItem, null, /*#__PURE__*/React.createElement("div", {
|
|
2562
|
+
className: styles$c.truncated
|
|
2563
|
+
}, 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)));
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2340
2566
|
function FetchingWrappedAssetCard(props) {
|
|
2341
2567
|
var _useEntities = fieldEditorReference.useEntities(),
|
|
2342
2568
|
getOrLoadAsset = _useEntities.getOrLoadAsset,
|
|
2343
|
-
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
|
|
2344
2569
|
assets = _useEntities.assets;
|
|
2345
2570
|
|
|
2571
|
+
var asset = assets[props.assetId];
|
|
2572
|
+
var defaultLocaleCode = props.sdk.locales["default"];
|
|
2573
|
+
var entityFile = asset != null && asset.fields.file ? asset.fields.file[props.locale] || asset.fields.file[defaultLocaleCode] : undefined;
|
|
2346
2574
|
React.useEffect(function () {
|
|
2347
2575
|
getOrLoadAsset(props.assetId);
|
|
2348
2576
|
}, [props.assetId]); // eslint-disable-line
|
|
2349
2577
|
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
}, [asset]); // eslint-disable-line
|
|
2578
|
+
function getAssetSrc() {
|
|
2579
|
+
if (!(entityFile != null && entityFile.url)) return '';
|
|
2580
|
+
return entityFile.url + "?h=300";
|
|
2581
|
+
}
|
|
2355
2582
|
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2583
|
+
function getFileType() {
|
|
2584
|
+
var groupToIconMap = {
|
|
2585
|
+
image: 'image',
|
|
2586
|
+
video: 'video',
|
|
2587
|
+
audio: 'audio',
|
|
2588
|
+
richtext: 'richtext',
|
|
2589
|
+
presentation: 'presentation',
|
|
2590
|
+
spreadsheet: 'spreadsheet',
|
|
2591
|
+
pdfdocument: 'pdf',
|
|
2592
|
+
archive: 'archive',
|
|
2593
|
+
plaintext: 'plaintext',
|
|
2594
|
+
code: 'code',
|
|
2595
|
+
markup: 'markup'
|
|
2596
|
+
};
|
|
2597
|
+
var archive = groupToIconMap['archive'];
|
|
2598
|
+
|
|
2599
|
+
if (!entityFile) {
|
|
2600
|
+
return archive;
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
var groupName = mimetype.getGroupLabel({
|
|
2604
|
+
type: entityFile.contentType,
|
|
2605
|
+
fallbackFileName: entityFile.fileName
|
|
2361
2606
|
});
|
|
2607
|
+
return groupToIconMap[groupName] || archive;
|
|
2362
2608
|
}
|
|
2363
2609
|
|
|
2364
2610
|
if (asset === undefined) {
|
|
@@ -2371,20 +2617,49 @@ function FetchingWrappedAssetCard(props) {
|
|
|
2371
2617
|
});
|
|
2372
2618
|
}
|
|
2373
2619
|
|
|
2374
|
-
|
|
2620
|
+
if (asset === 'failed') {
|
|
2621
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.MissingEntityCard, {
|
|
2622
|
+
entityType: "Asset",
|
|
2623
|
+
isDisabled: props.isDisabled,
|
|
2624
|
+
onRemove: props.onRemove
|
|
2625
|
+
});
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
var status = asset ? fieldEditorShared.entityHelpers.getEntryStatus(asset.sys) : undefined;
|
|
2629
|
+
|
|
2630
|
+
if (status === 'deleted') {
|
|
2631
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.MissingEntityCard, {
|
|
2632
|
+
entityType: "Asset",
|
|
2633
|
+
asSquare: true,
|
|
2634
|
+
isDisabled: props.isDisabled,
|
|
2635
|
+
onRemove: props.onRemove
|
|
2636
|
+
});
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
var entityTitle = fieldEditorShared.entityHelpers.getAssetTitle({
|
|
2375
2640
|
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
2641
|
localeCode: props.locale,
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2642
|
+
defaultLocaleCode: defaultLocaleCode,
|
|
2643
|
+
defaultTitle: 'Untitled'
|
|
2644
|
+
});
|
|
2645
|
+
return /*#__PURE__*/React.createElement(forma36ReactComponents.AssetCard, {
|
|
2646
|
+
title: entityTitle,
|
|
2647
|
+
selected: props.isSelected,
|
|
2648
|
+
size: "default",
|
|
2649
|
+
src: getAssetSrc(),
|
|
2650
|
+
type: getFileType(),
|
|
2651
|
+
status: status,
|
|
2652
|
+
statusIcon: /*#__PURE__*/React.createElement(EntityStatusIcon, {
|
|
2653
|
+
entityType: "Asset",
|
|
2654
|
+
entity: asset
|
|
2655
|
+
}),
|
|
2656
|
+
className: styles$c.assetCard,
|
|
2657
|
+
dropdownListElements: entityFile && /*#__PURE__*/React.createElement(AssetDropdownMenu, {
|
|
2658
|
+
onEdit: props.onEdit,
|
|
2659
|
+
onRemove: props.onRemove,
|
|
2660
|
+
isDisabled: props.isDisabled,
|
|
2661
|
+
entityFile: entityFile
|
|
2662
|
+
})
|
|
2388
2663
|
});
|
|
2389
2664
|
}
|
|
2390
2665
|
|
|
@@ -2428,7 +2703,7 @@ function getLinkedContentTypeIdsForNodeType(field, nodeType) {
|
|
|
2428
2703
|
}
|
|
2429
2704
|
|
|
2430
2705
|
var _templateObject$3, _SYS_LINK_TYPES, _LINK_TYPE_SELECTION_;
|
|
2431
|
-
var styles$
|
|
2706
|
+
var styles$d = {
|
|
2432
2707
|
removeSelectionLabel: /*#__PURE__*/emotion.css(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-left: ", ";\n "])), tokens.spacingS)
|
|
2433
2708
|
};
|
|
2434
2709
|
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 +2891,7 @@ function HyperlinkModal(props) {
|
|
|
2616
2891
|
htmlFor: ""
|
|
2617
2892
|
}, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(forma36ReactComponents.TextLink, {
|
|
2618
2893
|
onClick: resetLinkEntity,
|
|
2619
|
-
className: styles$
|
|
2894
|
+
className: styles$d.removeSelectionLabel
|
|
2620
2895
|
}, "Remove selection"), /*#__PURE__*/React.createElement("div", null, linkType === Contentful.INLINES.ENTRY_HYPERLINK && /*#__PURE__*/React.createElement(FetchingWrappedEntryCard, {
|
|
2621
2896
|
sdk: props.sdk,
|
|
2622
2897
|
locale: props.sdk.field.locale,
|
|
@@ -2731,7 +3006,7 @@ function _addOrEditLink() {
|
|
|
2731
3006
|
}
|
|
2732
3007
|
|
|
2733
3008
|
var _withHyperlinkOptions;
|
|
2734
|
-
var styles$
|
|
3009
|
+
var styles$e = {
|
|
2735
3010
|
hyperlinkWrapper: /*#__PURE__*/emotion.css({
|
|
2736
3011
|
display: 'inline',
|
|
2737
3012
|
position: 'static',
|
|
@@ -2910,14 +3185,14 @@ function UrlHyperlink(props) {
|
|
|
2910
3185
|
|
|
2911
3186
|
return /*#__PURE__*/React.createElement(forma36ReactComponents.Tooltip, {
|
|
2912
3187
|
content: uri,
|
|
2913
|
-
targetWrapperClassName: styles$
|
|
3188
|
+
targetWrapperClassName: styles$e.hyperlinkWrapper,
|
|
2914
3189
|
place: "bottom",
|
|
2915
3190
|
maxWidth: "auto"
|
|
2916
3191
|
}, /*#__PURE__*/React.createElement(forma36ReactComponents.TextLink, {
|
|
2917
3192
|
href: uri,
|
|
2918
3193
|
rel: "noopener noreferrer",
|
|
2919
3194
|
onClick: handleClick,
|
|
2920
|
-
className: styles$
|
|
3195
|
+
className: styles$e.hyperlink
|
|
2921
3196
|
}, props.children));
|
|
2922
3197
|
}
|
|
2923
3198
|
|
|
@@ -2966,14 +3241,14 @@ function EntityHyperlink(props) {
|
|
|
2966
3241
|
type: target.sys.linkType,
|
|
2967
3242
|
sdk: sdk
|
|
2968
3243
|
}),
|
|
2969
|
-
targetWrapperClassName: styles$
|
|
3244
|
+
targetWrapperClassName: styles$e.hyperlinkWrapper,
|
|
2970
3245
|
place: "bottom",
|
|
2971
3246
|
maxWidth: "auto"
|
|
2972
3247
|
}, /*#__PURE__*/React.createElement(forma36ReactComponents.TextLink, {
|
|
2973
3248
|
href: "javascript:void(0)",
|
|
2974
3249
|
rel: "noopener noreferrer",
|
|
2975
3250
|
onClick: handleClick,
|
|
2976
|
-
className: styles$
|
|
3251
|
+
className: styles$e.hyperlink,
|
|
2977
3252
|
"data-link-type": target.sys.linkType,
|
|
2978
3253
|
"data-link-id": target.sys.id
|
|
2979
3254
|
}, props.children));
|
|
@@ -3027,7 +3302,8 @@ function ToolbarHyperlinkButton(props) {
|
|
|
3027
3302
|
tooltipPlace: "bottom",
|
|
3028
3303
|
label: "Hyperlink",
|
|
3029
3304
|
testId: "hyperlink-toolbar-button",
|
|
3030
|
-
|
|
3305
|
+
// @ts-expect-error
|
|
3306
|
+
onMouseDown: handleClick,
|
|
3031
3307
|
isActive: isActive,
|
|
3032
3308
|
disabled: props.isDisabled
|
|
3033
3309
|
});
|
|
@@ -3245,7 +3521,7 @@ var setHeader = function setHeader(editor, enable) {
|
|
|
3245
3521
|
});
|
|
3246
3522
|
};
|
|
3247
3523
|
|
|
3248
|
-
var styles$
|
|
3524
|
+
var styles$f = {
|
|
3249
3525
|
topRight: /*#__PURE__*/emotion.css({
|
|
3250
3526
|
position: 'absolute',
|
|
3251
3527
|
top: tokens.spacingXs,
|
|
@@ -3323,7 +3599,7 @@ var TableActions = function TableActions() {
|
|
|
3323
3599
|
};
|
|
3324
3600
|
}, [editor, isHeaderEnabled, close, onViewportAction]);
|
|
3325
3601
|
return /*#__PURE__*/React__default.createElement(forma36ReactComponents.Dropdown, {
|
|
3326
|
-
className: styles$
|
|
3602
|
+
className: styles$f.topRight,
|
|
3327
3603
|
position: "left",
|
|
3328
3604
|
isOpen: isOpen,
|
|
3329
3605
|
onClose: close,
|
|
@@ -3363,27 +3639,36 @@ var TableActions = function TableActions() {
|
|
|
3363
3639
|
};
|
|
3364
3640
|
|
|
3365
3641
|
var _templateObject$4, _templateObject2$3, _templateObject3$3, _templateObject4$1, _styles$1, _withTableOptions;
|
|
3366
|
-
var styles$
|
|
3642
|
+
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);
|
|
3643
|
+
|
|
3644
|
+
var slateNodeToText = function slateNodeToText(node) {
|
|
3645
|
+
var contentfulNode = contentfulSlatejsAdapter.toContentfulDocument({
|
|
3646
|
+
document: [node],
|
|
3647
|
+
schema: schema
|
|
3648
|
+
});
|
|
3649
|
+
return richTextPlainTextRenderer.documentToPlainTextString(contentfulNode);
|
|
3650
|
+
};
|
|
3651
|
+
|
|
3367
3652
|
var Table = function Table(props) {
|
|
3368
3653
|
return /*#__PURE__*/React.createElement("table", Object.assign({}, props.attributes, {
|
|
3369
|
-
className: styles$
|
|
3654
|
+
className: styles$g[Contentful.BLOCKS.TABLE]
|
|
3370
3655
|
}), /*#__PURE__*/React.createElement("tbody", null, props.children));
|
|
3371
3656
|
};
|
|
3372
3657
|
var TR = function TR(props) {
|
|
3373
3658
|
return /*#__PURE__*/React.createElement("tr", Object.assign({}, props.attributes, {
|
|
3374
|
-
className: styles$
|
|
3659
|
+
className: styles$g[Contentful.BLOCKS.TABLE_ROW]
|
|
3375
3660
|
}), props.children);
|
|
3376
3661
|
};
|
|
3377
3662
|
var TH = function TH(props) {
|
|
3378
3663
|
var isSelected = Slate.useSelected();
|
|
3379
3664
|
return /*#__PURE__*/React.createElement("th", Object.assign({}, props.attributes, props.element.data, {
|
|
3380
|
-
className: styles$
|
|
3665
|
+
className: styles$g[Contentful.BLOCKS.TABLE_HEADER_CELL]
|
|
3381
3666
|
}), isSelected && /*#__PURE__*/React.createElement(TableActions, null), props.children);
|
|
3382
3667
|
};
|
|
3383
3668
|
var TD = function TD(props) {
|
|
3384
3669
|
var isSelected = Slate.useSelected();
|
|
3385
3670
|
return /*#__PURE__*/React.createElement("td", Object.assign({}, props.attributes, props.element.data, {
|
|
3386
|
-
className: styles$
|
|
3671
|
+
className: styles$g[Contentful.BLOCKS.TABLE_CELL]
|
|
3387
3672
|
}), isSelected && /*#__PURE__*/React.createElement(TableActions, null), props.children);
|
|
3388
3673
|
};
|
|
3389
3674
|
var withTableOptions = (_withTableOptions = {}, _withTableOptions[plateTable.ELEMENT_TABLE] = {
|
|
@@ -3416,7 +3701,8 @@ function addTableTrackingEvents(editor, _ref) {
|
|
|
3416
3701
|
|
|
3417
3702
|
if (hasTables(markupAfter)) {
|
|
3418
3703
|
onViewportAction('paste', {
|
|
3419
|
-
tablePasted: true
|
|
3704
|
+
tablePasted: true,
|
|
3705
|
+
hasHeadersOutsideFirstRow: hasHeadersOutsideFirstRow(markupAfter)
|
|
3420
3706
|
});
|
|
3421
3707
|
}
|
|
3422
3708
|
}, 1);
|
|
@@ -3424,6 +3710,56 @@ function addTableTrackingEvents(editor, _ref) {
|
|
|
3424
3710
|
};
|
|
3425
3711
|
}
|
|
3426
3712
|
|
|
3713
|
+
var paragraph = function paragraph() {
|
|
3714
|
+
return {
|
|
3715
|
+
type: Contentful.BLOCKS.PARAGRAPH,
|
|
3716
|
+
data: {},
|
|
3717
|
+
children: []
|
|
3718
|
+
};
|
|
3719
|
+
};
|
|
3720
|
+
|
|
3721
|
+
function addTableNormalization(editor) {
|
|
3722
|
+
var normalizeNode = editor.normalizeNode;
|
|
3723
|
+
|
|
3724
|
+
editor.normalizeNode = function (entry) {
|
|
3725
|
+
var node = entry[0],
|
|
3726
|
+
path = entry[1]; // TODO: This should be enforced by sanitizeSlateDoc() but the internal
|
|
3727
|
+
// editor value can be different.
|
|
3728
|
+
// cf. https://github.com/ianstormtaylor/slate/issues/2206
|
|
3729
|
+
|
|
3730
|
+
var cellTypes = [Contentful.BLOCKS.TABLE_CELL, Contentful.BLOCKS.TABLE_HEADER_CELL];
|
|
3731
|
+
|
|
3732
|
+
if (slate.Element.isElement(node) && cellTypes.includes(node.type)) {
|
|
3733
|
+
for (var _iterator = _createForOfIteratorHelperLoose(slate.Node.children(editor, path)), _step; !(_step = _iterator()).done;) {
|
|
3734
|
+
var _step$value = _step.value,
|
|
3735
|
+
child = _step$value[0],
|
|
3736
|
+
childPath = _step$value[1];
|
|
3737
|
+
|
|
3738
|
+
if (slate.Text.isText(child)) {
|
|
3739
|
+
slate.Transforms.wrapNodes(editor, paragraph(), {
|
|
3740
|
+
at: childPath
|
|
3741
|
+
});
|
|
3742
|
+
} else if (!Contentful.CONTAINERS[node.type].includes(child.type)) {
|
|
3743
|
+
var paragraphWithTextFromNode = _extends({}, paragraph(), {
|
|
3744
|
+
children: [{
|
|
3745
|
+
text: slateNodeToText(child)
|
|
3746
|
+
}]
|
|
3747
|
+
});
|
|
3748
|
+
|
|
3749
|
+
slate.Transforms.removeNodes(editor, {
|
|
3750
|
+
at: childPath
|
|
3751
|
+
});
|
|
3752
|
+
slate.Transforms.insertNodes(editor, paragraphWithTextFromNode, {
|
|
3753
|
+
at: childPath
|
|
3754
|
+
});
|
|
3755
|
+
}
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3759
|
+
normalizeNode(entry);
|
|
3760
|
+
};
|
|
3761
|
+
}
|
|
3762
|
+
|
|
3427
3763
|
function hasTables(nodes) {
|
|
3428
3764
|
return nodes.some(function (_ref2) {
|
|
3429
3765
|
var type = _ref2.type;
|
|
@@ -3431,16 +3767,62 @@ function hasTables(nodes) {
|
|
|
3431
3767
|
});
|
|
3432
3768
|
}
|
|
3433
3769
|
|
|
3770
|
+
var isTableHeaderCell = function isTableHeaderCell(_ref3) {
|
|
3771
|
+
var type = _ref3.type;
|
|
3772
|
+
return type === Contentful.BLOCKS.TABLE_HEADER_CELL;
|
|
3773
|
+
};
|
|
3774
|
+
|
|
3775
|
+
function hasHeadersOutsideFirstRow(nodes) {
|
|
3776
|
+
return nodes.filter(function (_ref4) {
|
|
3777
|
+
var type = _ref4.type;
|
|
3778
|
+
return type === Contentful.BLOCKS.TABLE;
|
|
3779
|
+
}).flatMap(function (_ref5) {
|
|
3780
|
+
var children = _ref5.children;
|
|
3781
|
+
return children.slice(1);
|
|
3782
|
+
}).some(function (_ref6) {
|
|
3783
|
+
var children = _ref6.children;
|
|
3784
|
+
return children.some(isTableHeaderCell);
|
|
3785
|
+
});
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3434
3788
|
function createWithTableEvents(tracking) {
|
|
3435
3789
|
return function withTableEvents(editor) {
|
|
3436
3790
|
addTableTrackingEvents(editor, tracking);
|
|
3791
|
+
addTableNormalization(editor);
|
|
3437
3792
|
return plateTable.getTableOnKeyDown()(editor);
|
|
3438
3793
|
};
|
|
3439
3794
|
}
|
|
3440
3795
|
|
|
3441
3796
|
var createTablePlugin = function createTablePlugin(tracking) {
|
|
3442
3797
|
return _extends({}, plateTable.createTablePlugin(), {
|
|
3443
|
-
onKeyDown: createWithTableEvents(tracking)
|
|
3798
|
+
onKeyDown: createWithTableEvents(tracking),
|
|
3799
|
+
withOverrides: function withOverrides(editor) {
|
|
3800
|
+
var insertFragment = editor.insertFragment;
|
|
3801
|
+
|
|
3802
|
+
editor.insertFragment = function (fragments) {
|
|
3803
|
+
// 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
|
|
3804
|
+
// More info: https://github.com/ianstormtaylor/slate/pull/4489 and https://github.com/ianstormtaylor/slate/issues/4542
|
|
3805
|
+
var fragmentHasTable = fragments.some(function (fragment) {
|
|
3806
|
+
return fragment.type === Contentful.BLOCKS.TABLE;
|
|
3807
|
+
});
|
|
3808
|
+
|
|
3809
|
+
if (fragmentHasTable) {
|
|
3810
|
+
var emptyParagraph = {
|
|
3811
|
+
type: Contentful.BLOCKS.PARAGRAPH,
|
|
3812
|
+
children: [{
|
|
3813
|
+
text: ''
|
|
3814
|
+
}],
|
|
3815
|
+
data: {},
|
|
3816
|
+
isVoid: false
|
|
3817
|
+
};
|
|
3818
|
+
slate.Transforms.insertNodes(editor, emptyParagraph);
|
|
3819
|
+
}
|
|
3820
|
+
|
|
3821
|
+
insertFragment(fragments);
|
|
3822
|
+
};
|
|
3823
|
+
|
|
3824
|
+
return editor;
|
|
3825
|
+
}
|
|
3444
3826
|
});
|
|
3445
3827
|
};
|
|
3446
3828
|
function ToolbarTableButton(props) {
|
|
@@ -3492,7 +3874,8 @@ function ToolbarTableButton(props) {
|
|
|
3492
3874
|
tooltipPlace: "bottom",
|
|
3493
3875
|
label: "Table",
|
|
3494
3876
|
testId: "table-toolbar-button",
|
|
3495
|
-
|
|
3877
|
+
// @ts-expect-error
|
|
3878
|
+
onMouseDown: handleClick,
|
|
3496
3879
|
// TODO: active state looks off since the button will be disabled. Do we still need it?
|
|
3497
3880
|
isActive: isActive,
|
|
3498
3881
|
disabled: props.isDisabled
|
|
@@ -3522,7 +3905,7 @@ function EmbeddedEntityDropdownButton(_ref) {
|
|
|
3522
3905
|
}, /*#__PURE__*/React.createElement(forma36ReactComponents.DropdownList, null, children));
|
|
3523
3906
|
}
|
|
3524
3907
|
|
|
3525
|
-
var styles$
|
|
3908
|
+
var styles$h = {
|
|
3526
3909
|
root: /*#__PURE__*/emotion.css({
|
|
3527
3910
|
marginBottom: '1.25rem'
|
|
3528
3911
|
})
|
|
@@ -3530,8 +3913,7 @@ var styles$e = {
|
|
|
3530
3913
|
function LinkedEntityBlock(props) {
|
|
3531
3914
|
var attributes = props.attributes,
|
|
3532
3915
|
children = props.children,
|
|
3533
|
-
element = props.element
|
|
3534
|
-
onEntityFetchComplete = props.onEntityFetchComplete;
|
|
3916
|
+
element = props.element;
|
|
3535
3917
|
var isSelected = Slate.useSelected();
|
|
3536
3918
|
var editor = useContentfulEditor();
|
|
3537
3919
|
var sdk = useSdkContext();
|
|
@@ -3556,7 +3938,7 @@ function LinkedEntityBlock(props) {
|
|
|
3556
3938
|
};
|
|
3557
3939
|
|
|
3558
3940
|
return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
|
|
3559
|
-
className: styles$
|
|
3941
|
+
className: styles$h.root,
|
|
3560
3942
|
"data-entity-type": entityType,
|
|
3561
3943
|
"data-entity-id": entityId
|
|
3562
3944
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -3568,12 +3950,7 @@ function LinkedEntityBlock(props) {
|
|
|
3568
3950
|
isDisabled: isDisabled,
|
|
3569
3951
|
isSelected: isSelected,
|
|
3570
3952
|
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
|
|
3953
|
+
onEdit: handleEditClick
|
|
3577
3954
|
}), entityType === 'Asset' && /*#__PURE__*/React__default.createElement(FetchingWrappedAssetCard, {
|
|
3578
3955
|
sdk: sdk,
|
|
3579
3956
|
assetId: entityId,
|
|
@@ -3581,12 +3958,7 @@ function LinkedEntityBlock(props) {
|
|
|
3581
3958
|
isDisabled: isDisabled,
|
|
3582
3959
|
isSelected: isSelected,
|
|
3583
3960
|
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
|
|
3961
|
+
onEdit: handleEditClick
|
|
3590
3962
|
})), children);
|
|
3591
3963
|
}
|
|
3592
3964
|
|
|
@@ -3726,7 +4098,7 @@ function insertBlock(editor, nodeType, entity) {
|
|
|
3726
4098
|
Slate.ReactEditor.focus(editor);
|
|
3727
4099
|
}
|
|
3728
4100
|
|
|
3729
|
-
var styles$
|
|
4101
|
+
var styles$i = {
|
|
3730
4102
|
icon: /*#__PURE__*/emotion.css({
|
|
3731
4103
|
marginRight: '10px'
|
|
3732
4104
|
})
|
|
@@ -3741,16 +4113,17 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
|
|
|
3741
4113
|
var sdk = useSdkContext();
|
|
3742
4114
|
|
|
3743
4115
|
var handleClick = /*#__PURE__*/function () {
|
|
3744
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
4116
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(event) {
|
|
3745
4117
|
return runtime_1.wrap(function _callee$(_context) {
|
|
3746
4118
|
while (1) {
|
|
3747
4119
|
switch (_context.prev = _context.next) {
|
|
3748
4120
|
case 0:
|
|
4121
|
+
event.preventDefault();
|
|
3749
4122
|
onClose();
|
|
3750
|
-
_context.next =
|
|
4123
|
+
_context.next = 4;
|
|
3751
4124
|
return selectEntityAndInsert(nodeType, sdk, editor, logAction || noop);
|
|
3752
4125
|
|
|
3753
|
-
case
|
|
4126
|
+
case 4:
|
|
3754
4127
|
case "end":
|
|
3755
4128
|
return _context.stop();
|
|
3756
4129
|
}
|
|
@@ -3758,7 +4131,7 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
|
|
|
3758
4131
|
}, _callee);
|
|
3759
4132
|
}));
|
|
3760
4133
|
|
|
3761
|
-
return function handleClick() {
|
|
4134
|
+
return function handleClick(_x) {
|
|
3762
4135
|
return _ref2.apply(this, arguments);
|
|
3763
4136
|
};
|
|
3764
4137
|
}();
|
|
@@ -3769,21 +4142,22 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
|
|
|
3769
4142
|
disabled: isDisabled,
|
|
3770
4143
|
className: baseClass + "-button",
|
|
3771
4144
|
size: "small",
|
|
3772
|
-
|
|
4145
|
+
// @ts-expect-error
|
|
4146
|
+
onMouseDown: handleClick,
|
|
3773
4147
|
icon: type === 'Asset' ? 'Asset' : 'EmbeddedEntryBlock',
|
|
3774
4148
|
buttonType: "muted",
|
|
3775
4149
|
testId: "toolbar-toggle-" + nodeType
|
|
3776
4150
|
}, "Embed " + type.toLowerCase()) : /*#__PURE__*/React__default.createElement(forma36ReactComponents.DropdownListItem, {
|
|
3777
4151
|
isDisabled: isDisabled,
|
|
3778
4152
|
className: baseClass + "-list-item",
|
|
3779
|
-
|
|
4153
|
+
onMouseDown: handleClick,
|
|
3780
4154
|
testId: "toolbar-toggle-" + nodeType
|
|
3781
4155
|
}, /*#__PURE__*/React__default.createElement(forma36ReactComponents.Flex, {
|
|
3782
4156
|
alignItems: "center",
|
|
3783
4157
|
flexDirection: "row"
|
|
3784
4158
|
}, /*#__PURE__*/React__default.createElement(forma36ReactComponents.Icon, {
|
|
3785
4159
|
icon: type === 'Asset' ? 'Asset' : 'EmbeddedEntryBlock',
|
|
3786
|
-
className: "rich-text__embedded-entry-list-icon " + styles$
|
|
4160
|
+
className: "rich-text__embedded-entry-list-icon " + styles$i.icon,
|
|
3787
4161
|
color: "secondary"
|
|
3788
4162
|
}), /*#__PURE__*/React__default.createElement("span", null, type)));
|
|
3789
4163
|
}
|
|
@@ -3826,6 +4200,7 @@ var createEmbeddedEntityPlugin = function createEmbeddedEntityPlugin(nodeType) {
|
|
|
3826
4200
|
if (!isBlock) return;
|
|
3827
4201
|
return {
|
|
3828
4202
|
type: nodeType,
|
|
4203
|
+
isVoid: true,
|
|
3829
4204
|
data: {
|
|
3830
4205
|
target: {
|
|
3831
4206
|
sys: {
|
|
@@ -3908,7 +4283,7 @@ function getWithEmbeddedEntityEvents(nodeType, sdk) {
|
|
|
3908
4283
|
|
|
3909
4284
|
var getEntryTitle = fieldEditorShared.entityHelpers.getEntryTitle,
|
|
3910
4285
|
getEntryStatus = fieldEditorShared.entityHelpers.getEntryStatus;
|
|
3911
|
-
var styles$
|
|
4286
|
+
var styles$j = {
|
|
3912
4287
|
scheduledIcon: /*#__PURE__*/emotion.css({
|
|
3913
4288
|
verticalAlign: 'text-bottom',
|
|
3914
4289
|
marginRight: tokens.spacing2Xs
|
|
@@ -3986,7 +4361,7 @@ function FetchingWrappedInlineEntryCard(props) {
|
|
|
3986
4361
|
entityType: "Entry",
|
|
3987
4362
|
entityId: entry.sys.id
|
|
3988
4363
|
}, /*#__PURE__*/React__default.createElement(forma36ReactComponents.Icon, {
|
|
3989
|
-
className: styles$
|
|
4364
|
+
className: styles$j.scheduledIcon,
|
|
3990
4365
|
icon: "Clock",
|
|
3991
4366
|
color: "muted",
|
|
3992
4367
|
testId: "scheduled-icon"
|
|
@@ -4012,7 +4387,7 @@ function createInlineEntryNode(id) {
|
|
|
4012
4387
|
}
|
|
4013
4388
|
|
|
4014
4389
|
var _withEmbeddedEntityIn;
|
|
4015
|
-
var styles$
|
|
4390
|
+
var styles$k = {
|
|
4016
4391
|
icon: /*#__PURE__*/emotion.css({
|
|
4017
4392
|
marginRight: '10px'
|
|
4018
4393
|
}),
|
|
@@ -4050,7 +4425,7 @@ function EmbeddedEntityInline(props) {
|
|
|
4050
4425
|
}
|
|
4051
4426
|
|
|
4052
4427
|
return /*#__PURE__*/React.createElement("span", Object.assign({}, props.attributes, {
|
|
4053
|
-
className: styles$
|
|
4428
|
+
className: styles$k.root,
|
|
4054
4429
|
"data-embedded-entity-inline-id": entryId
|
|
4055
4430
|
}), /*#__PURE__*/React.createElement("span", {
|
|
4056
4431
|
contentEditable: false
|
|
@@ -4168,7 +4543,7 @@ function ToolbarEmbeddedEntityInlineButton(props) {
|
|
|
4168
4543
|
}, /*#__PURE__*/React.createElement(forma36ReactComponents.Icon, {
|
|
4169
4544
|
icon: "EmbeddedEntryInline",
|
|
4170
4545
|
color: "secondary",
|
|
4171
|
-
className: "rich-text__embedded-entry-list-icon " + styles$
|
|
4546
|
+
className: "rich-text__embedded-entry-list-icon " + styles$k.icon
|
|
4172
4547
|
}), /*#__PURE__*/React.createElement("span", null, "Inline entry")));
|
|
4173
4548
|
}
|
|
4174
4549
|
function createEmbeddedEntityInlinePlugin(sdk) {
|
|
@@ -4288,7 +4663,7 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
|
|
|
4288
4663
|
}, actions);
|
|
4289
4664
|
};
|
|
4290
4665
|
|
|
4291
|
-
var styles$
|
|
4666
|
+
var styles$l = {
|
|
4292
4667
|
embedActionsWrapper: /*#__PURE__*/emotion.css({
|
|
4293
4668
|
display: ['-webkit-box', '-ms-flexbox', 'flex'],
|
|
4294
4669
|
webkitAlignSelf: 'flex-start',
|
|
@@ -4318,7 +4693,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
4318
4693
|
return /*#__PURE__*/React__default.createElement(forma36ReactComponents.EditorToolbar, {
|
|
4319
4694
|
testId: "toolbar"
|
|
4320
4695
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
4321
|
-
className: styles$
|
|
4696
|
+
className: styles$l.formattingOptionsWrapper
|
|
4322
4697
|
}, /*#__PURE__*/React__default.createElement(ToolbarHeadingButton, {
|
|
4323
4698
|
isDisabled: isDisabled || !canInsertBlocks
|
|
4324
4699
|
}), validationInfo.isAnyMarkEnabled && /*#__PURE__*/React__default.createElement(forma36ReactComponents.EditorToolbarDivider, null), isMarkEnabled(sdk.field, Contentful.MARKS.BOLD) && /*#__PURE__*/React__default.createElement(ToolbarBoldButton, {
|
|
@@ -4340,7 +4715,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
4340
4715
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.TABLE) && /*#__PURE__*/React__default.createElement(ToolbarTableButton, {
|
|
4341
4716
|
isDisabled: isDisabled || !canInsertBlocks
|
|
4342
4717
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
4343
|
-
className: styles$
|
|
4718
|
+
className: styles$l.embedActionsWrapper
|
|
4344
4719
|
}, /*#__PURE__*/React__default.createElement(EmbedEntityWidget, {
|
|
4345
4720
|
isDisabled: isDisabled,
|
|
4346
4721
|
canInsertBlocks: canInsertBlocks
|
|
@@ -4365,7 +4740,7 @@ function getValidationInfo(field) {
|
|
|
4365
4740
|
}
|
|
4366
4741
|
|
|
4367
4742
|
var _templateObject$5;
|
|
4368
|
-
var styles$
|
|
4743
|
+
var styles$m = {
|
|
4369
4744
|
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
4745
|
};
|
|
4371
4746
|
|
|
@@ -4373,15 +4748,158 @@ var StickyToolbarWrapper = function StickyToolbarWrapper(_ref) {
|
|
|
4373
4748
|
var isDisabled = _ref.isDisabled,
|
|
4374
4749
|
children = _ref.children;
|
|
4375
4750
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
4376
|
-
className: isDisabled ? '' : styles$
|
|
4751
|
+
className: isDisabled ? '' : styles$m.nativeSticky
|
|
4377
4752
|
}, children);
|
|
4378
4753
|
};
|
|
4379
4754
|
|
|
4755
|
+
var removeChildNodes = function removeChildNodes(node, predicate) {
|
|
4756
|
+
return Array.from(node.childNodes).filter(predicate).forEach(function (table) {
|
|
4757
|
+
return node.removeChild(table);
|
|
4758
|
+
});
|
|
4759
|
+
};
|
|
4760
|
+
|
|
4761
|
+
var removeChildNodesUsingPredicate = function removeChildNodesUsingPredicate(predicate) {
|
|
4762
|
+
return function (nodeList) {
|
|
4763
|
+
var nodes = Array.from(nodeList);
|
|
4764
|
+
|
|
4765
|
+
while (nodes.length > 0) {
|
|
4766
|
+
var node = nodes.pop();
|
|
4767
|
+
removeChildNodes(node, predicate);
|
|
4768
|
+
|
|
4769
|
+
for (var _i = 0, _Array$from = Array.from(node.childNodes); _i < _Array$from.length; _i++) {
|
|
4770
|
+
var childNode = _Array$from[_i];
|
|
4771
|
+
nodes.push(childNode);
|
|
4772
|
+
}
|
|
4773
|
+
}
|
|
4774
|
+
|
|
4775
|
+
return nodes;
|
|
4776
|
+
};
|
|
4777
|
+
};
|
|
4778
|
+
|
|
4779
|
+
var isComment = function isComment(node) {
|
|
4780
|
+
return node.nodeType === Node.COMMENT_NODE;
|
|
4781
|
+
};
|
|
4782
|
+
|
|
4783
|
+
var removeCommentChildren = /*#__PURE__*/removeChildNodesUsingPredicate(isComment);
|
|
4784
|
+
var removeComments = function removeComments(_ref) {
|
|
4785
|
+
var doc = _ref[0],
|
|
4786
|
+
editor = _ref[1];
|
|
4787
|
+
removeCommentChildren(doc.childNodes);
|
|
4788
|
+
return [doc, editor];
|
|
4789
|
+
};
|
|
4790
|
+
|
|
4791
|
+
var TAG_NAME_TABLE = 'TABLE';
|
|
4792
|
+
var TAG_NAME_TABLE_CAPTION = 'CAPTION';
|
|
4793
|
+
var DISALLOWED_TABLE_CHILD_ELEMENTS = [TAG_NAME_TABLE_CAPTION];
|
|
4794
|
+
|
|
4795
|
+
var isHTMLElement = function isHTMLElement(node) {
|
|
4796
|
+
return node.nodeType === Node.ELEMENT_NODE;
|
|
4797
|
+
};
|
|
4798
|
+
|
|
4799
|
+
var isTableElement = function isTableElement(node) {
|
|
4800
|
+
return isHTMLElement(node) && node.tagName === TAG_NAME_TABLE;
|
|
4801
|
+
};
|
|
4802
|
+
|
|
4803
|
+
var isDisallowedTableChildElement = function isDisallowedTableChildElement(node) {
|
|
4804
|
+
return isHTMLElement(node) && DISALLOWED_TABLE_CHILD_ELEMENTS.includes(node.tagName);
|
|
4805
|
+
};
|
|
4806
|
+
|
|
4807
|
+
var removeDisallowedTableChildElements = /*#__PURE__*/removeChildNodesUsingPredicate(isDisallowedTableChildElement);
|
|
4808
|
+
|
|
4809
|
+
var removeTableGrandchildren = function removeTableGrandchildren(nodeList) {
|
|
4810
|
+
var nodes = Array.from(nodeList);
|
|
4811
|
+
|
|
4812
|
+
while (nodes.length > 0) {
|
|
4813
|
+
var node = nodes.pop();
|
|
4814
|
+
|
|
4815
|
+
if (isTableElement(node)) {
|
|
4816
|
+
removeDisallowedTableChildElements(node.childNodes);
|
|
4817
|
+
continue;
|
|
4818
|
+
}
|
|
4819
|
+
|
|
4820
|
+
for (var _i = 0, _Array$from = Array.from(node.childNodes); _i < _Array$from.length; _i++) {
|
|
4821
|
+
var childNode = _Array$from[_i];
|
|
4822
|
+
nodes.push(childNode);
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4825
|
+
|
|
4826
|
+
return nodes;
|
|
4827
|
+
};
|
|
4828
|
+
|
|
4829
|
+
var sanitizeTables = function sanitizeTables(_ref) {
|
|
4830
|
+
var doc = _ref[0],
|
|
4831
|
+
editor = _ref[1];
|
|
4832
|
+
|
|
4833
|
+
var _getNodeEntryFromSele = getNodeEntryFromSelection(editor, Contentful.BLOCKS.TABLE),
|
|
4834
|
+
node = _getNodeEntryFromSele[0];
|
|
4835
|
+
|
|
4836
|
+
var isTableInCurrentSelection = !!node;
|
|
4837
|
+
|
|
4838
|
+
if (isTableInCurrentSelection) {
|
|
4839
|
+
removeDisallowedTableChildElements(doc.childNodes);
|
|
4840
|
+
} else {
|
|
4841
|
+
removeTableGrandchildren(doc.childNodes);
|
|
4842
|
+
}
|
|
4843
|
+
|
|
4844
|
+
return [doc, editor];
|
|
4845
|
+
};
|
|
4846
|
+
|
|
4847
|
+
|
|
4848
|
+
|
|
4849
|
+
var sanitizers = {
|
|
4850
|
+
__proto__: null,
|
|
4851
|
+
removeComments: removeComments,
|
|
4852
|
+
sanitizeTables: sanitizeTables
|
|
4853
|
+
};
|
|
4854
|
+
|
|
4855
|
+
var MIME_TYPE_HTML = 'text/html'; // TODO: Upgrade tslib so we can just flow(...sanitizers);
|
|
4856
|
+
|
|
4857
|
+
var sanitizeDocument = /*#__PURE__*/flow.apply(undefined, /*#__PURE__*/Object.values(sanitizers));
|
|
4858
|
+
|
|
4859
|
+
var sanitizeHtml = function sanitizeHtml(html, editor) {
|
|
4860
|
+
var doc = new DOMParser().parseFromString(html, MIME_TYPE_HTML);
|
|
4861
|
+
|
|
4862
|
+
var _sanitizeDocument = sanitizeDocument([doc, editor]),
|
|
4863
|
+
sanitizedDoc = _sanitizeDocument[0];
|
|
4864
|
+
|
|
4865
|
+
var sanitizedData = new XMLSerializer().serializeToString(sanitizedDoc);
|
|
4866
|
+
return sanitizedData;
|
|
4867
|
+
};
|
|
4868
|
+
|
|
4869
|
+
var htmlToDataTransfer = function htmlToDataTransfer(html) {
|
|
4870
|
+
var data = new DataTransfer();
|
|
4871
|
+
data.setData(MIME_TYPE_HTML, html);
|
|
4872
|
+
return data;
|
|
4873
|
+
};
|
|
4874
|
+
|
|
4875
|
+
function withPasteHandling(editor) {
|
|
4876
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4877
|
+
return function (_event) {
|
|
4878
|
+
var insertData = editor.insertData;
|
|
4879
|
+
|
|
4880
|
+
editor.insertData = function (data) {
|
|
4881
|
+
var html = data.getData(MIME_TYPE_HTML);
|
|
4882
|
+
|
|
4883
|
+
if (html) {
|
|
4884
|
+
var sanitized = sanitizeHtml(html, editor);
|
|
4885
|
+
var newData = htmlToDataTransfer(sanitized);
|
|
4886
|
+
insertData(newData);
|
|
4887
|
+
}
|
|
4888
|
+
};
|
|
4889
|
+
};
|
|
4890
|
+
}
|
|
4891
|
+
|
|
4892
|
+
var createPastePlugin = function createPastePlugin() {
|
|
4893
|
+
return {
|
|
4894
|
+
onKeyDown: withPasteHandling
|
|
4895
|
+
};
|
|
4896
|
+
};
|
|
4897
|
+
|
|
4380
4898
|
var _templateObject$6, _styles$2, _withParagraphOptions;
|
|
4381
|
-
var styles$
|
|
4899
|
+
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
4900
|
function Paragraph(props) {
|
|
4383
4901
|
return /*#__PURE__*/React.createElement("div", Object.assign({}, props.attributes, {
|
|
4384
|
-
className: styles$
|
|
4902
|
+
className: styles$n[Contentful.BLOCKS.PARAGRAPH]
|
|
4385
4903
|
}), props.children);
|
|
4386
4904
|
}
|
|
4387
4905
|
function createParagraphPlugin() {
|
|
@@ -4397,9 +4915,8 @@ function createParagraphPlugin() {
|
|
|
4397
4915
|
type: Contentful.BLOCKS.PARAGRAPH,
|
|
4398
4916
|
deserialize: function deserialize(element) {
|
|
4399
4917
|
var isParagraphText = element.nodeName === 'P';
|
|
4400
|
-
var isDivText = element.nodeName === 'DIV' && !element.getAttribute('data-entity-type');
|
|
4401
4918
|
var isNotEmpty = element.textContent !== '';
|
|
4402
|
-
var isText =
|
|
4919
|
+
var isText = isParagraphText && isNotEmpty;
|
|
4403
4920
|
if (!isText) return;
|
|
4404
4921
|
return {
|
|
4405
4922
|
type: Contentful.BLOCKS.PARAGRAPH
|
|
@@ -4560,9 +5077,10 @@ var _excluded = ["sdk", "isInitiallyDisabled", "onAction"];
|
|
|
4560
5077
|
|
|
4561
5078
|
var getPlugins = function getPlugins(sdk, tracking) {
|
|
4562
5079
|
var plugins = [// Core
|
|
4563
|
-
plateCore.createReactPlugin(), plateCore.createHistoryPlugin(), //
|
|
5080
|
+
plateCore.createReactPlugin(), plateCore.createHistoryPlugin(), // Behavior
|
|
5081
|
+
createPastePlugin(), // Global shortcuts
|
|
4564
5082
|
createNewLinePlugin(), createInsertBeforeFirstVoidBlockPlugin(), // Block Elements
|
|
4565
|
-
createParagraphPlugin(),
|
|
5083
|
+
createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(tracking), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
|
|
4566
5084
|
createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
|
|
4567
5085
|
createBoldPlugin(), createCodePlugin(), createItalicPlugin(), createUnderlinePlugin(), // Other
|
|
4568
5086
|
createTrailingParagraphPlugin()];
|
|
@@ -4633,8 +5151,6 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
4633
5151
|
sdk: sdk
|
|
4634
5152
|
}, /*#__PURE__*/React__default.createElement(SdkProvider, {
|
|
4635
5153
|
sdk: sdk
|
|
4636
|
-
}, /*#__PURE__*/React__default.createElement(ContentfulEditorProvider, {
|
|
4637
|
-
sdk: sdk
|
|
4638
5154
|
}, /*#__PURE__*/React__default.createElement(TrackingProvider, {
|
|
4639
5155
|
onAction: onAction || noop
|
|
4640
5156
|
}, /*#__PURE__*/React__default.createElement(fieldEditorShared.FieldConnector, {
|
|
@@ -4648,15 +5164,17 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
4648
5164
|
disabled = _ref.disabled,
|
|
4649
5165
|
setValue = _ref.setValue,
|
|
4650
5166
|
externalReset = _ref.externalReset;
|
|
4651
|
-
return /*#__PURE__*/React__default.createElement(
|
|
5167
|
+
return /*#__PURE__*/React__default.createElement(ContentfulEditorProvider, {
|
|
5168
|
+
sdk: sdk
|
|
5169
|
+
}, /*#__PURE__*/React__default.createElement(ConnectedRichTextEditor, Object.assign({}, otherProps, {
|
|
4652
5170
|
key: "rich-text-editor-" + externalReset,
|
|
4653
5171
|
value: lastRemoteValue,
|
|
4654
5172
|
sdk: sdk,
|
|
4655
5173
|
onAction: onAction || noop,
|
|
4656
5174
|
isDisabled: disabled,
|
|
4657
5175
|
onChange: setValue
|
|
4658
|
-
}));
|
|
4659
|
-
}))))
|
|
5176
|
+
})));
|
|
5177
|
+
}))));
|
|
4660
5178
|
};
|
|
4661
5179
|
|
|
4662
5180
|
var LINK_TYPES$1 = {
|