@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.
Files changed (39) hide show
  1. package/dist/field-editor-rich-text.cjs.development.js +133 -116
  2. package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
  3. package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
  4. package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
  5. package/dist/field-editor-rich-text.esm.js +23 -6
  6. package/dist/field-editor-rich-text.esm.js.map +1 -1
  7. package/dist/helpers/deserializer.d.ts +1 -1
  8. package/dist/helpers/editor.d.ts +1 -1
  9. package/dist/plugins/Bold/index.d.ts +1 -1
  10. package/dist/plugins/Code/index.d.ts +1 -1
  11. package/dist/plugins/DragAndDrop/index.d.ts +1 -1
  12. package/dist/plugins/EmbeddedEntityBlock/index.d.ts +1 -1
  13. package/dist/plugins/EmbeddedEntityInline/index.d.ts +1 -1
  14. package/dist/plugins/Heading/index.d.ts +1 -1
  15. package/dist/plugins/Hr/index.d.ts +1 -1
  16. package/dist/plugins/Hyperlink/HyperlinkModal.d.ts +1 -1
  17. package/dist/plugins/Hyperlink/index.d.ts +1 -1
  18. package/dist/plugins/InsertBeforeFirstVoidBlock/index.d.ts +1 -1
  19. package/dist/plugins/Italic/index.d.ts +1 -1
  20. package/dist/plugins/List/getListInsertFragment.d.ts +1 -1
  21. package/dist/plugins/List/index.d.ts +1 -1
  22. package/dist/plugins/NewLine/index.d.ts +1 -1
  23. package/dist/plugins/Paragraph/index.d.ts +1 -1
  24. package/dist/plugins/Paste/index.d.ts +1 -1
  25. package/dist/plugins/Paste/sanitizers/helpers.d.ts +1 -1
  26. package/dist/plugins/Quote/index.d.ts +1 -1
  27. package/dist/plugins/Table/actions/addColumn.d.ts +2 -1
  28. package/dist/plugins/Table/actions/addRow.d.ts +1 -1
  29. package/dist/plugins/Table/actions/setHeader.d.ts +1 -1
  30. package/dist/plugins/Table/helpers.d.ts +1 -1
  31. package/dist/plugins/Table/index.d.ts +168 -168
  32. package/dist/plugins/Table/normalizers.d.ts +1 -1
  33. package/dist/plugins/Text/index.d.ts +1 -1
  34. package/dist/plugins/TrailingParagraph/index.d.ts +1 -1
  35. package/dist/plugins/Underline/index.d.ts +1 -1
  36. package/dist/plugins/index.d.ts +171 -171
  37. package/dist/test-utils/createEditor.d.ts +1 -1
  38. package/dist/types.d.ts +1 -1
  39. package/package.json +14 -5
