@contentful/field-editor-rich-text 2.0.4 → 2.1.2

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 (27) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/field-editor-rich-text.cjs.development.js +1117 -585
  3. package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
  4. package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
  5. package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
  6. package/dist/field-editor-rich-text.esm.js +1097 -565
  7. package/dist/field-editor-rich-text.esm.js.map +1 -1
  8. package/dist/helpers/removeInternalMarks.d.ts +1 -0
  9. package/dist/plugins/CommandPalette/components/CommandList.d.ts +6 -0
  10. package/dist/plugins/CommandPalette/components/CommandList.styles.d.ts +13 -0
  11. package/dist/plugins/CommandPalette/components/CommandPrompt.d.ts +2 -0
  12. package/dist/plugins/CommandPalette/constants.d.ts +1 -0
  13. package/dist/plugins/CommandPalette/createCommandPalettePlugin.d.ts +13 -0
  14. package/dist/plugins/CommandPalette/hooks/useCommandList.d.ts +3 -0
  15. package/dist/plugins/CommandPalette/index.d.ts +1 -0
  16. package/dist/plugins/CommandPalette/onKeyDown.d.ts +3 -0
  17. package/dist/plugins/CommandPalette/useCommands.d.ts +14 -0
  18. package/dist/plugins/CommandPalette/utils/createInlineEntryNode.d.ts +16 -0
  19. package/dist/plugins/CommandPalette/utils/fetchAssets.d.ts +8 -0
  20. package/dist/plugins/CommandPalette/utils/fetchEntries.d.ts +9 -0
  21. package/dist/plugins/CommandPalette/utils/insertBlock.d.ts +1 -0
  22. package/dist/plugins/CommandPalette/utils/trimLeadingSlash.d.ts +7 -0
  23. package/package.json +3 -3
  24. package/dist/plugins/SlashCommands/SlashCommandsPalette.d.ts +0 -5
  25. package/dist/plugins/SlashCommands/createSlashCommandsPlugin.d.ts +0 -2
  26. package/dist/plugins/SlashCommands/helpers.d.ts +0 -6
  27. package/dist/plugins/SlashCommands/index.d.ts +0 -2
@@ -1,24 +1,24 @@
1
- import React__default, { createContext, useContext, useMemo, useState, useEffect, memo, createElement, Fragment, useCallback } from 'react';
1
+ import React__default, { createContext, useContext, useMemo, useState, useEffect, useRef, createElement, Fragment, memo, useCallback } from 'react';
2
2
  import { useEntities, MissingEntityCard, WrappedAssetCard, WrappedEntryCard, ScheduledIconWithTooltip, EntityProvider, getScheduleTooltipContent } from '@contentful/field-editor-reference';
3
3
  import { entityHelpers, ModalDialogLauncher, FieldConnector } from '@contentful/field-editor-shared';
4
4
  import { BLOCKS, INLINES, TEXT_CONTAINERS, HEADINGS, LIST_ITEM_BLOCKS, MARKS, CONTAINERS, TOP_LEVEL_BLOCKS, VOID_BLOCKS, EMPTY_DOCUMENT } from '@contentful/rich-text-types';
5
- import { usePlateEditorRef, usePlateEditorState, getNodes, toggleNodeType, getText, getAbove, setNodes, isAncestorEmpty, match, getLastChildPath, wrapNodes, getPluginType, unwrapNodes, isCollapsed, isRangeAcrossBlocks, ELEMENT_DEFAULT, findNode, getParent, getBlockAbove, isSelectionAtBlockStart, isSelectionAtBlockEnd, isFirstChild, insertNodes, moveChildren, isBlockAboveEmpty, mockPlugin, deleteFragment, isMarkActive, toggleMark, someHtmlElement, KEY_DESERIALIZE_HTML, hasSingleChild, isLastChild, someNode, getChildren as getChildren$1, queryNode, createDeserializeHtmlPlugin, createDeserializeAstPlugin, createPlateEditor, getPlateSelectors, getPlateActions, Plate } from '@udecode/plate-core';
5
+ import { usePlateEditorRef, usePlateEditorState, toggleNodeType, getText, getAbove, removeMark, setMarks, isMarkActive, getNodes, setNodes, isAncestorEmpty, match, getLastChildPath, wrapNodes, getPluginType, unwrapNodes, isCollapsed, isRangeAcrossBlocks, ELEMENT_DEFAULT, findNode, getParent, getBlockAbove, isSelectionAtBlockStart, isSelectionAtBlockEnd, isFirstChild, insertNodes, moveChildren, isBlockAboveEmpty, mockPlugin, deleteFragment, toggleMark, someHtmlElement, KEY_DESERIALIZE_HTML, hasSingleChild, isLastChild, someNode, getChildren as getChildren$1, queryNode, createDeserializeHtmlPlugin, createDeserializeAstPlugin, createPlateEditor, getPlateSelectors, getPlateActions, Plate } from '@udecode/plate-core';
6
6
  import { css, cx } from 'emotion';
7
7
  import areEqual from 'fast-deep-equal';
8
8
  import noop from 'lodash-es/noop';
9
9
  import { createDeserializeDocxPlugin } from '@udecode/plate-serializer-docx';
10
10
  import { createSoftBreakPlugin as createSoftBreakPlugin$1, createExitBreakPlugin as createExitBreakPlugin$1 } from '@udecode/plate-break';
11
11
  import { createResetNodePlugin as createResetNodePlugin$1, onKeyDownResetNode, SIMULATE_BACKSPACE } from '@udecode/plate-reset-node';
12
- import isHotkey from 'is-hotkey';
13
12
  import { Text, Element, Editor, Transforms, Range, Path, Node, Point } from 'slate';
14
13
  import { ReactEditor, useSelected, useReadOnly, useFocused } from 'slate-react';
14
+ import { ScreenReaderOnly, Popover, SectionHeading, Stack, Flex, AssetCard, EntryCard, Menu, Icon, InlineEntryCard, MenuItem, Text as Text$1, Button, Tooltip, ModalContent, Form, FormControl, TextInput, Select, FormLabel, TextLink, ModalControls, IconButton } from '@contentful/f36-components';
15
15
  import constate from 'constate';
16
- import { AssetCard, EntryCard, Menu, Flex, Icon, InlineEntryCard, MenuItem, Text as Text$1, Button, Tooltip, ModalContent, Form, FormControl, TextInput, Select, FormLabel, TextLink, ModalControls, Card, IconButton } from '@contentful/f36-components';
16
+ import isHotkey from 'is-hotkey';
17
+ import tokens from '@contentful/f36-tokens';
17
18
  import find from 'lodash-es/find';
18
19
  import flow from 'lodash-es/flow';
19
20
  import get from 'lodash-es/get';
20
21
  import { AssetIcon, EmbeddedEntryBlockIcon, ClockIcon, EmbeddedEntryInlineIcon, ChevronDownIcon, HorizontalRuleIcon, LinkIcon, ListBulletedIcon, ListNumberedIcon, FormatBoldIcon, CodeIcon, FormatItalicIcon, FormatUnderlinedIcon, QuoteIcon, TableIcon, PlusIcon } from '@contentful/f36-icons';
21
- import tokens from '@contentful/f36-tokens';
22
22
  import { getListTypes, ELEMENT_LIC, getListItemEntry, isListNested, moveListItemUp, ELEMENT_LI, unwrapList as unwrapList$1, removeFirstListItem, removeListItem, deleteForwardList, deleteFragmentList, normalizeList, createListPlugin as createListPlugin$1, ELEMENT_UL, ELEMENT_OL } from '@udecode/plate-list';
23
23
  import castArray from 'lodash-es/castArray';
24
24
  import { createBoldPlugin as createBoldPlugin$1, createCodePlugin as createCodePlugin$1, createItalicPlugin as createItalicPlugin$1, createUnderlinePlugin as createUnderlinePlugin$1 } from '@udecode/plate-basic-marks';
@@ -334,65 +334,6 @@ var createResetNodePlugin = function createResetNodePlugin() {
334
334
  });
335
335
  };
336
336
 
337
- function createDragAndDropPlugin() {
338
- var DRAGGABLE_TYPES = [BLOCKS.EMBEDDED_ENTRY, BLOCKS.EMBEDDED_ASSET, BLOCKS.HR, INLINES.EMBEDDED_ENTRY];
339
- /**
340
- * HTML node names where dropping should be allowed
341
- * Usually for elements where `Transforms.removeNodes` is needed
342
- * TODO: looking up for html nodes is not the best solution and it won't scale but it works fine for our current cases/elements
343
- */
344
-
345
- var ON_DROP_ALLOWED_TYPES = {
346
- TABLE: [INLINES.EMBEDDED_ENTRY]
347
- };
348
- return {
349
- key: 'DragAndDropPlugin',
350
- handlers: {
351
- // If true, the next handlers will be skipped.
352
- onDrop: function onDrop(editor) {
353
- return function (event) {
354
- var _Array$from = Array.from(getNodes(editor, {
355
- match: function match(node) {
356
- return DRAGGABLE_TYPES.includes(node == null ? void 0 : node.type);
357
- }
358
- })),
359
- draggingBlock = _Array$from[0];
360
-
361
- if (!draggingBlock) return false;
362
- var draggingNode = draggingBlock[0];
363
- 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
364
-
365
- var dropDisallowed = getParents(event.nativeEvent.target).some(function (node) {
366
- var _ON_DROP_ALLOWED_TYPE;
367
-
368
- 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;
369
- });
370
-
371
- if (!dropDisallowed) {
372
- // Move the drop event to a new undo batch mitigating the bug where undo not only moves it back,
373
- // but also undoes a previous action: https://github.com/ianstormtaylor/slate/issues/4694
374
- editor.history.undos.push([]);
375
- }
376
-
377
- return dropDisallowed;
378
- };
379
- }
380
- }
381
- };
382
- }
383
-
384
- function getParents(el) {
385
- var parents = [];
386
- parents.push(el);
387
-
388
- while (el.parentNode) {
389
- parents.unshift(el.parentNode);
390
- el = el.parentNode;
391
- }
392
-
393
- return parents;
394
- }
395
-
396
337
  var IS_SAFARI = typeof navigator !== 'undefined' && /*#__PURE__*/ /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
397
338
  var IS_CHROME = /*#__PURE__*/ /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9.]+)(:?\s|$)/.test(navigator.userAgent);
398
339
 
@@ -597,16 +538,18 @@ function toggleElement(editor, options, editorOptions) {
597
538
  });
598
539
  }
599
540
 
