@contentful/field-editor-rich-text 2.2.0 → 2.3.1

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.
@@ -16,15 +16,17 @@ var noop = _interopDefault(require('lodash/noop'));
16
16
  var plateSerializerDocx = require('@udecode/plate-serializer-docx');
17
17
  var plateBreak = require('@udecode/plate-break');
18
18
  var plateResetNode = require('@udecode/plate-reset-node');
19
- var slate = require('slate');
20
- var Slate = require('slate-react');
19
+ var reactPopper = require('react-popper');
21
20
  var f36Components = require('@contentful/f36-components');
21
+ var f36Utils = require('@contentful/f36-utils');
22
22
  var constate = _interopDefault(require('constate'));
23
23
  var isHotkey = _interopDefault(require('is-hotkey'));
24
- var tokens = _interopDefault(require('@contentful/f36-tokens'));
24
+ var slate = require('slate');
25
+ var Slate = require('slate-react');
25
26
  var find = _interopDefault(require('lodash/find'));
26
27
  var flow = _interopDefault(require('lodash/flow'));
27
28
  var get = _interopDefault(require('lodash/get'));
29
+ var tokens = _interopDefault(require('@contentful/f36-tokens'));
28
30
  var f36Icons = require('@contentful/f36-icons');
29
31
  var plateList = require('@udecode/plate-list');
30
32
  var castArray = _interopDefault(require('lodash/castArray'));
@@ -341,6 +343,131 @@ var createResetNodePlugin = function createResetNodePlugin() {
341
343
  });
342
344
  };
343
345
 
346
+ /**
347
+ * Trim leading slash character if found. Bails otherwise.
348
+ *
349
+ * @example
350
+ * trimLeadingSlash("/my query") // --> "my query"
351
+ */
352
+ function trimLeadingSlash(text) {
353
+ if (!text.startsWith('/')) {
354
+ return text;
355
+ }
356
+
357
+ return text.slice(1);
358
+ }
359
+
360
+ function useSdk(_ref) {
361
+ var sdk = _ref.sdk;
362
+ var sdkMemo = React.useMemo(function () {
363
+ return sdk;
364
+ }, []); // eslint-disable-line -- TODO: explain this disable
365
+
366
+ return sdkMemo;
367
+ }
368
+
369
+ var _constate = /*#__PURE__*/constate(useSdk),
370
+ SdkProvider = _constate[0],
371
+ useSdkContext = _constate[1];
372
+
373
+ var useCommandList = function useCommandList(commandItems, container) {
374
+ var _React$useState = React.useState(function () {
375
+ // select the first item on initial render
376
+ if ('group' in commandItems[0]) {
377
+ return commandItems[0].commands[0].id;
378
+ }
379
+
380
+ return commandItems[0].id;
381
+ }),
382
+ selectedItem = _React$useState[0],
383
+ setSelectedItem = _React$useState[1];
384
+
385
+ var _React$useState2 = React.useState(commandItems.length > 0),
386
+ isOpen = _React$useState2[0],
387
+ setIsOpen = _React$useState2[1];
388
+
389
+ React.useEffect(function () {
390
+ if (!container.current) {
391
+ return;
392
+ }
393
+
394
+ var buttons = Array.from(container.current.querySelectorAll('button'));
395
+ var currBtn = buttons.find(function (btn) {
396
+ return btn.id === selectedItem;
397
+ });
398
+ var currIndex = currBtn ? buttons.indexOf(currBtn) : 0;
399
+ var shouldSelectFirstBtn = !currBtn && buttons.length;
400
+
401
+ if (shouldSelectFirstBtn) {
402
+ setSelectedItem(buttons[0].id);
403
+ buttons[0].scrollIntoView({
404
+ block: 'nearest',
405
+ inline: 'start'
406
+ });
407
+ }
408
+
409
+ function handleKeyDown(event) {
410
+ if (isHotkey('up', event)) {
411
+ event.preventDefault();
412
+
413
+ if (currIndex === 0) {
414
+ return;
415
+ }
416
+
417
+ setSelectedItem(buttons[currIndex - 1].id);
418
+ buttons[currIndex - 1].scrollIntoView({
419
+ block: 'nearest',
420
+ inline: 'start'
421
+ });
422
+ } else if (isHotkey('down', event)) {
423
+ event.preventDefault();
424
+
425
+ if (currIndex === buttons.length - 1) {
426
+ return;
427
+ }
428
+
429
+ setSelectedItem(buttons[currIndex + 1].id);
430
+ buttons[currIndex + 1].scrollIntoView({
431
+ block: 'nearest',
432
+ inline: 'start'
433
+ });
434
+ } else if (isHotkey('enter', event)) {
435
+ event.preventDefault();
436
+
437
+ if (currBtn) {
438
+ setSelectedItem('');
439
+ currBtn.click();
440
+ }
441
+ } //TODO: handle shift+enter, which must be detected using separate events
442
+
443
+ }
444
+
445
+ if (commandItems.length) {
446
+ window.addEventListener('keydown', handleKeyDown);
447
+ }
448
+
449
+ return function () {
450
+ return window.removeEventListener('keydown', handleKeyDown);
451
+ };
452
+ }, [commandItems, container, selectedItem]);
453
+ React.useEffect(function () {
454
+ var handleMousedown = function handleMousedown(event) {
455
+ if (container.current && !container.current.contains(event.target)) {
456
+ setIsOpen(false);
457
+ }
458
+ };
459
+
460
+ document.addEventListener('mousedown', handleMousedown);
461
+ return function () {
462
+ document.removeEventListener('mousedown', handleMousedown);
463
+ };
464
+ }, [container]);
465
+ return {
466
+ selectedItem: selectedItem,
467
+ isOpen: isOpen
468
+ };
469
+ };
470
+
344
471
  var IS_SAFARI = typeof navigator !== 'undefined' && /*#__PURE__*/ /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