@@ -10,14 +10,22 @@ import { Button, Tooltip, Menu, EntryCard, MenuItem, AssetCard, Text as Text$1,
10
10
  import { useSelected, useFocused, ReactEditor, useReadOnly } from 'slate-react';
11
11
  import { HorizontalRuleIcon, ChevronDownIcon, QuoteIcon, ListBulletedIcon, ListNumberedIcon, FormatBoldIcon, CodeIcon, FormatItalicIcon, FormatUnderlinedIcon, ClockIcon, LinkIcon, TableIcon, PlusIcon, AssetIcon, EmbeddedEntryBlockIcon, EmbeddedEntryInlineIcon } from '@contentful/f36-icons';
12
12
  import { Editor, Element, Transforms, Text, Node as Node$1, Path, Range } from 'slate';
13
- import { getText, getElementDeserializer, getPlatePluginOptions, getLeafDeserializer, usePlateEditorRef, getRenderElement, getPlatePluginTypes, setNodes, insertNodes, toggleNodeType, findNode, ELEMENT_LI, ELEMENT_UL, ELEMENT_OL, ELEMENT_LIC, toggleList, createListPlugin as createListPlugin$1, getParent, getAbove, withList, getRenderLeaf, getToggleMarkOnKeyDown, isMarkActive, toggleMark, ELEMENT_TABLE, ELEMENT_TH, ELEMENT_TR, ELEMENT_TD, getChildren, insertTable, isFirstChild as isFirstChild$1, isAncestorEmpty, someNode, getPlatePluginType, getEmptyRowNode, getEmptyCellNode, deleteRow, deleteColumn, deleteTable, createTablePlugin as createTablePlugin$1, getTableOnKeyDown, ELEMENT_PARAGRAPH, getToggleElementOnKeyDown, createExitBreakPlugin, createTrailingBlockPlugin, getNodes, createDeserializeHTMLPlugin, createDeserializeAstPlugin, createReactPlugin, createHistoryPlugin, Plate } from '@udecode/plate';
13
+ import { getPlatePluginOptions, usePlateEditorRef, getRenderElement, getPlatePluginTypes, getRenderLeaf, getPlatePluginType, createReactPlugin, createHistoryPlugin, Plate } from '@udecode/plate-core';
14
+ import { getText, getElementDeserializer, getLeafDeserializer, setNodes, insertNodes, toggleNodeType, findNode, getParent, getAbove, getToggleMarkOnKeyDown, isMarkActive, toggleMark, getChildren, isFirstChild as isFirstChild$1, isAncestorEmpty, someNode, getToggleElementOnKeyDown, getNodes } from '@udecode/plate-common';
14
15
  import constate from 'constate';
15
16
  import find from 'lodash-es/find';
16
17
  import flow from 'lodash-es/flow';
17
18
  import get from 'lodash-es/get';
19
+ import { ELEMENT_LI, ELEMENT_UL, ELEMENT_OL, ELEMENT_LIC, toggleList, createListPlugin as createListPlugin$1, withList } from '@udecode/plate-list';
18
20
  import { entityHelpers, isValidImage, shortenStorageUnit, ModalDialogLauncher, FieldConnector } from '@contentful/field-editor-shared';
19
21
  import mimetype from '@contentful/mimetype';
22
+ import { ELEMENT_TABLE, ELEMENT_TH, ELEMENT_TR, ELEMENT_TD, insertTable, getEmptyRowNode, getEmptyCellNode, deleteRow, deleteColumn, deleteTable, createTablePlugin as createTablePlugin$1, getTableOnKeyDown } from '@udecode/plate-table';
20
23
  import values from 'lodash-es/values';
24
+ import { createDeserializeHTMLPlugin } from '@udecode/plate-html-serializer';
25
+ import { createDeserializeAstPlugin } from '@udecode/plate-ast-serializer';
26
+ import { ELEMENT_PARAGRAPH } from '@udecode/plate-paragraph';
27
+ import { createExitBreakPlugin } from '@udecode/plate-break';
28
+ import { createTrailingBlockPlugin } from '@udecode/plate-trailing-block';
21
29
  import PropTypes from 'prop-types';
22
30
 
23
31
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -2561,7 +2569,8 @@ function EntryThumbnail(_ref) {
2561
2569
  function FetchingWrappedEntryCard(props) {
2562
2570
  var _useEntities = useEntities(),
2563
2571
  getOrLoadEntry = _useEntities.getOrLoadEntry,
2564
- entries = _useEntities.entries;
2572
+ entries = _useEntities.entries,
2573
+ getOrLoadAsset = _useEntities.getOrLoadAsset;
2565
2574
 
2566
2575
  var _React$useState = useState(null),
2567
2576
  file = _React$useState[0],
@@ -2585,10 +2594,10 @@ function FetchingWrappedEntryCard(props) {
2585
2594
  contentType: contentType,
2586
2595
  localeCode: props.locale,
2587
2596
  defaultLocaleCode: defaultLocaleCode
2588
- }, props.sdk.space.getAsset).then(setFile)["catch"](function () {
2597
+ }, getOrLoadAsset).then(setFile)["catch"](function () {
2589
2598
  return setFile(null);
2590
2599
  });
2591
- }, [entry, contentType, props.locale, defaultLocaleCode, props.sdk, file]);
2600
+ }, [entry, contentType, props.locale, defaultLocaleCode, props.sdk, file, getOrLoadAsset]);
2592
2601
  useEffect(function () {
2593
2602
  getOrLoadEntry(props.entryId);
2594
2603
  }, [props.entryId]); // eslint-disable-line
@@ -5499,7 +5508,7 @@ function createDragAndDropPlugin() {
5499
5508
  return function (event) {
5500
5509
  var _Array$from = Array.from(getNodes(editor, {
5501
5510
  match: function match(node) {
5502
- return Editor.isBlock(editor, node) && DRAGGABLE_TYPES.includes(node.type);
5511
+ return DRAGGABLE_TYPES.includes(node == null ? void 0 : node.type);
5503
5512
  }
5504
5513
  })),
5505
5514
  draggingBlock = _Array$from[0];
@@ -5508,11 +5517,19 @@ function createDragAndDropPlugin() {
5508
5517
  var draggingNode = draggingBlock[0];
5509
5518
  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
5510
5519
 
5511
- return getParents(event.nativeEvent.target).some(function (node) {
5520
+ var dropDisallowed = getParents(event.nativeEvent.target).some(function (node) {
5512
5521
  var _ON_DROP_ALLOWED_TYPE;
5513
5522
 
5514
5523
  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;
5515
5524
  });
5525
+
5526
+ if (!dropDisallowed) {
5527
+ // Move the drop event to a new undo batch mitigating the bug where undo not only moves it back,
5528
+ // but also undoes a previous action: https://github.com/ianstormtaylor/slate/issues/4694
5529
+ editor.history.undos.push([]);
5530
+ }
5531
+
5532
+ return dropDisallowed;
5516
5533
  };
5517
5534
  }
5518
5535
  };