600
- function withLinkTracking(Component) {
601
- return function ComponentWithTracking(props) {
602
- var editor = useContentfulEditorRef();
603
- var onEntityFetchComplete = React__default.useCallback(function () {
604
- return editor.tracking.onViewportAction('linkRendered');
605
- }, [editor]);
606
- return /*#__PURE__*/React__default.createElement(Component, Object.assign({}, props, {
607
- onEntityFetchComplete: onEntityFetchComplete
608
- }));
609
- };
541
+ /**
542
+ * Trim leading slash character if found. Bails otherwise.
543
+ *
544
+ * @example
545
+ * trimLeadingSlash("/my query") // --> "my query"
546
+ */
547
+ function trimLeadingSlash(text) {
548
+ if (!text.startsWith('/')) {
549
+ return text;
550
+ }
551
+
552
+ return text.slice(1);
610
553
  }
611
554
 
612
555
  function useSdk(_ref) {
@@ -622,233 +565,106 @@ var _constate = /*#__PURE__*/constate(useSdk),
622
565
  SdkProvider = _constate[0],
623
566
  useSdkContext = _constate[1];
624
567
 
625
- function useFetchedEntity(_ref) {
626
- var type = _ref.type,
627
- id = _ref.id,
628
- onEntityFetchComplete = _ref.onEntityFetchComplete;
629
-
630
- var _useEntities = useEntities(),
631
- entries = _useEntities.entries,
632
- assets = _useEntities.assets,
633
- getOrLoadEntry = _useEntities.getOrLoadEntry,
634
- getOrLoadAsset = _useEntities.getOrLoadAsset;
635
-
636
- var store = type === 'Entry' ? entries : assets;
637
-
638
- var _useState = useState(store[id]),
639
- entity = _useState[0],
640
- setEntity = _useState[1]; // Deep compare the entity value to keep re-rendering to minimal
568
+ var useCommandList = function useCommandList(commandItems, container) {
569
+ var _React$useState = useState(function () {
570
+ // select the first item on initial render
571
+ if ('group' in commandItems[0]) {
572
+ return commandItems[0].commands[0].id;
573
+ }
641
574
 
575
+ return commandItems[0].id;
576
+ }),
577
+ selectedItem = _React$useState[0],
578
+ setSelectedItem = _React$useState[1];
642
579
 
643
580
  useEffect(function () {
644
- var newValue = store[id];
645
-
646
- if (!areEqual(entity, newValue)) {
647
- setEntity(newValue);
581
+ if (!(container != null && container.current)) {
582
+ return;
648
583
  }
649
- }, [store, entity, id]); // Fetch the entity if needed
650
584
 
651
- useEffect(function () {
652
- (type === 'Entry' ? getOrLoadEntry : getOrLoadAsset)(id); // "getOrLoadEntry" and "getOrLoadAsset" instances change with every
653
- // entity store update causing page lag on initial load
654
- // TODO: consider rewriting useEntities() hook to avoid that happening in
655
- // first place.
656
- // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: explain this disable
657
- }, [type, id]);
658
- useEffect(function () {
659
- if (entity) {
660
- onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
585
+ var buttons = Array.from(container.current.querySelectorAll('button'));
586
+ var currBtn = buttons.find(function (btn) {
587
+ return btn.id === selectedItem;
588
+ });
589
+ var currIndex = currBtn ? buttons.indexOf(currBtn) : 0;
590
+ var shouldSelectFirstBtn = !currBtn && buttons.length;
591
+
592
+ if (shouldSelectFirstBtn) {
593
+ setSelectedItem(buttons[0].id);
594
+ buttons[0].scrollIntoView({
595
+ block: 'nearest',
596
+ inline: 'start'
597
+ });
661
598
  }
662
- }, [onEntityFetchComplete, entity]);
663
- return entity;
664
- }
665
599
 
666
- var InternalAssetCard = /*#__PURE__*/memo(function (props) {
667
- if (props.asset === undefined) {
668
- return /*#__PURE__*/createElement(AssetCard, {
669
- size: "default",
670
- isLoading: true
671
- });
672
- }
600
+ function handleKeyDown(event) {
601
+ if (isHotkey('up', event)) {
602
+ event.preventDefault();
673
603
 
674
- if (props.asset === 'failed') {
675
- return /*#__PURE__*/createElement(MissingEntityCard, {
676
- entityType: "Asset",
677
- isDisabled: props.isDisabled,
678
- onRemove: props.onRemove
679
- });
680
- }
604
+ if (currIndex === 0) {
605
+ return;
606
+ }
681
607
 
682
- return /*#__PURE__*/createElement(WrappedAssetCard, {
683
- getEntityScheduledActions: props.loadEntityScheduledActions,
684
- size: "small",
685
- isSelected: props.isSelected,
686
- isDisabled: props.isDisabled,
687
- localeCode: props.locale,
688
- defaultLocaleCode: props.sdk.locales["default"],
689
- asset: props.asset,
690
- onEdit: props.onEdit,
691
- onRemove: props.isDisabled ? undefined : props.onRemove,
692
- isClickable: false
693
- });
694
- }, areEqual);
695
- InternalAssetCard.displayName = 'InternalAssetCard';
696
- function FetchingWrappedAssetCard(props) {
697
- var onEntityFetchComplete = props.onEntityFetchComplete,
698
- assetId = props.assetId;
608
+ setSelectedItem(buttons[currIndex - 1].id);
609
+ buttons[currIndex - 1].scrollIntoView({
610
+ block: 'nearest',
611
+ inline: 'start'
612
+ });
613
+ } else if (isHotkey('down', event)) {
614
+ event.preventDefault();
699
615
 
700
- var _useEntities = useEntities(),
701
- loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
616
+ if (currIndex === buttons.length - 1) {
617
+ return;
618
+ }
702
619
 
703
- var asset = useFetchedEntity({
704
- type: 'Asset',
705
- id: assetId,
706
- onEntityFetchComplete: onEntityFetchComplete
707
- });
708
- return /*#__PURE__*/createElement(InternalAssetCard, {
709
- asset: asset,
710
- sdk: props.sdk,
711
- isDisabled: props.isDisabled,
712
- isSelected: props.isSelected,
713
- loadEntityScheduledActions: loadEntityScheduledActions,
714
- locale: props.locale,
715
- onEdit: props.onEdit,
716
- onRemove: props.onRemove
717
- });
718
- }
620
+ setSelectedItem(buttons[currIndex + 1].id);
621
+ buttons[currIndex + 1].scrollIntoView({
622
+ block: 'nearest',
623
+ inline: 'start'
624
+ });
625
+ } else if (isHotkey('enter', event)) {
626
+ event.preventDefault();
719
627
 
720
- var InternalEntryCard = /*#__PURE__*/memo(function (props) {
721
- var entry = props.entry,
722
- sdk = props.sdk,
723
- loadEntityScheduledActions = props.loadEntityScheduledActions;
628
+ if (currBtn) {
629
+ setSelectedItem('');
630
+ currBtn.click();
631
+ }
632
+ } //TODO: handle shift+enter, which must be detected using separate events
724
633
 
725
- if (entry === undefined) {
726
- return /*#__PURE__*/createElement(EntryCard, {
727
- isLoading: true
728
- });
729
- }
634
+ }
730
635
 
731
- if (entry === 'failed') {
732
- return /*#__PURE__*/createElement(MissingEntityCard, {
733
- entityType: "Entry",
734
- isDisabled: props.isDisabled,
735
- onRemove: props.onRemove
736
- });
737
- }
636
+ if (commandItems.length) {
637
+ window.addEventListener('keydown', handleKeyDown);
638
+ }
738
639
 
739
- var contentType = sdk.space.getCachedContentTypes().find(function (contentType) {
740
- return contentType.sys.id === entry.sys.contentType.sys.id;
741
- });
742
- return /*#__PURE__*/createElement(WrappedEntryCard, {
743
- size: "default",
744
- getAsset: props.sdk.space.getAsset,
745
- getEntityScheduledActions: loadEntityScheduledActions,
746
- isSelected: props.isSelected,
747
- isDisabled: props.isDisabled,
748
- localeCode: props.locale,
749
- defaultLocaleCode: props.sdk.locales["default"],
750
- contentType: contentType,
751
- entry: entry,
752
- onEdit: props.onEdit,
753
- onRemove: props.isDisabled ? undefined : props.onRemove,
754
- isClickable: false
755
- });
756
- }, areEqual);
757
- InternalEntryCard.displayName = 'ReferenceCard';
758
- var FetchingWrappedEntryCard = function FetchingWrappedEntryCard(props) {
759
- var entryId = props.entryId,
760
- onEntityFetchComplete = props.onEntityFetchComplete;
640
+ return function () {
641
+ return window.removeEventListener('keydown', handleKeyDown);
642
+ };
643
+ }, [commandItems, container, selectedItem]);
644
+ return {
645
+ selectedItem: selectedItem
646
+ };
647
+ };
761
648
 
762
- var _useEntities = useEntities(),
763
- loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
649
+ var COMMAND_PROMPT = 'command-prompt';
764
650
 
765
- var entry = useFetchedEntity({
766
- type: 'Entry',
767
- id: entryId,
768
- onEntityFetchComplete: onEntityFetchComplete
769
- });
770
- return /*#__PURE__*/createElement(InternalEntryCard, {
771
- entry: entry,
772
- sdk: props.sdk,
773
- locale: props.locale,
774
- isDisabled: props.isDisabled,
775
- isSelected: props.isSelected,
776
- onEdit: props.onEdit,
777
- onRemove: props.onRemove,
778
- loadEntityScheduledActions: loadEntityScheduledActions
779
- });
780
- };
781
-
782
- var styles = {
783
- root: /*#__PURE__*/css({
784
- marginBottom: '1.25rem !important',
785
- display: 'block'
786
- }),
787
- container: /*#__PURE__*/css({
788
- // The next 2 properties ensure Entity card won't be aligned above
789
- // a list item marker (i.e. bullet)
790
- display: 'inline-block',
791
- verticalAlign: 'text-top',
792
- width: '100%'
793
- })
794
- };
795
- function LinkedEntityBlock(props) {
796
- var attributes = props.attributes,
797
- children = props.children,
798
- element = props.element,
799
- onEntityFetchComplete = props.onEntityFetchComplete;
800
- var isSelected = useSelected();
801
- var editor = useContentfulEditor();
802
- var sdk = useSdkContext();
803
- var isDisabled = useReadOnly();
804
- var _element$data$target$ = element.data.target.sys,
805
- entityId = _element$data$target$.id,
806
- entityType = _element$data$target$.linkType;
807
- var handleEditClick = React__default.useCallback(function () {
808
- var openEntity = entityType === 'Asset' ? sdk.navigator.openAsset : sdk.navigator.openEntry;
809
- return openEntity(entityId, {
810
- slideIn: true
811
- });
812
- }, [sdk, entityId, entityType]);
813
- var handleRemoveClick = React__default.useCallback(function () {
814
- if (!editor) return;
815
- var pathToElement = ReactEditor.findPath(editor, element);
816
- Transforms.removeNodes(editor, {
817
- at: pathToElement
818
- });
819
- }, [editor, element]);
820
- return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
821
- className: styles.root,
822
- "data-entity-type": entityType,
823
- "data-entity-id": entityId,
824
- // COMPAT: This makes copy & paste work for Firefox
825
- contentEditable: IS_CHROME ? undefined : false,
826
- draggable: IS_CHROME ? true : undefined
827
- }), /*#__PURE__*/React__default.createElement("div", {
828
- // COMPAT: This makes copy & paste work for Chromium/Blink browsers and Safari
829
- contentEditable: IS_CHROME ? false : undefined,
830
- draggable: IS_CHROME ? true : undefined,
831
- className: styles.container
832
- }, entityType === 'Entry' && /*#__PURE__*/React__default.createElement(FetchingWrappedEntryCard, {
833
- sdk: sdk,
834
- entryId: entityId,
835
- locale: sdk.field.locale,
836
- isDisabled: isDisabled,
837
- isSelected: isSelected,
838
- onRemove: handleRemoveClick,
839
- onEdit: handleEditClick,
840
- onEntityFetchComplete: onEntityFetchComplete
841
- }), entityType === 'Asset' && /*#__PURE__*/React__default.createElement(FetchingWrappedAssetCard, {
842
- sdk: sdk,
843
- assetId: entityId,
844
- locale: sdk.field.locale,
845
- isDisabled: isDisabled,
846
- isSelected: isSelected,
847
- onRemove: handleRemoveClick,
848
- onEdit: handleEditClick,
849
- onEntityFetchComplete: onEntityFetchComplete
850
- })), children);
851
- }
651
+ function createInlineEntryNode(id) {
652
+ return {
653
+ type: INLINES.EMBEDDED_ENTRY,
654
+ children: [{
655
+ text: ''
656
+ }],
657
+ data: {
658
+ target: {
659
+ sys: {
660
+ id: id,
661
+ type: 'Link',
662
+ linkType: 'Entry'
663
+ }
664
+ }
665
+ }
666
+ };
667
+ }
852
668
 
853
669
  function createCommonjsModule(fn, module) {
854
670
  return module = { exports: {} }, fn(module, module.exports), module.exports;
@@ -1542,41 +1358,920 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
1542
1358
  nextLoc: nextLoc
1543
1359
  };
1544
1360
 