345
472
  var IS_CHROME = /*#__PURE__*/ /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9.]+)(:?\s|$)/.test(navigator.userAgent);
346
473
 
@@ -545,129 +672,36 @@ function toggleElement(editor, options, editorOptions) {
545
672
  });
546
673
  }
547
674
 
548
- /**
549
- * Trim leading slash character if found. Bails otherwise.
550
- *
551
- * @example
552
- * trimLeadingSlash("/my query") // --> "my query"
553
- */
554
- function trimLeadingSlash(text) {
555
- if (!text.startsWith('/')) {
556
- return text;
557
- }
558
-
559
- return text.slice(1);
560
- }
561
-
562
- function useSdk(_ref) {
563
- var sdk = _ref.sdk;
564
- var sdkMemo = React.useMemo(function () {
565
- return sdk;
566
- }, []); // eslint-disable-line -- TODO: explain this disable
567
-
568
- return sdkMemo;
569
- }
570
-
571
- var _constate = /*#__PURE__*/constate(useSdk),
572
- SdkProvider = _constate[0],
573
- useSdkContext = _constate[1];
574
-
575
- var useCommandList = function useCommandList(commandItems, container) {
576
- var _React$useState = React.useState(function () {
577
- // select the first item on initial render
578
- if ('group' in commandItems[0]) {
579
- return commandItems[0].commands[0].id;
580
- }
581
-
582
- return commandItems[0].id;
583
- }),
584
- selectedItem = _React$useState[0],
585
- setSelectedItem = _React$useState[1];
586
-
587
- var _React$useState2 = React.useState(commandItems.length > 0),
588
- isOpen = _React$useState2[0],
589
- setIsOpen = _React$useState2[1];
590
-
591
- React.useEffect(function () {
592
- if (!(container != null && container.current)) {
593
- return;
594
- }
595
-
596
- var buttons = Array.from(container.current.querySelectorAll('button'));
597
- var currBtn = buttons.find(function (btn) {
598
- return btn.id === selectedItem;
599
- });
600
- var currIndex = currBtn ? buttons.indexOf(currBtn) : 0;
601
- var shouldSelectFirstBtn = !currBtn && buttons.length;
602
-
603
- if (shouldSelectFirstBtn) {
604
- setSelectedItem(buttons[0].id);
605
- buttons[0].scrollIntoView({
606
- block: 'nearest',
607
- inline: 'start'
608
- });
609
- }
610
-
611
- function handleKeyDown(event) {
612
- if (isHotkey('up', event)) {
613
- event.preventDefault();
614
-
615
- if (currIndex === 0) {
616
- return;
617
- }
618
-
619
- setSelectedItem(buttons[currIndex - 1].id);
620
- buttons[currIndex - 1].scrollIntoView({
621
- block: 'nearest',
622
- inline: 'start'
623
- });
624
- } else if (isHotkey('down', event)) {
625
- event.preventDefault();
626
-
627
- if (currIndex === buttons.length - 1) {
628
- return;
629
- }
630
-
631
- setSelectedItem(buttons[currIndex + 1].id);
632
- buttons[currIndex + 1].scrollIntoView({
633
- block: 'nearest',
634
- inline: 'start'
635
- });
636
- } else if (isHotkey('enter', event)) {
637
- event.preventDefault();
675
+ var VALIDATIONS = {
676
+ ENABLED_MARKS: 'enabledMarks',
677
+ ENABLED_NODE_TYPES: 'enabledNodeTypes'
678
+ };
679
+ var DEFAULT_ENABLED_NODE_TYPES = [Contentful.BLOCKS.DOCUMENT, Contentful.BLOCKS.PARAGRAPH, 'text'];
638
680
 
639
- if (currBtn) {
640
- setSelectedItem('');
641
- currBtn.click();
642
- }
643
- } //TODO: handle shift+enter, which must be detected using separate events
681
+ var getRichTextValidation = function getRichTextValidation(field, validationType) {
682
+ return flow(function (v) {
683
+ return find(v, validationType);
684
+ }, function (v) {
685
+ return get(v, validationType);
686
+ })(field.validations);
687
+ };
644
688
 
645
- }
689
+ var isFormattingOptionEnabled = function isFormattingOptionEnabled(field, validationType, nodeTypeOrMark) {
690
+ var enabledFormattings = getRichTextValidation(field, validationType); // TODO: In the future, validations will always be opt-in. In that case
691
+ // we don't need this step.
646
692
 
647
- if (commandItems.length) {
648
- window.addEventListener('keydown', handleKeyDown);
649
- }
693
+ if (enabledFormattings === undefined) {
694
+ return true;
695
+ }
650
696
 
651
- return function () {
652
- return window.removeEventListener('keydown', handleKeyDown);
653
- };
654
- }, [commandItems, container, selectedItem]);
655
- React.useEffect(function () {
656
- var handleClick = function handleClick(event) {
657
- if (container.current && !container.current.contains(event.target)) {
658
- setIsOpen(false);
659
- }
660
- };
697
+ return DEFAULT_ENABLED_NODE_TYPES.concat(enabledFormattings).includes(nodeTypeOrMark);
698
+ };
661
699
 
662
- document.addEventListener('click', handleClick);
663
- return function () {
664
- document.removeEventListener('click', handleClick);
665
- };
666
- }, [container]);
667
- return {
668
- selectedItem: selectedItem,
669
- isOpen: isOpen
670
- };
700
+ var isNodeTypeEnabled = function isNodeTypeEnabled(field, nodeType) {
701
+ return isFormattingOptionEnabled(field, VALIDATIONS.ENABLED_NODE_TYPES, nodeType);
702
+ };
703
+ var isMarkEnabled = function isMarkEnabled(field, mark) {
704
+ return isFormattingOptionEnabled(field, VALIDATIONS.ENABLED_MARKS, mark);
671
705
  };
672
706
 
673
707
  var COMMAND_PROMPT = 'command-prompt';
@@ -1579,38 +1613,124 @@ var removeQuery = function removeQuery(editor) {
1579
1613
 
1580
1614
  var useCommands = function useCommands(sdk, query, editor) {
1581
1615
  var contentTypes = sdk.space.getCachedContentTypes();
1616
+ var canInsertBlocks = !isNodeTypeSelected(editor, Contentful.BLOCKS.TABLE);
1617
+ var inlineAllowed = isNodeTypeEnabled(sdk.field, Contentful.INLINES.EMBEDDED_ENTRY);
1618
+ var entriesAllowed = isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.EMBEDDED_ENTRY) && canInsertBlocks;
1619
+ var assetsAllowed = isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.EMBEDDED_ASSET) && canInsertBlocks;
1582
1620
 
1583
1621
  var _useState = React.useState(function () {
1584
- var contentTypeCommands = contentTypes.map(function (contentType) {
1622
+ var getEmbedEntry = function getEmbedEntry(contentType) {
1623
+ return {
1624
+ id: contentType.sys.id,
1625
+ label: "Embed " + contentType.name,
1626
+ callback: function callback() {
1627
+ fetchEntries(sdk, contentType, query).then(function (entries) {
1628
+ removeQuery(editor);
1629
+
1630
+ if (!entries.length) {
1631
+ setCommands([{
1632
+ id: 'no-results',
1633
+ label: 'No results'
1634
+ }]);
1635
+ } else {
1636
+ setCommands(entries.map(function (entry) {
1637
+ return {
1638
+ id: entry.id + "-" + entry.displayTitle.replace(/\W+/g, '-').toLowerCase(),
1639
+ label: entry.displayTitle,
1640
+ callback: function callback() {
1641
+ removeCommand(editor);
1642
+
1643
+ if (editor.selection) {
1644
+ var selection = editor.selection;
1645
+ editor.insertSoftBreak();
1646
+ insertBlock(editor, Contentful.BLOCKS.EMBEDDED_ENTRY, entry.entry);
1647
+ slate.Transforms.select(editor, selection);
1648
+ editor.tracking.onCommandPaletteAction('insert', {
1649
+ nodeType: Contentful.BLOCKS.EMBEDDED_ENTRY
1650
+ });
1651
+ }
1652
+ }
1653
+ };
1654
+ }));
1655
+ }
1656
+ });
1657
+ }
1658
+ };
1659
+ };
1660
+
1661
+ var getEmbedInline = function getEmbedInline(contentType) {
1662
+ return {
1663
+ id: contentType.sys.id + "-inline",
1664
+ label: "Embed " + contentType.name + " - Inline",
1665
+ callback: function callback() {
1666
+ fetchEntries(sdk, contentType, query).then(function (entries) {
1667
+ removeQuery(editor);
1668
+
1669
+ if (!entries.length) {
1670
+ setCommands([{
1671
+ id: 'no-results',
1672
+ label: 'No results'
1673
+ }]);
1674
+ } else {
1675
+ setCommands(entries.map(function (entry) {
1676
+ return {
1677
+ id: entry.id + "-" + entry.displayTitle.replace(/\W+/g, '-').toLowerCase(),
1678
+ label: entry.displayTitle,
1679
+ callback: function callback() {
1680
+ var inlineNode = createInlineEntryNode(entry.id);
1681
+ removeCommand(editor);
1682
+ slate.Transforms.insertNodes(editor, inlineNode);
1683
+ editor.insertText('');
1684
+ editor.tracking.onCommandPaletteAction('insert', {
1685
+ nodeType: Contentful.INLINES.EMBEDDED_ENTRY
1686
+ });
1687
+ }
1688
+ };
1689
+ }));
1690
+ }
1691
+ });
1692
+ }
1693
+ };
1694
+ };
1695
+
1696
+ var contentTypeCommands = entriesAllowed || inlineAllowed ? contentTypes.map(function (contentType) {
1585
1697
  return {
1586
1698
  group: contentType.name,
1699
+ commands: entriesAllowed && inlineAllowed ? [getEmbedEntry(contentType), getEmbedInline(contentType)] : entriesAllowed ? [getEmbedEntry(contentType)] : [getEmbedInline(contentType)]
1700
+ };
1701
+ }) : [];
1702
+
1703
+ if (assetsAllowed) {
1704
+ var assetCommand = {
1705
+ group: 'Assets',
1587
1706
  commands: [{
1588
- id: contentType.sys.id,
1589
- label: "Embed " + contentType.name,
1707
+ id: 'embed-asset',
1708
+ label: 'Embed Asset',
1590
1709
  callback: function callback() {
1591
- fetchEntries(sdk, contentType, query).then(function (entries) {
1710
+ fetchAssets(sdk, query).then(function (assets) {
1592
1711
  removeQuery(editor);
1593
1712
 
1594
- if (!entries.length) {
1713
+ if (!assets.length) {
1595
1714
  setCommands([{
1596
1715
  id: 'no-results',
1597
1716
  label: 'No results'
1598
1717
  }]);
1599
1718
  } else {
1600
- setCommands(entries.map(function (entry) {
1719
+ setCommands(assets.map(function (asset) {
1601
1720
  return {
1602
- id: entry.id + "-" + entry.displayTitle.replace(/\W+/g, '-').toLowerCase(),
1603
- label: entry.displayTitle,
1721
+ id: asset.id + "-" + asset.displayTitle.replace(/\W+/g, '-').toLowerCase(),
1722
+ label: asset.displayTitle,
1723
+ thumbnail: asset.thumbnail,
1604
1724
  callback: function callback() {
1605
1725
  removeCommand(editor);
1606
1726
 
1607
1727
  if (editor.selection) {
1608
1728
  var selection = editor.selection;
1609
1729
  editor.insertSoftBreak();
1610
- insertBlock(editor, Contentful.BLOCKS.EMBEDDED_ENTRY, entry.entry);
1730
+ insertBlock(editor, Contentful.BLOCKS.EMBEDDED_ASSET, asset.entity);
1611
1731
  slate.Transforms.select(editor, selection);
1612
1732
  editor.tracking.onCommandPaletteAction('insert', {
1613
- nodeType: Contentful.BLOCKS.EMBEDDED_ENTRY
1733
+ nodeType: Contentful.BLOCKS.EMBEDDED_ASSET
1614
1734
  });
1615
1735
  }
1616
1736
  }
@@ -1619,81 +1739,12 @@ var useCommands = function useCommands(sdk, query, editor) {
1619
1739
  }
1620
1740
  });
1621
1741
  }
1622
- }, {
1623
- id: contentType.sys.id + "-inline",
1624
- label: "Embed " + contentType.name + " - Inline",
1625
- callback: function callback() {
1626
- fetchEntries(sdk, contentType, query).then(function (entries) {
1627
- removeQuery(editor);
1628
-
1629
- if (!entries.length) {
1630
- setCommands([{
1631
- id: 'no-results',
1632
- label: 'No results'
1633
- }]);
1634
- } else {
1635
- setCommands(entries.map(function (entry) {
1636
- return {
1637
- id: entry.id + "-" + entry.displayTitle.replace(/\W+/g, '-').toLowerCase(),
1638
- label: entry.displayTitle,
1639
- callback: function callback() {
1640
- var inlineNode = createInlineEntryNode(entry.id);
1641
- removeCommand(editor);
1642
- slate.Transforms.insertNodes(editor, inlineNode);
1643
- editor.insertText('');
1644
- editor.tracking.onCommandPaletteAction('insert', {
1645
- nodeType: Contentful.INLINES.EMBEDDED_ENTRY
1646
- });
1647
- }
1648
- };
1649
- }));
1650
- }
1651
- });
1652
- }
1653
1742
  }]
1654
1743
  };
1655
- });
1656
- var assetCommand = {
1657
- group: 'Assets',
1658
- commands: [{
1659
- id: 'embed-asset',
1660
- label: 'Embed Asset',
1661
- callback: function callback() {
1662
- fetchAssets(sdk, query).then(function (assets) {
1663
- removeQuery(editor);
1664
-
1665
- if (!assets.length) {
1666
- setCommands([{
1667
- id: 'no-results',
1668
- label: 'No results'
1669
- }]);
1670
- } else {
1671
- setCommands(assets.map(function (asset) {
1672
- return {
1673
- id: asset.id + "-" + asset.displayTitle.replace(/\W+/g, '-').toLowerCase(),
1674
- label: asset.displayTitle,
1675
- thumbnail: asset.thumbnail,
1676
- callback: function callback() {
1677
- removeCommand(editor);
1744
+ return [].concat(contentTypeCommands, [assetCommand]);
1745
+ }
1678
1746
 
1679
- if (editor.selection) {
1680
- var selection = editor.selection;
1681
- editor.insertSoftBreak();
1682
- insertBlock(editor, Contentful.BLOCKS.EMBEDDED_ASSET, asset.entity);
1683
- slate.Transforms.select(editor, selection);
1684
- editor.tracking.onCommandPaletteAction('insert', {
1685
- nodeType: Contentful.BLOCKS.EMBEDDED_ASSET
1686
- });
1687
- }
1688
- }
1689
- };
1690
- }));
1691
- }
1692
- });
1693
- }
1694
- }]
1695
- };
1696
- return [].concat(contentTypeCommands, [assetCommand]);
1747
+ return contentTypeCommands;
1697
1748
  }),
1698
1749
  commands = _useState[0],
1699
1750
  setCommands = _useState[1];
@@ -1779,7 +1830,6 @@ var styles = {
1779
1830
  margin: tokens.spacingXs + " 0"
1780
1831
  }),
1781
1832
  menuHeader: /*#__PURE__*/emotion.css({
1782
- position: 'sticky',
1783
1833
  zIndex: tokens.zIndexDefault,
1784
1834
  top: 0,
1785
1835
  backgroundColor: tokens.gray100,
@@ -1878,25 +1928,34 @@ var CommandListItems = function CommandListItems(_ref4) {
1878
1928
 
1879
1929
  var CommandList = function CommandList(_ref5) {
1880
1930
  var query = _ref5.query,
1881
- editor = _ref5.editor;
1931
+ editor = _ref5.editor,
1932
+ textContainer = _ref5.textContainer;
1882
1933
  var sdk = useSdkContext();
1883
- var container = React.useRef(null);
1934
+ var popoverContainer = React.useRef(null);
1935
+ var popper = reactPopper.usePopper(textContainer, popoverContainer == null ? void 0 : popoverContainer.current, {
1936
+ placement: 'bottom-start'
1937
+ });
1884
1938
  var commandItems = useCommands(sdk, query, editor);
1885
1939
 
1886
- var _useCommandList = useCommandList(commandItems, container),
1940
+ var _useCommandList = useCommandList(commandItems, popoverContainer),
1887
1941
  selectedItem = _useCommandList.selectedItem,
1888
1942
  isOpen = _useCommandList.isOpen;
1889
1943
 
1944
+ if (!commandItems.length) {
1945
+ return null;
1946
+ }
1947
+
1890
1948
  return /*#__PURE__*/React.createElement("div", {
1891
1949
  className: styles.container,
1892
1950
  tabIndex: -1,
1893
- ref: container,
1894
1951
  contentEditable: false
1895
1952
  }, /*#__PURE__*/React.createElement("div", {
1896
1953
  role: "alert"
1897
- }, /*#__PURE__*/React.createElement(f36Components.ScreenReaderOnly, null, "Richtext commands. Currently focused item: ", selectedItem, ". Press ", /*#__PURE__*/React.createElement("kbd", null, "enter"), " to select, ", /*#__PURE__*/React.createElement("kbd", null, "arrows"), " to navigate, ", /*#__PURE__*/React.createElement("kbd", null, "escape"), " to close.")), /*#__PURE__*/React.createElement("div", {
1898
- "aria-hidden": true
1899
- }, /*#__PURE__*/React.createElement(f36Components.Popover, {
1954
+ }, /*#__PURE__*/React.createElement(f36Components.ScreenReaderOnly, null, "Richtext commands. Currently focused item: ", selectedItem, ". Press ", /*#__PURE__*/React.createElement("kbd", null, "enter"), " to select, ", /*#__PURE__*/React.createElement("kbd", null, "arrows"), " to navigate, ", /*#__PURE__*/React.createElement("kbd", null, "escape"), " to close.")), /*#__PURE__*/React.createElement(f36Utils.Portal, null, /*#__PURE__*/React.createElement("div", Object.assign({
1955
+ "aria-hidden": true,
1956
+ ref: popoverContainer,
1957
+ style: popper.styles.popper
1958
+ }, popper.attributes.popper), /*#__PURE__*/React.createElement(f36Components.Popover, {
1900
1959
  isOpen: isOpen,
1901
1960
  usePortal: false,
1902
1961
 
@@ -1923,7 +1982,7 @@ var CommandList = function CommandList(_ref5) {
1923
1982
  padding: "none",
1924
1983
  spacing: "spacingS",
1925
1984
  className: styles.footerList
1926
- }, /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("kbd", null, "\u2191"), /*#__PURE__*/React.createElement("kbd", null, "\u2193"), " to navigate"), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("kbd", null, "\u21B5"), " to confirm"), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("kbd", null, "esc"), " to close")))))));
1985
+ }, /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("kbd", null, "\u2191"), /*#__PURE__*/React.createElement("kbd", null, "\u2193"), " to navigate"), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("kbd", null, "\u21B5"), " to confirm"), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("kbd", null, "esc"), " to close"))))))));
1927
1986
  };
