@contentful/field-editor-rich-text 2.0.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/field-editor-rich-text.cjs.development.js +1112 -585
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +1092 -565
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/plugins/CommandPalette/components/CommandList.d.ts +6 -0
- package/dist/plugins/CommandPalette/components/CommandList.styles.d.ts +13 -0
- package/dist/plugins/CommandPalette/components/CommandPrompt.d.ts +2 -0
- package/dist/plugins/CommandPalette/constants.d.ts +1 -0
- package/dist/plugins/CommandPalette/createCommandPalettePlugin.d.ts +13 -0
- package/dist/plugins/CommandPalette/hooks/useCommandList.d.ts +3 -0
- package/dist/plugins/CommandPalette/index.d.ts +1 -0
- package/dist/plugins/CommandPalette/onKeyDown.d.ts +3 -0
- package/dist/plugins/CommandPalette/useCommands.d.ts +14 -0
- package/dist/plugins/CommandPalette/utils/createInlineEntryNode.d.ts +16 -0
- package/dist/plugins/CommandPalette/utils/fetchAssets.d.ts +8 -0
- package/dist/plugins/CommandPalette/utils/fetchEntries.d.ts +9 -0
- package/dist/plugins/CommandPalette/utils/insertBlock.d.ts +1 -0
- package/dist/plugins/CommandPalette/utils/trimLeadingSlash.d.ts +7 -0
- package/package.json +2 -2
- package/dist/plugins/SlashCommands/SlashCommandsPalette.d.ts +0 -5
- package/dist/plugins/SlashCommands/createSlashCommandsPlugin.d.ts +0 -2
- package/dist/plugins/SlashCommands/helpers.d.ts +0 -6
- package/dist/plugins/SlashCommands/index.d.ts +0 -2
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React__default, { createContext, useContext, useMemo, useState, useEffect,
|
|
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,
|
|
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
|
|
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
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
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
|
|
626
|
-
var
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
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
|
-
|
|
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
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
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
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
size: "default",
|
|
670
|
-
isLoading: true
|
|
671
|
-
});
|
|
672
|
-
}
|
|
600
|
+
function handleKeyDown(event) {
|
|
601
|
+
if (isHotkey('up', event)) {
|
|
602
|
+
event.preventDefault();
|
|
673
603
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
isDisabled: props.isDisabled,
|
|
678
|
-
onRemove: props.onRemove
|
|
679
|
-
});
|
|
680
|
-
}
|
|
604
|
+
if (currIndex === 0) {
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
681
607
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
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
|
-
|
|
701
|
-
|
|
616
|
+
if (currIndex === buttons.length - 1) {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
702
619
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
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
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
628
|
+
if (currBtn) {
|
|
629
|
+
setSelectedItem('');
|
|
630
|
+
currBtn.click();
|
|
631
|
+
}
|
|
632
|
+
} //TODO: handle shift+enter, which must be detected using separate events
|
|
724
633
|
|
|
725
|
-
|
|
726
|
-
return /*#__PURE__*/createElement(EntryCard, {
|
|
727
|
-
isLoading: true
|
|
728
|
-
});
|
|
729
|
-
}
|
|
634
|
+
}
|
|
730
635
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
isDisabled: props.isDisabled,
|
|
735
|
-
onRemove: props.onRemove
|
|
736
|
-
});
|
|
737
|
-
}
|
|
636
|
+
if (commandItems.length) {
|
|
637
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
638
|
+
}
|
|
738
639
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
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
|
-
|
|
763
|
-
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
|
|
649
|
+
var COMMAND_PROMPT = 'command-prompt';
|
|
764
650
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
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,916 @@ 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
|
+
autoFocus: false
|
|
1873
|
+
}, /*#__PURE__*/createElement(Popover.Trigger, null, /*#__PURE__*/createElement("span", null)), /*#__PURE__*/createElement(Popover.Content, {
|
|
1874
|
+
className: styles.menuContent
|
|
1875
|
+
}, /*#__PURE__*/createElement("header", {
|
|
1876
|
+
className: styles.menuHeader
|
|
1877
|
+
}, /*#__PURE__*/createElement(SectionHeading, {
|
|
1878
|
+
marginBottom: "none"
|
|
1879
|
+
}, "Richtext commands")), /*#__PURE__*/createElement("div", {
|
|
1880
|
+
className: styles.menuList
|
|
1881
|
+
}, /*#__PURE__*/createElement(CommandListItems, {
|
|
1882
|
+
commandItems: commandItems,
|
|
1883
|
+
selectedItem: selectedItem
|
|
1884
|
+
})), /*#__PURE__*/createElement("footer", {
|
|
1885
|
+
className: styles.menuFooter
|
|
1886
|
+
}, /*#__PURE__*/createElement(Stack, {
|
|
1887
|
+
as: "ul",
|
|
1888
|
+
margin: "none",
|
|
1889
|
+
padding: "none",
|
|
1890
|
+
spacing: "spacingS",
|
|
1891
|
+
className: styles.footerList
|
|
1892
|
+
}, /*#__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")))))));
|
|
1893
|
+
};
|
|
1894
|
+
|
|
1895
|
+
var CommandPrompt = function CommandPrompt(props) {
|
|
1896
|
+
var query = useMemo(function () {
|
|
1897
|
+
return trimLeadingSlash(props.text.text);
|
|
1898
|
+
}, [props.text.text]);
|
|
1899
|
+
var editor = props.editor;
|
|
1900
|
+
var canInsertBlocks = !isNodeTypeSelected(editor, BLOCKS.TABLE);
|
|
1901
|
+
return /*#__PURE__*/createElement("span", Object.assign({}, props.attributes), props.children, canInsertBlocks && /*#__PURE__*/createElement(CommandList, {
|
|
1902
|
+
query: query,
|
|
1903
|
+
editor: editor
|
|
1904
|
+
}));
|
|
1905
|
+
};
|
|
1906
|
+
|
|
1907
|
+
var createOnKeyDown = function createOnKeyDown() {
|
|
1908
|
+
return function (editor) {
|
|
1909
|
+
return function (event) {
|
|
1910
|
+
if (isHotkey('/', event)) {
|
|
1911
|
+
var _setMarks;
|
|
1912
|
+
|
|
1913
|
+
setMarks(editor, (_setMarks = {}, _setMarks[COMMAND_PROMPT] = true, _setMarks));
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
var isActive = isMarkActive(editor, COMMAND_PROMPT);
|
|
1917
|
+
|
|
1918
|
+
if (isActive) {
|
|
1919
|
+
if (isHotkey('enter', event)) {
|
|
1920
|
+
event.preventDefault();
|
|
1921
|
+
} else if (isHotkey('backspace', event)) {
|
|
1922
|
+
var _getAbove = getAbove(editor),
|
|
1923
|
+
path = _getAbove[1];
|
|
1924
|
+
|
|
1925
|
+
var range = Editor.range(editor, path); // if it is the last character in the command string
|
|
1926
|
+
|
|
1927
|
+
if (range.focus.offset - range.anchor.offset === 1) {
|
|
1928
|
+
removeMark(editor, {
|
|
1929
|
+
key: COMMAND_PROMPT,
|
|
1930
|
+
at: range
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
} else if (isHotkey('escape', event)) {
|
|
1934
|
+
var _getAbove2 = getAbove(editor),
|
|
1935
|
+
_path = _getAbove2[1];
|
|
1936
|
+
|
|
1937
|
+
var _range = Editor.range(editor, _path);
|
|
1938
|
+
|
|
1939
|
+
removeMark(editor, {
|
|
1940
|
+
key: COMMAND_PROMPT,
|
|
1941
|
+
at: _range
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
};
|
|
1946
|
+
};
|
|
1947
|
+
};
|
|
1948
|
+
|
|
1949
|
+
/**
|
|
1950
|
+
* A command palette plugin (aka slash commands)
|
|
1951
|
+
*
|
|
1952
|
+
* How does it work?
|
|
1953
|
+
* * When the user presses the slash key, the editor will show a command palette
|
|
1954
|
+
* * When the user presses a key, the command palette will show the command suggestions
|
|
1955
|
+
* * When the user presses enter, the command palette will execute the command
|
|
1956
|
+
* * When the user presses escape, the command palette will hide
|
|
1957
|
+
* * When the user presses a letter, number, or space, the command palette will show the command suggestions
|
|
1958
|
+
* * When the user presses backspace, the command palette will remove the last character from the command string
|
|
1959
|
+
*/
|
|
1960
|
+
|
|
1961
|
+
var createCommandPalettePlugin = function createCommandPalettePlugin() {
|
|
1962
|
+
return {
|
|
1963
|
+
key: COMMAND_PROMPT,
|
|
1964
|
+
type: COMMAND_PROMPT,
|
|
1965
|
+
isLeaf: true,
|
|
1966
|
+
component: CommandPrompt,
|
|
1967
|
+
handlers: {
|
|
1968
|
+
onKeyDown: createOnKeyDown()
|
|
1969
|
+
}
|
|
1970
|
+
};
|
|
1971
|
+
};
|
|
1972
|
+
|
|
1973
|
+
function createDragAndDropPlugin() {
|
|
1974
|
+
var DRAGGABLE_TYPES = [BLOCKS.EMBEDDED_ENTRY, BLOCKS.EMBEDDED_ASSET, BLOCKS.HR, INLINES.EMBEDDED_ENTRY];
|
|
1975
|
+
/**
|
|
1976
|
+
* HTML node names where dropping should be allowed
|
|
1977
|
+
* Usually for elements where `Transforms.removeNodes` is needed
|
|
1978
|
+
* 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
|
|
1979
|
+
*/
|
|
1980
|
+
|
|
1981
|
+
var ON_DROP_ALLOWED_TYPES = {
|
|
1982
|
+
TABLE: [INLINES.EMBEDDED_ENTRY]
|
|
1983
|
+
};
|
|
1984
|
+
return {
|
|
1985
|
+
key: 'DragAndDropPlugin',
|
|
1986
|
+
handlers: {
|
|
1987
|
+
// If true, the next handlers will be skipped.
|
|
1988
|
+
onDrop: function onDrop(editor) {
|
|
1989
|
+
return function (event) {
|
|
1990
|
+
var _Array$from = Array.from(getNodes(editor, {
|
|
1991
|
+
match: function match(node) {
|
|
1992
|
+
return DRAGGABLE_TYPES.includes(node == null ? void 0 : node.type);
|
|
1993
|
+
}
|
|
1994
|
+
})),
|
|
1995
|
+
draggingBlock = _Array$from[0];
|
|
1996
|
+
|
|
1997
|
+
if (!draggingBlock) return false;
|
|
1998
|
+
var draggingNode = draggingBlock[0];
|
|
1999
|
+
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
|
|
2000
|
+
|
|
2001
|
+
var dropDisallowed = getParents(event.nativeEvent.target).some(function (node) {
|
|
2002
|
+
var _ON_DROP_ALLOWED_TYPE;
|
|
2003
|
+
|
|
2004
|
+
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;
|
|
2005
|
+
});
|
|
2006
|
+
|
|
2007
|
+
if (!dropDisallowed) {
|
|
2008
|
+
// Move the drop event to a new undo batch mitigating the bug where undo not only moves it back,
|
|
2009
|
+
// but also undoes a previous action: https://github.com/ianstormtaylor/slate/issues/4694
|
|
2010
|
+
editor.history.undos.push([]);
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
return dropDisallowed;
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
};
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
function getParents(el) {
|
|
2021
|
+
var parents = [];
|
|
2022
|
+
parents.push(el);
|
|
2023
|
+
|
|
2024
|
+
while (el.parentNode) {
|
|
2025
|
+
parents.unshift(el.parentNode);
|
|
2026
|
+
el = el.parentNode;
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
return parents;
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
function withLinkTracking(Component) {
|
|
2033
|
+
return function ComponentWithTracking(props) {
|
|
2034
|
+
var editor = useContentfulEditorRef();
|
|
2035
|
+
var onEntityFetchComplete = React__default.useCallback(function () {
|
|
2036
|
+
return editor.tracking.onViewportAction('linkRendered');
|
|
2037
|
+
}, [editor]);
|
|
2038
|
+
return /*#__PURE__*/React__default.createElement(Component, Object.assign({}, props, {
|
|
2039
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2040
|
+
}));
|
|
2041
|
+
};
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
function useFetchedEntity(_ref) {
|
|
2045
|
+
var type = _ref.type,
|
|
2046
|
+
id = _ref.id,
|
|
2047
|
+
onEntityFetchComplete = _ref.onEntityFetchComplete;
|
|
2048
|
+
|
|
2049
|
+
var _useEntities = useEntities(),
|
|
2050
|
+
entries = _useEntities.entries,
|
|
2051
|
+
assets = _useEntities.assets,
|
|
2052
|
+
getOrLoadEntry = _useEntities.getOrLoadEntry,
|
|
2053
|
+
getOrLoadAsset = _useEntities.getOrLoadAsset;
|
|
2054
|
+
|
|
2055
|
+
var store = type === 'Entry' ? entries : assets;
|
|
2056
|
+
|
|
2057
|
+
var _useState = useState(store[id]),
|
|
2058
|
+
entity = _useState[0],
|
|
2059
|
+
setEntity = _useState[1]; // Deep compare the entity value to keep re-rendering to minimal
|
|
2060
|
+
|
|
2061
|
+
|
|
2062
|
+
useEffect(function () {
|
|
2063
|
+
var newValue = store[id];
|
|
2064
|
+
|
|
2065
|
+
if (!areEqual(entity, newValue)) {
|
|
2066
|
+
setEntity(newValue);
|
|
2067
|
+
}
|
|
2068
|
+
}, [store, entity, id]); // Fetch the entity if needed
|
|
2069
|
+
|
|
2070
|
+
useEffect(function () {
|
|
2071
|
+
(type === 'Entry' ? getOrLoadEntry : getOrLoadAsset)(id); // "getOrLoadEntry" and "getOrLoadAsset" instances change with every
|
|
2072
|
+
// entity store update causing page lag on initial load
|
|
2073
|
+
// TODO: consider rewriting useEntities() hook to avoid that happening in
|
|
2074
|
+
// first place.
|
|
2075
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: explain this disable
|
|
2076
|
+
}, [type, id]);
|
|
2077
|
+
useEffect(function () {
|
|
2078
|
+
if (entity) {
|
|
2079
|
+
onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
|
|
2080
|
+
}
|
|
2081
|
+
}, [onEntityFetchComplete, entity]);
|
|
2082
|
+
return entity;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
var InternalAssetCard = /*#__PURE__*/memo(function (props) {
|
|
2086
|
+
if (props.asset === undefined) {
|
|
2087
|
+
return /*#__PURE__*/createElement(AssetCard, {
|
|
2088
|
+
size: "default",
|
|
2089
|
+
isLoading: true
|
|
2090
|
+
});
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
if (props.asset === 'failed') {
|
|
2094
|
+
return /*#__PURE__*/createElement(MissingEntityCard, {
|
|
2095
|
+
entityType: "Asset",
|
|
2096
|
+
isDisabled: props.isDisabled,
|
|
2097
|
+
onRemove: props.onRemove
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
return /*#__PURE__*/createElement(WrappedAssetCard, {
|
|
2102
|
+
getEntityScheduledActions: props.loadEntityScheduledActions,
|
|
2103
|
+
size: "small",
|
|
2104
|
+
isSelected: props.isSelected,
|
|
2105
|
+
isDisabled: props.isDisabled,
|
|
2106
|
+
localeCode: props.locale,
|
|
2107
|
+
defaultLocaleCode: props.sdk.locales["default"],
|
|
2108
|
+
asset: props.asset,
|
|
2109
|
+
onEdit: props.onEdit,
|
|
2110
|
+
onRemove: props.isDisabled ? undefined : props.onRemove,
|
|
2111
|
+
isClickable: false
|
|
2112
|
+
});
|
|
2113
|
+
}, areEqual);
|
|
2114
|
+
InternalAssetCard.displayName = 'InternalAssetCard';
|
|
2115
|
+
function FetchingWrappedAssetCard(props) {
|
|
2116
|
+
var onEntityFetchComplete = props.onEntityFetchComplete,
|
|
2117
|
+
assetId = props.assetId;
|
|
2118
|
+
|
|
2119
|
+
var _useEntities = useEntities(),
|
|
2120
|
+
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
|
|
2121
|
+
|
|
2122
|
+
var asset = useFetchedEntity({
|
|
2123
|
+
type: 'Asset',
|
|
2124
|
+
id: assetId,
|
|
2125
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2126
|
+
});
|
|
2127
|
+
return /*#__PURE__*/createElement(InternalAssetCard, {
|
|
2128
|
+
asset: asset,
|
|
2129
|
+
sdk: props.sdk,
|
|
2130
|
+
isDisabled: props.isDisabled,
|
|
2131
|
+
isSelected: props.isSelected,
|
|
2132
|
+
loadEntityScheduledActions: loadEntityScheduledActions,
|
|
2133
|
+
locale: props.locale,
|
|
2134
|
+
onEdit: props.onEdit,
|
|
2135
|
+
onRemove: props.onRemove
|
|
2136
|
+
});
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
var InternalEntryCard = /*#__PURE__*/memo(function (props) {
|
|
2140
|
+
var entry = props.entry,
|
|
2141
|
+
sdk = props.sdk,
|
|
2142
|
+
loadEntityScheduledActions = props.loadEntityScheduledActions;
|
|
2143
|
+
|
|
2144
|
+
if (entry === undefined) {
|
|
2145
|
+
return /*#__PURE__*/createElement(EntryCard, {
|
|
2146
|
+
isLoading: true
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
if (entry === 'failed') {
|
|
2151
|
+
return /*#__PURE__*/createElement(MissingEntityCard, {
|
|
2152
|
+
entityType: "Entry",
|
|
2153
|
+
isDisabled: props.isDisabled,
|
|
2154
|
+
onRemove: props.onRemove
|
|
2155
|
+
});
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
var contentType = sdk.space.getCachedContentTypes().find(function (contentType) {
|
|
2159
|
+
return contentType.sys.id === entry.sys.contentType.sys.id;
|
|
2160
|
+
});
|
|
2161
|
+
return /*#__PURE__*/createElement(WrappedEntryCard, {
|
|
2162
|
+
size: "default",
|
|
2163
|
+
getAsset: props.sdk.space.getAsset,
|
|
2164
|
+
getEntityScheduledActions: loadEntityScheduledActions,
|
|
2165
|
+
isSelected: props.isSelected,
|
|
2166
|
+
isDisabled: props.isDisabled,
|
|
2167
|
+
localeCode: props.locale,
|
|
2168
|
+
defaultLocaleCode: props.sdk.locales["default"],
|
|
2169
|
+
contentType: contentType,
|
|
2170
|
+
entry: entry,
|
|
2171
|
+
onEdit: props.onEdit,
|
|
2172
|
+
onRemove: props.isDisabled ? undefined : props.onRemove,
|
|
2173
|
+
isClickable: false
|
|
2174
|
+
});
|
|
2175
|
+
}, areEqual);
|
|
2176
|
+
InternalEntryCard.displayName = 'ReferenceCard';
|
|
2177
|
+
var FetchingWrappedEntryCard = function FetchingWrappedEntryCard(props) {
|
|
2178
|
+
var entryId = props.entryId,
|
|
2179
|
+
onEntityFetchComplete = props.onEntityFetchComplete;
|
|
1550
2180
|
|
|
1551
|
-
|
|
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`.
|
|
2181
|
+
var _useEntities = useEntities(),
|
|
2182
|
+
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
|
|
1557
2183
|
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
2184
|
+
var entry = useFetchedEntity({
|
|
2185
|
+
type: 'Entry',
|
|
2186
|
+
id: entryId,
|
|
2187
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2188
|
+
});
|
|
2189
|
+
return /*#__PURE__*/createElement(InternalEntryCard, {
|
|
2190
|
+
entry: entry,
|
|
2191
|
+
sdk: props.sdk,
|
|
2192
|
+
locale: props.locale,
|
|
2193
|
+
isDisabled: props.isDisabled,
|
|
2194
|
+
isSelected: props.isSelected,
|
|
2195
|
+
onEdit: props.onEdit,
|
|
2196
|
+
onRemove: props.onRemove,
|
|
2197
|
+
loadEntityScheduledActions: loadEntityScheduledActions
|
|
2198
|
+
});
|
|
2199
|
+
};
|
|
1564
2200
|
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
//
|
|
1572
|
-
//
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
2201
|
+
var styles$1 = {
|
|
2202
|
+
root: /*#__PURE__*/css({
|
|
2203
|
+
marginBottom: '1.25rem !important',
|
|
2204
|
+
display: 'block'
|
|
2205
|
+
}),
|
|
2206
|
+
container: /*#__PURE__*/css({
|
|
2207
|
+
// The next 2 properties ensure Entity card won't be aligned above
|
|
2208
|
+
// a list item marker (i.e. bullet)
|
|
2209
|
+
display: 'inline-block',
|
|
2210
|
+
verticalAlign: 'text-top',
|
|
2211
|
+
width: '100%'
|
|
2212
|
+
})
|
|
2213
|
+
};
|
|
2214
|
+
function LinkedEntityBlock(props) {
|
|
2215
|
+
var attributes = props.attributes,
|
|
2216
|
+
children = props.children,
|
|
2217
|
+
element = props.element,
|
|
2218
|
+
onEntityFetchComplete = props.onEntityFetchComplete;
|
|
2219
|
+
var isSelected = useSelected();
|
|
2220
|
+
var editor = useContentfulEditor();
|
|
2221
|
+
var sdk = useSdkContext();
|
|
2222
|
+
var isDisabled = useReadOnly();
|
|
2223
|
+
var _element$data$target$ = element.data.target.sys,
|
|
2224
|
+
entityId = _element$data$target$.id,
|
|
2225
|
+
entityType = _element$data$target$.linkType;
|
|
2226
|
+
var handleEditClick = React__default.useCallback(function () {
|
|
2227
|
+
var openEntity = entityType === 'Asset' ? sdk.navigator.openAsset : sdk.navigator.openEntry;
|
|
2228
|
+
return openEntity(entityId, {
|
|
2229
|
+
slideIn: true
|
|
2230
|
+
});
|
|
2231
|
+
}, [sdk, entityId, entityType]);
|
|
2232
|
+
var handleRemoveClick = React__default.useCallback(function () {
|
|
2233
|
+
if (!editor) return;
|
|
2234
|
+
var pathToElement = ReactEditor.findPath(editor, element);
|
|
2235
|
+
Transforms.removeNodes(editor, {
|
|
2236
|
+
at: pathToElement
|
|
2237
|
+
});
|
|
2238
|
+
}, [editor, element]);
|
|
2239
|
+
return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
|
|
2240
|
+
className: styles$1.root,
|
|
2241
|
+
"data-entity-type": entityType,
|
|
2242
|
+
"data-entity-id": entityId,
|
|
2243
|
+
// COMPAT: This makes copy & paste work for Firefox
|
|
2244
|
+
contentEditable: IS_CHROME ? undefined : false,
|
|
2245
|
+
draggable: IS_CHROME ? true : undefined
|
|
2246
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
2247
|
+
// COMPAT: This makes copy & paste work for Chromium/Blink browsers and Safari
|
|
2248
|
+
contentEditable: IS_CHROME ? false : undefined,
|
|
2249
|
+
draggable: IS_CHROME ? true : undefined,
|
|
2250
|
+
className: styles$1.container
|
|
2251
|
+
}, entityType === 'Entry' && /*#__PURE__*/React__default.createElement(FetchingWrappedEntryCard, {
|
|
2252
|
+
sdk: sdk,
|
|
2253
|
+
entryId: entityId,
|
|
2254
|
+
locale: sdk.field.locale,
|
|
2255
|
+
isDisabled: isDisabled,
|
|
2256
|
+
isSelected: isSelected,
|
|
2257
|
+
onRemove: handleRemoveClick,
|
|
2258
|
+
onEdit: handleEditClick,
|
|
2259
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2260
|
+
}), entityType === 'Asset' && /*#__PURE__*/React__default.createElement(FetchingWrappedAssetCard, {
|
|
2261
|
+
sdk: sdk,
|
|
2262
|
+
assetId: entityId,
|
|
2263
|
+
locale: sdk.field.locale,
|
|
2264
|
+
isDisabled: isDisabled,
|
|
2265
|
+
isSelected: isSelected,
|
|
2266
|
+
onRemove: handleRemoveClick,
|
|
2267
|
+
onEdit: handleEditClick,
|
|
2268
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2269
|
+
})), children);
|
|
2270
|
+
}
|
|
1580
2271
|
|
|
1581
2272
|
/* eslint-disable you-dont-need-lodash-underscore/find */
|
|
1582
2273
|
/**
|
|
@@ -1688,7 +2379,7 @@ function _selectEntityAndInsert() {
|
|
|
1688
2379
|
|
|
1689
2380
|
case 12:
|
|
1690
2381
|
Transforms.select(editor, selection);
|
|
1691
|
-
insertBlock(editor, nodeType, entity);
|
|
2382
|
+
insertBlock$1(editor, nodeType, entity);
|
|
1692
2383
|
ensureFollowingParagraph(editor);
|
|
1693
2384
|
logAction('insert', {
|
|
1694
2385
|
nodeType: nodeType
|
|
@@ -1741,7 +2432,7 @@ function ensureFollowingParagraph(editor) {
|
|
|
1741
2432
|
moveToTheNextChar(editor);
|
|
1742
2433
|
}
|
|
1743
2434
|
|
|
1744
|
-
var createNode = function createNode(nodeType, entity) {
|
|
2435
|
+
var createNode$1 = function createNode(nodeType, entity) {
|
|
1745
2436
|
return {
|
|
1746
2437
|
type: nodeType,
|
|
1747
2438
|
data: {
|
|
@@ -1761,9 +2452,9 @@ var createNode = function createNode(nodeType, entity) {
|
|
|
1761
2452
|
}; // TODO: DRY up copied code from HR
|
|
1762
2453
|
|
|
1763
2454
|
|
|
1764
|
-
function insertBlock(editor, nodeType, entity) {
|
|
2455
|
+
function insertBlock$1(editor, nodeType, entity) {
|
|
1765
2456
|
if (!(editor != null && editor.selection)) return;
|
|
1766
|
-
var linkedEntityBlock = createNode(nodeType, entity);
|
|
2457
|
+
var linkedEntityBlock = createNode$1(nodeType, entity);
|
|
1767
2458
|
var hasText = editor.selection && !!getText(editor, editor.selection.focus.path);
|
|
1768
2459
|
|
|
1769
2460
|
if (hasText) {
|
|
@@ -1775,7 +2466,7 @@ function insertBlock(editor, nodeType, entity) {
|
|
|
1775
2466
|
focus(editor);
|
|
1776
2467
|
}
|
|
1777
2468
|
|
|
1778
|
-
var styles$
|
|
2469
|
+
var styles$2 = {
|
|
1779
2470
|
icon: /*#__PURE__*/css({
|
|
1780
2471
|
marginRight: '10px'
|
|
1781
2472
|
})
|
|
@@ -1823,7 +2514,7 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
|
|
|
1823
2514
|
flexDirection: "row"
|
|
1824
2515
|
}, /*#__PURE__*/React__default.createElement(Icon, {
|
|
1825
2516
|
as: type === 'Asset' ? AssetIcon : EmbeddedEntryBlockIcon,
|
|
1826
|
-
className: "rich-text__embedded-entry-list-icon " + styles$
|
|
2517
|
+
className: "rich-text__embedded-entry-list-icon " + styles$2.icon,
|
|
1827
2518
|
variant: "secondary"
|
|
1828
2519
|
}), /*#__PURE__*/React__default.createElement("span", null, type)));
|
|
1829
2520
|
}
|
|
@@ -1922,7 +2613,7 @@ var createEmbeddedAssetBlockPlugin = /*#__PURE__*/createEmbeddedEntityPlugin(BLO
|
|
|
1922
2613
|
|
|
1923
2614
|
var getEntryTitle = entityHelpers.getEntryTitle,
|
|
1924
2615
|
getEntryStatus = entityHelpers.getEntryStatus;
|
|
1925
|
-
var styles$
|
|
2616
|
+
var styles$3 = {
|
|
1926
2617
|
scheduledIcon: /*#__PURE__*/css({
|
|
1927
2618
|
verticalAlign: 'text-bottom',
|
|
1928
2619
|
marginRight: tokens.spacing2Xs
|
|
@@ -2017,13 +2708,13 @@ function FetchingWrappedInlineEntryCard(props) {
|
|
|
2017
2708
|
entityType: "Entry",
|
|
2018
2709
|
entityId: entry.sys.id
|
|
2019
2710
|
}, /*#__PURE__*/React__default.createElement(ClockIcon, {
|
|
2020
|
-
className: styles$
|
|
2711
|
+
className: styles$3.scheduledIcon,
|
|
2021
2712
|
variant: "muted",
|
|
2022
2713
|
testId: "scheduled-icon"
|
|
2023
2714
|
})), /*#__PURE__*/React__default.createElement(Text$1, null, title));
|
|
2024
2715
|
}
|
|
2025
2716
|
|
|
2026
|
-
function createInlineEntryNode(id) {
|
|
2717
|
+
function createInlineEntryNode$1(id) {
|
|
2027
2718
|
return {
|
|
2028
2719
|
type: INLINES.EMBEDDED_ENTRY,
|
|
2029
2720
|
children: [{
|
|
@@ -2041,7 +2732,7 @@ function createInlineEntryNode(id) {
|
|
|
2041
2732
|
};
|
|
2042
2733
|
}
|
|
2043
2734
|
|
|
2044
|
-
var styles$
|
|
2735
|
+
var styles$4 = {
|
|
2045
2736
|
icon: /*#__PURE__*/css({
|
|
2046
2737
|
marginRight: '10px'
|
|
2047
2738
|
}),
|
|
@@ -2077,7 +2768,7 @@ function EmbeddedEntityInline(props) {
|
|
|
2077
2768
|
}
|
|
2078
2769
|
|
|
2079
2770
|
return /*#__PURE__*/createElement("span", Object.assign({}, props.attributes, {
|
|
2080
|
-
className: styles$
|
|
2771
|
+
className: styles$4.root,
|
|
2081
2772
|
"data-embedded-entity-inline-id": entryId,
|
|
2082
2773
|
// COMPAT: This makes copy & paste work for Firefox
|
|
2083
2774
|
contentEditable: IS_CHROME ? undefined : false,
|
|
@@ -2133,7 +2824,7 @@ function _selectEntityAndInsert$1() {
|
|
|
2133
2824
|
return _context2.abrupt("return");
|
|
2134
2825
|
|
|
2135
2826
|
case 10:
|
|
2136
|
-
inlineEntryNode = createInlineEntryNode(entry.sys.id);
|
|
2827
|
+
inlineEntryNode = createInlineEntryNode$1(entry.sys.id);
|
|
2137
2828
|
logAction('insert', {
|
|
2138
2829
|
nodeType: INLINES.EMBEDDED_ENTRY
|
|
2139
2830
|
}); // Got to wait until focus is really back on the editor or setSelection() won't work.
|
|
@@ -2207,7 +2898,7 @@ function ToolbarEmbeddedEntityInlineButton(props) {
|
|
|
2207
2898
|
flexDirection: "row"
|
|
2208
2899
|
}, /*#__PURE__*/createElement(EmbeddedEntryInlineIcon, {
|
|
2209
2900
|
variant: "secondary",
|
|
2210
|
-
className: "rich-text__embedded-entry-list-icon " + styles$
|
|
2901
|
+
className: "rich-text__embedded-entry-list-icon " + styles$4.icon
|
|
2211
2902
|
}), /*#__PURE__*/createElement("span", null, "Inline entry")));
|
|
2212
2903
|
}
|
|
2213
2904
|
function createEmbeddedEntityInlinePlugin(sdk) {
|
|
@@ -2231,7 +2922,7 @@ function createEmbeddedEntityInlinePlugin(sdk) {
|
|
|
2231
2922
|
}],
|
|
2232
2923
|
withoutChildren: true,
|
|
2233
2924
|
getNode: function getNode(el) {
|
|
2234
|
-
return createInlineEntryNode(el.getAttribute(htmlAttributeName));
|
|
2925
|
+
return createInlineEntryNode$1(el.getAttribute(htmlAttributeName));
|
|
2235
2926
|
}
|
|
2236
2927
|
}
|
|
2237
2928
|
};
|
|
@@ -2283,7 +2974,7 @@ var isMarkEnabled = function isMarkEnabled(field, mark) {
|
|
|
2283
2974
|
};
|
|
2284
2975
|
|
|
2285
2976
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _dropdown, _LABELS;
|
|
2286
|
-
var styles$
|
|
2977
|
+
var styles$5 = {
|
|
2287
2978
|
dropdown: (_dropdown = {
|
|
2288
2979
|
root: /*#__PURE__*/css(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-weight: ", ";\n "])), tokens.fontWeightDemiBold)
|
|
2289
2980
|
}, _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 +3069,7 @@ function ToolbarHeadingButton(props) {
|
|
|
2378
3069
|
testId: "dropdown-option-" + nodeType,
|
|
2379
3070
|
disabled: props.isDisabled
|
|
2380
3071
|
}, /*#__PURE__*/createElement("span", {
|
|
2381
|
-
className: cx(styles$
|
|
3072
|
+
className: cx(styles$5.dropdown.root, styles$5.dropdown[nodeType])
|
|
2382
3073
|
}, LABELS[nodeType]));
|
|
2383
3074
|
}).filter(Boolean)));
|
|
2384
3075
|
}
|
|
@@ -2448,7 +3139,7 @@ var transformLift = function transformLift(editor, _ref4) {
|
|
|
2448
3139
|
};
|
|
2449
3140
|
|
|
2450
3141
|
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$
|
|
3142
|
+
var styles$6 = {
|
|
2452
3143
|
dropdown: (_dropdown$1 = {
|
|
2453
3144
|
root: /*#__PURE__*/css(_templateObject$1 || (_templateObject$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-weight: ", ";\n "])), tokens.fontWeightDemiBold)
|
|
2454
3145
|
}, _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 +3151,7 @@ var styles$5 = {
|
|
|
2460
3151
|
function createHeading(Tag, block) {
|
|
2461
3152
|
return function Heading(props) {
|
|
2462
3153
|
return /*#__PURE__*/createElement(Tag, Object.assign({}, props.attributes, {
|
|
2463
|
-
className: cx(styles$
|
|
3154
|
+
className: cx(styles$6.headings.root, styles$6.headings[block])
|
|
2464
3155
|
}), props.children);
|
|
2465
3156
|
};
|
|
2466
3157
|
}
|
|
@@ -2556,7 +3247,7 @@ var createHeadingPlugin = function createHeadingPlugin() {
|
|
|
2556
3247
|
};
|
|
2557
3248
|
};
|
|
2558
3249
|
|
|
2559
|
-
var styles$
|
|
3250
|
+
var styles$7 = {
|
|
2560
3251
|
button: /*#__PURE__*/css({
|
|
2561
3252
|
height: '30px',
|
|
2562
3253
|
width: '30px',
|
|
@@ -2582,7 +3273,7 @@ function ToolbarButton(props) {
|
|
|
2582
3273
|
};
|
|
2583
3274
|
|
|
2584
3275
|
var button = /*#__PURE__*/React__default.createElement(Button, {
|
|
2585
|
-
className: cx(styles$
|
|
3276
|
+
className: cx(styles$7.button, className),
|
|
2586
3277
|
isDisabled: isDisabled,
|
|
2587
3278
|
startIcon: children,
|
|
2588
3279
|
onClick: handleClick,
|
|
@@ -2593,7 +3284,7 @@ function ToolbarButton(props) {
|
|
|
2593
3284
|
|
|
2594
3285
|
if (title) {
|
|
2595
3286
|
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
2596
|
-
className: styles$
|
|
3287
|
+
className: styles$7.tooltip,
|
|
2597
3288
|
placement: "bottom",
|
|
2598
3289
|
content: title
|
|
2599
3290
|
}, button);
|
|
@@ -2603,7 +3294,7 @@ function ToolbarButton(props) {
|
|
|
2603
3294
|
}
|
|
2604
3295
|
|
|
2605
3296
|
var _templateObject$2, _templateObject2$2, _templateObject3$2;
|
|
2606
|
-
var styles$
|
|
3297
|
+
var styles$8 = {
|
|
2607
3298
|
container: /*#__PURE__*/css(_templateObject$2 || (_templateObject$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0 0 ", ";\n "])), tokens.spacingL),
|
|
2608
3299
|
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
3300
|
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 +3352,14 @@ function Hr(props) {
|
|
|
2661
3352
|
var isSelected = useSelected();
|
|
2662
3353
|
var isFocused = useFocused();
|
|
2663
3354
|
return /*#__PURE__*/createElement("div", Object.assign({}, props.attributes, {
|
|
2664
|
-
className: styles$
|
|
3355
|
+
className: styles$8.container,
|
|
2665
3356
|
"data-void-element": BLOCKS.HR
|
|
2666
3357
|
}), /*#__PURE__*/createElement("div", {
|
|
2667
3358
|
draggable: true,
|
|
2668
3359
|
// 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
3360
|
contentEditable: false
|
|
2670
3361
|
}, /*#__PURE__*/createElement("hr", {
|
|
2671
|
-
className: cx(styles$
|
|
3362
|
+
className: cx(styles$8.hr, isSelected && isFocused ? styles$8.hrSelected : undefined)
|
|
2672
3363
|
})), props.children);
|
|
2673
3364
|
}
|
|
2674
3365
|
var createHrPlugin = function createHrPlugin() {
|
|
@@ -2695,7 +3386,7 @@ var createHrPlugin = function createHrPlugin() {
|
|
|
2695
3386
|
};
|
|
2696
3387
|
|
|
2697
3388
|
var _templateObject$3, _SYS_LINK_TYPES, _LINK_TYPE_SELECTION_;
|
|
2698
|
-
var styles$
|
|
3389
|
+
var styles$9 = {
|
|
2699
3390
|
removeSelectionLabel: /*#__PURE__*/css(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-left: ", ";\n "])), tokens.spacingS)
|
|
2700
3391
|
};
|
|
2701
3392
|
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 +3569,7 @@ function HyperlinkModal(props) {
|
|
|
2878
3569
|
}, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? /*#__PURE__*/createElement(Fragment, null, !props.readonly && /*#__PURE__*/createElement(TextLink, {
|
|
2879
3570
|
testId: "entity-selection-link",
|
|
2880
3571
|
onClick: resetLinkEntity,
|
|
2881
|
-
className: styles$
|
|
3572
|
+
className: styles$9.removeSelectionLabel
|
|
2882
3573
|
}, "Remove selection"), /*#__PURE__*/createElement("div", null, linkType === INLINES.ENTRY_HYPERLINK && /*#__PURE__*/createElement(FetchingWrappedEntryCard, {
|
|
2883
3574
|
sdk: props.sdk,
|
|
2884
3575
|
locale: props.sdk.field.locale,
|
|
@@ -3219,7 +3910,7 @@ function useEntityInfo(props) {
|
|
|
3219
3910
|
return getEntityInfo(status.data);
|
|
3220
3911
|
}
|
|
3221
3912
|
|
|
3222
|
-
var styles$
|
|
3913
|
+
var styles$a = {
|
|
3223
3914
|
hyperlinkWrapper: /*#__PURE__*/css({
|
|
3224
3915
|
display: 'inline',
|
|
3225
3916
|
position: 'static',
|
|
@@ -3264,13 +3955,13 @@ function EntityHyperlink(props) {
|
|
|
3264
3955
|
|
|
3265
3956
|
return /*#__PURE__*/createElement(Tooltip, {
|
|
3266
3957
|
content: tooltipContent,
|
|
3267
|
-
targetWrapperClassName: styles$
|
|
3958
|
+
targetWrapperClassName: styles$a.hyperlinkWrapper,
|
|
3268
3959
|
placement: "bottom",
|
|
3269
3960
|
maxWidth: "auto"
|
|
3270
3961
|
}, /*#__PURE__*/createElement(TextLink, {
|
|
3271
3962
|
as: "a",
|
|
3272
3963
|
onClick: handleClick,
|
|
3273
|
-
className: styles$
|
|
3964
|
+
className: styles$a.hyperlink,
|
|
3274
3965
|
"data-link-type": target.sys.linkType,
|
|
3275
3966
|
"data-link-id": target.sys.id
|
|
3276
3967
|
}, props.children));
|
|
@@ -3294,7 +3985,7 @@ function UrlHyperlink(props) {
|
|
|
3294
3985
|
|
|
3295
3986
|
return /*#__PURE__*/createElement(Tooltip, {
|
|
3296
3987
|
content: uri,
|
|
3297
|
-
targetWrapperClassName: styles$
|
|
3988
|
+
targetWrapperClassName: styles$a.hyperlinkWrapper,
|
|
3298
3989
|
placement: "bottom",
|
|
3299
3990
|
maxWidth: "auto"
|
|
3300
3991
|
}, /*#__PURE__*/createElement(TextLink, {
|
|
@@ -3302,7 +3993,7 @@ function UrlHyperlink(props) {
|
|
|
3302
3993
|
href: uri,
|
|
3303
3994
|
rel: "noopener noreferrer",
|
|
3304
3995
|
onClick: handleClick,
|
|
3305
|
-
className: styles$
|
|
3996
|
+
className: styles$a.hyperlink
|
|
3306
3997
|
}, props.children));
|
|
3307
3998
|
}
|
|
3308
3999
|
|
|
@@ -3428,12 +4119,12 @@ var createHyperlinkPlugin = function createHyperlinkPlugin(sdk) {
|
|
|
3428
4119
|
|
|
3429
4120
|
var _templateObject$4, _templateObject2$3, _templateObject3$3, _styles;
|
|
3430
4121
|
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$
|
|
4122
|
+
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
4123
|
|
|
3433
4124
|
function createList(Tag, block) {
|
|
3434
4125
|
return function List(props) {
|
|
3435
4126
|
return /*#__PURE__*/createElement(Tag, Object.assign({}, props.attributes, {
|
|
3436
|
-
className: cx(baseStyle, styles$
|
|
4127
|
+
className: cx(baseStyle, styles$b[block])
|
|
3437
4128
|
}), props.children);
|
|
3438
4129
|
};
|
|
3439
4130
|
}
|
|
@@ -4414,14 +5105,14 @@ var ToolbarBoldButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
4414
5105
|
mark: MARKS.BOLD,
|
|
4415
5106
|
icon: /*#__PURE__*/createElement(FormatBoldIcon, null)
|
|
4416
5107
|
});
|
|
4417
|
-
var styles$
|
|
5108
|
+
var styles$c = {
|
|
4418
5109
|
bold: /*#__PURE__*/css({
|
|
4419
5110
|
fontWeight: 600
|
|
4420
5111
|
})
|
|
4421
5112
|
};
|
|
4422
5113
|
function Bold(props) {
|
|
4423
5114
|
return /*#__PURE__*/createElement("strong", Object.assign({}, props.attributes, {
|
|
4424
|
-
className: styles$
|
|
5115
|
+
className: styles$c.bold
|
|
4425
5116
|
}), props.children);
|
|
4426
5117
|
}
|
|
4427
5118
|
|
|
@@ -4461,7 +5152,7 @@ var ToolbarCodeButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
4461
5152
|
mark: MARKS.CODE,
|
|
4462
5153
|
icon: /*#__PURE__*/createElement(CodeIcon, null)
|
|
4463
5154
|
});
|
|
4464
|
-
var styles$
|
|
5155
|
+
var styles$d = {
|
|
4465
5156
|
code: /*#__PURE__*/css({
|
|
4466
5157
|
fontFamily: 'monospace',
|
|
4467
5158
|
fontSize: '.9em'
|
|
@@ -4469,7 +5160,7 @@ var styles$c = {
|
|
|
4469
5160
|
};
|
|
4470
5161
|
function Code(props) {
|
|
4471
5162
|
return /*#__PURE__*/createElement("code", Object.assign({}, props.attributes, {
|
|
4472
|
-
className: styles$
|
|
5163
|
+
className: styles$d.code
|
|
4473
5164
|
}), props.children);
|
|
4474
5165
|
}
|
|
4475
5166
|
var createCodePlugin = function createCodePlugin() {
|
|
@@ -4499,14 +5190,14 @@ var ToolbarItalicButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
4499
5190
|
mark: MARKS.ITALIC,
|
|
4500
5191
|
icon: /*#__PURE__*/createElement(FormatItalicIcon, null)
|
|
4501
5192
|
});
|
|
4502
|
-
var styles$
|
|
5193
|
+
var styles$e = {
|
|
4503
5194
|
italic: /*#__PURE__*/css({
|
|
4504
5195
|
fontStyle: 'italic'
|
|
4505
5196
|
})
|
|
4506
5197
|
};
|
|
4507
5198
|
function Italic(props) {
|
|
4508
5199
|
return /*#__PURE__*/createElement("em", Object.assign({}, props.attributes, {
|
|
4509
|
-
className: styles$
|
|
5200
|
+
className: styles$e.italic
|
|
4510
5201
|
}), props.children);
|
|
4511
5202
|
}
|
|
4512
5203
|
var createItalicPlugin = function createItalicPlugin() {
|
|
@@ -4782,10 +5473,10 @@ var createNormalizerPlugin = function createNormalizerPlugin() {
|
|
|
4782
5473
|
};
|
|
4783
5474
|
|
|
4784
5475
|
var _templateObject$6, _styles$1;
|
|
4785
|
-
var styles$
|
|
5476
|
+
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
5477
|
function Paragraph(props) {
|
|
4787
5478
|
return /*#__PURE__*/createElement("div", Object.assign({}, props.attributes, {
|
|
4788
|
-
className: styles$
|
|
5479
|
+
className: styles$f[BLOCKS.PARAGRAPH]
|
|
4789
5480
|
}), props.children);
|
|
4790
5481
|
}
|
|
4791
5482
|
|
|
@@ -5198,185 +5889,6 @@ var createSelectOnBackspacePlugin = function createSelectOnBackspacePlugin() {
|
|
|
5198
5889
|
});
|
|
5199
5890
|
};
|
|
5200
5891
|
|
|
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
5892
|
var addRow = function addRow(editor, getNextRowPath) {
|
|
5381
5893
|
if (someNode(editor, {
|
|
5382
5894
|
match: {
|
|
@@ -5606,7 +6118,7 @@ var isTable = function isTable(node) {
|
|
|
5606
6118
|
return Element.isElement(node) && node.type === BLOCKS.TABLE;
|
|
5607
6119
|
};
|
|
5608
6120
|
|
|
5609
|
-
var styles$
|
|
6121
|
+
var styles$g = {
|
|
5610
6122
|
topRight: /*#__PURE__*/css({
|
|
5611
6123
|
position: 'absolute',
|
|
5612
6124
|
top: '6px',
|
|
@@ -5695,7 +6207,7 @@ var TableActions = function TableActions() {
|
|
|
5695
6207
|
size: "small",
|
|
5696
6208
|
variant: "transparent",
|
|
5697
6209
|
tabIndex: -1,
|
|
5698
|
-
className: styles$
|
|
6210
|
+
className: styles$g.topRight,
|
|
5699
6211
|
icon: /*#__PURE__*/React__default.createElement(ChevronDownIcon, null),
|
|
5700
6212
|
"aria-label": "Open table menu",
|
|
5701
6213
|
testId: "cf-table-actions-button"
|
|
@@ -5720,38 +6232,38 @@ var TableActions = function TableActions() {
|
|
|
5720
6232
|
};
|
|
5721
6233
|
|
|
5722
6234
|
var _templateObject$7;
|
|
5723
|
-
var style$
|
|
6235
|
+
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
6236
|
var Cell = function Cell(props) {
|
|
5725
6237
|
var isSelected = useSelected();
|
|
5726
6238
|
return /*#__PURE__*/createElement("td", Object.assign({}, props.attributes, props.element.data, {
|
|
5727
|
-
className: style$
|
|
6239
|
+
className: style$2
|
|
5728
6240
|
}), isSelected && /*#__PURE__*/createElement(TableActions, null), props.children);
|
|
5729
6241
|
};
|
|
5730
6242
|
|
|
5731
6243
|
var _templateObject$8;
|
|
5732
|
-
var style$
|
|
6244
|
+
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
6245
|
var HeaderCell = function HeaderCell(props) {
|
|
5734
6246
|
var isSelected = useSelected();
|
|
5735
6247
|
return /*#__PURE__*/createElement("th", Object.assign({}, props.attributes, props.element.data, {
|
|
5736
|
-
className: style$
|
|
6248
|
+
className: style$3
|
|
5737
6249
|
}), isSelected && /*#__PURE__*/createElement(TableActions, null), props.children);
|
|
5738
6250
|
};
|
|
5739
6251
|
|
|
5740
6252
|
var _templateObject$9;
|
|
5741
|
-
var style$
|
|
6253
|
+
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
6254
|
var Row = function Row(props) {
|
|
5743
6255
|
return /*#__PURE__*/createElement("tr", Object.assign({}, props.attributes, {
|
|
5744
|
-
className: style$
|
|
6256
|
+
className: style$4
|
|
5745
6257
|
}), props.children);
|
|
5746
6258
|
};
|
|
5747
6259
|
|
|
5748
6260
|
var _templateObject$a;
|
|
5749
|
-
var style$
|
|
6261
|
+
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
6262
|
var Table = function Table(props) {
|
|
5751
6263
|
return /*#__PURE__*/createElement("div", {
|
|
5752
6264
|
"data-block-type": BLOCKS.TABLE
|
|
5753
6265
|
}, /*#__PURE__*/createElement("table", Object.assign({
|
|
5754
|
-
className: style$
|
|
6266
|
+
className: style$5
|
|
5755
6267
|
}, props.attributes), /*#__PURE__*/createElement("tbody", null, props.children)));
|
|
5756
6268
|
};
|
|
5757
6269
|
|
|
@@ -6498,7 +7010,7 @@ var getPlugins = function getPlugins(sdk, onAction) {
|
|
|
6498
7010
|
return [// AST must come after the HTML deserializer
|
|
6499
7011
|
createDeserializeHtmlPlugin(), createDeserializeAstPlugin(), createDeserializeDocxPlugin(), // Tracking - This should come first so all plugins below will have access to `editor.tracking`
|
|
6500
7012
|
createTrackingPlugin(onAction), // Global / Global shortcuts
|
|
6501
|
-
createDragAndDropPlugin(),
|
|
7013
|
+
createDragAndDropPlugin(), createCommandPalettePlugin(), // Block Elements
|
|
6502
7014
|
createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
|
|
6503
7015
|
createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
|
|
6504
7016
|
createMarksPlugin(), // Other
|
|
@@ -6629,7 +7141,7 @@ var normalizeEditorValue = function normalizeEditorValue(value, options) {
|
|
|
6629
7141
|
};
|
|
6630
7142
|
|
|
6631
7143
|
var STYLE_EDITOR_BORDER = "1px solid " + tokens.gray400;
|
|
6632
|
-
var styles$
|
|
7144
|
+
var styles$h = {
|
|
6633
7145
|
root: /*#__PURE__*/css({
|
|
6634
7146
|
position: 'relative'
|
|
6635
7147
|
}),
|
|
@@ -6746,7 +7258,7 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
|
|
|
6746
7258
|
}, actions) : null;
|
|
6747
7259
|
};
|
|
6748
7260
|
|
|
6749
|
-
var styles$
|
|
7261
|
+
var styles$i = {
|
|
6750
7262
|
toolbar: /*#__PURE__*/css({
|
|
6751
7263
|
border: "1px solid " + tokens.gray400,
|
|
6752
7264
|
backgroundColor: tokens.gray100,
|
|
@@ -6791,14 +7303,14 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
6791
7303
|
var shouldDisableTables = isDisabled || !canInsertBlocks || isListSelected || isBlockquoteSelected;
|
|
6792
7304
|
return /*#__PURE__*/React__default.createElement(Flex, {
|
|
6793
7305
|
testId: "toolbar",
|
|
6794
|
-
className: styles$
|
|
7306
|
+
className: styles$i.toolbar,
|
|
6795
7307
|
alignItems: "center"
|
|
6796
7308
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
6797
|
-
className: styles$
|
|
7309
|
+
className: styles$i.formattingOptionsWrapper
|
|
6798
7310
|
}, /*#__PURE__*/React__default.createElement(ToolbarHeadingButton, {
|
|
6799
7311
|
isDisabled: isDisabled || !canInsertBlocks
|
|
6800
7312
|
}), validationInfo.isAnyMarkEnabled && /*#__PURE__*/React__default.createElement("span", {
|
|
6801
|
-
className: styles$
|
|
7313
|
+
className: styles$i.divider
|
|
6802
7314
|
}), isMarkEnabled(sdk.field, MARKS.BOLD) && /*#__PURE__*/React__default.createElement(ToolbarBoldButton, {
|
|
6803
7315
|
isDisabled: isDisabled
|
|
6804
7316
|
}), isMarkEnabled(sdk.field, MARKS.ITALIC) && /*#__PURE__*/React__default.createElement(ToolbarItalicButton, {
|
|
@@ -6808,11 +7320,11 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
6808
7320
|
}), isMarkEnabled(sdk.field, MARKS.CODE) && /*#__PURE__*/React__default.createElement(ToolbarCodeButton, {
|
|
6809
7321
|
isDisabled: isDisabled
|
|
6810
7322
|
}), validationInfo.isAnyHyperlinkEnabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
|
6811
|
-
className: styles$
|
|
7323
|
+
className: styles$i.divider
|
|
6812
7324
|
}), /*#__PURE__*/React__default.createElement(ToolbarHyperlinkButton, {
|
|
6813
7325
|
isDisabled: isDisabled
|
|
6814
7326
|
})), validationInfo.isAnyBlockFormattingEnabled && /*#__PURE__*/React__default.createElement("span", {
|
|
6815
|
-
className: styles$
|
|
7327
|
+
className: styles$i.divider
|
|
6816
7328
|
}), /*#__PURE__*/React__default.createElement(ToolbarListButton, {
|
|
6817
7329
|
isDisabled: isDisabled || !canInsertBlocks
|
|
6818
7330
|
}), isNodeTypeEnabled(sdk.field, BLOCKS.QUOTE) && /*#__PURE__*/React__default.createElement(ToolbarQuoteButton, {
|
|
@@ -6822,7 +7334,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
6822
7334
|
}), isNodeTypeEnabled(sdk.field, BLOCKS.TABLE) && /*#__PURE__*/React__default.createElement(ToolbarTableButton, {
|
|
6823
7335
|
isDisabled: shouldDisableTables
|
|
6824
7336
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
6825
|
-
className: styles$
|
|
7337
|
+
className: styles$i.embedActionsWrapper
|
|
6826
7338
|
}, /*#__PURE__*/React__default.createElement(EmbedEntityWidget, {
|
|
6827
7339
|
isDisabled: isDisabled,
|
|
6828
7340
|
canInsertBlocks: canInsertBlocks
|
|
@@ -6847,7 +7359,7 @@ function getValidationInfo(field) {
|
|
|
6847
7359
|
}
|
|
6848
7360
|
|
|
6849
7361
|
var _templateObject$b;
|
|
6850
|
-
var styles$
|
|
7362
|
+
var styles$j = {
|
|
6851
7363
|
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
7364
|
};
|
|
6853
7365
|
|
|
@@ -6855,7 +7367,7 @@ var StickyToolbarWrapper = function StickyToolbarWrapper(_ref) {
|
|
|
6855
7367
|
var isDisabled = _ref.isDisabled,
|
|
6856
7368
|
children = _ref.children;
|
|
6857
7369
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
6858
|
-
className: isDisabled ? '' : styles$
|
|
7370
|
+
className: isDisabled ? '' : styles$j.nativeSticky
|
|
6859
7371
|
}, children);
|
|
6860
7372
|
};
|
|
6861
7373
|
|
|
@@ -6871,6 +7383,21 @@ var isRelevantOperation = function isRelevantOperation(op) {
|
|
|
6871
7383
|
return true;
|
|
6872
7384
|
};
|
|
6873
7385
|
|
|
7386
|
+
var removeInternalMarks = function removeInternalMarks(document) {
|
|
7387
|
+
return _extends({}, document, {
|
|
7388
|
+
content: document.content.map(function (node) {
|
|
7389
|
+
if (node.nodeType === 'text') {
|
|
7390
|
+
node.marks = node.marks.filter(function (mark) {
|
|
7391
|
+
return mark.type !== COMMAND_PROMPT;
|
|
7392
|
+
});
|
|
7393
|
+
return node;
|
|
7394
|
+
}
|
|
7395
|
+
|
|
7396
|
+
return removeInternalMarks(node);
|
|
7397
|
+
})
|
|
7398
|
+
});
|
|
7399
|
+
};
|
|
7400
|
+
|
|
6874
7401
|
var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
6875
7402
|
var editorId = _ref.editorId,
|
|
6876
7403
|
handler = _ref.handler,
|
|
@@ -6878,10 +7405,12 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
|
6878
7405
|
onSkip = _ref.onSkip;
|
|
6879
7406
|
var onChange = useMemo(function () {
|
|
6880
7407
|
return debounce(function (document) {
|
|
6881
|
-
|
|
7408
|
+
var contentfulDocument = toContentfulDocument({
|
|
6882
7409
|
document: document,
|
|
6883
7410
|
schema: schema
|
|
6884
|
-
})
|
|
7411
|
+
});
|
|
7412
|
+
var cleanedDocument = removeInternalMarks(contentfulDocument);
|
|
7413
|
+
handler == null ? void 0 : handler(cleanedDocument);
|
|
6885
7414
|
}, 500);
|
|
6886
7415
|
}, [handler]);
|
|
6887
7416
|
return useCallback(function (value) {
|
|
@@ -6950,9 +7479,9 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6950
7479
|
setPendingExternalUpdate(true);
|
|
6951
7480
|
setEditorContent(editor, documentToEditorValue(props.value));
|
|
6952
7481
|
}, [props.value, id]);
|
|
6953
|
-
var classNames = cx(styles$
|
|
7482
|
+
var classNames = cx(styles$h.editor, props.minHeight !== undefined ? css({
|
|
6954
7483
|
minHeight: props.minHeight
|
|
6955
|
-
}) : undefined, props.isDisabled ? styles$
|
|
7484
|
+
}) : undefined, props.isDisabled ? styles$h.disabled : styles$h.enabled, props.isToolbarHidden && styles$h.hiddenToolbar);
|
|
6956
7485
|
useEffect(function () {
|
|
6957
7486
|
if (!isFirstRender) {
|
|
6958
7487
|
return;
|
|
@@ -6968,7 +7497,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6968
7497
|
}, /*#__PURE__*/React__default.createElement(ContentfulEditorIdProvider, {
|
|
6969
7498
|
value: id
|
|
6970
7499
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
6971
|
-
className: styles$
|
|
7500
|
+
className: styles$h.root,
|
|
6972
7501
|
"data-test-id": "rich-text-editor"
|
|
6973
7502
|
}, /*#__PURE__*/React__default.createElement(Plate, {
|
|
6974
7503
|
id: id,
|
|
@@ -6983,9 +7512,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6983
7512
|
isDisabled: props.isDisabled
|
|
6984
7513
|
}, /*#__PURE__*/React__default.createElement(Toolbar, {
|
|
6985
7514
|
isDisabled: props.isDisabled
|
|
6986
|
-
}))
|
|
6987
|
-
editorId: id
|
|
6988
|
-
})))));
|
|
7515
|
+
}))))));
|
|
6989
7516
|
};
|
|
6990
7517
|
|
|
6991
7518
|
var RichTextEditor = function RichTextEditor(props) {
|