1545
- if (this.method === "next") {
1546
- // Deliberately forget the last sent value so that we don't
1547
- // accidentally pass it on to the delegate.
1548
- this.arg = undefined$1;
1549
- }
1361
+ if (this.method === "next") {
1362
+ // Deliberately forget the last sent value so that we don't
1363
+ // accidentally pass it on to the delegate.
1364
+ this.arg = undefined$1;
1365
+ }
1366
+
1367
+ return ContinueSentinel;
1368
+ }
1369
+ }; // Regardless of whether this script is executing as a CommonJS module
1370
+ // or not, return the runtime object so that we can declare the variable
1371
+ // regeneratorRuntime in the outer scope, which allows this module to be
1372
+ // injected easily by `bin/regenerator --include-runtime script.js`.
1373
+
1374
+ return exports;
1375
+ }( // If this script is executing as a CommonJS module, use module.exports
1376
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
1377
+ // object. Either way, the resulting object will be used to initialize
1378
+ // the regeneratorRuntime variable at the top of this file.
1379
+ module.exports );
1380
+
1381
+ try {
1382
+ regeneratorRuntime = runtime;
1383
+ } catch (accidentalStrictMode) {
1384
+ // This module should not be running in strict mode, so the above
1385
+ // assignment should always work unless something is misconfigured. Just
1386
+ // in case runtime.js accidentally runs in strict mode, we can escape
1387
+ // strict mode using a global Function call. This could conceivably fail
1388
+ // if a Content Security Policy forbids using Function, but in that case
1389
+ // the proper solution is to fix the accidental strict mode problem. If
1390
+ // you've misconfigured your bundler to force strict mode and applied a
1391
+ // CSP to forbid Function, and you're not willing to fix either of those
1392
+ // problems, please detail your unique predicament in a GitHub issue.
1393
+ Function("r", "regeneratorRuntime = r")(runtime);
1394
+ }
1395
+ });
1396
+
1397
+ function fetchAssets(_x, _x2) {
1398
+ return _fetchAssets.apply(this, arguments);
1399
+ }
1400
+
1401
+ function _fetchAssets() {
1402
+ _fetchAssets = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(sdk, query) {
1403
+ var assets;
1404
+ return runtime_1.wrap(function _callee$(_context) {
1405
+ while (1) {
1406
+ switch (_context.prev = _context.next) {
1407
+ case 0:
1408
+ _context.next = 2;
1409
+ return sdk.space.getAssets({
1410
+ query: query
1411
+ });
1412
+
1413
+ case 2:
1414
+ assets = _context.sent;
1415
+ return _context.abrupt("return", assets.items.map(function (asset) {
1416
+ var displayTitle = entityHelpers.getAssetTitle({
1417
+ asset: asset,
1418
+ localeCode: sdk.field.locale,
1419
+ defaultLocaleCode: sdk.locales["default"],
1420
+ defaultTitle: 'Untitled'
1421
+ });
1422
+ return {
1423
+ contentTypeName: 'Asset',
1424
+ displayTitle: displayTitle,
1425
+ id: asset.sys.id,
1426
+ entity: asset,
1427
+ thumbnail: asset.fields.file && asset.fields.file[sdk.field.locale] && asset.fields.file[sdk.field.locale].url + "?h=30"
1428
+ };
1429
+ }));
1430
+
1431
+ case 4:
1432
+ case "end":
1433
+ return _context.stop();
1434
+ }
1435
+ }
1436
+ }, _callee);
1437
+ }));
1438
+ return _fetchAssets.apply(this, arguments);
1439
+ }
1440
+
1441
+ function fetchEntries(_x, _x2, _x3) {
1442
+ return _fetchEntries.apply(this, arguments);
1443
+ }
1444
+
1445
+ function _fetchEntries() {
1446
+ _fetchEntries = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(sdk, contentType, query) {
1447
+ var entries;
1448
+ return runtime_1.wrap(function _callee$(_context) {
1449
+ while (1) {
1450
+ switch (_context.prev = _context.next) {
1451
+ case 0:
1452
+ _context.next = 2;
1453
+ return sdk.space.getEntries({
1454
+ content_type: contentType.sys.id,
1455
+ query: query
1456
+ });
1457
+
1458
+ case 2:
1459
+ entries = _context.sent;
1460
+ return _context.abrupt("return", entries.items.map(function (entry) {
1461
+ var description = entityHelpers.getEntityDescription({
1462
+ contentType: contentType,
1463
+ // @ts-expect-error inconsistent in typing between app-sdk & field-editors-shared
1464
+ entity: entry,
1465
+ localeCode: sdk.field.locale,
1466
+ defaultLocaleCode: sdk.locales["default"]
1467
+ });
1468
+ var displayTitle = entityHelpers.getEntryTitle({
1469
+ // @ts-expect-error inconsistent in typing between app-sdk & field-editors-shared
1470
+ entry: entry,
1471
+ contentType: contentType,
1472
+ localeCode: sdk.field.locale,
1473
+ defaultLocaleCode: sdk.locales["default"],
1474
+ defaultTitle: 'Untitled'
1475
+ });
1476
+ return {
1477
+ contentTypeName: contentType.name,
1478
+ displayTitle: displayTitle,
1479
+ id: entry.sys.contentType.sys.id,
1480
+ description: description,
1481
+ entry: entry
1482
+ };
1483
+ }));
1484
+
1485
+ case 4:
1486
+ case "end":
1487
+ return _context.stop();
1488
+ }
1489
+ }
1490
+ }, _callee);
1491
+ }));
1492
+ return _fetchEntries.apply(this, arguments);
1493
+ }
1494
+
1495
+ var createNode = function createNode(nodeType, entity) {
1496
+ return {
1497
+ type: nodeType,
1498
+ data: {
1499
+ target: {
1500
+ sys: {
1501
+ id: entity.sys.id,
1502
+ type: 'Link',
1503
+ linkType: entity.sys.type
1504
+ }
1505
+ }
1506
+ },
1507
+ children: [{
1508
+ text: ''
1509
+ }],
1510
+ isVoid: true
1511
+ };
1512
+ };
1513
+
1514
+ function insertBlock(editor, nodeType, entity) {
1515
+ if (!(editor != null && editor.selection)) return;
1516
+ var linkedEntityBlock = createNode(nodeType, entity);
1517
+ var hasText = editor.selection && !!getText(editor, editor.selection.focus.path);
1518
+
1519
+ if (hasText) {
1520
+ Transforms.insertNodes(editor, linkedEntityBlock);
1521
+ } else {
1522
+ Transforms.setNodes(editor, linkedEntityBlock);
1523
+ }
1524
+
1525
+ focus(editor);
1526
+ }
1527
+
1528
+ var removeCommand = function removeCommand(editor) {
1529
+ var _getAbove = getAbove(editor),
1530
+ path = _getAbove[1];
1531
+
1532
+ var range = Editor.range(editor, path);
1533
+ Transforms.select(editor, range.focus.path);
1534
+ removeMark(editor, {
1535
+ key: COMMAND_PROMPT,
1536
+ at: range
1537
+ });
1538
+ Transforms["delete"](editor);
1539
+ };
1540
+
1541
+ var removeQuery = function removeQuery(editor) {
1542
+ var _getAbove2 = getAbove(editor),
1543
+ path = _getAbove2[1];
1544
+
1545
+ var range = Editor.range(editor, path);
1546
+
1547
+ if (range.focus.offset - range.anchor.offset > 1) {
1548
+ Transforms["delete"](editor, {
1549
+ at: range.focus,
1550
+ distance: range.focus.offset - 1,
1551
+ reverse: true
1552
+ });
1553
+ }
1554
+ };
1555
+
1556
+ var useCommands = function useCommands(sdk, query, editor) {
1557
+ var contentTypes = sdk.space.getCachedContentTypes();
1558
+
1559
+ var _useState = useState(function () {
1560
+ var contentTypeCommands = contentTypes.map(function (contentType) {
1561
+ return {
1562
+ group: contentType.name,
1563
+ commands: [{
1564
+ id: contentType.sys.id,
1565
+ label: "Embed " + contentType.name,
1566
+ callback: function callback() {
1567
+ fetchEntries(sdk, contentType, query).then(function (entries) {
1568
+ removeQuery(editor);
1569
+
1570
+ if (!entries.length) {
1571
+ setCommands([{
1572
+ id: 'no-results',
1573
+ label: 'No results'
1574
+ }]);
1575
+ } else {
1576
+ setCommands(entries.map(function (entry) {
1577
+ return {
1578
+ id: entry.id + "-" + entry.displayTitle.replace(/\W+/g, '-').toLowerCase(),
1579
+ label: entry.displayTitle,
1580
+ callback: function callback() {
1581
+ removeCommand(editor);
1582
+
1583
+ if (editor.selection) {
1584
+ var selection = editor.selection;
1585
+ editor.insertSoftBreak();
1586
+ insertBlock(editor, BLOCKS.EMBEDDED_ENTRY, entry.entry);
1587
+ Transforms.select(editor, selection);
1588
+ }
1589
+ }
1590
+ };
1591
+ }));
1592
+ }
1593
+ });
1594
+ }
1595
+ }, {
1596
+ id: contentType.sys.id + "-inline",
1597
+ label: "Embed " + contentType.name + " - Inline",
1598
+ callback: function callback() {
1599
+ fetchEntries(sdk, contentType, query).then(function (entries) {
1600
+ removeQuery(editor);
1601
+
1602
+ if (!entries.length) {
1603
+ setCommands([{
1604
+ id: 'no-results',
1605
+ label: 'No results'
1606
+ }]);
1607
+ } else {
1608
+ setCommands(entries.map(function (entry) {
1609
+ return {
1610
+ id: entry.id + "-" + entry.displayTitle.replace(/\W+/g, '-').toLowerCase(),
1611
+ label: entry.displayTitle,
1612
+ callback: function callback() {
1613
+ var inlineNode = createInlineEntryNode(entry.id);
1614
+ removeCommand(editor);
1615
+ Transforms.insertNodes(editor, inlineNode);
1616
+ editor.insertText('');
1617
+ }
1618
+ };
1619
+ }));
1620
+ }
1621
+ });
1622
+ }
1623
+ }]
1624
+ };
1625
+ });
1626
+ var assetCommand = {
1627
+ group: 'Assets',
1628
+ commands: [{
1629
+ id: 'embed-asset',
1630
+ label: 'Embed Asset',
1631
+ callback: function callback() {
1632
+ fetchAssets(sdk, query).then(function (assets) {
1633
+ removeQuery(editor);
1634
+
1635
+ if (!assets.length) {
1636
+ setCommands([{
1637
+ id: 'no-results',
1638
+ label: 'No results'
1639
+ }]);
1640
+ } else {
1641
+ setCommands(assets.map(function (asset) {
1642
+ return {
1643
+ id: asset.id + "-" + asset.displayTitle.replace(/\W+/g, '-').toLowerCase(),
1644
+ label: asset.displayTitle,
1645
+ thumbnail: asset.thumbnail,
1646
+ callback: function callback() {
1647
+ removeCommand(editor);
1648
+
1649
+ if (editor.selection) {
1650
+ var selection = editor.selection;
1651
+ editor.insertSoftBreak();
1652
+ insertBlock(editor, BLOCKS.EMBEDDED_ASSET, asset.entity);
1653
+ Transforms.select(editor, selection);
1654
+ }
1655
+ }
1656
+ };
1657
+ }));
1658
+ }
1659
+ });
1660
+ }
1661
+ }]
1662
+ };
1663
+ return [].concat(contentTypeCommands, [assetCommand]);
1664
+ }),
1665
+ commands = _useState[0],
1666
+ setCommands = _useState[1];
1667
+ /* filter both commands and groups of commands with the user typed query */
1668
+
1669
+
1670
+ return query ? commands.reduce(function (list, nextItem) {
1671
+ if ('group' in nextItem) {
1672
+ var subcommands = nextItem.commands.filter(function (command) {
1673
+ return command.label.toLowerCase().includes(query.toLowerCase());
1674
+ });
1675
+
1676
+ if (subcommands.length > 0) {
1677
+ list.push(nextItem);
1678
+ }
1679
+ } else {
1680
+ if (nextItem.label.toLowerCase().includes(query.toLowerCase())) {
1681
+ list.push(nextItem);
1682
+ }
1683
+ }
1684
+
1685
+ return list;
1686
+ }, []) : commands;
1687
+ };
1688
+
1689
+ var styles = {
1690
+ container: /*#__PURE__*/css({
1691
+ position: 'absolute',
1692
+ zIndex: tokens.zIndexNotification,
1693
+ fontWeight: tokens.fontWeightNormal,
1694
+ fontStyle: 'normal',
1695
+ fontFamily: tokens.fontStackPrimary,
1696
+ 'ul, ol, dl': {
1697
+ listStyle: 'none',
1698
+ marginLeft: 0
1699
+ }
1700
+ }),
1701
+ menuContent: /*#__PURE__*/css({
1702
+ width: '400px',
1703
+ maxHeight: '300px'
1704
+ }),
1705
+ menuList: /*#__PURE__*/css({
1706
+ overflow: 'auto',
1707
+ maxHeight: '200px'
1708
+ }),
1709
+ menuItem: /*#__PURE__*/css({
1710
+ display: 'block',
1711
+ width: '100%',
1712
+ background: 'none',
1713
+ border: 0,
1714
+ margin: 0,
1715
+ outline: 'none',
1716
+ fontSize: tokens.fontSizeM,
1717
+ lineHeight: tokens.lineHeightM,
1718
+ fontWeight: tokens.fontWeightNormal,
1719
+ position: 'relative',
1720
+ textAlign: 'left',
1721
+ padding: tokens.spacingXs + " " + tokens.spacingM,
1722
+ wordBreak: 'break-word',
1723
+ whiteSpace: 'break-spaces',
1724
+ cursor: 'pointer',
1725
+ hyphens: 'auto',
1726
+ minWidth: '150px',
1727
+ textDecoration: 'none',
1728
+ color: tokens.gray800,
1729
+ '&:hover': {
1730
+ backgroundColor: tokens.gray100
1731
+ },
1732
+ '&:disabled': {
1733
+ opacity: 0.5,
1734
+ cursor: 'auto'
1735
+ }
1736
+ }),
1737
+ menuItemSelected: /*#__PURE__*/css({
1738
+ boxShadow: "inset " + tokens.glowPrimary,
1739
+ borderRadius: tokens.borderRadiusMedium
1740
+ }),
1741
+ menuDivider: /*#__PURE__*/css({
1742
+ border: 'none',
1743
+ width: '100%',
1744
+ height: '1px',
1745
+ background: tokens.gray300,
1746
+ margin: tokens.spacingXs + " 0"
1747
+ }),
1748
+ menuHeader: /*#__PURE__*/css({
1749
+ position: 'sticky',
1750
+ zIndex: tokens.zIndexDefault,
1751
+ top: 0,
1752
+ backgroundColor: tokens.gray100,
1753
+ padding: tokens.spacingM
1754
+ }),
1755
+ menuFooter: /*#__PURE__*/css({
1756
+ position: 'sticky',
1757
+ bottom: 0,
1758
+ backgroundColor: tokens.gray100,
1759
+ padding: tokens.spacingM
1760
+ }),
1761
+ footerList: /*#__PURE__*/css({
1762
+ listStyle: 'none',
1763
+ color: tokens.gray600,
1764
+ fontSize: tokens.fontSizeM
1765
+ }),
1766
+ thumbnail: /*#__PURE__*/css({
1767
+ width: '30px',
1768
+ height: '30px',
1769
+ objectFit: 'cover'
1770
+ })
1771
+ };
1772
+
1773
+ var Group = function Group(_ref) {
1774
+ var commandGroup = _ref.commandGroup,
1775
+ selectedItem = _ref.selectedItem;
1776
+ return /*#__PURE__*/createElement("section", {
1777
+ key: commandGroup.group
1778
+ }, /*#__PURE__*/createElement(SectionHeading, {
1779
+ as: "h3",
1780
+ marginBottom: "spacingS",
1781
+ marginTop: "spacingS",
1782
+ marginLeft: "spacingM",
1783
+ marginRight: "spacingM"
1784
+ }, commandGroup.group), commandGroup.commands.map(function (command) {
1785
+ var _cx;
1786
+
1787
+ return /*#__PURE__*/createElement("button", {
1788
+ key: command.id,
1789
+ id: command.id,
1790
+ className: cx(styles.menuItem, (_cx = {}, _cx[styles.menuItemSelected] = command.id === selectedItem, _cx)),
1791
+ onClick: command.callback
1792
+ }, command.label);
1793
+ }), /*#__PURE__*/createElement("hr", {
1794
+ className: styles.menuDivider,
1795
+ "aria-orientation": "horizontal"
1796
+ }));
1797
+ };
1798
+
1799
+ var Asset = function Asset(_ref2) {
1800
+ var _cx2;
1801
+
1802
+ var command = _ref2.command,
1803
+ selectedItem = _ref2.selectedItem;
1804
+ return /*#__PURE__*/createElement("button", {
1805
+ key: command.id,
1806
+ id: command.id,
1807
+ className: cx(styles.menuItem, (_cx2 = {}, _cx2[styles.menuItemSelected] = command.id === selectedItem, _cx2)),
1808
+ onClick: command.callback
1809
+ }, /*#__PURE__*/createElement(Flex, {
1810
+ alignItems: "center",
1811
+ gap: "spacingS"
1812
+ }, command.thumbnail && /*#__PURE__*/createElement("img", {
1813
+ width: "30",
1814
+ height: "30",
1815
+ src: command.thumbnail,
1816
+ alt: "",
1817
+ className: styles.thumbnail
1818
+ }), /*#__PURE__*/createElement("span", null, command.label)));
1819
+ };
1820
+
1821
+ var Item = function Item(_ref3) {
1822
+ var command = _ref3.command;
1823
+ return /*#__PURE__*/createElement("button", {
1824
+ key: command.id,
1825
+ id: command.id,
1826
+ className: styles.menuItem
1827
+ }, command.label);
1828
+ };
1829
+
1830
+ var CommandListItems = function CommandListItems(_ref4) {
1831
+ var commandItems = _ref4.commandItems,
1832
+ selectedItem = _ref4.selectedItem;
1833
+ return /*#__PURE__*/createElement(Fragment, null, commandItems.map(function (command) {
1834
+ return 'group' in command ? /*#__PURE__*/createElement(Group, {
1835
+ commandGroup: command,
1836
+ selectedItem: selectedItem
1837
+ }) : command.callback ? /*#__PURE__*/createElement(Asset, {
1838
+ command: command,
1839
+ selectedItem: selectedItem
1840
+ }) : /*#__PURE__*/createElement(Item, {
1841
+ command: command
1842
+ });
1843
+ }));
1844
+ };
1845
+
1846
+ var CommandList = function CommandList(_ref5) {
1847
+ var query = _ref5.query,
1848
+ editor = _ref5.editor;
1849
+ var sdk = useSdkContext();
1850
+ var container = useRef(null);
1851
+ var commandItems = useCommands(sdk, query, editor);
1852
+
1853
+ var _useCommandList = useCommandList(commandItems, container),
1854
+ selectedItem = _useCommandList.selectedItem;
1855
+
1856
+ if (commandItems.length === 0) {
1857
+ return null;
1858
+ }
1859
+
1860
+ return /*#__PURE__*/createElement("div", {
1861
+ className: styles.container,
1862
+ tabIndex: -1,
1863
+ ref: container,
1864
+ contentEditable: false
1865
+ }, /*#__PURE__*/createElement("div", {
1866
+ role: "alert"
1867
+ }, /*#__PURE__*/createElement(ScreenReaderOnly, null, "Richtext commands. Currently focused item: ", selectedItem, ". Press ", /*#__PURE__*/createElement("kbd", null, "enter"), " to select, ", /*#__PURE__*/createElement("kbd", null, "arrows"), " to navigate, ", /*#__PURE__*/createElement("kbd", null, "escape"), " to close.")), /*#__PURE__*/createElement("div", {
1868
+ "aria-hidden": true
1869
+ }, /*#__PURE__*/createElement(Popover, {
1870
+ isOpen: true,
1871
+ usePortal: false,
1872
+
1873
+ /* eslint-disable-next-line jsx-a11y/no-autofocus -- we want to keep focus on text input*/
1874
+ autoFocus: false
1875
+ }, /*#__PURE__*/createElement(Popover.Trigger, null, /*#__PURE__*/createElement("span", null)), /*#__PURE__*/createElement(Popover.Content, {
1876
+ className: styles.menuContent,
1877
+ testId: "rich-text-commands"
1878
+ }, /*#__PURE__*/createElement("header", {
1879
+ className: styles.menuHeader
1880
+ }, /*#__PURE__*/createElement(SectionHeading, {
1881
+ marginBottom: "none"
1882
+ }, "Richtext commands")), /*#__PURE__*/createElement("div", {
1883
+ className: styles.menuList,
1884
+ "data-test-id": "rich-text-commands-list"
1885
+ }, /*#__PURE__*/createElement(CommandListItems, {
1886
+ commandItems: commandItems,
1887
+ selectedItem: selectedItem
1888
+ })), /*#__PURE__*/createElement("footer", {
1889
+ className: styles.menuFooter
1890
+ }, /*#__PURE__*/createElement(Stack, {
1891
+ as: "ul",
1892
+ margin: "none",
1893
+ padding: "none",
1894
+ spacing: "spacingS",
1895
+ className: styles.footerList
1896
+ }, /*#__PURE__*/createElement("li", null, /*#__PURE__*/createElement("kbd", null, "\u2191"), /*#__PURE__*/createElement("kbd", null, "\u2193"), " to navigate"), /*#__PURE__*/createElement("li", null, /*#__PURE__*/createElement("kbd", null, "\u21B5"), " to confirm"), /*#__PURE__*/createElement("li", null, /*#__PURE__*/createElement("kbd", null, "esc"), " to close")))))));
1897
+ };
1898
+
1899
+ var CommandPrompt = function CommandPrompt(props) {
1900
+ var query = useMemo(function () {
1901
+ return trimLeadingSlash(props.text.text);
1902
+ }, [props.text.text]);
1903
+ var editor = props.editor;
1904
+ var canInsertBlocks = !isNodeTypeSelected(editor, BLOCKS.TABLE);
1905
+ return /*#__PURE__*/createElement("span", Object.assign({}, props.attributes), props.children, canInsertBlocks && /*#__PURE__*/createElement(CommandList, {
1906
+ query: query,
1907
+ editor: editor
1908
+ }));
1909
+ };
1910
+
1911
+ var createOnKeyDown = function createOnKeyDown() {
1912
+ return function (editor) {
1913
+ return function (event) {
1914
+ if (isHotkey('/', event)) {
1915
+ var _setMarks;
1916
+
1917
+ setMarks(editor, (_setMarks = {}, _setMarks[COMMAND_PROMPT] = true, _setMarks));
1918
+ }
1919
+
1920
+ var isActive = isMarkActive(editor, COMMAND_PROMPT);
1921
+
1922
+ if (isActive) {
1923
+ if (isHotkey('enter', event)) {
1924
+ event.preventDefault();
1925
+ } else if (isHotkey('backspace', event)) {
1926
+ var _getAbove = getAbove(editor),
1927
+ path = _getAbove[1];
1928
+
1929
+ var range = Editor.range(editor, path); // if it is the last character in the command string
1930
+
1931
+ if (range.focus.offset - range.anchor.offset === 1) {
1932
+ removeMark(editor, {
1933
+ key: COMMAND_PROMPT,
1934
+ at: range
1935
+ });
1936
+ }
1937
+ } else if (isHotkey('escape', event)) {
1938
+ var _getAbove2 = getAbove(editor),
1939
+ _path = _getAbove2[1];
1940
+
1941
+ var _range = Editor.range(editor, _path);
1942
+
1943
+ removeMark(editor, {
1944
+ key: COMMAND_PROMPT,
1945
+ at: _range
1946
+ });
1947
+ }
1948
+ }
1949
+ };
1950
+ };
1951
+ };
1952
+
1953
+ /**
1954
+ * A command palette plugin (aka slash commands)
1955
+ *
1956
+ * How does it work?
1957
+ * * When the user presses the slash key, the editor will show a command palette
1958
+ * * When the user presses a key, the command palette will show the command suggestions
1959
+ * * When the user presses enter, the command palette will execute the command
1960
+ * * When the user presses escape, the command palette will hide
1961
+ * * When the user presses a letter, number, or space, the command palette will show the command suggestions
1962
+ * * When the user presses backspace, the command palette will remove the last character from the command string
1963
+ */
1964
+
1965
+ var createCommandPalettePlugin = function createCommandPalettePlugin() {
1966
+ return {
1967
+ key: COMMAND_PROMPT,
1968
+ type: COMMAND_PROMPT,
1969
+ isLeaf: true,
1970
+ component: CommandPrompt,
1971
+ handlers: {
1972
+ onKeyDown: createOnKeyDown()
1973
+ }
1974
+ };
1975
+ };
1976
+
1977
+ function createDragAndDropPlugin() {
1978
+ var DRAGGABLE_TYPES = [BLOCKS.EMBEDDED_ENTRY, BLOCKS.EMBEDDED_ASSET, BLOCKS.HR, INLINES.EMBEDDED_ENTRY];
1979
+ /**
1980
+ * HTML node names where dropping should be allowed
1981
+ * Usually for elements where `Transforms.removeNodes` is needed
1982
+ * TODO: looking up for html nodes is not the best solution and it won't scale but it works fine for our current cases/elements
1983
+ */
1984
+
1985
+ var ON_DROP_ALLOWED_TYPES = {
1986
+ TABLE: [INLINES.EMBEDDED_ENTRY]
1987
+ };
1988
+ return {
1989
+ key: 'DragAndDropPlugin',
1990
+ handlers: {
1991
+ // If true, the next handlers will be skipped.
1992
+ onDrop: function onDrop(editor) {
1993
+ return function (event) {
1994
+ var _Array$from = Array.from(getNodes(editor, {
1995
+ match: function match(node) {
1996
+ return DRAGGABLE_TYPES.includes(node == null ? void 0 : node.type);
1997
+ }
1998
+ })),
1999
+ draggingBlock = _Array$from[0];
2000
+
2001
+ if (!draggingBlock) return false;
2002
+ var draggingNode = draggingBlock[0];
2003
+ 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
2004
+
2005
+ var dropDisallowed = getParents(event.nativeEvent.target).some(function (node) {
2006
+ var _ON_DROP_ALLOWED_TYPE;
2007
+
2008
+ 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;
2009
+ });
2010
+
2011
+ if (!dropDisallowed) {
2012
+ // Move the drop event to a new undo batch mitigating the bug where undo not only moves it back,
2013
+ // but also undoes a previous action: https://github.com/ianstormtaylor/slate/issues/4694
2014
+ editor.history.undos.push([]);
2015
+ }
2016
+
2017
+ return dropDisallowed;
2018
+ };
2019
+ }
2020
+ }
2021
+ };
2022
+ }
2023
+
2024
+ function getParents(el) {
2025
+ var parents = [];
2026
+ parents.push(el);
2027
+
2028
+ while (el.parentNode) {
2029
+ parents.unshift(el.parentNode);
2030
+ el = el.parentNode;
2031
+ }
2032
+
2033
+ return parents;
2034
+ }
2035
+
2036
+ function withLinkTracking(Component) {
2037
+ return function ComponentWithTracking(props) {
2038
+ var editor = useContentfulEditorRef();
2039
+ var onEntityFetchComplete = React__default.useCallback(function () {
2040
+ return editor.tracking.onViewportAction('linkRendered');
2041
+ }, [editor]);
2042
+ return /*#__PURE__*/React__default.createElement(Component, Object.assign({}, props, {
2043
+ onEntityFetchComplete: onEntityFetchComplete
2044
+ }));
2045
+ };
2046
+ }
2047
+
2048
+ function useFetchedEntity(_ref) {
2049
+ var type = _ref.type,
2050
+ id = _ref.id,
2051
+ onEntityFetchComplete = _ref.onEntityFetchComplete;
2052
+
2053
+ var _useEntities = useEntities(),
2054
+ entries = _useEntities.entries,
2055
+ assets = _useEntities.assets,
2056
+ getOrLoadEntry = _useEntities.getOrLoadEntry,
2057
+ getOrLoadAsset = _useEntities.getOrLoadAsset;
2058
+
2059
+ var store = type === 'Entry' ? entries : assets;
2060
+
2061
+ var _useState = useState(store[id]),
2062
+ entity = _useState[0],
2063
+ setEntity = _useState[1]; // Deep compare the entity value to keep re-rendering to minimal
2064
+
2065
+
2066
+ useEffect(function () {
2067
+ var newValue = store[id];
2068
+
2069
+ if (!areEqual(entity, newValue)) {
2070
+ setEntity(newValue);
2071
+ }
2072
+ }, [store, entity, id]); // Fetch the entity if needed
2073
+
2074
+ useEffect(function () {
2075
+ (type === 'Entry' ? getOrLoadEntry : getOrLoadAsset)(id); // "getOrLoadEntry" and "getOrLoadAsset" instances change with every
2076
+ // entity store update causing page lag on initial load
2077
+ // TODO: consider rewriting useEntities() hook to avoid that happening in
2078
+ // first place.
2079
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: explain this disable
2080
+ }, [type, id]);
2081
+ useEffect(function () {
2082
+ if (entity) {
2083
+ onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
2084
+ }
2085
+ }, [onEntityFetchComplete, entity]);
2086
+ return entity;
2087
+ }
2088
+
2089
+ var InternalAssetCard = /*#__PURE__*/memo(function (props) {
2090
+ if (props.asset === undefined) {
2091
+ return /*#__PURE__*/createElement(AssetCard, {
2092
+ size: "default",
2093
+ isLoading: true
2094
+ });
2095
+ }
2096
+
2097
+ if (props.asset === 'failed') {
2098
+ return /*#__PURE__*/createElement(MissingEntityCard, {
2099
+ entityType: "Asset",
2100
+ isDisabled: props.isDisabled,
2101
+ onRemove: props.onRemove
2102
+ });
2103
+ }
2104
+
2105
+ return /*#__PURE__*/createElement(WrappedAssetCard, {
2106
+ getEntityScheduledActions: props.loadEntityScheduledActions,
2107
+ size: "small",
2108
+ isSelected: props.isSelected,
2109
+ isDisabled: props.isDisabled,
2110
+ localeCode: props.locale,
2111
+ defaultLocaleCode: props.sdk.locales["default"],
2112
+ asset: props.asset,
2113
+ onEdit: props.onEdit,
2114
+ onRemove: props.isDisabled ? undefined : props.onRemove,
2115
+ isClickable: false
2116
+ });
2117
+ }, areEqual);
2118
+ InternalAssetCard.displayName = 'InternalAssetCard';
2119
+ function FetchingWrappedAssetCard(props) {
2120
+ var onEntityFetchComplete = props.onEntityFetchComplete,
2121
+ assetId = props.assetId;
2122
+
2123
+ var _useEntities = useEntities(),
2124
+ loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
2125
+
2126
+ var asset = useFetchedEntity({
2127
+ type: 'Asset',
2128
+ id: assetId,
2129
+ onEntityFetchComplete: onEntityFetchComplete
2130
+ });
2131
+ return /*#__PURE__*/createElement(InternalAssetCard, {
2132
+ asset: asset,
2133
+ sdk: props.sdk,
2134
+ isDisabled: props.isDisabled,
2135
+ isSelected: props.isSelected,
2136
+ loadEntityScheduledActions: loadEntityScheduledActions,
2137
+ locale: props.locale,
2138
+ onEdit: props.onEdit,
2139
+ onRemove: props.onRemove
2140
+ });
2141
+ }
2142
+
2143
+ var InternalEntryCard = /*#__PURE__*/memo(function (props) {
2144
+ var entry = props.entry,
2145
+ sdk = props.sdk,
2146
+ loadEntityScheduledActions = props.loadEntityScheduledActions;
2147
+
2148
+ if (entry === undefined) {
2149
+ return /*#__PURE__*/createElement(EntryCard, {
2150
+ isLoading: true
2151
+ });
2152
+ }
2153
+
2154
+ if (entry === 'failed') {
2155
+ return /*#__PURE__*/createElement(MissingEntityCard, {
2156
+ entityType: "Entry",
2157
+ isDisabled: props.isDisabled,
2158
+ onRemove: props.onRemove
2159
+ });
2160
+ }
2161
+
2162
+ var contentType = sdk.space.getCachedContentTypes().find(function (contentType) {
2163
+ return contentType.sys.id === entry.sys.contentType.sys.id;
2164
+ });
2165
+ return /*#__PURE__*/createElement(WrappedEntryCard, {
2166
+ size: "default",
2167
+ getAsset: props.sdk.space.getAsset,
2168
+ getEntityScheduledActions: loadEntityScheduledActions,
2169
+ isSelected: props.isSelected,
2170
+ isDisabled: props.isDisabled,
2171
+ localeCode: props.locale,
2172
+ defaultLocaleCode: props.sdk.locales["default"],
2173
+ contentType: contentType,
2174
+ entry: entry,
2175
+ onEdit: props.onEdit,
2176
+ onRemove: props.isDisabled ? undefined : props.onRemove,
2177
+ isClickable: false
2178
+ });
2179
+ }, areEqual);
2180
+ InternalEntryCard.displayName = 'ReferenceCard';
2181
+ var FetchingWrappedEntryCard = function FetchingWrappedEntryCard(props) {
2182
+ var entryId = props.entryId,
2183
+ onEntityFetchComplete = props.onEntityFetchComplete;
1550
2184
 
1551
- return ContinueSentinel;
1552
- }
1553
- }; // Regardless of whether this script is executing as a CommonJS module
1554
- // or not, return the runtime object so that we can declare the variable
1555
- // regeneratorRuntime in the outer scope, which allows this module to be
1556
- // injected easily by `bin/regenerator --include-runtime script.js`.
2185
+ var _useEntities = useEntities(),
2186
+ loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
1557
2187
 
