@contentful/field-editor-rich-text 2.0.0-next.2 → 2.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/field-editor-rich-text.cjs.development.js +133 -116
- 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 +23 -6
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/deserializer.d.ts +1 -1
- package/dist/helpers/editor.d.ts +1 -1
- package/dist/plugins/Bold/index.d.ts +1 -1
- package/dist/plugins/Code/index.d.ts +1 -1
- package/dist/plugins/DragAndDrop/index.d.ts +1 -1
- package/dist/plugins/EmbeddedEntityBlock/index.d.ts +1 -1
- package/dist/plugins/EmbeddedEntityInline/index.d.ts +1 -1
- package/dist/plugins/Heading/index.d.ts +1 -1
- package/dist/plugins/Hr/index.d.ts +1 -1
- package/dist/plugins/Hyperlink/HyperlinkModal.d.ts +1 -1
- package/dist/plugins/Hyperlink/index.d.ts +1 -1
- package/dist/plugins/InsertBeforeFirstVoidBlock/index.d.ts +1 -1
- package/dist/plugins/Italic/index.d.ts +1 -1
- package/dist/plugins/List/getListInsertFragment.d.ts +1 -1
- package/dist/plugins/List/index.d.ts +1 -1
- package/dist/plugins/NewLine/index.d.ts +1 -1
- package/dist/plugins/Paragraph/index.d.ts +1 -1
- package/dist/plugins/Paste/index.d.ts +1 -1
- package/dist/plugins/Paste/sanitizers/helpers.d.ts +1 -1
- package/dist/plugins/Quote/index.d.ts +1 -1
- package/dist/plugins/Table/actions/addColumn.d.ts +2 -1
- package/dist/plugins/Table/actions/addRow.d.ts +1 -1
- package/dist/plugins/Table/actions/setHeader.d.ts +1 -1
- package/dist/plugins/Table/helpers.d.ts +1 -1
- package/dist/plugins/Table/index.d.ts +168 -168
- package/dist/plugins/Table/normalizers.d.ts +1 -1
- package/dist/plugins/Text/index.d.ts +1 -1
- package/dist/plugins/TrailingParagraph/index.d.ts +1 -1
- package/dist/plugins/Underline/index.d.ts +1 -1
- package/dist/plugins/index.d.ts +171 -171
- package/dist/test-utils/createEditor.d.ts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +14 -5
|
@@ -17,14 +17,22 @@ var f36Components = require('@contentful/f36-components');
|
|
|
17
17
|
var Slate = require('slate-react');
|
|
18
18
|
var f36Icons = require('@contentful/f36-icons');
|
|
19
19
|
var slate = require('slate');
|
|
20
|
-
var
|
|
20
|
+
var plateCore = require('@udecode/plate-core');
|
|
21
|
+
var plateCommon = require('@udecode/plate-common');
|
|
21
22
|
var constate = _interopDefault(require('constate'));
|
|
22
23
|
var find = _interopDefault(require('lodash/find'));
|
|
23
24
|
var flow = _interopDefault(require('lodash/flow'));
|
|
24
25
|
var get = _interopDefault(require('lodash/get'));
|
|
26
|
+
var plateList = require('@udecode/plate-list');
|
|
25
27
|
var fieldEditorShared = require('@contentful/field-editor-shared');
|
|
26
28
|
var mimetype = _interopDefault(require('@contentful/mimetype'));
|
|
29
|
+
var plateTable = require('@udecode/plate-table');
|
|
27
30
|
var values = _interopDefault(require('lodash/values'));
|
|
31
|
+
var plateHtmlSerializer = require('@udecode/plate-html-serializer');
|
|
32
|
+
var plateAstSerializer = require('@udecode/plate-ast-serializer');
|
|
33
|
+
var plateParagraph = require('@udecode/plate-paragraph');
|
|
34
|
+
var plateBreak = require('@udecode/plate-break');
|
|
35
|
+
var plateTrailingBlock = require('@udecode/plate-trailing-block');
|
|
28
36
|
var PropTypes = _interopDefault(require('prop-types'));
|
|
29
37
|
|
|
30
38
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -560,7 +568,7 @@ function unwrapFromRoot(editor) {
|
|
|
560
568
|
var isAtEndOfTextSelection = function isAtEndOfTextSelection(editor) {
|
|
561
569
|
var _editor$selection, _editor$selection2;
|
|
562
570
|
|
|
563
|
-
return ((_editor$selection = editor.selection) == null ? void 0 : _editor$selection.focus.offset) ===
|
|
571
|
+
return ((_editor$selection = editor.selection) == null ? void 0 : _editor$selection.focus.offset) === plateCommon.getText(editor, (_editor$selection2 = editor.selection) == null ? void 0 : _editor$selection2.focus.path).length;
|
|
564
572
|
};
|
|
565
573
|
function currentSelectionStartsTableCell(editor) {
|
|
566
574
|
var _editor$selection3;
|
|
@@ -569,7 +577,7 @@ function currentSelectionStartsTableCell(editor) {
|
|
|
569
577
|
tableCellNode = _getNodeEntryFromSele2[0],
|
|
570
578
|
path = _getNodeEntryFromSele2[1];
|
|
571
579
|
|
|
572
|
-
return !!tableCellNode && (!
|
|
580
|
+
return !!tableCellNode && (!plateCommon.getText(editor, path) || ((_editor$selection3 = editor.selection) == null ? void 0 : _editor$selection3.focus.offset) === 0);
|
|
573
581
|
}
|
|
574
582
|
/**
|
|
575
583
|
* This traversal strategy is unfortunately necessary because Slate doesn't
|
|
@@ -638,9 +646,9 @@ function extractParagraphsAt(editor, path) {
|
|
|
638
646
|
|
|
639
647
|
function deserializeLeaf(type, rules) {
|
|
640
648
|
return function (editor) {
|
|
641
|
-
var pluginOptions =
|
|
649
|
+
var pluginOptions = plateCore.getPlatePluginOptions(editor, type);
|
|
642
650
|
return {
|
|
643
|
-
leaf:
|
|
651
|
+
leaf: plateCommon.getLeafDeserializer(_extends({
|
|
644
652
|
type: type,
|
|
645
653
|
rules: rules
|
|
646
654
|
}, pluginOptions.deserialize))
|
|
@@ -649,9 +657,9 @@ function deserializeLeaf(type, rules) {
|
|
|
649
657
|
}
|
|
650
658
|
function deserializeElement(type, rules) {
|
|
651
659
|
return function (editor) {
|
|
652
|
-
var pluginOptions =
|
|
660
|
+
var pluginOptions = plateCore.getPlatePluginOptions(editor, type);
|
|
653
661
|
return {
|
|
654
|
-
element:
|
|
662
|
+
element: plateCommon.getElementDeserializer(_extends({
|
|
655
663
|
type: type,
|
|
656
664
|
rules: rules
|
|
657
665
|
}, pluginOptions.deserialize))
|
|
@@ -669,7 +677,7 @@ function getContentfulEditorId(sdk) {
|
|
|
669
677
|
function useContentfulEditorHook(_ref) {
|
|
670
678
|
var sdk = _ref.sdk;
|
|
671
679
|
var editorId = getContentfulEditorId(sdk);
|
|
672
|
-
var editor =
|
|
680
|
+
var editor = plateCore.usePlateEditorRef(editorId);
|
|
673
681
|
return editor;
|
|
674
682
|
}
|
|
675
683
|
|
|
@@ -726,8 +734,8 @@ function ToolbarHrButton(props) {
|
|
|
726
734
|
}],
|
|
727
735
|
isVoid: true
|
|
728
736
|
};
|
|
729
|
-
var hasText = !!
|
|
730
|
-
hasText ? slate.Transforms.insertNodes(editor, hr) :
|
|
737
|
+
var hasText = !!plateCommon.getText(editor, editor.selection.focus.path);
|
|
738
|
+
hasText ? slate.Transforms.insertNodes(editor, hr) : plateCommon.setNodes(editor, hr); // Move focus to the next paragraph (added by TrailingParagraph plugin)
|
|
731
739
|
|
|
732
740
|
moveToTheNextLine(editor);
|
|
733
741
|
Slate.ReactEditor.focus(editor);
|
|
@@ -755,10 +763,10 @@ function Hr(props) {
|
|
|
755
763
|
}
|
|
756
764
|
function createHrPlugin() {
|
|
757
765
|
return {
|
|
758
|
-
renderElement:
|
|
766
|
+
renderElement: plateCore.getRenderElement(Contentful.BLOCKS.HR),
|
|
759
767
|
pluginKeys: Contentful.BLOCKS.HR,
|
|
760
768
|
onKeyDown: withHrEvents,
|
|
761
|
-
voidTypes:
|
|
769
|
+
voidTypes: plateCore.getPlatePluginTypes(Contentful.BLOCKS.HR),
|
|
762
770
|
deserialize: deserializeElement(Contentful.BLOCKS.HR, [{
|
|
763
771
|
nodeNames: ['HR']
|
|
764
772
|
}])
|
|
@@ -860,19 +868,19 @@ function withHeadingEvents(editor) {
|
|
|
860
868
|
var cursorIsAtTheEnd = currentTextLength === currentOffset;
|
|
861
869
|
|
|
862
870
|
if (cursorIsAtTheBeginning) {
|
|
863
|
-
|
|
871
|
+
plateCommon.insertNodes(editor, paragraph, {
|
|
864
872
|
at: editor.selection
|
|
865
873
|
});
|
|
866
874
|
} else if (cursorIsAtTheEnd) {
|
|
867
|
-
|
|
875
|
+
plateCommon.insertNodes(editor, paragraph);
|
|
868
876
|
} else {
|
|
869
877
|
// Otherwise the cursor is in the middle
|
|
870
878
|
slate.Transforms.splitNodes(editor);
|
|
871
|
-
|
|
879
|
+
plateCommon.setNodes(editor, paragraph);
|
|
872
880
|
}
|
|
873
881
|
} else {
|
|
874
|
-
|
|
875
|
-
|
|
882
|
+
plateCommon.setNodes(editor, paragraph);
|
|
883
|
+
plateCommon.insertNodes(editor, heading);
|
|
876
884
|
}
|
|
877
885
|
} // Toggle heading blocks when pressing cmd/ctrl+alt+1|2|3|4|5|6
|
|
878
886
|
|
|
@@ -896,7 +904,7 @@ function withHeadingEvents(editor) {
|
|
|
896
904
|
unwrapFromRoot(editor);
|
|
897
905
|
}
|
|
898
906
|
|
|
899
|
-
|
|
907
|
+
plateCommon.toggleNodeType(editor, {
|
|
900
908
|
activeType: headingKey,
|
|
901
909
|
inactiveType: Contentful.BLOCKS.PARAGRAPH
|
|
902
910
|
});
|
|
@@ -947,7 +955,7 @@ function ToolbarHeadingButton(props) {
|
|
|
947
955
|
unwrapFromRoot(editor);
|
|
948
956
|
}
|
|
949
957
|
|
|
950
|
-
|
|
958
|
+
plateCommon.toggleNodeType(editor, {
|
|
951
959
|
activeType: type,
|
|
952
960
|
inactiveType: type
|
|
953
961
|
}); // TODO: Figure out why focus only works with timeout here.
|
|
@@ -1002,13 +1010,13 @@ var H6 = /*#__PURE__*/createHeading('h6', Contentful.BLOCKS.HEADING_6);
|
|
|
1002
1010
|
function createHeadingPlugin() {
|
|
1003
1011
|
var headings = [Contentful.BLOCKS.HEADING_1, Contentful.BLOCKS.HEADING_2, Contentful.BLOCKS.HEADING_3, Contentful.BLOCKS.HEADING_4, Contentful.BLOCKS.HEADING_5, Contentful.BLOCKS.HEADING_6];
|
|
1004
1012
|
return {
|
|
1005
|
-
renderElement:
|
|
1013
|
+
renderElement: plateCore.getRenderElement(headings),
|
|
1006
1014
|
pluginKeys: headings,
|
|
1007
1015
|
onKeyDown: withHeadingEvents,
|
|
1008
1016
|
deserialize: function deserialize(editor) {
|
|
1009
1017
|
return {
|
|
1010
1018
|
element: headings.map(function (headingType, index) {
|
|
1011
|
-
var options =
|
|
1019
|
+
var options = plateCore.getPlatePluginOptions(editor, headingType);
|
|
1012
1020
|
return _extends({
|
|
1013
1021
|
type: headingType,
|
|
1014
1022
|
deserialize: function deserialize(element) {
|
|
@@ -1150,7 +1158,7 @@ function Quote(props) {
|
|
|
1150
1158
|
function createQuotePlugin() {
|
|
1151
1159
|
return {
|
|
1152
1160
|
pluginKeys: Contentful.BLOCKS.QUOTE,
|
|
1153
|
-
renderElement:
|
|
1161
|
+
renderElement: plateCore.getRenderElement(Contentful.BLOCKS.QUOTE),
|
|
1154
1162
|
onKeyDown: withQuoteEvents,
|
|
1155
1163
|
deserialize: deserializeElement(Contentful.BLOCKS.QUOTE, [{
|
|
1156
1164
|
nodeNames: 'BLOCKQUOTE'
|
|
@@ -1168,9 +1176,9 @@ var withQuoteOptions = (_withQuoteOptions = {}, _withQuoteOptions[Contentful.BLO
|
|
|
1168
1176
|
*/
|
|
1169
1177
|
var getListInsertFragment = function getListInsertFragment(editor) {
|
|
1170
1178
|
var insertFragment = editor.insertFragment;
|
|
1171
|
-
var li =
|
|
1172
|
-
var ul =
|
|
1173
|
-
var ol =
|
|
1179
|
+
var li = plateCore.getPlatePluginOptions(editor, plateList.ELEMENT_LI);
|
|
1180
|
+
var ul = plateCore.getPlatePluginOptions(editor, plateList.ELEMENT_UL);
|
|
1181
|
+
var ol = plateCore.getPlatePluginOptions(editor, plateList.ELEMENT_OL);
|
|
1174
1182
|
|
|
1175
1183
|
var isListRoot = function isListRoot(node) {
|
|
1176
1184
|
return [ul.type, ol.type].includes(node.type);
|
|
@@ -1207,7 +1215,7 @@ var getListInsertFragment = function getListInsertFragment(editor) {
|
|
|
1207
1215
|
};
|
|
1208
1216
|
|
|
1209
1217
|
return function (fragment) {
|
|
1210
|
-
var liEntry =
|
|
1218
|
+
var liEntry = plateCommon.findNode(editor, {
|
|
1211
1219
|
match: {
|
|
1212
1220
|
type: li.type
|
|
1213
1221
|
},
|
|
@@ -1247,7 +1255,7 @@ function ToolbarListButton(props) {
|
|
|
1247
1255
|
unwrapFromRoot(editor);
|
|
1248
1256
|
}
|
|
1249
1257
|
|
|
1250
|
-
|
|
1258
|
+
plateList.toggleList(editor, {
|
|
1251
1259
|
type: type
|
|
1252
1260
|
});
|
|
1253
1261
|
Slate.ReactEditor.focus(editor);
|
|
@@ -1281,15 +1289,15 @@ function createList(Tag, block) {
|
|
|
1281
1289
|
var UL = /*#__PURE__*/createList('ul', Contentful.BLOCKS.UL_LIST);
|
|
1282
1290
|
var OL = /*#__PURE__*/createList('ol', Contentful.BLOCKS.OL_LIST);
|
|
1283
1291
|
var LI = /*#__PURE__*/createList('li', Contentful.BLOCKS.LIST_ITEM);
|
|
1284
|
-
var withListOptions = (_withListOptions = {}, _withListOptions[
|
|
1292
|
+
var withListOptions = (_withListOptions = {}, _withListOptions[plateList.ELEMENT_LIC] = {
|
|
1285
1293
|
type: Contentful.BLOCKS.PARAGRAPH
|
|
1286
|
-
}, _withListOptions[
|
|
1294
|
+
}, _withListOptions[plateList.ELEMENT_LI] = {
|
|
1287
1295
|
type: Contentful.BLOCKS.LIST_ITEM,
|
|
1288
1296
|
component: LI
|
|
1289
|
-
}, _withListOptions[
|
|
1297
|
+
}, _withListOptions[plateList.ELEMENT_UL] = {
|
|
1290
1298
|
type: Contentful.BLOCKS.UL_LIST,
|
|
1291
1299
|
component: UL
|
|
1292
|
-
}, _withListOptions[
|
|
1300
|
+
}, _withListOptions[plateList.ELEMENT_OL] = {
|
|
1293
1301
|
type: Contentful.BLOCKS.OL_LIST,
|
|
1294
1302
|
component: OL
|
|
1295
1303
|
}, _withListOptions);
|
|
@@ -1311,7 +1319,7 @@ var isListItem = function isListItem(node) {
|
|
|
1311
1319
|
};
|
|
1312
1320
|
|
|
1313
1321
|
var hasListAsDirectParent = function hasListAsDirectParent(editor, path) {
|
|
1314
|
-
var _ref =
|
|
1322
|
+
var _ref = plateCommon.getParent(editor, path) || [],
|
|
1315
1323
|
parentNode = _ref[0];
|
|
1316
1324
|
|
|
1317
1325
|
return isList(parentNode);
|
|
@@ -1349,7 +1357,7 @@ var normalizeList = function normalizeList(editor, path) {
|
|
|
1349
1357
|
};
|
|
1350
1358
|
|
|
1351
1359
|
var getNearestListAncestor = function getNearestListAncestor(editor, path) {
|
|
1352
|
-
return
|
|
1360
|
+
return plateCommon.getAbove(editor, {
|
|
1353
1361
|
at: path,
|
|
1354
1362
|
mode: 'lowest',
|
|
1355
1363
|
match: isList
|
|
@@ -1377,7 +1385,7 @@ var normalizeOrphanedListItem = function normalizeOrphanedListItem(editor, path)
|
|
|
1377
1385
|
};
|
|
1378
1386
|
|
|
1379
1387
|
var withCustomList = function withCustomList(options) {
|
|
1380
|
-
var withDefaultOverrides =
|
|
1388
|
+
var withDefaultOverrides = plateList.withList(options);
|
|
1381
1389
|
return function (editor) {
|
|
1382
1390
|
var insertFragment = editor.insertFragment;
|
|
1383
1391
|
withDefaultOverrides(editor); // Reverts any overrides to insertFragment
|
|
@@ -1439,7 +1447,7 @@ var createListPlugin = function createListPlugin() {
|
|
|
1439
1447
|
var options = {
|
|
1440
1448
|
validLiChildrenTypes: Contentful.LIST_ITEM_BLOCKS
|
|
1441
1449
|
};
|
|
1442
|
-
var plugin =
|
|
1450
|
+
var plugin = plateList.createListPlugin(options);
|
|
1443
1451
|
plugin.withOverrides = withCustomList(options);
|
|
1444
1452
|
return plugin;
|
|
1445
1453
|
};
|
|
@@ -1450,7 +1458,7 @@ function ToolbarBoldButton(props) {
|
|
|
1450
1458
|
|
|
1451
1459
|
function handleClick() {
|
|
1452
1460
|
if (!(editor != null && editor.selection)) return;
|
|
1453
|
-
|
|
1461
|
+
plateCommon.toggleMark(editor, Contentful.MARKS.BOLD);
|
|
1454
1462
|
Slate.ReactEditor.focus(editor);
|
|
1455
1463
|
}
|
|
1456
1464
|
|
|
@@ -1459,7 +1467,7 @@ function ToolbarBoldButton(props) {
|
|
|
1459
1467
|
title: "Bold",
|
|
1460
1468
|
testId: "bold-toolbar-button",
|
|
1461
1469
|
onClick: handleClick,
|
|
1462
|
-
isActive:
|
|
1470
|
+
isActive: plateCommon.isMarkActive(editor, Contentful.MARKS.BOLD),
|
|
1463
1471
|
isDisabled: props.isDisabled
|
|
1464
1472
|
}, /*#__PURE__*/React.createElement(f36Icons.FormatBoldIcon, null));
|
|
1465
1473
|
}
|
|
@@ -1476,8 +1484,8 @@ function Bold(props) {
|
|
|
1476
1484
|
function createBoldPlugin() {
|
|
1477
1485
|
return {
|
|
1478
1486
|
pluginKeys: Contentful.MARKS.BOLD,
|
|
1479
|
-
renderLeaf:
|
|
1480
|
-
onKeyDown:
|
|
1487
|
+
renderLeaf: plateCore.getRenderLeaf(Contentful.MARKS.BOLD),
|
|
1488
|
+
onKeyDown: plateCommon.getToggleMarkOnKeyDown(Contentful.MARKS.BOLD),
|
|
1481
1489
|
deserialize: function deserialize() {
|
|
1482
1490
|
return {
|
|
1483
1491
|
leaf: [{
|
|
@@ -1508,7 +1516,7 @@ function ToolbarCodeButton(props) {
|
|
|
1508
1516
|
|
|
1509
1517
|
function handleClick() {
|
|
1510
1518
|
if (!(editor != null && editor.selection)) return;
|
|
1511
|
-
|
|
1519
|
+
plateCommon.toggleMark(editor, Contentful.MARKS.CODE);
|
|
1512
1520
|
Slate.ReactEditor.focus(editor);
|
|
1513
1521
|
}
|
|
1514
1522
|
|
|
@@ -1517,7 +1525,7 @@ function ToolbarCodeButton(props) {
|
|
|
1517
1525
|
title: "Code",
|
|
1518
1526
|
testId: "code-toolbar-button",
|
|
1519
1527
|
onClick: handleClick,
|
|
1520
|
-
isActive:
|
|
1528
|
+
isActive: plateCommon.isMarkActive(editor, Contentful.MARKS.CODE),
|
|
1521
1529
|
isDisabled: props.isDisabled
|
|
1522
1530
|
}, /*#__PURE__*/React.createElement(f36Icons.CodeIcon, null));
|
|
1523
1531
|
}
|
|
@@ -1542,8 +1550,8 @@ function createCodePlugin() {
|
|
|
1542
1550
|
}];
|
|
1543
1551
|
return {
|
|
1544
1552
|
pluginKeys: Contentful.MARKS.CODE,
|
|
1545
|
-
renderLeaf:
|
|
1546
|
-
onKeyDown:
|
|
1553
|
+
renderLeaf: plateCore.getRenderLeaf(Contentful.MARKS.CODE),
|
|
1554
|
+
onKeyDown: plateCommon.getToggleMarkOnKeyDown(Contentful.MARKS.CODE),
|
|
1547
1555
|
deserialize: deserializeLeaf(Contentful.MARKS.CODE, deserializeRule)
|
|
1548
1556
|
};
|
|
1549
1557
|
}
|
|
@@ -1559,7 +1567,7 @@ function ToolbarItalicButton(props) {
|
|
|
1559
1567
|
|
|
1560
1568
|
function handleClick() {
|
|
1561
1569
|
if (!(editor != null && editor.selection)) return;
|
|
1562
|
-
|
|
1570
|
+
plateCommon.toggleMark(editor, Contentful.MARKS.ITALIC);
|
|
1563
1571
|
Slate.ReactEditor.focus(editor);
|
|
1564
1572
|
}
|
|
1565
1573
|
|
|
@@ -1568,7 +1576,7 @@ function ToolbarItalicButton(props) {
|
|
|
1568
1576
|
title: "Italic",
|
|
1569
1577
|
testId: "italic-toolbar-button",
|
|
1570
1578
|
onClick: handleClick,
|
|
1571
|
-
isActive:
|
|
1579
|
+
isActive: plateCommon.isMarkActive(editor, Contentful.MARKS.ITALIC),
|
|
1572
1580
|
isDisabled: props.isDisabled
|
|
1573
1581
|
}, /*#__PURE__*/React.createElement(f36Icons.FormatItalicIcon, null));
|
|
1574
1582
|
}
|
|
@@ -1592,8 +1600,8 @@ function createItalicPlugin() {
|
|
|
1592
1600
|
}];
|
|
1593
1601
|
return {
|
|
1594
1602
|
pluginKeys: Contentful.MARKS.ITALIC,
|
|
1595
|
-
renderLeaf:
|
|
1596
|
-
onKeyDown:
|
|
1603
|
+
renderLeaf: plateCore.getRenderLeaf(Contentful.MARKS.ITALIC),
|
|
1604
|
+
onKeyDown: plateCommon.getToggleMarkOnKeyDown(Contentful.MARKS.ITALIC),
|
|
1597
1605
|
deserialize: deserializeLeaf(Contentful.MARKS.ITALIC, deserializeRules)
|
|
1598
1606
|
};
|
|
1599
1607
|
}
|
|
@@ -1609,7 +1617,7 @@ function ToolbarUnderlineButton(props) {
|
|
|
1609
1617
|
|
|
1610
1618
|
function handleClick() {
|
|
1611
1619
|
if (!(editor != null && editor.selection)) return;
|
|
1612
|
-
|
|
1620
|
+
plateCommon.toggleMark(editor, Contentful.MARKS.UNDERLINE);
|
|
1613
1621
|
Slate.ReactEditor.focus(editor);
|
|
1614
1622
|
}
|
|
1615
1623
|
|
|
@@ -1618,7 +1626,7 @@ function ToolbarUnderlineButton(props) {
|
|
|
1618
1626
|
title: "Underline",
|
|
1619
1627
|
testId: "underline-toolbar-button",
|
|
1620
1628
|
onClick: handleClick,
|
|
1621
|
-
isActive:
|
|
1629
|
+
isActive: plateCommon.isMarkActive(editor, Contentful.MARKS.UNDERLINE),
|
|
1622
1630
|
isDisabled: props.isDisabled
|
|
1623
1631
|
}, /*#__PURE__*/React.createElement(f36Icons.FormatUnderlinedIcon, null));
|
|
1624
1632
|
}
|
|
@@ -1635,8 +1643,8 @@ function createUnderlinePlugin() {
|
|
|
1635
1643
|
}];
|
|
1636
1644
|
return {
|
|
1637
1645
|
pluginKeys: Contentful.MARKS.UNDERLINE,
|
|
1638
|
-
renderLeaf:
|
|
1639
|
-
onKeyDown:
|
|
1646
|
+
renderLeaf: plateCore.getRenderLeaf(Contentful.MARKS.UNDERLINE),
|
|
1647
|
+
onKeyDown: plateCommon.getToggleMarkOnKeyDown(Contentful.MARKS.UNDERLINE),
|
|
1640
1648
|
deserialize: deserializeLeaf(Contentful.MARKS.UNDERLINE, deserializeRules)
|
|
1641
1649
|
};
|
|
1642
1650
|
}
|
|
@@ -2568,7 +2576,8 @@ function EntryThumbnail(_ref) {
|
|
|
2568
2576
|
function FetchingWrappedEntryCard(props) {
|
|
2569
2577
|
var _useEntities = fieldEditorReference.useEntities(),
|
|
2570
2578
|
getOrLoadEntry = _useEntities.getOrLoadEntry,
|
|
2571
|
-
entries = _useEntities.entries
|
|
2579
|
+
entries = _useEntities.entries,
|
|
2580
|
+
getOrLoadAsset = _useEntities.getOrLoadAsset;
|
|
2572
2581
|
|
|
2573
2582
|
var _React$useState = React.useState(null),
|
|
2574
2583
|
file = _React$useState[0],
|
|
@@ -2592,10 +2601,10 @@ function FetchingWrappedEntryCard(props) {
|
|
|
2592
2601
|
contentType: contentType,
|
|
2593
2602
|
localeCode: props.locale,
|
|
2594
2603
|
defaultLocaleCode: defaultLocaleCode
|
|
2595
|
-
},
|
|
2604
|
+
}, getOrLoadAsset).then(setFile)["catch"](function () {
|
|
2596
2605
|
return setFile(null);
|
|
2597
2606
|
});
|
|
2598
|
-
}, [entry, contentType, props.locale, defaultLocaleCode, props.sdk, file]);
|
|
2607
|
+
}, [entry, contentType, props.locale, defaultLocaleCode, props.sdk, file, getOrLoadAsset]);
|
|
2599
2608
|
React.useEffect(function () {
|
|
2600
2609
|
getOrLoadEntry(props.entryId);
|
|
2601
2610
|
}, [props.entryId]); // eslint-disable-line
|
|
@@ -3230,14 +3239,14 @@ var styles$d = {
|
|
|
3230
3239
|
};
|
|
3231
3240
|
function createHyperlinkPlugin(sdk) {
|
|
3232
3241
|
return {
|
|
3233
|
-
renderElement:
|
|
3242
|
+
renderElement: plateCore.getRenderElement(LINK_TYPES),
|
|
3234
3243
|
pluginKeys: LINK_TYPES,
|
|
3235
|
-
inlineTypes:
|
|
3244
|
+
inlineTypes: plateCore.getPlatePluginTypes(LINK_TYPES),
|
|
3236
3245
|
onKeyDown: buildHyperlinkEventHandler(sdk),
|
|
3237
3246
|
deserialize: function deserialize(editor) {
|
|
3238
|
-
var hyperlinkOptions =
|
|
3239
|
-
var entryHyperlinkOptions =
|
|
3240
|
-
var assetHyperlinkOptions =
|
|
3247
|
+
var hyperlinkOptions = plateCore.getPlatePluginOptions(editor, Contentful.INLINES.HYPERLINK);
|
|
3248
|
+
var entryHyperlinkOptions = plateCore.getPlatePluginOptions(editor, Contentful.INLINES.ENTRY_HYPERLINK);
|
|
3249
|
+
var assetHyperlinkOptions = plateCore.getPlatePluginOptions(editor, Contentful.INLINES.ASSET_HYPERLINK);
|
|
3241
3250
|
|
|
3242
3251
|
var isAnchor = function isAnchor(element) {
|
|
3243
3252
|
return element.nodeName === 'A' && !!element.getAttribute('href') && element.getAttribute('href') !== '#';
|
|
@@ -3523,20 +3532,20 @@ function moveToFirstCellFromSelectedTable(editor) {
|
|
|
3523
3532
|
function insertTableAndFocusFirstCell(editor) {
|
|
3524
3533
|
// FIXME: a table should only be allowed at root level. Currently this
|
|
3525
3534
|
// code adds it at any level
|
|
3526
|
-
|
|
3535
|
+
plateTable.insertTable(editor, {
|
|
3527
3536
|
header: true
|
|
3528
3537
|
});
|
|
3529
3538
|
moveToFirstCellFromSelectedTable(editor);
|
|
3530
3539
|
replaceEmptyParagraphWithTable(editor);
|
|
3531
3540
|
}
|
|
3532
3541
|
function isTableActive(editor) {
|
|
3533
|
-
var tableElements = [
|
|
3542
|
+
var tableElements = [plateTable.ELEMENT_TABLE, plateTable.ELEMENT_TH, plateTable.ELEMENT_TR, plateTable.ELEMENT_TD];
|
|
3534
3543
|
return tableElements.some(function (el) {
|
|
3535
3544
|
return isBlockSelected(editor, el);
|
|
3536
3545
|
});
|
|
3537
3546
|
}
|
|
3538
3547
|
function isTableHeaderEnabled(editor) {
|
|
3539
|
-
var tableItem =
|
|
3548
|
+
var tableItem = plateCommon.getAbove(editor, {
|
|
3540
3549
|
match: {
|
|
3541
3550
|
type: Contentful.BLOCKS.TABLE
|
|
3542
3551
|
}
|
|
@@ -3546,20 +3555,20 @@ function isTableHeaderEnabled(editor) {
|
|
|
3546
3555
|
return false;
|
|
3547
3556
|
}
|
|
3548
3557
|
|
|
3549
|
-
var firstRow =
|
|
3558
|
+
var firstRow = plateCommon.getChildren(tableItem)[0];
|
|
3550
3559
|
|
|
3551
3560
|
if (!firstRow) {
|
|
3552
3561
|
return false;
|
|
3553
3562
|
}
|
|
3554
3563
|
|
|
3555
|
-
return
|
|
3564
|
+
return plateCommon.getChildren(firstRow).every(function (_ref) {
|
|
3556
3565
|
var node = _ref[0];
|
|
3557
3566
|
return node.type === Contentful.BLOCKS.TABLE_HEADER_CELL;
|
|
3558
3567
|
});
|
|
3559
3568
|
}
|
|
3560
3569
|
function replaceEmptyParagraphWithTable(editor) {
|
|
3561
3570
|
var tablePath = getAncestorPathFromSelection(editor);
|
|
3562
|
-
if (!tablePath ||
|
|
3571
|
+
if (!tablePath || plateCommon.isFirstChild(tablePath)) return;
|
|
3563
3572
|
var previousPath = slate.Path.previous(tablePath);
|
|
3564
3573
|
if (!previousPath) return;
|
|
3565
3574
|
|
|
@@ -3573,7 +3582,7 @@ function replaceEmptyParagraphWithTable(editor) {
|
|
|
3573
3582
|
|
|
3574
3583
|
if (!nodes) return;
|
|
3575
3584
|
var previousNode = nodes[0];
|
|
3576
|
-
var isPreviousNodeTextEmpty =
|
|
3585
|
+
var isPreviousNodeTextEmpty = plateCommon.isAncestorEmpty(editor, previousNode);
|
|
3577
3586
|
|
|
3578
3587
|
if (isPreviousNodeTextEmpty) {
|
|
3579
3588
|
// Switch table with previous empty paragraph
|
|
@@ -3612,14 +3621,14 @@ var _constate$2 = /*#__PURE__*/constate(useTracking),
|
|
|
3612
3621
|
useTrackingContext = _constate$2[1];
|
|
3613
3622
|
|
|
3614
3623
|
var addRow = function addRow(editor, getNextRowPath) {
|
|
3615
|
-
if (
|
|
3624
|
+
if (plateCommon.someNode(editor, {
|
|
3616
3625
|
match: {
|
|
3617
|
-
type:
|
|
3626
|
+
type: plateCore.getPlatePluginType(editor, plateTable.ELEMENT_TABLE)
|
|
3618
3627
|
}
|
|
3619
3628
|
})) {
|
|
3620
|
-
var currentRowItem =
|
|
3629
|
+
var currentRowItem = plateCommon.getAbove(editor, {
|
|
3621
3630
|
match: {
|
|
3622
|
-
type:
|
|
3631
|
+
type: plateCore.getPlatePluginType(editor, plateTable.ELEMENT_TR)
|
|
3623
3632
|
}
|
|
3624
3633
|
});
|
|
3625
3634
|
|
|
@@ -3627,8 +3636,8 @@ var addRow = function addRow(editor, getNextRowPath) {
|
|
|
3627
3636
|
var currentRowElem = currentRowItem[0],
|
|
3628
3637
|
currentRowPath = currentRowItem[1];
|
|
3629
3638
|
var nextRowPath = getNextRowPath(currentRowPath);
|
|
3630
|
-
|
|
3631
|
-
|
|
3639
|
+
plateCommon.insertNodes(editor, // @ts-expect-error
|
|
3640
|
+
plateTable.getEmptyRowNode(editor, {
|
|
3632
3641
|
header: false,
|
|
3633
3642
|
colCount: currentRowElem.children.length
|
|
3634
3643
|
}), {
|
|
@@ -3657,19 +3666,19 @@ var addRowAbove = function addRowAbove(editor) {
|
|
|
3657
3666
|
var addColumn = function addColumn(editor, _ref, getNextCellPath) {
|
|
3658
3667
|
var header = _ref.header;
|
|
3659
3668
|
|
|
3660
|
-
if (
|
|
3669
|
+
if (plateCommon.someNode(editor, {
|
|
3661
3670
|
match: {
|
|
3662
|
-
type:
|
|
3671
|
+
type: plateCore.getPlatePluginType(editor, plateTable.ELEMENT_TABLE)
|
|
3663
3672
|
}
|
|
3664
3673
|
})) {
|
|
3665
|
-
var currentCellItem =
|
|
3674
|
+
var currentCellItem = plateCommon.getAbove(editor, {
|
|
3666
3675
|
match: {
|
|
3667
|
-
type: [
|
|
3676
|
+
type: [plateCore.getPlatePluginType(editor, plateTable.ELEMENT_TD), plateCore.getPlatePluginType(editor, plateTable.ELEMENT_TH)]
|
|
3668
3677
|
}
|
|
3669
3678
|
});
|
|
3670
|
-
var currentTableItem =
|
|
3679
|
+
var currentTableItem = plateCommon.getAbove(editor, {
|
|
3671
3680
|
match: {
|
|
3672
|
-
type:
|
|
3681
|
+
type: plateCore.getPlatePluginType(editor, plateTable.ELEMENT_TABLE)
|
|
3673
3682
|
}
|
|
3674
3683
|
});
|
|
3675
3684
|
|
|
@@ -3679,8 +3688,8 @@ var addColumn = function addColumn(editor, _ref, getNextCellPath) {
|
|
|
3679
3688
|
var replacePathPos = newCellPath.length - 2;
|
|
3680
3689
|
currentTableItem[0].children.forEach(function (_, rowIdx) {
|
|
3681
3690
|
newCellPath[replacePathPos] = rowIdx;
|
|
3682
|
-
|
|
3683
|
-
|
|
3691
|
+
plateCommon.insertNodes(editor, // @ts-expect-error
|
|
3692
|
+
plateTable.getEmptyCellNode(editor, {
|
|
3684
3693
|
header: header && rowIdx === 0
|
|
3685
3694
|
}), {
|
|
3686
3695
|
at: newCellPath,
|
|
@@ -3704,7 +3713,7 @@ var addColumnLeft = function addColumnLeft(editor, options) {
|
|
|
3704
3713
|
};
|
|
3705
3714
|
|
|
3706
3715
|
var setHeader = function setHeader(editor, enable) {
|
|
3707
|
-
var tableItem =
|
|
3716
|
+
var tableItem = plateCommon.getAbove(editor, {
|
|
3708
3717
|
match: {
|
|
3709
3718
|
type: Contentful.BLOCKS.TABLE
|
|
3710
3719
|
}
|
|
@@ -3714,15 +3723,15 @@ var setHeader = function setHeader(editor, enable) {
|
|
|
3714
3723
|
return;
|
|
3715
3724
|
}
|
|
3716
3725
|
|
|
3717
|
-
var firstRow =
|
|
3726
|
+
var firstRow = plateCommon.getChildren(tableItem)[0];
|
|
3718
3727
|
|
|
3719
3728
|
if (!firstRow) {
|
|
3720
3729
|
return;
|
|
3721
3730
|
}
|
|
3722
3731
|
|
|
3723
|
-
|
|
3732
|
+
plateCommon.getChildren(firstRow).forEach(function (_ref) {
|
|
3724
3733
|
var path = _ref[1];
|
|
3725
|
-
|
|
3734
|
+
plateCommon.setNodes(editor, {
|
|
3726
3735
|
type: enable ? Contentful.BLOCKS.TABLE_HEADER_CELL : Contentful.BLOCKS.TABLE_CELL
|
|
3727
3736
|
}, {
|
|
3728
3737
|
at: path
|
|
@@ -3774,7 +3783,7 @@ var TableActions = function TableActions() {
|
|
|
3774
3783
|
return false;
|
|
3775
3784
|
}
|
|
3776
3785
|
|
|
3777
|
-
var headerCell =
|
|
3786
|
+
var headerCell = plateCommon.getAbove(editor, {
|
|
3778
3787
|
match: {
|
|
3779
3788
|
type: Contentful.BLOCKS.TABLE_HEADER_CELL
|
|
3780
3789
|
}
|
|
@@ -3834,11 +3843,11 @@ var TableActions = function TableActions() {
|
|
|
3834
3843
|
}, "Add column right"), /*#__PURE__*/React__default.createElement(f36Components.Menu.Divider, null), /*#__PURE__*/React__default.createElement(f36Components.Menu.Item, {
|
|
3835
3844
|
onClick: toggleHeader
|
|
3836
3845
|
}, isHeaderEnabled ? 'Disable table header' : 'Enable table header'), /*#__PURE__*/React__default.createElement(f36Components.Menu.Divider, null), /*#__PURE__*/React__default.createElement(f36Components.Menu.Item, {
|
|
3837
|
-
onClick: action(
|
|
3846
|
+
onClick: action(plateTable.deleteRow, 'remove', 'Row')
|
|
3838
3847
|
}, "Delete row"), /*#__PURE__*/React__default.createElement(f36Components.Menu.Item, {
|
|
3839
|
-
onClick: action(
|
|
3848
|
+
onClick: action(plateTable.deleteColumn, 'remove', 'Column')
|
|
3840
3849
|
}, "Delete column"), /*#__PURE__*/React__default.createElement(f36Components.Menu.Item, {
|
|
3841
|
-
onClick: action(
|
|
3850
|
+
onClick: action(plateTable.deleteTable, 'remove', 'Table')
|
|
3842
3851
|
}, "Delete table")));
|
|
3843
3852
|
};
|
|
3844
3853
|
|
|
@@ -3975,16 +3984,16 @@ var TD = function TD(props) {
|
|
|
3975
3984
|
className: styles$f[Contentful.BLOCKS.TABLE_CELL]
|
|
3976
3985
|
}), isSelected && /*#__PURE__*/React.createElement(TableActions, null), props.children);
|
|
3977
3986
|
};
|
|
3978
|
-
var withTableOptions = (_withTableOptions = {}, _withTableOptions[
|
|
3987
|
+
var withTableOptions = (_withTableOptions = {}, _withTableOptions[plateTable.ELEMENT_TABLE] = {
|
|
3979
3988
|
type: Contentful.BLOCKS.TABLE,
|
|
3980
3989
|
component: Table
|
|
3981
|
-
}, _withTableOptions[
|
|
3990
|
+
}, _withTableOptions[plateTable.ELEMENT_TR] = {
|
|
3982
3991
|
type: Contentful.BLOCKS.TABLE_ROW,
|
|
3983
3992
|
component: TR
|
|
3984
|
-
}, _withTableOptions[
|
|
3993
|
+
}, _withTableOptions[plateTable.ELEMENT_TH] = {
|
|
3985
3994
|
type: Contentful.BLOCKS.TABLE_HEADER_CELL,
|
|
3986
3995
|
component: TH
|
|
3987
|
-
}, _withTableOptions[
|
|
3996
|
+
}, _withTableOptions[plateTable.ELEMENT_TD] = {
|
|
3988
3997
|
type: Contentful.BLOCKS.TABLE_CELL,
|
|
3989
3998
|
component: TD
|
|
3990
3999
|
}, _withTableOptions);
|
|
@@ -4043,7 +4052,7 @@ function hasHeadersOutsideFirstRow(nodes) {
|
|
|
4043
4052
|
|
|
4044
4053
|
function createTableOnKeyDown() {
|
|
4045
4054
|
return function withTableEvents(editor) {
|
|
4046
|
-
var handleKeyDownFromPlateUdecode =
|
|
4055
|
+
var handleKeyDownFromPlateUdecode = plateTable.getTableOnKeyDown()(editor);
|
|
4047
4056
|
return function handleKeyDown(event) {
|
|
4048
4057
|
if (event.key === 'Backspace' && currentSelectionStartsTableCell(editor) || event.key === 'Delete' && currentSelectionPrecedesTableCell(editor)) {
|
|
4049
4058
|
// The default behavior here would be to delete the preceding or forthcoming
|
|
@@ -4060,7 +4069,7 @@ function createTableOnKeyDown() {
|
|
|
4060
4069
|
}
|
|
4061
4070
|
|
|
4062
4071
|
var createTablePlugin = function createTablePlugin(tracking) {
|
|
4063
|
-
return _extends({},
|
|
4072
|
+
return _extends({}, plateTable.createTablePlugin(), {
|
|
4064
4073
|
onKeyDown: createTableOnKeyDown(),
|
|
4065
4074
|
withOverrides: function withOverrides(editor) {
|
|
4066
4075
|
addTableTrackingEvents(editor, tracking);
|
|
@@ -4364,7 +4373,7 @@ var createNode = function createNode(nodeType, entity) {
|
|
|
4364
4373
|
function insertBlock(editor, nodeType, entity) {
|
|
4365
4374
|
if (!(editor != null && editor.selection)) return;
|
|
4366
4375
|
var linkedEntityBlock = createNode(nodeType, entity);
|
|
4367
|
-
var hasText = editor.selection && !!
|
|
4376
|
+
var hasText = editor.selection && !!plateCommon.getText(editor, editor.selection.focus.path);
|
|
4368
4377
|
|
|
4369
4378
|
if (hasText) {
|
|
4370
4379
|
slate.Transforms.insertNodes(editor, linkedEntityBlock);
|
|
@@ -4439,14 +4448,14 @@ var _withEmbeddedEntryBlo, _withEmbeddedAssetBlo;
|
|
|
4439
4448
|
var createEmbeddedEntityPlugin = function createEmbeddedEntityPlugin(nodeType) {
|
|
4440
4449
|
return function (sdk) {
|
|
4441
4450
|
return {
|
|
4442
|
-
renderElement:
|
|
4451
|
+
renderElement: plateCore.getRenderElement(nodeType),
|
|
4443
4452
|
pluginKeys: nodeType,
|
|
4444
4453
|
onKeyDown: getWithEmbeddedEntityEvents(nodeType, sdk),
|
|
4445
|
-
voidTypes:
|
|
4454
|
+
voidTypes: plateCore.getPlatePluginTypes(nodeType),
|
|
4446
4455
|
deserialize: function deserialize(editor) {
|
|
4447
4456
|
var _entityTypes;
|
|
4448
4457
|
|
|
4449
|
-
var options =
|
|
4458
|
+
var options = plateCore.getPlatePluginOptions(editor, nodeType);
|
|
4450
4459
|
var entityTypes = (_entityTypes = {}, _entityTypes[Contentful.BLOCKS.EMBEDDED_ENTRY] = 'Entry', _entityTypes[Contentful.BLOCKS.EMBEDDED_ASSET] = 'Asset', _entityTypes);
|
|
4451
4460
|
return {
|
|
4452
4461
|
element: [_extends({
|
|
@@ -4817,13 +4826,13 @@ function ToolbarEmbeddedEntityInlineButton(props) {
|
|
|
4817
4826
|
}
|
|
4818
4827
|
function createEmbeddedEntityInlinePlugin(sdk) {
|
|
4819
4828
|
return {
|
|
4820
|
-
renderElement:
|
|
4829
|
+
renderElement: plateCore.getRenderElement(Contentful.INLINES.EMBEDDED_ENTRY),
|
|
4821
4830
|
pluginKeys: Contentful.INLINES.EMBEDDED_ENTRY,
|
|
4822
|
-
inlineTypes:
|
|
4823
|
-
voidTypes:
|
|
4831
|
+
inlineTypes: plateCore.getPlatePluginTypes(Contentful.INLINES.EMBEDDED_ENTRY),
|
|
4832
|
+
voidTypes: plateCore.getPlatePluginTypes(Contentful.INLINES.EMBEDDED_ENTRY),
|
|
4824
4833
|
onKeyDown: getWithEmbeddedEntryInlineEvents(sdk),
|
|
4825
4834
|
deserialize: function deserialize(editor) {
|
|
4826
|
-
var options =
|
|
4835
|
+
var options = plateCore.getPlatePluginOptions(editor, Contentful.INLINES.EMBEDDED_ENTRY);
|
|
4827
4836
|
return {
|
|
4828
4837
|
element: [_extends({
|
|
4829
4838
|
type: Contentful.INLINES.EMBEDDED_ENTRY,
|
|
@@ -5331,14 +5340,14 @@ function isEmpty(element) {
|
|
|
5331
5340
|
}
|
|
5332
5341
|
|
|
5333
5342
|
function createParagraphPlugin() {
|
|
5334
|
-
var elementKeys = [
|
|
5343
|
+
var elementKeys = [plateParagraph.ELEMENT_PARAGRAPH, Contentful.BLOCKS.PARAGRAPH];
|
|
5335
5344
|
var deserializer = deserializeElement(Contentful.BLOCKS.PARAGRAPH, [{
|
|
5336
5345
|
nodeNames: ['P', 'DIV']
|
|
5337
5346
|
}]);
|
|
5338
5347
|
return {
|
|
5339
|
-
renderElement:
|
|
5348
|
+
renderElement: plateCore.getRenderElement(elementKeys),
|
|
5340
5349
|
pluginKeys: elementKeys,
|
|
5341
|
-
onKeyDown:
|
|
5350
|
+
onKeyDown: plateCommon.getToggleElementOnKeyDown(Contentful.BLOCKS.PARAGRAPH),
|
|
5342
5351
|
deserialize: function deserialize(editor) {
|
|
5343
5352
|
var _deserializer = deserializer(editor),
|
|
5344
5353
|
element = _deserializer.element,
|
|
@@ -5388,7 +5397,7 @@ function createParagraphPlugin() {
|
|
|
5388
5397
|
}
|
|
5389
5398
|
};
|
|
5390
5399
|
}
|
|
5391
|
-
var withParagraphOptions = (_withParagraphOptions = {}, _withParagraphOptions[
|
|
5400
|
+
var withParagraphOptions = (_withParagraphOptions = {}, _withParagraphOptions[plateParagraph.ELEMENT_PARAGRAPH] = {
|
|
5392
5401
|
// We convert the default slate plugin `p` to Contentful `BLOCKS.PARAGRAPH`
|
|
5393
5402
|
type: Contentful.BLOCKS.PARAGRAPH,
|
|
5394
5403
|
component: Paragraph
|
|
@@ -5440,11 +5449,11 @@ function createInsertBeforeFirstVoidBlockPlugin() {
|
|
|
5440
5449
|
}
|
|
5441
5450
|
}]
|
|
5442
5451
|
};
|
|
5443
|
-
return
|
|
5452
|
+
return plateBreak.createExitBreakPlugin(optionsExitBreakPlugin);
|
|
5444
5453
|
}
|
|
5445
5454
|
|
|
5446
5455
|
var createTrailingParagraphPlugin = function createTrailingParagraphPlugin() {
|
|
5447
|
-
return
|
|
5456
|
+
return plateTrailingBlock.createTrailingBlockPlugin({
|
|
5448
5457
|
type: Contentful.BLOCKS.PARAGRAPH,
|
|
5449
5458
|
level: 0
|
|
5450
5459
|
});
|
|
@@ -5504,9 +5513,9 @@ function createDragAndDropPlugin() {
|
|
|
5504
5513
|
// If true, the next handlers will be skipped.
|
|
5505
5514
|
onDrop: function onDrop(editor) {
|
|
5506
5515
|
return function (event) {
|
|
5507
|
-
var _Array$from = Array.from(
|
|
5516
|
+
var _Array$from = Array.from(plateCommon.getNodes(editor, {
|
|
5508
5517
|
match: function match(node) {
|
|
5509
|
-
return
|
|
5518
|
+
return DRAGGABLE_TYPES.includes(node == null ? void 0 : node.type);
|
|
5510
5519
|
}
|
|
5511
5520
|
})),
|
|
5512
5521
|
draggingBlock = _Array$from[0];
|
|
@@ -5515,11 +5524,19 @@ function createDragAndDropPlugin() {
|
|
|
5515
5524
|
var draggingNode = draggingBlock[0];
|
|
5516
5525
|
if (!event.nativeEvent.target) return false; // TODO: looking up for html nodes is not the best solution and it won't scale, we need to find a way to know the dropping target slate element
|
|
5517
5526
|
|
|
5518
|
-
|
|
5527
|
+
var dropDisallowed = getParents(event.nativeEvent.target).some(function (node) {
|
|
5519
5528
|
var _ON_DROP_ALLOWED_TYPE;
|
|
5520
5529
|
|
|
5521
5530
|
return ON_DROP_ALLOWED_TYPES[node.nodeName] ? !((_ON_DROP_ALLOWED_TYPE = ON_DROP_ALLOWED_TYPES[node.nodeName]) != null && _ON_DROP_ALLOWED_TYPE.includes(draggingNode.type)) : false;
|
|
5522
5531
|
});
|
|
5532
|
+
|
|
5533
|
+
if (!dropDisallowed) {
|
|
5534
|
+
// Move the drop event to a new undo batch mitigating the bug where undo not only moves it back,
|
|
5535
|
+
// but also undoes a previous action: https://github.com/ianstormtaylor/slate/issues/4694
|
|
5536
|
+
editor.history.undos.push([]);
|
|
5537
|
+
}
|
|
5538
|
+
|
|
5539
|
+
return dropDisallowed;
|
|
5523
5540
|
};
|
|
5524
5541
|
}
|
|
5525
5542
|
};
|
|
@@ -5556,7 +5573,7 @@ function createTextPlugin() {
|
|
|
5556
5573
|
if (nodes) {
|
|
5557
5574
|
var paragraphOrHeading = nodes[0],
|
|
5558
5575
|
path = nodes[1];
|
|
5559
|
-
var isTextEmpty =
|
|
5576
|
+
var isTextEmpty = plateCommon.isAncestorEmpty(editor, paragraphOrHeading); // We ignore paragraphs/headings that are children of ul, ol, blockquote, tables, etc
|
|
5560
5577
|
|
|
5561
5578
|
var isRootLevel = path.length === 1;
|
|
5562
5579
|
|
|
@@ -5579,16 +5596,16 @@ function createTextPlugin() {
|
|
|
5579
5596
|
|
|
5580
5597
|
var getPlugins = function getPlugins(sdk, tracking) {
|
|
5581
5598
|
var plugins = [// Core
|
|
5582
|
-
|
|
5599
|
+
plateCore.createReactPlugin(), plateCore.createHistoryPlugin(), // Behavior
|
|
5583
5600
|
createPastePlugin(), // Global shortcuts
|
|
5584
5601
|
createNewLinePlugin(), createInsertBeforeFirstVoidBlockPlugin(), createDragAndDropPlugin(), // Block Elements
|
|
5585
5602
|
createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(tracking), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
|
|
5586
5603
|
createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
|
|
5587
5604
|
createBoldPlugin(), createCodePlugin(), createItalicPlugin(), createUnderlinePlugin(), // Other
|
|
5588
5605
|
createTrailingParagraphPlugin(), createTextPlugin()];
|
|
5589
|
-
return plugins.concat([
|
|
5606
|
+
return plugins.concat([plateHtmlSerializer.createDeserializeHTMLPlugin({
|
|
5590
5607
|
plugins: plugins
|
|
5591
|
-
}),
|
|
5608
|
+
}), plateAstSerializer.createDeserializeAstPlugin({
|
|
5592
5609
|
plugins: plugins
|
|
5593
5610
|
})]);
|
|
5594
5611
|
};
|
|
@@ -5616,7 +5633,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
5616
5633
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
5617
5634
|
className: styles.root,
|
|
5618
5635
|
"data-test-id": "rich-text-editor"
|
|
5619
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
5636
|
+
}, /*#__PURE__*/React__default.createElement(plateCore.Plate, {
|
|
5620
5637
|
id: getContentfulEditorId(props.sdk),
|
|
5621
5638
|
initialValue: value,
|
|
5622
5639
|
plugins: plugins,
|