1928
1987
 
1929
1988
  var CommandPrompt = function CommandPrompt(props) {
@@ -1931,10 +1990,19 @@ var CommandPrompt = function CommandPrompt(props) {
1931
1990
  return trimLeadingSlash(props.text.text);
1932
1991
  }, [props.text.text]);
1933
1992
  var editor = props.editor;
1934
- var canInsertBlocks = !isNodeTypeSelected(editor, Contentful.BLOCKS.TABLE);
1935
- return /*#__PURE__*/React.createElement("span", Object.assign({}, props.attributes), props.children, canInsertBlocks && /*#__PURE__*/React.createElement(CommandList, {
1993
+
1994
+ var _React$useState = React.useState(),
1995
+ textElement = _React$useState[0],
1996
+ setTextElement = _React$useState[1];
1997
+
1998
+ return /*#__PURE__*/React.createElement("span", Object.assign({
1999
+ ref: function ref(e) {
2000
+ setTextElement(e);
2001
+ }
2002
+ }, props.attributes), props.children, /*#__PURE__*/React.createElement(CommandList, {
1936
2003
  query: query,
1937
- editor: editor
2004
+ editor: editor,
2005
+ textContainer: textElement
1938
2006
  }));
1939
2007
  };
1940
2008
 
@@ -2085,8 +2153,8 @@ function useFetchedEntity(_ref) {
2085
2153
  var _useEntities = fieldEditorReference.useEntities(),
2086
2154
  entries = _useEntities.entries,
2087
2155
  assets = _useEntities.assets,
2088
- getOrLoadEntry = _useEntities.getOrLoadEntry,
2089
- getOrLoadAsset = _useEntities.getOrLoadAsset;
2156
+ getEntry = _useEntities.getEntry,
2157
+ getAsset = _useEntities.getAsset;
2090
2158
 
2091
2159
  var store = type === 'Entry' ? entries : assets;
2092
2160
 
@@ -2104,7 +2172,7 @@ function useFetchedEntity(_ref) {
2104
2172
  }, [store, entity, id]); // Fetch the entity if needed
2105
2173
 
2106
2174
  React.useEffect(function () {
2107
- (type === 'Entry' ? getOrLoadEntry : getOrLoadAsset)(id); // "getOrLoadEntry" and "getOrLoadAsset" instances change with every
2175
+ (type === 'Entry' ? getEntry : getAsset)(id); // "getEntry" and "getAsset" instances change with every
2108
2176
  // entity store update causing page lag on initial load
2109
2177
  // TODO: consider rewriting useEntities() hook to avoid that happening in
2110
2178
  // first place.
@@ -2657,7 +2725,7 @@ var styles$3 = {
2657
2725
  };
2658
2726
  function FetchingWrappedInlineEntryCard(props) {
2659
2727
  var _useEntities = fieldEditorReference.useEntities(),
2660
- getOrLoadEntry = _useEntities.getOrLoadEntry,
2728
+ getEntry = _useEntities.getEntry,
2661
2729
  loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
2662
2730
  entries = _useEntities.entries;
2663
2731
 
@@ -2691,7 +2759,7 @@ function FetchingWrappedInlineEntryCard(props) {
2691
2759
  }, [entry, contentType, props.sdk.field.locale, props.sdk.locales["default"]]);
2692
2760
  React__default.useEffect(function () {
2693
2761
  if (!props.entryId) return;
2694
- getOrLoadEntry(props.entryId); // We don't include getOrLoadEntry below because it's part of the constate-derived
2762
+ getEntry(props.entryId); // We don't include getEntry below because it's part of the constate-derived
2695
2763
  // useEntities(), not props.
2696
2764
  // eslint-disable-next-line -- TODO: explain this disable
2697
2765
  }, [props.entryId]);
@@ -2977,38 +3045,6 @@ function getWithEmbeddedEntryInlineEvents(sdk) {
2977
3045
  };
2978
3046
  }
2979
3047
 
2980
- var VALIDATIONS = {
2981
- ENABLED_MARKS: 'enabledMarks',
2982
- ENABLED_NODE_TYPES: 'enabledNodeTypes'
2983
- };
2984
- var DEFAULT_ENABLED_NODE_TYPES = [Contentful.BLOCKS.DOCUMENT, Contentful.BLOCKS.PARAGRAPH, 'text'];
2985
-
2986
- var getRichTextValidation = function getRichTextValidation(field, validationType) {
2987
- return flow(function (v) {
2988
- return find(v, validationType);
2989
- }, function (v) {
2990
- return get(v, validationType);
2991
- })(field.validations);
2992
- };
2993
-
2994
- var isFormattingOptionEnabled = function isFormattingOptionEnabled(field, validationType, nodeTypeOrMark) {
2995
- var enabledFormattings = getRichTextValidation(field, validationType); // TODO: In the future, validations will always be opt-in. In that case
2996
- // we don't need this step.
2997
-
2998
- if (enabledFormattings === undefined) {
2999
- return true;
3000
- }
3001
-
3002
- return DEFAULT_ENABLED_NODE_TYPES.concat(enabledFormattings).includes(nodeTypeOrMark);
3003
- };
3004
-
3005
- var isNodeTypeEnabled = function isNodeTypeEnabled(field, nodeType) {
3006
- return isFormattingOptionEnabled(field, VALIDATIONS.ENABLED_NODE_TYPES, nodeType);
3007
- };
3008
- var isMarkEnabled = function isMarkEnabled(field, mark) {
3009
- return isFormattingOptionEnabled(field, VALIDATIONS.ENABLED_MARKS, mark);
3010
- };
3011
-
3012
3048
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _dropdown, _LABELS;
3013
3049
  var styles$5 = {
3014
3050
  dropdown: (_dropdown = {