1558
- return exports;
1559
- }( // If this script is executing as a CommonJS module, use module.exports
1560
- // as the regeneratorRuntime namespace. Otherwise create a new empty
1561
- // object. Either way, the resulting object will be used to initialize
1562
- // the regeneratorRuntime variable at the top of this file.
1563
- module.exports );
2188
+ var entry = useFetchedEntity({
2189
+ type: 'Entry',
2190
+ id: entryId,
2191
+ onEntityFetchComplete: onEntityFetchComplete
2192
+ });
2193
+ return /*#__PURE__*/createElement(InternalEntryCard, {
2194
+ entry: entry,
2195
+ sdk: props.sdk,
2196
+ locale: props.locale,
2197
+ isDisabled: props.isDisabled,
2198
+ isSelected: props.isSelected,
2199
+ onEdit: props.onEdit,
2200
+ onRemove: props.onRemove,
2201
+ loadEntityScheduledActions: loadEntityScheduledActions
2202
+ });
2203
+ };
1564
2204
 
1565
- try {
1566
- regeneratorRuntime = runtime;
1567
- } catch (accidentalStrictMode) {
1568
- // This module should not be running in strict mode, so the above
1569
- // assignment should always work unless something is misconfigured. Just
1570
- // in case runtime.js accidentally runs in strict mode, we can escape
1571
- // strict mode using a global Function call. This could conceivably fail
1572
- // if a Content Security Policy forbids using Function, but in that case
1573
- // the proper solution is to fix the accidental strict mode problem. If
1574
- // you've misconfigured your bundler to force strict mode and applied a
1575
- // CSP to forbid Function, and you're not willing to fix either of those
1576
- // problems, please detail your unique predicament in a GitHub issue.
1577
- Function("r", "regeneratorRuntime = r")(runtime);
1578
- }
1579
- });
2205
+ var styles$1 = {
2206
+ root: /*#__PURE__*/css({
2207
+ marginBottom: '1.25rem !important',
2208
+ display: 'block'
2209
+ }),
2210
+ container: /*#__PURE__*/css({
2211
+ // The next 2 properties ensure Entity card won't be aligned above
2212
+ // a list item marker (i.e. bullet)
2213
+ display: 'inline-block',
2214
+ verticalAlign: 'text-top',
2215
+ width: '100%'
2216
+ })
2217
+ };
2218
+ function LinkedEntityBlock(props) {
2219
+ var attributes = props.attributes,
2220
+ children = props.children,
2221
+ element = props.element,
2222
+ onEntityFetchComplete = props.onEntityFetchComplete;
2223
+ var isSelected = useSelected();
2224
+ var editor = useContentfulEditor();
2225
+ var sdk = useSdkContext();
2226
+ var isDisabled = useReadOnly();
2227
+ var _element$data$target$ = element.data.target.sys,
2228
+ entityId = _element$data$target$.id,
2229
+ entityType = _element$data$target$.linkType;
2230
+ var handleEditClick = React__default.useCallback(function () {
2231
+ var openEntity = entityType === 'Asset' ? sdk.navigator.openAsset : sdk.navigator.openEntry;
2232
+ return openEntity(entityId, {
2233
+ slideIn: true
2234
+ });
2235
+ }, [sdk, entityId, entityType]);
2236
+ var handleRemoveClick = React__default.useCallback(function () {
2237
+ if (!editor) return;
2238
+ var pathToElement = ReactEditor.findPath(editor, element);
2239
+ Transforms.removeNodes(editor, {
2240
+ at: pathToElement
2241
+ });
2242
+ }, [editor, element]);
2243
+ return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
2244
+ className: styles$1.root,
2245
+ "data-entity-type": entityType,
2246
+ "data-entity-id": entityId,
2247
+ // COMPAT: This makes copy & paste work for Firefox
2248
+ contentEditable: IS_CHROME ? undefined : false,
2249
+ draggable: IS_CHROME ? true : undefined
2250
+ }), /*#__PURE__*/React__default.createElement("div", {
2251
+ // COMPAT: This makes copy & paste work for Chromium/Blink browsers and Safari
2252
+ contentEditable: IS_CHROME ? false : undefined,
2253
+ draggable: IS_CHROME ? true : undefined,
2254
+ className: styles$1.container
2255
+ }, entityType === 'Entry' && /*#__PURE__*/React__default.createElement(FetchingWrappedEntryCard, {
2256
+ sdk: sdk,
2257
+ entryId: entityId,
2258
+ locale: sdk.field.locale,
2259
+ isDisabled: isDisabled,
2260
+ isSelected: isSelected,
2261
+ onRemove: handleRemoveClick,
2262
+ onEdit: handleEditClick,
2263
+ onEntityFetchComplete: onEntityFetchComplete
2264
+ }), entityType === 'Asset' && /*#__PURE__*/React__default.createElement(FetchingWrappedAssetCard, {
2265
+ sdk: sdk,
2266
+ assetId: entityId,
2267
+ locale: sdk.field.locale,
2268
+ isDisabled: isDisabled,
2269
+ isSelected: isSelected,
2270
+ onRemove: handleRemoveClick,
2271
+ onEdit: handleEditClick,
2272
+ onEntityFetchComplete: onEntityFetchComplete
2273
+ })), children);
2274
+ }
1580
2275
 
1581
2276
  /* eslint-disable you-dont-need-lodash-underscore/find */
1582
2277
  /**
@@ -1688,7 +2383,7 @@ function _selectEntityAndInsert() {
1688
2383
 
1689
2384
  case 12:
1690
2385
  Transforms.select(editor, selection);
1691
- insertBlock(editor, nodeType, entity);
2386
+ insertBlock$1(editor, nodeType, entity);
1692
2387
  ensureFollowingParagraph(editor);
1693
2388
  logAction('insert', {
1694
2389
  nodeType: nodeType
@@ -1741,7 +2436,7 @@ function ensureFollowingParagraph(editor) {
1741
2436
  moveToTheNextChar(editor);
1742
2437
  }
1743
2438
 
1744
- var createNode = function createNode(nodeType, entity) {
2439
+ var createNode$1 = function createNode(nodeType, entity) {
1745
2440
  return {
1746
2441
  type: nodeType,
1747
2442
  data: {
@@ -1761,9 +2456,9 @@ var createNode = function createNode(nodeType, entity) {
1761
2456
  }; // TODO: DRY up copied code from HR
1762
2457
 
1763
2458
 
1764
- function insertBlock(editor, nodeType, entity) {
2459
+ function insertBlock$1(editor, nodeType, entity) {
1765
2460
  if (!(editor != null && editor.selection)) return;
1766
- var linkedEntityBlock = createNode(nodeType, entity);
2461
+ var linkedEntityBlock = createNode$1(nodeType, entity);
1767
2462
  var hasText = editor.selection && !!getText(editor, editor.selection.focus.path);
1768
2463
 
1769
2464
  if (hasText) {
@@ -1775,7 +2470,7 @@ function insertBlock(editor, nodeType, entity) {
1775
2470
  focus(editor);
1776
2471
  }
1777
2472
 
1778
- var styles$1 = {
2473
+ var styles$2 = {
1779
2474
  icon: /*#__PURE__*/css({
1780
2475
  marginRight: '10px'
1781
2476
  })
@@ -1823,7 +2518,7 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
1823
2518
  flexDirection: "row"
1824
2519
  }, /*#__PURE__*/React__default.createElement(Icon, {
1825
2520
  as: type === 'Asset' ? AssetIcon : EmbeddedEntryBlockIcon,
1826
- className: "rich-text__embedded-entry-list-icon " + styles$1.icon,
2521
+ className: "rich-text__embedded-entry-list-icon " + styles$2.icon,
1827
2522
  variant: "secondary"
1828
2523
  }), /*#__PURE__*/React__default.createElement("span", null, type)));
1829
2524
  }
@@ -1922,7 +2617,7 @@ var createEmbeddedAssetBlockPlugin = /*#__PURE__*/createEmbeddedEntityPlugin(BLO
1922
2617
 
1923
2618
  var getEntryTitle = entityHelpers.getEntryTitle,
1924
2619
  getEntryStatus = entityHelpers.getEntryStatus;
1925
- var styles$2 = {
2620
+ var styles$3 = {
1926
2621
  scheduledIcon: /*#__PURE__*/css({
1927
2622
  verticalAlign: 'text-bottom',
1928
2623
  marginRight: tokens.spacing2Xs
@@ -2017,13 +2712,13 @@ function FetchingWrappedInlineEntryCard(props) {
2017
2712
  entityType: "Entry",
2018
2713
  entityId: entry.sys.id
2019
2714
  }, /*#__PURE__*/React__default.createElement(ClockIcon, {
2020
- className: styles$2.scheduledIcon,
2715
+ className: styles$3.scheduledIcon,
2021
2716
  variant: "muted",
2022
2717
  testId: "scheduled-icon"
2023
2718
  })), /*#__PURE__*/React__default.createElement(Text$1, null, title));
2024
2719
  }
2025
2720
 
2026
- function createInlineEntryNode(id) {
2721
+ function createInlineEntryNode$1(id) {
2027
2722
  return {
2028
2723
  type: INLINES.EMBEDDED_ENTRY,
2029
2724
  children: [{
@@ -2041,7 +2736,7 @@ function createInlineEntryNode(id) {
2041
2736
  };
2042
2737
  }
2043
2738
 
2044
- var styles$3 = {
2739
+ var styles$4 = {
2045
2740
  icon: /*#__PURE__*/css({
2046
2741
  marginRight: '10px'
2047
2742
  }),
@@ -2077,7 +2772,7 @@ function EmbeddedEntityInline(props) {
2077
2772
  }
2078
2773
 
2079
2774
  return /*#__PURE__*/createElement("span", Object.assign({}, props.attributes, {
2080
- className: styles$3.root,
2775
+ className: styles$4.root,
2081
2776
  "data-embedded-entity-inline-id": entryId,
2082
2777
  // COMPAT: This makes copy & paste work for Firefox
2083
2778
  contentEditable: IS_CHROME ? undefined : false,
@@ -2133,7 +2828,7 @@ function _selectEntityAndInsert$1() {
2133
2828
  return _context2.abrupt("return");
2134
2829
 
2135
2830
  case 10:
2136
- inlineEntryNode = createInlineEntryNode(entry.sys.id);
2831
+ inlineEntryNode = createInlineEntryNode$1(entry.sys.id);
2137
2832
  logAction('insert', {
2138
2833
  nodeType: INLINES.EMBEDDED_ENTRY
2139
2834
  }); // Got to wait until focus is really back on the editor or setSelection() won't work.
@@ -2207,7 +2902,7 @@ function ToolbarEmbeddedEntityInlineButton(props) {
2207
2902
  flexDirection: "row"
2208
2903
  }, /*#__PURE__*/createElement(EmbeddedEntryInlineIcon, {
2209
2904
  variant: "secondary",
2210
- className: "rich-text__embedded-entry-list-icon " + styles$3.icon
2905
+ className: "rich-text__embedded-entry-list-icon " + styles$4.icon
2211
2906
  }), /*#__PURE__*/createElement("span", null, "Inline entry")));
2212
2907
  }
2213
2908
  function createEmbeddedEntityInlinePlugin(sdk) {
@@ -2231,7 +2926,7 @@ function createEmbeddedEntityInlinePlugin(sdk) {
2231
2926
  }],
2232
2927
  withoutChildren: true,
2233
2928
  getNode: function getNode(el) {
2234
- return createInlineEntryNode(el.getAttribute(htmlAttributeName));
2929
+ return createInlineEntryNode$1(el.getAttribute(htmlAttributeName));
2235
2930
  }
2236
2931
  }
2237
2932
  };
@@ -2283,7 +2978,7 @@ var isMarkEnabled = function isMarkEnabled(field, mark) {
2283
2978
  };
2284
2979
 
2285
2980
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _dropdown, _LABELS;
2286
- var styles$4 = {
2981
+ var styles$5 = {
2287
2982
  dropdown: (_dropdown = {
2288
2983
  root: /*#__PURE__*/css(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-weight: ", ";\n "])), tokens.fontWeightDemiBold)
2289
2984
  }, _dropdown[BLOCKS.PARAGRAPH] = /*#__PURE__*/css(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: ", ";\n "])), tokens.fontSizeL), _dropdown[BLOCKS.HEADING_1] = /*#__PURE__*/css(_templateObject3 || (_templateObject3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.625rem;\n "]))), _dropdown[BLOCKS.HEADING_2] = /*#__PURE__*/css(_templateObject4 || (_templateObject4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.4375rem;\n "]))), _dropdown[BLOCKS.HEADING_3] = /*#__PURE__*/css(_templateObject5 || (_templateObject5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.25rem;\n "]))), _dropdown[BLOCKS.HEADING_4] = /*#__PURE__*/css(_templateObject6 || (_templateObject6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.125rem;\n "]))), _dropdown[BLOCKS.HEADING_5] = /*#__PURE__*/css(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1rem;\n "]))), _dropdown[BLOCKS.HEADING_6] = /*#__PURE__*/css(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 0.875rem;\n "]))), _dropdown)
@@ -2378,7 +3073,7 @@ function ToolbarHeadingButton(props) {
2378
3073
  testId: "dropdown-option-" + nodeType,
2379
3074
  disabled: props.isDisabled
2380
3075
  }, /*#__PURE__*/createElement("span", {
2381
- className: cx(styles$4.dropdown.root, styles$4.dropdown[nodeType])
3076
+ className: cx(styles$5.dropdown.root, styles$5.dropdown[nodeType])
2382
3077
  }, LABELS[nodeType]));
2383
3078
  }).filter(Boolean)));
2384
3079
  }
@@ -2448,7 +3143,7 @@ var transformLift = function transformLift(editor, _ref4) {
2448
3143
  };
2449
3144
 
2450
3145
  var _templateObject$1, _templateObject2$1, _templateObject3$1, _templateObject4$1, _templateObject5$1, _templateObject6$1, _templateObject7$1, _templateObject8$1, _dropdown$1, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _headings, _HeadingComponents;
2451
- var styles$5 = {
3146
+ var styles$6 = {
2452
3147
  dropdown: (_dropdown$1 = {
2453
3148
  root: /*#__PURE__*/css(_templateObject$1 || (_templateObject$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-weight: ", ";\n "])), tokens.fontWeightDemiBold)
2454
3149
  }, _dropdown$1[BLOCKS.PARAGRAPH] = /*#__PURE__*/css(_templateObject2$1 || (_templateObject2$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: ", ";\n "])), tokens.fontSizeL), _dropdown$1[BLOCKS.HEADING_1] = /*#__PURE__*/css(_templateObject3$1 || (_templateObject3$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.625rem;\n "]))), _dropdown$1[BLOCKS.HEADING_2] = /*#__PURE__*/css(_templateObject4$1 || (_templateObject4$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.4375rem;\n "]))), _dropdown$1[BLOCKS.HEADING_3] = /*#__PURE__*/css(_templateObject5$1 || (_templateObject5$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.25rem;\n "]))), _dropdown$1[BLOCKS.HEADING_4] = /*#__PURE__*/css(_templateObject6$1 || (_templateObject6$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.125rem;\n "]))), _dropdown$1[BLOCKS.HEADING_5] = /*#__PURE__*/css(_templateObject7$1 || (_templateObject7$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1rem;\n "]))), _dropdown$1[BLOCKS.HEADING_6] = /*#__PURE__*/css(_templateObject8$1 || (_templateObject8$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 0.875rem;\n "]))), _dropdown$1),
@@ -2460,7 +3155,7 @@ var styles$5 = {
2460
3155
  function createHeading(Tag, block) {
2461
3156
  return function Heading(props) {
2462
3157
  return /*#__PURE__*/createElement(Tag, Object.assign({}, props.attributes, {
2463
- className: cx(styles$5.headings.root, styles$5.headings[block])
3158
+ className: cx(styles$6.headings.root, styles$6.headings[block])
2464
3159
  }), props.children);
2465
3160
  };
2466
3161
  }
@@ -2556,7 +3251,7 @@ var createHeadingPlugin = function createHeadingPlugin() {
2556
3251
  };
2557
3252
  };
2558
3253
 
2559
- var styles$6 = {
3254
+ var styles$7 = {
2560
3255
  button: /*#__PURE__*/css({
2561
3256
  height: '30px',
2562
3257
  width: '30px',
@@ -2582,7 +3277,7 @@ function ToolbarButton(props) {
2582
3277
  };
2583
3278
 
2584
3279
  var button = /*#__PURE__*/React__default.createElement(Button, {
2585
- className: cx(styles$6.button, className),
3280
+ className: cx(styles$7.button, className),
2586
3281
  isDisabled: isDisabled,
2587
3282
  startIcon: children,
2588
3283
  onClick: handleClick,
@@ -2593,7 +3288,7 @@ function ToolbarButton(props) {
2593
3288
 
2594
3289
  if (title) {
2595
3290
  return /*#__PURE__*/React__default.createElement(Tooltip, {
2596
- className: styles$6.tooltip,
3291
+ className: styles$7.tooltip,
2597
3292
  placement: "bottom",
2598
3293
  content: title
2599
3294
  }, button);
@@ -2603,7 +3298,7 @@ function ToolbarButton(props) {
2603
3298
  }
2604
3299
 
2605
3300
  var _templateObject$2, _templateObject2$2, _templateObject3$2;
2606
- var styles$7 = {
3301
+ var styles$8 = {
2607
3302
  container: /*#__PURE__*/css(_templateObject$2 || (_templateObject$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0 0 ", ";\n "])), tokens.spacingL),
2608
3303
  hr: /*#__PURE__*/css(_templateObject2$2 || (_templateObject2$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0;\n height: ", ";\n background: transparent;\n position: relative;\n border: 0;\n user-select: none;\n &:hover {\n cursor: pointer;\n }\n &::after {\n content: '';\n position: absolute;\n width: 100%;\n height: 1px;\n background: ", ";\n top: 50%;\n }\n "])), tokens.spacingM, tokens.gray300),
2609
3304
  hrSelected: /*#__PURE__*/css(_templateObject3$2 || (_templateObject3$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n &::after {\n background: ", ";\n -webkit-box-shadow: 0px 0px 5px ", ";\n box-shadow: 0px 0px 5px ", ";\n }\n "])), tokens.colorPrimary, tokens.colorPrimary, tokens.colorPrimary)
@@ -2661,14 +3356,14 @@ function Hr(props) {
2661
3356
  var isSelected = useSelected();
2662
3357
  var isFocused = useFocused();
2663
3358
  return /*#__PURE__*/createElement("div", Object.assign({}, props.attributes, {
2664
- className: styles$7.container,
3359
+ className: styles$8.container,
2665
3360
  "data-void-element": BLOCKS.HR
2666
3361
  }), /*#__PURE__*/createElement("div", {
2667
3362
  draggable: true,
2668
3363
  // Moving `contentEditable` to this div makes it to be selectable when being the first void element, e.g pressing ctrl + a to select everything
2669
3364
  contentEditable: false
2670
3365
  }, /*#__PURE__*/createElement("hr", {
2671
- className: cx(styles$7.hr, isSelected && isFocused ? styles$7.hrSelected : undefined)
3366
+ className: cx(styles$8.hr, isSelected && isFocused ? styles$8.hrSelected : undefined)
2672
3367
  })), props.children);
2673
3368
  }
2674
3369
  var createHrPlugin = function createHrPlugin() {
@@ -2695,7 +3390,7 @@ var createHrPlugin = function createHrPlugin() {
2695
3390
  };
2696
3391
 
2697
3392
  var _templateObject$3, _SYS_LINK_TYPES, _LINK_TYPE_SELECTION_;
2698
- var styles$8 = {
3393
+ var styles$9 = {
2699
3394
  removeSelectionLabel: /*#__PURE__*/css(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-left: ", ";\n "])), tokens.spacingS)
2700
3395
  };
2701
3396
  var SYS_LINK_TYPES = (_SYS_LINK_TYPES = {}, _SYS_LINK_TYPES[INLINES.ENTRY_HYPERLINK] = 'Entry', _SYS_LINK_TYPES[INLINES.ASSET_HYPERLINK] = 'Asset', _SYS_LINK_TYPES);
@@ -2878,7 +3573,7 @@ function HyperlinkModal(props) {
2878
3573
  }, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? /*#__PURE__*/createElement(Fragment, null, !props.readonly && /*#__PURE__*/createElement(TextLink, {
2879
3574
  testId: "entity-selection-link",
2880
3575
  onClick: resetLinkEntity,
2881
- className: styles$8.removeSelectionLabel
3576
+ className: styles$9.removeSelectionLabel
2882
3577
  }, "Remove selection"), /*#__PURE__*/createElement("div", null, linkType === INLINES.ENTRY_HYPERLINK && /*#__PURE__*/createElement(FetchingWrappedEntryCard, {
2883
3578
  sdk: props.sdk,
2884
3579
  locale: props.sdk.field.locale,
@@ -3219,7 +3914,7 @@ function useEntityInfo(props) {
3219
3914
  return getEntityInfo(status.data);
3220
3915
  }
3221
3916
 
3222
- var styles$9 = {
3917
+ var styles$a = {
3223
3918
  hyperlinkWrapper: /*#__PURE__*/css({
3224
3919
  display: 'inline',
3225
3920
  position: 'static',
@@ -3264,13 +3959,13 @@ function EntityHyperlink(props) {
3264
3959
 
3265
3960
  return /*#__PURE__*/createElement(Tooltip, {
3266
3961
  content: tooltipContent,
3267
- targetWrapperClassName: styles$9.hyperlinkWrapper,
3962
+ targetWrapperClassName: styles$a.hyperlinkWrapper,
3268
3963
  placement: "bottom",
3269
3964
  maxWidth: "auto"
3270
3965
  }, /*#__PURE__*/createElement(TextLink, {
3271
3966
  as: "a",
3272
3967
  onClick: handleClick,
3273
- className: styles$9.hyperlink,
3968
+ className: styles$a.hyperlink,
3274
3969
  "data-link-type": target.sys.linkType,
3275
3970
  "data-link-id": target.sys.id
3276
3971
  }, props.children));
@@ -3294,7 +3989,7 @@ function UrlHyperlink(props) {
3294
3989
 
3295
3990
  return /*#__PURE__*/createElement(Tooltip, {
3296
3991
  content: uri,
3297
- targetWrapperClassName: styles$9.hyperlinkWrapper,
3992
+ targetWrapperClassName: styles$a.hyperlinkWrapper,
3298
3993
  placement: "bottom",
3299
3994
  maxWidth: "auto"
3300
3995
  }, /*#__PURE__*/createElement(TextLink, {
@@ -3302,7 +3997,7 @@ function UrlHyperlink(props) {
3302
3997
  href: uri,
3303
3998
  rel: "noopener noreferrer",
3304
3999
  onClick: handleClick,
3305
- className: styles$9.hyperlink
4000
+ className: styles$a.hyperlink
3306
4001
  }, props.children));
3307
4002
  }
3308
4003
 
@@ -3428,12 +4123,12 @@ var createHyperlinkPlugin = function createHyperlinkPlugin(sdk) {
3428
4123
 
3429
4124
  var _templateObject$4, _templateObject2$3, _templateObject3$3, _styles;
3430
4125
  var baseStyle = /*#__PURE__*/css(_templateObject$4 || (_templateObject$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 0;\n margin: 0 0 1.25rem 1.25rem;\n\n div:first-child {\n margin: 0;\n line-height: ", ";\n }\n"])), tokens.lineHeightDefault);
3431
- var styles$a = (_styles = {}, _styles[BLOCKS.UL_LIST] = /*#__PURE__*/css(_templateObject2$3 || (_templateObject2$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n list-style-type: disc;\n ul {\n list-style-type: circle;\n ul {\n list-style-type: square;\n }\n }\n "]))), _styles[BLOCKS.OL_LIST] = /*#__PURE__*/css(_templateObject3$3 || (_templateObject3$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n list-style-type: decimal;\n ol {\n list-style-type: upper-alpha;\n ol {\n list-style-type: lower-roman;\n ol {\n list-style-type: lower-alpha;\n }\n }\n }\n "]))), _styles);
4126
+ var styles$b = (_styles = {}, _styles[BLOCKS.UL_LIST] = /*#__PURE__*/css(_templateObject2$3 || (_templateObject2$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n list-style-type: disc;\n ul {\n list-style-type: circle;\n ul {\n list-style-type: square;\n }\n }\n "]))), _styles[BLOCKS.OL_LIST] = /*#__PURE__*/css(_templateObject3$3 || (_templateObject3$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n list-style-type: decimal;\n ol {\n list-style-type: upper-alpha;\n ol {\n list-style-type: lower-roman;\n ol {\n list-style-type: lower-alpha;\n }\n }\n }\n "]))), _styles);
3432
4127
 
3433
4128
  function createList(Tag, block) {
3434
4129
  return function List(props) {
3435
4130
  return /*#__PURE__*/createElement(Tag, Object.assign({}, props.attributes, {
3436
- className: cx(baseStyle, styles$a[block])
4131
+ className: cx(baseStyle, styles$b[block])
3437
4132
  }), props.children);
3438
4133
  };
3439
4134
  }
@@ -4414,14 +5109,14 @@ var ToolbarBoldButton = /*#__PURE__*/createMarkToolbarButton({
4414
5109
  mark: MARKS.BOLD,
4415
5110
  icon: /*#__PURE__*/createElement(FormatBoldIcon, null)
4416
5111
  });
4417
- var styles$b = {
5112
+ var styles$c = {
4418
5113
  bold: /*#__PURE__*/css({
4419
5114
  fontWeight: 600
4420
5115
  })
4421
5116
  };
4422
5117
  function Bold(props) {
4423
5118
  return /*#__PURE__*/createElement("strong", Object.assign({}, props.attributes, {
4424
- className: styles$b.bold
5119
+ className: styles$c.bold
4425
5120
  }), props.children);
4426
5121
  }
4427
5122
 
@@ -4461,7 +5156,7 @@ var ToolbarCodeButton = /*#__PURE__*/createMarkToolbarButton({
4461
5156
  mark: MARKS.CODE,
4462
5157
  icon: /*#__PURE__*/createElement(CodeIcon, null)
4463
5158
  });
4464
- var styles$c = {
5159
+ var styles$d = {
4465
5160
  code: /*#__PURE__*/css({
4466
5161
  fontFamily: 'monospace',
4467
5162
  fontSize: '.9em'
@@ -4469,7 +5164,7 @@ var styles$c = {
4469
5164
  };
4470
5165
  function Code(props) {
4471
5166
  return /*#__PURE__*/createElement("code", Object.assign({}, props.attributes, {
4472
- className: styles$c.code
5167
+ className: styles$d.code
4473
5168
  }), props.children);
4474
5169
  }
4475
5170
  var createCodePlugin = function createCodePlugin() {
@@ -4499,14 +5194,14 @@ var ToolbarItalicButton = /*#__PURE__*/createMarkToolbarButton({
4499
5194
  mark: MARKS.ITALIC,
4500
5195
  icon: /*#__PURE__*/createElement(FormatItalicIcon, null)
4501
5196
  });
4502
- var styles$d = {
5197
+ var styles$e = {
4503
5198
  italic: /*#__PURE__*/css({
4504
5199
  fontStyle: 'italic'
4505
5200
  })
4506
5201
  };
4507
5202
  function Italic(props) {
4508
5203
  return /*#__PURE__*/createElement("em", Object.assign({}, props.attributes, {
4509
- className: styles$d.italic
5204
+ className: styles$e.italic
4510
5205
  }), props.children);
4511
5206
  }
4512
5207
  var createItalicPlugin = function createItalicPlugin() {
@@ -4782,10 +5477,10 @@ var createNormalizerPlugin = function createNormalizerPlugin() {
4782
5477
  };
4783
5478
 
4784
5479
  var _templateObject$6, _styles$1;
4785
- var styles$e = (_styles$1 = {}, _styles$1[BLOCKS.PARAGRAPH] = /*#__PURE__*/css(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: ", ";\n margin-bottom: 1.5em;\n "])), tokens.lineHeightDefault), _styles$1);
5480
+ var styles$f = (_styles$1 = {}, _styles$1[BLOCKS.PARAGRAPH] = /*#__PURE__*/css(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: ", ";\n margin-bottom: 1.5em;\n "])), tokens.lineHeightDefault), _styles$1);
4786
5481
  function Paragraph(props) {
4787
5482
  return /*#__PURE__*/createElement("div", Object.assign({}, props.attributes, {
4788
- className: styles$e[BLOCKS.PARAGRAPH]
5483
+ className: styles$f[BLOCKS.PARAGRAPH]
4789
5484
  }), props.children);
4790
5485
  }
4791
5486
 
@@ -5198,185 +5893,6 @@ var createSelectOnBackspacePlugin = function createSelectOnBackspacePlugin() {
5198
5893
  });
5199
5894
  };
5200
5895
 
5201
- function getCaretTopPoint() {
5202
- var sel = document.getSelection();
5203
- if (!sel) return;
5204
- var r = sel.getRangeAt(0);
5205
- var rect;
5206
- var r2; // supposed to be textNode in most cases
5207
- // but div[contenteditable] when empty
5208
-
5209
- var node = r.startContainer;
5210
- var offset = r.startOffset;
5211
-
5212
- if (offset > 0) {
5213
- // new range, don't influence DOM state
5214
- r2 = document.createRange();
5215
- r2.setStart(node, offset - 1);
5216
- r2.setEnd(node, offset); // https://developer.mozilla.org/en-US/docs/Web/API/range.getBoundingClientRect
5217
- // IE9, Safari?(but look good in Safari 8)
5218
-
5219
- rect = r2.getBoundingClientRect();
5220
- return {
5221
- left: rect.right,
5222
- top: rect.top
5223
- }; // @ts-expect-error
5224
- } else if (offset < node.length) {
5225
- r2 = document.createRange(); // similar but select next on letter
5226
-
5227
- r2.setStart(node, offset);
5228
- r2.setEnd(node, offset + 1);
5229
- rect = r2.getBoundingClientRect();
5230
- return {
5231
- left: rect.left,
5232
- top: rect.top
5233
- };
5234
- } else {
5235
- // textNode has length
5236
- // https://developer.mozilla.org/en-US/docs/Web/API/Element.getBoundingClientRect
5237
- // @ts-expect-error
5238
- rect = node.getBoundingClientRect(); // @ts-expect-error
5239
-
5240
- var styles = getComputedStyle(node);
5241
- var lineHeight = parseInt(styles.lineHeight);
5242
- var fontSize = parseInt(styles.fontSize); // roughly half the whitespace... but not exactly
5243
-
5244
- var delta = (lineHeight - fontSize) / 2;
5245
- return {
5246
- left: rect.left,
5247
- top: rect.top + delta
5248
- };
5249
- }
5250
- }
5251
- function closePanel(editorId) {
5252
- document.dispatchEvent(new CustomEvent('close-rte-palette-commands', {
5253
- detail: {
5254
- editorId: editorId
5255
- }
5256
- }));
5257
- }
5258
- function openPanel(editorId) {
5259
- document.dispatchEvent(new CustomEvent('open-rte-palette-commands', {
5260
- detail: {
5261
- editorId: editorId
5262
- }
5263
- }));
5264
- }
5265
-
5266
- // import debounce from 'lodash/debounce';
5267
- var SLASH_COMMANDS_PLUGIN_KEY = 'SlashCommands'; // TODO: Explore a solution using marks and ReactDOM.createPortal to activate the commands panel
5268
-
5269
- function createSlashCommandsPlugin() {
5270
- return {
5271
- key: SLASH_COMMANDS_PLUGIN_KEY,
5272
- type: SLASH_COMMANDS_PLUGIN_KEY,
5273
- handlers: {
5274
- onClick: function onClick(editor) {
5275
- return function () {
5276
- closePanel(editor.id);
5277
- };
5278
- },
5279
- onKeyDown: function onKeyDown(editor) {
5280
- return function (event) {
5281
- closePanel(editor.id);
5282
-
5283
- if (event.key === '/') {
5284
- openPanel(editor.id);
5285
- }
5286
- };
5287
- }
5288
- }
5289
- };
5290
- }
5291
-
5292
- var style$2 = {
5293
- container: function container(_ref) {
5294
- var top = _ref.top,
5295
- left = _ref.left;
5296
- return css({
5297
- position: 'fixed',
5298
- top: top - 14,
5299
- left: left + 10,
5300
- zIndex: 1,
5301
- boxShadow: '0 5px 15px rgba(0, 0, 0, 0.15)',
5302
- borderRadius: '8px',
5303
- userSelect: 'none'
5304
- });
5305
- }
5306
- };
5307
- function SlashCommandsPalette(_ref2) {
5308
- var editorId = _ref2.editorId;
5309
-
5310
- var _React$useState = useState(null),
5311
- position = _React$useState[0],
5312
- setPosition = _React$useState[1];
5313
-
5314
- var _React$useState2 = useState(false),
5315
- isOpen = _React$useState2[0],
5316
- setIsOpen = _React$useState2[1]; // The user is not annoyed every time they type `/`
5317
-
5318
-
5319
- var MAX_TRIES = 3;
5320
-
5321
- var _React$useState3 = useState(0),
5322
- currentTries = _React$useState3[0],
5323
- setCurrentTries = _React$useState3[1];
5324
-
5325
- useEffect(function () {
5326
- function handler(event) {
5327
- if (editorId !== event.detail.editorId) return;
5328
- var topLeft = getCaretTopPoint();
5329
- if (!topLeft) return;
5330
- setPosition(topLeft);
5331
- setIsOpen(true);
5332
- setCurrentTries(function (curr) {
5333
- return curr + 1;
5334
- });
5335
- }
5336
-
5337
- document.addEventListener('open-rte-palette-commands', handler);
5338
- return function () {
5339
- document.removeEventListener('open-rte-palette-commands', handler);
5340
- };
5341
- }, [editorId]);
5342
- useEffect(function () {
5343
- function handler(event) {
5344
- if (editorId !== event.detail.editorId) return;
5345
- closePanel();
5346
- }
5347
-
5348
- document.addEventListener('close-rte-palette-commands', handler);
5349
- return function () {
5350
- return document.removeEventListener('close-rte-palette-commands', handler);
5351
- };
5352
- }, [editorId]);
5353
- useEffect(function () {
5354
- if (!isOpen) return;
5355
-
5356
- function handler() {
5357
- closePanel();
5358
- }
5359
-
5360
- window.addEventListener('resize', handler);
5361
- window.addEventListener('scroll', handler, true);
5362
- return function () {
5363
- window.removeEventListener('resize', handler);
5364
- window.removeEventListener('scroll', handler, true);
5365
- };
5366
- }, [isOpen]);
5367
-
5368
- function closePanel() {
5369
- setIsOpen(false);
5370
- setPosition(null);
5371
- }
5372
-
5373
- if (!isOpen || !position || currentTries > MAX_TRIES) return null;
5374
- return /*#__PURE__*/createElement("div", {
5375
- className: style$2.container(position),
5376
- "data-test-id": "rte-slash-commands"
5377
- }, /*#__PURE__*/createElement(Card, null, /*#__PURE__*/createElement(Text$1, null, "Slash commands are temporarily unavailable.")));
5378
- }
5379
-
5380
5896
  var addRow = function addRow(editor, getNextRowPath) {
5381
5897
  if (someNode(editor, {
5382
5898
  match: {
@@ -5606,7 +6122,7 @@ var isTable = function isTable(node) {
5606
6122
  return Element.isElement(node) && node.type === BLOCKS.TABLE;
5607
6123
  };
5608
6124
 
5609
- var styles$f = {
6125
+ var styles$g = {
5610
6126
  topRight: /*#__PURE__*/css({
5611
6127
  position: 'absolute',
5612
6128
  top: '6px',
@@ -5695,7 +6211,7 @@ var TableActions = function TableActions() {
5695
6211
  size: "small",
5696
6212
  variant: "transparent",
5697
6213
  tabIndex: -1,
5698
- className: styles$f.topRight,
6214
+ className: styles$g.topRight,
5699
6215
  icon: /*#__PURE__*/React__default.createElement(ChevronDownIcon, null),
5700
6216
  "aria-label": "Open table menu",
5701
6217
  testId: "cf-table-actions-button"
@@ -5720,38 +6236,38 @@ var TableActions = function TableActions() {
5720
6236
  };
5721
6237
 
5722
6238
  var _templateObject$7;
5723
- var style$3 = /*#__PURE__*/css(_templateObject$7 || (_templateObject$7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 1px solid ", ";\n border-collapse: collapse;\n padding: 10px 12px;\n min-width: 48px;\n position: relative;\n vertical-align: top;\n\n div:last-child {\n margin-bottom: 0;\n }\n"])), tokens.gray400);
6239
+ var style$2 = /*#__PURE__*/css(_templateObject$7 || (_templateObject$7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 1px solid ", ";\n border-collapse: collapse;\n padding: 10px 12px;\n min-width: 48px;\n position: relative;\n vertical-align: top;\n\n div:last-child {\n margin-bottom: 0;\n }\n"])), tokens.gray400);
5724
6240
  var Cell = function Cell(props) {
5725
6241
  var isSelected = useSelected();
5726
6242
  return /*#__PURE__*/createElement("td", Object.assign({}, props.attributes, props.element.data, {
5727
- className: style$3
6243
+ className: style$2
5728
6244
  }), isSelected && /*#__PURE__*/createElement(TableActions, null), props.children);
5729
6245
  };
5730
6246
 
5731
6247
  var _templateObject$8;
5732
- var style$4 = /*#__PURE__*/css(_templateObject$8 || (_templateObject$8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background-clip: padding-box;\n background-color: ", ";\n border: 1px solid ", ";\n border-collapse: collapse;\n padding: 10px 12px;\n font-weight: ", ";\n text-align: left;\n min-width: 48px;\n position: relative;\n\n div:last-child {\n margin-bottom: 0;\n }\n"])), tokens.gray200, tokens.gray400, tokens.fontWeightNormal);
6248
+ var style$3 = /*#__PURE__*/css(_templateObject$8 || (_templateObject$8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background-clip: padding-box;\n background-color: ", ";\n border: 1px solid ", ";\n border-collapse: collapse;\n padding: 10px 12px;\n font-weight: ", ";\n text-align: left;\n min-width: 48px;\n position: relative;\n\n div:last-child {\n margin-bottom: 0;\n }\n"])), tokens.gray200, tokens.gray400, tokens.fontWeightNormal);
5733
6249
  var HeaderCell = function HeaderCell(props) {
5734
6250
  var isSelected = useSelected();
5735
6251
  return /*#__PURE__*/createElement("th", Object.assign({}, props.attributes, props.element.data, {
5736
- className: style$4
6252
+ className: style$3
5737
6253
  }), isSelected && /*#__PURE__*/createElement(TableActions, null), props.children);
5738
6254
  };
5739
6255
 
5740
6256
  var _templateObject$9;
5741
- var style$5 = /*#__PURE__*/css(_templateObject$9 || (_templateObject$9 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 1px solid ", ";\n border-collapse: collapse;\n\n &:hover td {\n background-color: transparent !important;\n }\n"])), tokens.gray400);
6257
+ var style$4 = /*#__PURE__*/css(_templateObject$9 || (_templateObject$9 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 1px solid ", ";\n border-collapse: collapse;\n\n &:hover td {\n background-color: transparent !important;\n }\n"])), tokens.gray400);
5742
6258
  var Row = function Row(props) {
5743
6259
  return /*#__PURE__*/createElement("tr", Object.assign({}, props.attributes, {
5744
- className: style$5
6260
+ className: style$4
5745
6261
  }), props.children);
5746
6262
  };
5747
6263
 
5748
6264
  var _templateObject$a;
5749
- var style$6 = /*#__PURE__*/css(_templateObject$a || (_templateObject$a = /*#__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);
6265
+ var style$5 = /*#__PURE__*/css(_templateObject$a || (_templateObject$a = /*#__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);
5750
6266
  var Table = function Table(props) {
5751
6267
  return /*#__PURE__*/createElement("div", {
5752
6268
  "data-block-type": BLOCKS.TABLE
5753
6269
  }, /*#__PURE__*/createElement("table", Object.assign({
5754
- className: style$6
6270
+ className: style$5
5755
6271
  }, props.attributes), /*#__PURE__*/createElement("tbody", null, props.children)));
5756
6272
  };
5757
6273
 
@@ -6498,7 +7014,7 @@ var getPlugins = function getPlugins(sdk, onAction) {
6498
7014
  return [// AST must come after the HTML deserializer
6499
7015
  createDeserializeHtmlPlugin(), createDeserializeAstPlugin(), createDeserializeDocxPlugin(), // Tracking - This should come first so all plugins below will have access to `editor.tracking`
6500
7016
  createTrackingPlugin(onAction), // Global / Global shortcuts
6501
- createDragAndDropPlugin(), createSlashCommandsPlugin(), // Block Elements
7017
+ createDragAndDropPlugin(), createCommandPalettePlugin(), // Block Elements
6502
7018
  createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
6503
7019
  createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
6504
7020
  createMarksPlugin(), // Other
@@ -6629,7 +7145,7 @@ var normalizeEditorValue = function normalizeEditorValue(value, options) {
6629
7145
  };
6630
7146
 
6631
7147
  var STYLE_EDITOR_BORDER = "1px solid " + tokens.gray400;
6632
- var styles$g = {
7148
+ var styles$h = {
6633
7149
  root: /*#__PURE__*/css({
6634
7150
  position: 'relative'
6635
7151
  }),
@@ -6746,7 +7262,7 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
6746
7262
  }, actions) : null;
6747
7263
  };
6748
7264
 
6749
- var styles$h = {
7265
+ var styles$i = {
6750
7266
  toolbar: /*#__PURE__*/css({
6751
7267
  border: "1px solid " + tokens.gray400,
6752
7268
  backgroundColor: tokens.gray100,
@@ -6791,14 +7307,14 @@ var Toolbar = function Toolbar(_ref) {
6791
7307
  var shouldDisableTables = isDisabled || !canInsertBlocks || isListSelected || isBlockquoteSelected;
6792
7308
  return /*#__PURE__*/React__default.createElement(Flex, {
6793
7309
  testId: "toolbar",
6794
- className: styles$h.toolbar,
7310
+ className: styles$i.toolbar,
6795
7311
  alignItems: "center"
6796
7312
  }, /*#__PURE__*/React__default.createElement("div", {
6797
- className: styles$h.formattingOptionsWrapper
7313
+ className: styles$i.formattingOptionsWrapper
6798
7314
  }, /*#__PURE__*/React__default.createElement(ToolbarHeadingButton, {
6799
7315
  isDisabled: isDisabled || !canInsertBlocks
6800
7316
  }), validationInfo.isAnyMarkEnabled && /*#__PURE__*/React__default.createElement("span", {
6801
- className: styles$h.divider
7317
+ className: styles$i.divider
6802
7318
  }), isMarkEnabled(sdk.field, MARKS.BOLD) && /*#__PURE__*/React__default.createElement(ToolbarBoldButton, {
6803
7319
  isDisabled: isDisabled
6804
7320
  }), isMarkEnabled(sdk.field, MARKS.ITALIC) && /*#__PURE__*/React__default.createElement(ToolbarItalicButton, {
@@ -6808,11 +7324,11 @@ var Toolbar = function Toolbar(_ref) {
6808
7324
  }), isMarkEnabled(sdk.field, MARKS.CODE) && /*#__PURE__*/React__default.createElement(ToolbarCodeButton, {
6809
7325
  isDisabled: isDisabled
6810
7326
  }), validationInfo.isAnyHyperlinkEnabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
6811
- className: styles$h.divider
7327
+ className: styles$i.divider
6812
7328
  }), /*#__PURE__*/React__default.createElement(ToolbarHyperlinkButton, {
6813
7329
  isDisabled: isDisabled
6814
7330
  })), validationInfo.isAnyBlockFormattingEnabled && /*#__PURE__*/React__default.createElement("span", {
6815
- className: styles$h.divider
7331
+ className: styles$i.divider
6816
7332
  }), /*#__PURE__*/React__default.createElement(ToolbarListButton, {
6817
7333
  isDisabled: isDisabled || !canInsertBlocks
6818
7334
  }), isNodeTypeEnabled(sdk.field, BLOCKS.QUOTE) && /*#__PURE__*/React__default.createElement(ToolbarQuoteButton, {
@@ -6822,7 +7338,7 @@ var Toolbar = function Toolbar(_ref) {
6822
7338
  }), isNodeTypeEnabled(sdk.field, BLOCKS.TABLE) && /*#__PURE__*/React__default.createElement(ToolbarTableButton, {
6823
7339
  isDisabled: shouldDisableTables
6824
7340
  })), /*#__PURE__*/React__default.createElement("div", {
6825
- className: styles$h.embedActionsWrapper
7341
+ className: styles$i.embedActionsWrapper
6826
7342
  }, /*#__PURE__*/React__default.createElement(EmbedEntityWidget, {
6827
7343
  isDisabled: isDisabled,
6828
7344
  canInsertBlocks: canInsertBlocks
@@ -6847,7 +7363,7 @@ function getValidationInfo(field) {
6847
7363
  }
6848
7364
 
6849
7365
  var _templateObject$b;
6850
- var styles$i = {
7366
+ var styles$j = {
6851
7367
  nativeSticky: /*#__PURE__*/css(_templateObject$b || (_templateObject$b = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: -webkit-sticky;\n position: sticky;\n top: -1px;\n z-index: 2;\n "])))
6852
7368
  };
6853
7369
 
@@ -6855,10 +7371,26 @@ var StickyToolbarWrapper = function StickyToolbarWrapper(_ref) {
6855
7371
  var isDisabled = _ref.isDisabled,
6856
7372
  children = _ref.children;
6857
7373
  return /*#__PURE__*/React__default.createElement("div", {
6858
- className: isDisabled ? '' : styles$i.nativeSticky
7374
+ className: isDisabled ? '' : styles$j.nativeSticky
6859
7375
  }, children);
6860
7376
  };
6861
7377
 
7378
+ var internalMarks = [COMMAND_PROMPT];
7379
+ var removeInternalMarks = function removeInternalMarks(document) {
7380
+ return _extends({}, document, {
7381
+ content: document.content.map(function (node) {
7382
+ if (node.nodeType === 'text') {
7383
+ node.marks = node.marks.filter(function (mark) {
7384
+ return !internalMarks.includes(mark.type);
7385
+ });
7386
+ return node;
7387
+ }
7388
+
7389
+ return removeInternalMarks(node);
7390
+ })
7391
+ });
7392
+ };
7393
+
6862
7394
  /**
6863
7395
  * Returns whether a given operation is relevant enough to trigger a save.
6864
7396
  */
@@ -6878,10 +7410,12 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
6878
7410
  onSkip = _ref.onSkip;
6879
7411
  var onChange = useMemo(function () {
6880
7412
  return debounce(function (document) {
6881
- handler == null ? void 0 : handler(toContentfulDocument({
7413
+ var contentfulDocument = toContentfulDocument({
6882
7414
  document: document,
6883
7415
  schema: schema
6884
- }));
7416
+ });
7417
+ var cleanedDocument = removeInternalMarks(contentfulDocument);
7418
+ handler == null ? void 0 : handler(cleanedDocument);
6885
7419
  }, 500);
6886
7420
  }, [handler]);
6887
7421
  return useCallback(function (value) {
@@ -6950,9 +7484,9 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
6950
7484
  setPendingExternalUpdate(true);
6951
7485
  setEditorContent(editor, documentToEditorValue(props.value));
6952
7486
  }, [props.value, id]);
6953
- var classNames = cx(styles$g.editor, props.minHeight !== undefined ? css({
7487
+ var classNames = cx(styles$h.editor, props.minHeight !== undefined ? css({
6954
7488
  minHeight: props.minHeight
6955
- }) : undefined, props.isDisabled ? styles$g.disabled : styles$g.enabled, props.isToolbarHidden && styles$g.hiddenToolbar);
7489
+ }) : undefined, props.isDisabled ? styles$h.disabled : styles$h.enabled, props.isToolbarHidden && styles$h.hiddenToolbar);
6956
7490
  useEffect(function () {
6957
7491
  if (!isFirstRender) {
6958
7492
  return;
@@ -6968,7 +7502,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
6968
7502
  }, /*#__PURE__*/React__default.createElement(ContentfulEditorIdProvider, {
6969
7503
  value: id
6970
7504
  }, /*#__PURE__*/React__default.createElement("div", {
6971
- className: styles$g.root,
7505
+ className: styles$h.root,
6972
7506
  "data-test-id": "rich-text-editor"
6973
7507
  }, /*#__PURE__*/React__default.createElement(Plate, {
6974
7508
  id: id,
@@ -6983,9 +7517,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
6983
7517
  isDisabled: props.isDisabled
6984
7518
  }, /*#__PURE__*/React__default.createElement(Toolbar, {
6985
7519
  isDisabled: props.isDisabled
6986
- })), /*#__PURE__*/React__default.createElement(SlashCommandsPalette, {
6987
- editorId: id
6988
- })))));
7520
+ }))))));
6989
7521
  };
6990
7522
 
6991
7523
  var RichTextEditor = function RichTextEditor(props) {