@contentful/field-editor-rich-text 2.0.2 → 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 +14 -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 +3 -3
- package/dist/plugins/CommandPalette/CommandPanel/InViewport/InViewport.d.ts +0 -37
- package/dist/plugins/EmbeddedEntryInline/FetchingWrappedInlineEntryCard.d.ts +0 -14
- package/dist/plugins/Hyperlink/Hyperlink.d.ts +0 -13
- 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
|
@@ -16,16 +16,16 @@ var noop = _interopDefault(require('lodash/noop'));
|
|
|
16
16
|
var plateSerializerDocx = require('@udecode/plate-serializer-docx');
|
|
17
17
|
var plateBreak = require('@udecode/plate-break');
|
|
18
18
|
var plateResetNode = require('@udecode/plate-reset-node');
|
|
19
|
-
var isHotkey = _interopDefault(require('is-hotkey'));
|
|
20
19
|
var slate = require('slate');
|
|
21
20
|
var Slate = require('slate-react');
|
|
22
|
-
var constate = _interopDefault(require('constate'));
|
|
23
21
|
var f36Components = require('@contentful/f36-components');
|
|
22
|
+
var constate = _interopDefault(require('constate'));
|
|
23
|
+
var isHotkey = _interopDefault(require('is-hotkey'));
|
|
24
|
+
var tokens = _interopDefault(require('@contentful/f36-tokens'));
|
|
24
25
|
var find = _interopDefault(require('lodash/find'));
|
|
25
26
|
var flow = _interopDefault(require('lodash/flow'));
|
|
26
27
|
var get = _interopDefault(require('lodash/get'));
|
|
27
28
|
var f36Icons = require('@contentful/f36-icons');
|
|
28
|
-
var tokens = _interopDefault(require('@contentful/f36-tokens'));
|
|
29
29
|
var plateList = require('@udecode/plate-list');
|
|
30
30
|
var castArray = _interopDefault(require('lodash/castArray'));
|
|
31
31
|
var plateBasicMarks = require('@udecode/plate-basic-marks');
|
|
@@ -341,65 +341,6 @@ var createResetNodePlugin = function createResetNodePlugin() {
|
|
|
341
341
|
});
|
|
342
342
|
};
|
|
343
343
|
|
|
344
|
-
function createDragAndDropPlugin() {
|
|
345
|
-
var DRAGGABLE_TYPES = [Contentful.BLOCKS.EMBEDDED_ENTRY, Contentful.BLOCKS.EMBEDDED_ASSET, Contentful.BLOCKS.HR, Contentful.INLINES.EMBEDDED_ENTRY];
|
|
346
|
-
/**
|
|
347
|
-
* HTML node names where dropping should be allowed
|
|
348
|
-
* Usually for elements where `Transforms.removeNodes` is needed
|
|
349
|
-
* 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
|
|
350
|
-
*/
|
|
351
|
-
|
|
352
|
-
var ON_DROP_ALLOWED_TYPES = {
|
|
353
|
-
TABLE: [Contentful.INLINES.EMBEDDED_ENTRY]
|
|
354
|
-
};
|
|
355
|
-
return {
|
|
356
|
-
key: 'DragAndDropPlugin',
|
|
357
|
-
handlers: {
|
|
358
|
-
// If true, the next handlers will be skipped.
|
|
359
|
-
onDrop: function onDrop(editor) {
|
|
360
|
-
return function (event) {
|
|
361
|
-
var _Array$from = Array.from(plateCore.getNodes(editor, {
|
|
362
|
-
match: function match(node) {
|
|
363
|
-
return DRAGGABLE_TYPES.includes(node == null ? void 0 : node.type);
|
|
364
|
-
}
|
|
365
|
-
})),
|
|
366
|
-
draggingBlock = _Array$from[0];
|
|
367
|
-
|
|
368
|
-
if (!draggingBlock) return false;
|
|
369
|
-
var draggingNode = draggingBlock[0];
|
|
370
|
-
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
|
|
371
|
-
|
|
372
|
-
var dropDisallowed = getParents(event.nativeEvent.target).some(function (node) {
|
|
373
|
-
var _ON_DROP_ALLOWED_TYPE;
|
|
374
|
-
|
|
375
|
-
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;
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
if (!dropDisallowed) {
|
|
379
|
-
// Move the drop event to a new undo batch mitigating the bug where undo not only moves it back,
|
|
380
|
-
// but also undoes a previous action: https://github.com/ianstormtaylor/slate/issues/4694
|
|
381
|
-
editor.history.undos.push([]);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
return dropDisallowed;
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
function getParents(el) {
|
|
392
|
-
var parents = [];
|
|
393
|
-
parents.push(el);
|
|
394
|
-
|
|
395
|
-
while (el.parentNode) {
|
|
396
|
-
parents.unshift(el.parentNode);
|
|
397
|
-
el = el.parentNode;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
return parents;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
344
|
var IS_SAFARI = typeof navigator !== 'undefined' && /*#__PURE__*/ /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
|
|
404
345
|
var IS_CHROME = /*#__PURE__*/ /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9.]+)(:?\s|$)/.test(navigator.userAgent);
|
|
405
346
|
|
|
@@ -604,16 +545,18 @@ function toggleElement(editor, options, editorOptions) {
|
|
|
604
545
|
});
|
|
605
546
|
}
|
|
606
547
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
}
|
|
548
|
+
/**
|
|
549
|
+
* Trim leading slash character if found. Bails otherwise.
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* trimLeadingSlash("/my query") // --> "my query"
|
|
553
|
+
*/
|
|
554
|
+
function trimLeadingSlash(text) {
|
|
555
|
+
if (!text.startsWith('/')) {
|
|
556
|
+
return text;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
return text.slice(1);
|
|
617
560
|
}
|
|
618
561
|
|
|
619
562
|
function useSdk(_ref) {
|
|
@@ -629,255 +572,128 @@ var _constate = /*#__PURE__*/constate(useSdk),
|
|
|
629
572
|
SdkProvider = _constate[0],
|
|
630
573
|
useSdkContext = _constate[1];
|
|
631
574
|
|
|
632
|
-
function
|
|
633
|
-
var
|
|
634
|
-
|
|
635
|
-
|
|
575
|
+
var useCommandList = function useCommandList(commandItems, container) {
|
|
576
|
+
var _React$useState = React.useState(function () {
|
|
577
|
+
// select the first item on initial render
|
|
578
|
+
if ('group' in commandItems[0]) {
|
|
579
|
+
return commandItems[0].commands[0].id;
|
|
580
|
+
}
|
|
636
581
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
getOrLoadAsset = _useEntities.getOrLoadAsset;
|
|
582
|
+
return commandItems[0].id;
|
|
583
|
+
}),
|
|
584
|
+
selectedItem = _React$useState[0],
|
|
585
|
+
setSelectedItem = _React$useState[1];
|
|
642
586
|
|
|
643
|
-
|
|
587
|
+
React.useEffect(function () {
|
|
588
|
+
if (!(container != null && container.current)) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
644
591
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
592
|
+
var buttons = Array.from(container.current.querySelectorAll('button'));
|
|
593
|
+
var currBtn = buttons.find(function (btn) {
|
|
594
|
+
return btn.id === selectedItem;
|
|
595
|
+
});
|
|
596
|
+
var currIndex = currBtn ? buttons.indexOf(currBtn) : 0;
|
|
597
|
+
var shouldSelectFirstBtn = !currBtn && buttons.length;
|
|
598
|
+
|
|
599
|
+
if (shouldSelectFirstBtn) {
|
|
600
|
+
setSelectedItem(buttons[0].id);
|
|
601
|
+
buttons[0].scrollIntoView({
|
|
602
|
+
block: 'nearest',
|
|
603
|
+
inline: 'start'
|
|
604
|
+
});
|
|
605
|
+
}
|
|
648
606
|
|
|
607
|
+
function handleKeyDown(event) {
|
|
608
|
+
if (isHotkey('up', event)) {
|
|
609
|
+
event.preventDefault();
|
|
649
610
|
|
|
650
|
-
|
|
651
|
-
|
|
611
|
+
if (currIndex === 0) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
652
614
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
615
|
+
setSelectedItem(buttons[currIndex - 1].id);
|
|
616
|
+
buttons[currIndex - 1].scrollIntoView({
|
|
617
|
+
block: 'nearest',
|
|
618
|
+
inline: 'start'
|
|
619
|
+
});
|
|
620
|
+
} else if (isHotkey('down', event)) {
|
|
621
|
+
event.preventDefault();
|
|
622
|
+
|
|
623
|
+
if (currIndex === buttons.length - 1) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
setSelectedItem(buttons[currIndex + 1].id);
|
|
628
|
+
buttons[currIndex + 1].scrollIntoView({
|
|
629
|
+
block: 'nearest',
|
|
630
|
+
inline: 'start'
|
|
631
|
+
});
|
|
632
|
+
} else if (isHotkey('enter', event)) {
|
|
633
|
+
event.preventDefault();
|
|
634
|
+
|
|
635
|
+
if (currBtn) {
|
|
636
|
+
setSelectedItem('');
|
|
637
|
+
currBtn.click();
|
|
638
|
+
}
|
|
639
|
+
} //TODO: handle shift+enter, which must be detected using separate events
|
|
657
640
|
|
|
658
|
-
React.useEffect(function () {
|
|
659
|
-
(type === 'Entry' ? getOrLoadEntry : getOrLoadAsset)(id); // "getOrLoadEntry" and "getOrLoadAsset" instances change with every
|
|
660
|
-
// entity store update causing page lag on initial load
|
|
661
|
-
// TODO: consider rewriting useEntities() hook to avoid that happening in
|
|
662
|
-
// first place.
|
|
663
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: explain this disable
|
|
664
|
-
}, [type, id]);
|
|
665
|
-
React.useEffect(function () {
|
|
666
|
-
if (entity) {
|
|
667
|
-
onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
|
|
668
641
|
}
|
|
669
|
-
}, [onEntityFetchComplete, entity]);
|
|
670
|
-
return entity;
|
|
671
|
-
}
|
|
672
642
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
size: "default",
|
|
677
|
-
isLoading: true
|
|
678
|
-
});
|
|
679
|
-
}
|
|
643
|
+
if (commandItems.length) {
|
|
644
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
645
|
+
}
|
|
680
646
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}
|
|
647
|
+
return function () {
|
|
648
|
+
return window.removeEventListener('keydown', handleKeyDown);
|
|
649
|
+
};
|
|
650
|
+
}, [commandItems, container, selectedItem]);
|
|
651
|
+
return {
|
|
652
|
+
selectedItem: selectedItem
|
|
653
|
+
};
|
|
654
|
+
};
|
|
688
655
|
|
|
689
|
-
|
|
690
|
-
getEntityScheduledActions: props.loadEntityScheduledActions,
|
|
691
|
-
size: "small",
|
|
692
|
-
isSelected: props.isSelected,
|
|
693
|
-
isDisabled: props.isDisabled,
|
|
694
|
-
localeCode: props.locale,
|
|
695
|
-
defaultLocaleCode: props.sdk.locales["default"],
|
|
696
|
-
asset: props.asset,
|
|
697
|
-
onEdit: props.onEdit,
|
|
698
|
-
onRemove: props.isDisabled ? undefined : props.onRemove,
|
|
699
|
-
isClickable: false
|
|
700
|
-
});
|
|
701
|
-
}, areEqual);
|
|
702
|
-
InternalAssetCard.displayName = 'InternalAssetCard';
|
|
703
|
-
function FetchingWrappedAssetCard(props) {
|
|
704
|
-
var onEntityFetchComplete = props.onEntityFetchComplete,
|
|
705
|
-
assetId = props.assetId;
|
|
656
|
+
var COMMAND_PROMPT = 'command-prompt';
|
|
706
657
|
|
|
707
|
-
|
|
708
|
-
|
|
658
|
+
function createInlineEntryNode(id) {
|
|
659
|
+
return {
|
|
660
|
+
type: Contentful.INLINES.EMBEDDED_ENTRY,
|
|
661
|
+
children: [{
|
|
662
|
+
text: ''
|
|
663
|
+
}],
|
|
664
|
+
data: {
|
|
665
|
+
target: {
|
|
666
|
+
sys: {
|
|
667
|
+
id: id,
|
|
668
|
+
type: 'Link',
|
|
669
|
+
linkType: 'Entry'
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
}
|
|
709
675
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
id: assetId,
|
|
713
|
-
onEntityFetchComplete: onEntityFetchComplete
|
|
714
|
-
});
|
|
715
|
-
return /*#__PURE__*/React.createElement(InternalAssetCard, {
|
|
716
|
-
asset: asset,
|
|
717
|
-
sdk: props.sdk,
|
|
718
|
-
isDisabled: props.isDisabled,
|
|
719
|
-
isSelected: props.isSelected,
|
|
720
|
-
loadEntityScheduledActions: loadEntityScheduledActions,
|
|
721
|
-
locale: props.locale,
|
|
722
|
-
onEdit: props.onEdit,
|
|
723
|
-
onRemove: props.onRemove
|
|
724
|
-
});
|
|
676
|
+
function createCommonjsModule(fn, module) {
|
|
677
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
725
678
|
}
|
|
726
679
|
|
|
727
|
-
var
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
680
|
+
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
681
|
+
/**
|
|
682
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
683
|
+
*
|
|
684
|
+
* This source code is licensed under the MIT license found in the
|
|
685
|
+
* LICENSE file in the root directory of this source tree.
|
|
686
|
+
*/
|
|
687
|
+
var runtime = function (exports) {
|
|
731
688
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
});
|
|
736
|
-
}
|
|
689
|
+
var Op = Object.prototype;
|
|
690
|
+
var hasOwn = Op.hasOwnProperty;
|
|
691
|
+
var undefined$1; // More compressible than void 0.
|
|
737
692
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
onRemove: props.onRemove
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
var contentType = sdk.space.getCachedContentTypes().find(function (contentType) {
|
|
747
|
-
return contentType.sys.id === entry.sys.contentType.sys.id;
|
|
748
|
-
});
|
|
749
|
-
return /*#__PURE__*/React.createElement(fieldEditorReference.WrappedEntryCard, {
|
|
750
|
-
size: "default",
|
|
751
|
-
getAsset: props.sdk.space.getAsset,
|
|
752
|
-
getEntityScheduledActions: loadEntityScheduledActions,
|
|
753
|
-
isSelected: props.isSelected,
|
|
754
|
-
isDisabled: props.isDisabled,
|
|
755
|
-
localeCode: props.locale,
|
|
756
|
-
defaultLocaleCode: props.sdk.locales["default"],
|
|
757
|
-
contentType: contentType,
|
|
758
|
-
entry: entry,
|
|
759
|
-
onEdit: props.onEdit,
|
|
760
|
-
onRemove: props.isDisabled ? undefined : props.onRemove,
|
|
761
|
-
isClickable: false
|
|
762
|
-
});
|
|
763
|
-
}, areEqual);
|
|
764
|
-
InternalEntryCard.displayName = 'ReferenceCard';
|
|
765
|
-
var FetchingWrappedEntryCard = function FetchingWrappedEntryCard(props) {
|
|
766
|
-
var entryId = props.entryId,
|
|
767
|
-
onEntityFetchComplete = props.onEntityFetchComplete;
|
|
768
|
-
|
|
769
|
-
var _useEntities = fieldEditorReference.useEntities(),
|
|
770
|
-
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
|
|
771
|
-
|
|
772
|
-
var entry = useFetchedEntity({
|
|
773
|
-
type: 'Entry',
|
|
774
|
-
id: entryId,
|
|
775
|
-
onEntityFetchComplete: onEntityFetchComplete
|
|
776
|
-
});
|
|
777
|
-
return /*#__PURE__*/React.createElement(InternalEntryCard, {
|
|
778
|
-
entry: entry,
|
|
779
|
-
sdk: props.sdk,
|
|
780
|
-
locale: props.locale,
|
|
781
|
-
isDisabled: props.isDisabled,
|
|
782
|
-
isSelected: props.isSelected,
|
|
783
|
-
onEdit: props.onEdit,
|
|
784
|
-
onRemove: props.onRemove,
|
|
785
|
-
loadEntityScheduledActions: loadEntityScheduledActions
|
|
786
|
-
});
|
|
787
|
-
};
|
|
788
|
-
|
|
789
|
-
var styles = {
|
|
790
|
-
root: /*#__PURE__*/emotion.css({
|
|
791
|
-
marginBottom: '1.25rem !important',
|
|
792
|
-
display: 'block'
|
|
793
|
-
}),
|
|
794
|
-
container: /*#__PURE__*/emotion.css({
|
|
795
|
-
// The next 2 properties ensure Entity card won't be aligned above
|
|
796
|
-
// a list item marker (i.e. bullet)
|
|
797
|
-
display: 'inline-block',
|
|
798
|
-
verticalAlign: 'text-top',
|
|
799
|
-
width: '100%'
|
|
800
|
-
})
|
|
801
|
-
};
|
|
802
|
-
function LinkedEntityBlock(props) {
|
|
803
|
-
var attributes = props.attributes,
|
|
804
|
-
children = props.children,
|
|
805
|
-
element = props.element,
|
|
806
|
-
onEntityFetchComplete = props.onEntityFetchComplete;
|
|
807
|
-
var isSelected = Slate.useSelected();
|
|
808
|
-
var editor = useContentfulEditor();
|
|
809
|
-
var sdk = useSdkContext();
|
|
810
|
-
var isDisabled = Slate.useReadOnly();
|
|
811
|
-
var _element$data$target$ = element.data.target.sys,
|
|
812
|
-
entityId = _element$data$target$.id,
|
|
813
|
-
entityType = _element$data$target$.linkType;
|
|
814
|
-
var handleEditClick = React__default.useCallback(function () {
|
|
815
|
-
var openEntity = entityType === 'Asset' ? sdk.navigator.openAsset : sdk.navigator.openEntry;
|
|
816
|
-
return openEntity(entityId, {
|
|
817
|
-
slideIn: true
|
|
818
|
-
});
|
|
819
|
-
}, [sdk, entityId, entityType]);
|
|
820
|
-
var handleRemoveClick = React__default.useCallback(function () {
|
|
821
|
-
if (!editor) return;
|
|
822
|
-
var pathToElement = Slate.ReactEditor.findPath(editor, element);
|
|
823
|
-
slate.Transforms.removeNodes(editor, {
|
|
824
|
-
at: pathToElement
|
|
825
|
-
});
|
|
826
|
-
}, [editor, element]);
|
|
827
|
-
return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
|
|
828
|
-
className: styles.root,
|
|
829
|
-
"data-entity-type": entityType,
|
|
830
|
-
"data-entity-id": entityId,
|
|
831
|
-
// COMPAT: This makes copy & paste work for Firefox
|
|
832
|
-
contentEditable: IS_CHROME ? undefined : false,
|
|
833
|
-
draggable: IS_CHROME ? true : undefined
|
|
834
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
835
|
-
// COMPAT: This makes copy & paste work for Chromium/Blink browsers and Safari
|
|
836
|
-
contentEditable: IS_CHROME ? false : undefined,
|
|
837
|
-
draggable: IS_CHROME ? true : undefined,
|
|
838
|
-
className: styles.container
|
|
839
|
-
}, entityType === 'Entry' && /*#__PURE__*/React__default.createElement(FetchingWrappedEntryCard, {
|
|
840
|
-
sdk: sdk,
|
|
841
|
-
entryId: entityId,
|
|
842
|
-
locale: sdk.field.locale,
|
|
843
|
-
isDisabled: isDisabled,
|
|
844
|
-
isSelected: isSelected,
|
|
845
|
-
onRemove: handleRemoveClick,
|
|
846
|
-
onEdit: handleEditClick,
|
|
847
|
-
onEntityFetchComplete: onEntityFetchComplete
|
|
848
|
-
}), entityType === 'Asset' && /*#__PURE__*/React__default.createElement(FetchingWrappedAssetCard, {
|
|
849
|
-
sdk: sdk,
|
|
850
|
-
assetId: entityId,
|
|
851
|
-
locale: sdk.field.locale,
|
|
852
|
-
isDisabled: isDisabled,
|
|
853
|
-
isSelected: isSelected,
|
|
854
|
-
onRemove: handleRemoveClick,
|
|
855
|
-
onEdit: handleEditClick,
|
|
856
|
-
onEntityFetchComplete: onEntityFetchComplete
|
|
857
|
-
})), children);
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
function createCommonjsModule(fn, module) {
|
|
861
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
865
|
-
/**
|
|
866
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
867
|
-
*
|
|
868
|
-
* This source code is licensed under the MIT license found in the
|
|
869
|
-
* LICENSE file in the root directory of this source tree.
|
|
870
|
-
*/
|
|
871
|
-
var runtime = function (exports) {
|
|
872
|
-
|
|
873
|
-
var Op = Object.prototype;
|
|
874
|
-
var hasOwn = Op.hasOwnProperty;
|
|
875
|
-
var undefined$1; // More compressible than void 0.
|
|
876
|
-
|
|
877
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
878
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
879
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
880
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
693
|
+
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
694
|
+
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
695
|
+
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
696
|
+
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
881
697
|
|
|
882
698
|
function define(obj, key, value) {
|
|
883
699
|
Object.defineProperty(obj, key, {
|
|
@@ -1549,41 +1365,916 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
1549
1365
|
nextLoc: nextLoc
|
|
1550
1366
|
};
|
|
1551
1367
|
|
|
1552
|
-
if (this.method === "next") {
|
|
1553
|
-
// Deliberately forget the last sent value so that we don't
|
|
1554
|
-
// accidentally pass it on to the delegate.
|
|
1555
|
-
this.arg = undefined$1;
|
|
1556
|
-
}
|
|
1368
|
+
if (this.method === "next") {
|
|
1369
|
+
// Deliberately forget the last sent value so that we don't
|
|
1370
|
+
// accidentally pass it on to the delegate.
|
|
1371
|
+
this.arg = undefined$1;
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
return ContinueSentinel;
|
|
1375
|
+
}
|
|
1376
|
+
}; // Regardless of whether this script is executing as a CommonJS module
|
|
1377
|
+
// or not, return the runtime object so that we can declare the variable
|
|
1378
|
+
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1379
|
+
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
1380
|
+
|
|
1381
|
+
return exports;
|
|
1382
|
+
}( // If this script is executing as a CommonJS module, use module.exports
|
|
1383
|
+
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
1384
|
+
// object. Either way, the resulting object will be used to initialize
|
|
1385
|
+
// the regeneratorRuntime variable at the top of this file.
|
|
1386
|
+
module.exports );
|
|
1387
|
+
|
|
1388
|
+
try {
|
|
1389
|
+
regeneratorRuntime = runtime;
|
|
1390
|
+
} catch (accidentalStrictMode) {
|
|
1391
|
+
// This module should not be running in strict mode, so the above
|
|
1392
|
+
// assignment should always work unless something is misconfigured. Just
|
|
1393
|
+
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
1394
|
+
// strict mode using a global Function call. This could conceivably fail
|
|
1395
|
+
// if a Content Security Policy forbids using Function, but in that case
|
|
1396
|
+
// the proper solution is to fix the accidental strict mode problem. If
|
|
1397
|
+
// you've misconfigured your bundler to force strict mode and applied a
|
|
1398
|
+
// CSP to forbid Function, and you're not willing to fix either of those
|
|
1399
|
+
// problems, please detail your unique predicament in a GitHub issue.
|
|
1400
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1401
|
+
}
|
|
1402
|
+
});
|
|
1403
|
+
|
|
1404
|
+
function fetchAssets(_x, _x2) {
|
|
1405
|
+
return _fetchAssets.apply(this, arguments);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
function _fetchAssets() {
|
|
1409
|
+
_fetchAssets = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(sdk, query) {
|
|
1410
|
+
var assets;
|
|
1411
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1412
|
+
while (1) {
|
|
1413
|
+
switch (_context.prev = _context.next) {
|
|
1414
|
+
case 0:
|
|
1415
|
+
_context.next = 2;
|
|
1416
|
+
return sdk.space.getAssets({
|
|
1417
|
+
query: query
|
|
1418
|
+
});
|
|
1419
|
+
|
|
1420
|
+
case 2:
|
|
1421
|
+
assets = _context.sent;
|
|
1422
|
+
return _context.abrupt("return", assets.items.map(function (asset) {
|
|
1423
|
+
var displayTitle = fieldEditorShared.entityHelpers.getAssetTitle({
|
|
1424
|
+
asset: asset,
|
|
1425
|
+
localeCode: sdk.field.locale,
|
|
1426
|
+
defaultLocaleCode: sdk.locales["default"],
|
|
1427
|
+
defaultTitle: 'Untitled'
|
|
1428
|
+
});
|
|
1429
|
+
return {
|
|
1430
|
+
contentTypeName: 'Asset',
|
|
1431
|
+
displayTitle: displayTitle,
|
|
1432
|
+
id: asset.sys.id,
|
|
1433
|
+
entity: asset,
|
|
1434
|
+
thumbnail: asset.fields.file && asset.fields.file[sdk.field.locale] && asset.fields.file[sdk.field.locale].url + "?h=30"
|
|
1435
|
+
};
|
|
1436
|
+
}));
|
|
1437
|
+
|
|
1438
|
+
case 4:
|
|
1439
|
+
case "end":
|
|
1440
|
+
return _context.stop();
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
}, _callee);
|
|
1444
|
+
}));
|
|
1445
|
+
return _fetchAssets.apply(this, arguments);
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
function fetchEntries(_x, _x2, _x3) {
|
|
1449
|
+
return _fetchEntries.apply(this, arguments);
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
function _fetchEntries() {
|
|
1453
|
+
_fetchEntries = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(sdk, contentType, query) {
|
|
1454
|
+
var entries;
|
|
1455
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1456
|
+
while (1) {
|
|
1457
|
+
switch (_context.prev = _context.next) {
|
|
1458
|
+
case 0:
|
|
1459
|
+
_context.next = 2;
|
|
1460
|
+
return sdk.space.getEntries({
|
|
1461
|
+
content_type: contentType.sys.id,
|
|
1462
|
+
query: query
|
|
1463
|
+
});
|
|
1464
|
+
|
|
1465
|
+
case 2:
|
|
1466
|
+
entries = _context.sent;
|
|
1467
|
+
return _context.abrupt("return", entries.items.map(function (entry) {
|
|
1468
|
+
var description = fieldEditorShared.entityHelpers.getEntityDescription({
|
|
1469
|
+
contentType: contentType,
|
|
1470
|
+
// @ts-expect-error inconsistent in typing between app-sdk & field-editors-shared
|
|
1471
|
+
entity: entry,
|
|
1472
|
+
localeCode: sdk.field.locale,
|
|
1473
|
+
defaultLocaleCode: sdk.locales["default"]
|
|
1474
|
+
});
|
|
1475
|
+
var displayTitle = fieldEditorShared.entityHelpers.getEntryTitle({
|
|
1476
|
+
// @ts-expect-error inconsistent in typing between app-sdk & field-editors-shared
|
|
1477
|
+
entry: entry,
|
|
1478
|
+
contentType: contentType,
|
|
1479
|
+
localeCode: sdk.field.locale,
|
|
1480
|
+
defaultLocaleCode: sdk.locales["default"],
|
|
1481
|
+
defaultTitle: 'Untitled'
|
|
1482
|
+
});
|
|
1483
|
+
return {
|
|
1484
|
+
contentTypeName: contentType.name,
|
|
1485
|
+
displayTitle: displayTitle,
|
|
1486
|
+
id: entry.sys.contentType.sys.id,
|
|
1487
|
+
description: description,
|
|
1488
|
+
entry: entry
|
|
1489
|
+
};
|
|
1490
|
+
}));
|
|
1491
|
+
|
|
1492
|
+
case 4:
|
|
1493
|
+
case "end":
|
|
1494
|
+
return _context.stop();
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
}, _callee);
|
|
1498
|
+
}));
|
|
1499
|
+
return _fetchEntries.apply(this, arguments);
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
var createNode = function createNode(nodeType, entity) {
|
|
1503
|
+
return {
|
|
1504
|
+
type: nodeType,
|
|
1505
|
+
data: {
|
|
1506
|
+
target: {
|
|
1507
|
+
sys: {
|
|
1508
|
+
id: entity.sys.id,
|
|
1509
|
+
type: 'Link',
|
|
1510
|
+
linkType: entity.sys.type
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
},
|
|
1514
|
+
children: [{
|
|
1515
|
+
text: ''
|
|
1516
|
+
}],
|
|
1517
|
+
isVoid: true
|
|
1518
|
+
};
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1521
|
+
function insertBlock(editor, nodeType, entity) {
|
|
1522
|
+
if (!(editor != null && editor.selection)) return;
|
|
1523
|
+
var linkedEntityBlock = createNode(nodeType, entity);
|
|
1524
|
+
var hasText = editor.selection && !!plateCore.getText(editor, editor.selection.focus.path);
|
|
1525
|
+
|
|
1526
|
+
if (hasText) {
|
|
1527
|
+
slate.Transforms.insertNodes(editor, linkedEntityBlock);
|
|
1528
|
+
} else {
|
|
1529
|
+
slate.Transforms.setNodes(editor, linkedEntityBlock);
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
focus(editor);
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
var removeCommand = function removeCommand(editor) {
|
|
1536
|
+
var _getAbove = plateCore.getAbove(editor),
|
|
1537
|
+
path = _getAbove[1];
|
|
1538
|
+
|
|
1539
|
+
var range = slate.Editor.range(editor, path);
|
|
1540
|
+
slate.Transforms.select(editor, range.focus.path);
|
|
1541
|
+
plateCore.removeMark(editor, {
|
|
1542
|
+
key: COMMAND_PROMPT,
|
|
1543
|
+
at: range
|
|
1544
|
+
});
|
|
1545
|
+
slate.Transforms["delete"](editor);
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
var removeQuery = function removeQuery(editor) {
|
|
1549
|
+
var _getAbove2 = plateCore.getAbove(editor),
|
|
1550
|
+
path = _getAbove2[1];
|
|
1551
|
+
|
|
1552
|
+
var range = slate.Editor.range(editor, path);
|
|
1553
|
+
|
|
1554
|
+
if (range.focus.offset - range.anchor.offset > 1) {
|
|
1555
|
+
slate.Transforms["delete"](editor, {
|
|
1556
|
+
at: range.focus,
|
|
1557
|
+
distance: range.focus.offset - 1,
|
|
1558
|
+
reverse: true
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
};
|
|
1562
|
+
|
|
1563
|
+
var useCommands = function useCommands(sdk, query, editor) {
|
|
1564
|
+
var contentTypes = sdk.space.getCachedContentTypes();
|
|
1565
|
+
|
|
1566
|
+
var _useState = React.useState(function () {
|
|
1567
|
+
var contentTypeCommands = contentTypes.map(function (contentType) {
|
|
1568
|
+
return {
|
|
1569
|
+
group: contentType.name,
|
|
1570
|
+
commands: [{
|
|
1571
|
+
id: contentType.sys.id,
|
|
1572
|
+
label: "Embed " + contentType.name,
|
|
1573
|
+
callback: function callback() {
|
|
1574
|
+
fetchEntries(sdk, contentType, query).then(function (entries) {
|
|
1575
|
+
removeQuery(editor);
|
|
1576
|
+
|
|
1577
|
+
if (!entries.length) {
|
|
1578
|
+
setCommands([{
|
|
1579
|
+
id: 'no-results',
|
|
1580
|
+
label: 'No results'
|
|
1581
|
+
}]);
|
|
1582
|
+
} else {
|
|
1583
|
+
setCommands(entries.map(function (entry) {
|
|
1584
|
+
return {
|
|
1585
|
+
id: entry.id + "-" + entry.displayTitle.replace(/\W+/g, '-').toLowerCase(),
|
|
1586
|
+
label: entry.displayTitle,
|
|
1587
|
+
callback: function callback() {
|
|
1588
|
+
removeCommand(editor);
|
|
1589
|
+
|
|
1590
|
+
if (editor.selection) {
|
|
1591
|
+
var selection = editor.selection;
|
|
1592
|
+
editor.insertSoftBreak();
|
|
1593
|
+
insertBlock(editor, Contentful.BLOCKS.EMBEDDED_ENTRY, entry.entry);
|
|
1594
|
+
slate.Transforms.select(editor, selection);
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
}));
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
}, {
|
|
1603
|
+
id: contentType.sys.id + "-inline",
|
|
1604
|
+
label: "Embed " + contentType.name + " - Inline",
|
|
1605
|
+
callback: function callback() {
|
|
1606
|
+
fetchEntries(sdk, contentType, query).then(function (entries) {
|
|
1607
|
+
removeQuery(editor);
|
|
1608
|
+
|
|
1609
|
+
if (!entries.length) {
|
|
1610
|
+
setCommands([{
|
|
1611
|
+
id: 'no-results',
|
|
1612
|
+
label: 'No results'
|
|
1613
|
+
}]);
|
|
1614
|
+
} else {
|
|
1615
|
+
setCommands(entries.map(function (entry) {
|
|
1616
|
+
return {
|
|
1617
|
+
id: entry.id + "-" + entry.displayTitle.replace(/\W+/g, '-').toLowerCase(),
|
|
1618
|
+
label: entry.displayTitle,
|
|
1619
|
+
callback: function callback() {
|
|
1620
|
+
var inlineNode = createInlineEntryNode(entry.id);
|
|
1621
|
+
removeCommand(editor);
|
|
1622
|
+
slate.Transforms.insertNodes(editor, inlineNode);
|
|
1623
|
+
editor.insertText('');
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
}));
|
|
1627
|
+
}
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
}]
|
|
1631
|
+
};
|
|
1632
|
+
});
|
|
1633
|
+
var assetCommand = {
|
|
1634
|
+
group: 'Assets',
|
|
1635
|
+
commands: [{
|
|
1636
|
+
id: 'embed-asset',
|
|
1637
|
+
label: 'Embed Asset',
|
|
1638
|
+
callback: function callback() {
|
|
1639
|
+
fetchAssets(sdk, query).then(function (assets) {
|
|
1640
|
+
removeQuery(editor);
|
|
1641
|
+
|
|
1642
|
+
if (!assets.length) {
|
|
1643
|
+
setCommands([{
|
|
1644
|
+
id: 'no-results',
|
|
1645
|
+
label: 'No results'
|
|
1646
|
+
}]);
|
|
1647
|
+
} else {
|
|
1648
|
+
setCommands(assets.map(function (asset) {
|
|
1649
|
+
return {
|
|
1650
|
+
id: asset.id + "-" + asset.displayTitle.replace(/\W+/g, '-').toLowerCase(),
|
|
1651
|
+
label: asset.displayTitle,
|
|
1652
|
+
thumbnail: asset.thumbnail,
|
|
1653
|
+
callback: function callback() {
|
|
1654
|
+
removeCommand(editor);
|
|
1655
|
+
|
|
1656
|
+
if (editor.selection) {
|
|
1657
|
+
var selection = editor.selection;
|
|
1658
|
+
editor.insertSoftBreak();
|
|
1659
|
+
insertBlock(editor, Contentful.BLOCKS.EMBEDDED_ASSET, asset.entity);
|
|
1660
|
+
slate.Transforms.select(editor, selection);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
};
|
|
1664
|
+
}));
|
|
1665
|
+
}
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
}]
|
|
1669
|
+
};
|
|
1670
|
+
return [].concat(contentTypeCommands, [assetCommand]);
|
|
1671
|
+
}),
|
|
1672
|
+
commands = _useState[0],
|
|
1673
|
+
setCommands = _useState[1];
|
|
1674
|
+
/* filter both commands and groups of commands with the user typed query */
|
|
1675
|
+
|
|
1676
|
+
|
|
1677
|
+
return query ? commands.reduce(function (list, nextItem) {
|
|
1678
|
+
if ('group' in nextItem) {
|
|
1679
|
+
var subcommands = nextItem.commands.filter(function (command) {
|
|
1680
|
+
return command.label.toLowerCase().includes(query.toLowerCase());
|
|
1681
|
+
});
|
|
1682
|
+
|
|
1683
|
+
if (subcommands.length > 0) {
|
|
1684
|
+
list.push(nextItem);
|
|
1685
|
+
}
|
|
1686
|
+
} else {
|
|
1687
|
+
if (nextItem.label.toLowerCase().includes(query.toLowerCase())) {
|
|
1688
|
+
list.push(nextItem);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
return list;
|
|
1693
|
+
}, []) : commands;
|
|
1694
|
+
};
|
|
1695
|
+
|
|
1696
|
+
var styles = {
|
|
1697
|
+
container: /*#__PURE__*/emotion.css({
|
|
1698
|
+
position: 'absolute',
|
|
1699
|
+
zIndex: tokens.zIndexNotification,
|
|
1700
|
+
fontWeight: tokens.fontWeightNormal,
|
|
1701
|
+
fontStyle: 'normal',
|
|
1702
|
+
fontFamily: tokens.fontStackPrimary,
|
|
1703
|
+
'ul, ol, dl': {
|
|
1704
|
+
listStyle: 'none',
|
|
1705
|
+
marginLeft: 0
|
|
1706
|
+
}
|
|
1707
|
+
}),
|
|
1708
|
+
menuContent: /*#__PURE__*/emotion.css({
|
|
1709
|
+
width: '400px',
|
|
1710
|
+
maxHeight: '300px'
|
|
1711
|
+
}),
|
|
1712
|
+
menuList: /*#__PURE__*/emotion.css({
|
|
1713
|
+
overflow: 'auto',
|
|
1714
|
+
maxHeight: '200px'
|
|
1715
|
+
}),
|
|
1716
|
+
menuItem: /*#__PURE__*/emotion.css({
|
|
1717
|
+
display: 'block',
|
|
1718
|
+
width: '100%',
|
|
1719
|
+
background: 'none',
|
|
1720
|
+
border: 0,
|
|
1721
|
+
margin: 0,
|
|
1722
|
+
outline: 'none',
|
|
1723
|
+
fontSize: tokens.fontSizeM,
|
|
1724
|
+
lineHeight: tokens.lineHeightM,
|
|
1725
|
+
fontWeight: tokens.fontWeightNormal,
|
|
1726
|
+
position: 'relative',
|
|
1727
|
+
textAlign: 'left',
|
|
1728
|
+
padding: tokens.spacingXs + " " + tokens.spacingM,
|
|
1729
|
+
wordBreak: 'break-word',
|
|
1730
|
+
whiteSpace: 'break-spaces',
|
|
1731
|
+
cursor: 'pointer',
|
|
1732
|
+
hyphens: 'auto',
|
|
1733
|
+
minWidth: '150px',
|
|
1734
|
+
textDecoration: 'none',
|
|
1735
|
+
color: tokens.gray800,
|
|
1736
|
+
'&:hover': {
|
|
1737
|
+
backgroundColor: tokens.gray100
|
|
1738
|
+
},
|
|
1739
|
+
'&:disabled': {
|
|
1740
|
+
opacity: 0.5,
|
|
1741
|
+
cursor: 'auto'
|
|
1742
|
+
}
|
|
1743
|
+
}),
|
|
1744
|
+
menuItemSelected: /*#__PURE__*/emotion.css({
|
|
1745
|
+
boxShadow: "inset " + tokens.glowPrimary,
|
|
1746
|
+
borderRadius: tokens.borderRadiusMedium
|
|
1747
|
+
}),
|
|
1748
|
+
menuDivider: /*#__PURE__*/emotion.css({
|
|
1749
|
+
border: 'none',
|
|
1750
|
+
width: '100%',
|
|
1751
|
+
height: '1px',
|
|
1752
|
+
background: tokens.gray300,
|
|
1753
|
+
margin: tokens.spacingXs + " 0"
|
|
1754
|
+
}),
|
|
1755
|
+
menuHeader: /*#__PURE__*/emotion.css({
|
|
1756
|
+
position: 'sticky',
|
|
1757
|
+
zIndex: tokens.zIndexDefault,
|
|
1758
|
+
top: 0,
|
|
1759
|
+
backgroundColor: tokens.gray100,
|
|
1760
|
+
padding: tokens.spacingM
|
|
1761
|
+
}),
|
|
1762
|
+
menuFooter: /*#__PURE__*/emotion.css({
|
|
1763
|
+
position: 'sticky',
|
|
1764
|
+
bottom: 0,
|
|
1765
|
+
backgroundColor: tokens.gray100,
|
|
1766
|
+
padding: tokens.spacingM
|
|
1767
|
+
}),
|
|
1768
|
+
footerList: /*#__PURE__*/emotion.css({
|
|
1769
|
+
listStyle: 'none',
|
|
1770
|
+
color: tokens.gray600,
|
|
1771
|
+
fontSize: tokens.fontSizeM
|
|
1772
|
+
}),
|
|
1773
|
+
thumbnail: /*#__PURE__*/emotion.css({
|
|
1774
|
+
width: '30px',
|
|
1775
|
+
height: '30px',
|
|
1776
|
+
objectFit: 'cover'
|
|
1777
|
+
})
|
|
1778
|
+
};
|
|
1779
|
+
|
|
1780
|
+
var Group = function Group(_ref) {
|
|
1781
|
+
var commandGroup = _ref.commandGroup,
|
|
1782
|
+
selectedItem = _ref.selectedItem;
|
|
1783
|
+
return /*#__PURE__*/React.createElement("section", {
|
|
1784
|
+
key: commandGroup.group
|
|
1785
|
+
}, /*#__PURE__*/React.createElement(f36Components.SectionHeading, {
|
|
1786
|
+
as: "h3",
|
|
1787
|
+
marginBottom: "spacingS",
|
|
1788
|
+
marginTop: "spacingS",
|
|
1789
|
+
marginLeft: "spacingM",
|
|
1790
|
+
marginRight: "spacingM"
|
|
1791
|
+
}, commandGroup.group), commandGroup.commands.map(function (command) {
|
|
1792
|
+
var _cx;
|
|
1793
|
+
|
|
1794
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
1795
|
+
key: command.id,
|
|
1796
|
+
id: command.id,
|
|
1797
|
+
className: emotion.cx(styles.menuItem, (_cx = {}, _cx[styles.menuItemSelected] = command.id === selectedItem, _cx)),
|
|
1798
|
+
onClick: command.callback
|
|
1799
|
+
}, command.label);
|
|
1800
|
+
}), /*#__PURE__*/React.createElement("hr", {
|
|
1801
|
+
className: styles.menuDivider,
|
|
1802
|
+
"aria-orientation": "horizontal"
|
|
1803
|
+
}));
|
|
1804
|
+
};
|
|
1805
|
+
|
|
1806
|
+
var Asset = function Asset(_ref2) {
|
|
1807
|
+
var _cx2;
|
|
1808
|
+
|
|
1809
|
+
var command = _ref2.command,
|
|
1810
|
+
selectedItem = _ref2.selectedItem;
|
|
1811
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
1812
|
+
key: command.id,
|
|
1813
|
+
id: command.id,
|
|
1814
|
+
className: emotion.cx(styles.menuItem, (_cx2 = {}, _cx2[styles.menuItemSelected] = command.id === selectedItem, _cx2)),
|
|
1815
|
+
onClick: command.callback
|
|
1816
|
+
}, /*#__PURE__*/React.createElement(f36Components.Flex, {
|
|
1817
|
+
alignItems: "center",
|
|
1818
|
+
gap: "spacingS"
|
|
1819
|
+
}, command.thumbnail && /*#__PURE__*/React.createElement("img", {
|
|
1820
|
+
width: "30",
|
|
1821
|
+
height: "30",
|
|
1822
|
+
src: command.thumbnail,
|
|
1823
|
+
alt: "",
|
|
1824
|
+
className: styles.thumbnail
|
|
1825
|
+
}), /*#__PURE__*/React.createElement("span", null, command.label)));
|
|
1826
|
+
};
|
|
1827
|
+
|
|
1828
|
+
var Item = function Item(_ref3) {
|
|
1829
|
+
var command = _ref3.command;
|
|
1830
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
1831
|
+
key: command.id,
|
|
1832
|
+
id: command.id,
|
|
1833
|
+
className: styles.menuItem
|
|
1834
|
+
}, command.label);
|
|
1835
|
+
};
|
|
1836
|
+
|
|
1837
|
+
var CommandListItems = function CommandListItems(_ref4) {
|
|
1838
|
+
var commandItems = _ref4.commandItems,
|
|
1839
|
+
selectedItem = _ref4.selectedItem;
|
|
1840
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, commandItems.map(function (command) {
|
|
1841
|
+
return 'group' in command ? /*#__PURE__*/React.createElement(Group, {
|
|
1842
|
+
commandGroup: command,
|
|
1843
|
+
selectedItem: selectedItem
|
|
1844
|
+
}) : command.callback ? /*#__PURE__*/React.createElement(Asset, {
|
|
1845
|
+
command: command,
|
|
1846
|
+
selectedItem: selectedItem
|
|
1847
|
+
}) : /*#__PURE__*/React.createElement(Item, {
|
|
1848
|
+
command: command
|
|
1849
|
+
});
|
|
1850
|
+
}));
|
|
1851
|
+
};
|
|
1852
|
+
|
|
1853
|
+
var CommandList = function CommandList(_ref5) {
|
|
1854
|
+
var query = _ref5.query,
|
|
1855
|
+
editor = _ref5.editor;
|
|
1856
|
+
var sdk = useSdkContext();
|
|
1857
|
+
var container = React.useRef(null);
|
|
1858
|
+
var commandItems = useCommands(sdk, query, editor);
|
|
1859
|
+
|
|
1860
|
+
var _useCommandList = useCommandList(commandItems, container),
|
|
1861
|
+
selectedItem = _useCommandList.selectedItem;
|
|
1862
|
+
|
|
1863
|
+
if (commandItems.length === 0) {
|
|
1864
|
+
return null;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1868
|
+
className: styles.container,
|
|
1869
|
+
tabIndex: -1,
|
|
1870
|
+
ref: container,
|
|
1871
|
+
contentEditable: false
|
|
1872
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1873
|
+
role: "alert"
|
|
1874
|
+
}, /*#__PURE__*/React.createElement(f36Components.ScreenReaderOnly, null, "Richtext commands. Currently focused item: ", selectedItem, ". Press ", /*#__PURE__*/React.createElement("kbd", null, "enter"), " to select, ", /*#__PURE__*/React.createElement("kbd", null, "arrows"), " to navigate, ", /*#__PURE__*/React.createElement("kbd", null, "escape"), " to close.")), /*#__PURE__*/React.createElement("div", {
|
|
1875
|
+
"aria-hidden": true
|
|
1876
|
+
}, /*#__PURE__*/React.createElement(f36Components.Popover, {
|
|
1877
|
+
isOpen: true,
|
|
1878
|
+
usePortal: false,
|
|
1879
|
+
autoFocus: false
|
|
1880
|
+
}, /*#__PURE__*/React.createElement(f36Components.Popover.Trigger, null, /*#__PURE__*/React.createElement("span", null)), /*#__PURE__*/React.createElement(f36Components.Popover.Content, {
|
|
1881
|
+
className: styles.menuContent
|
|
1882
|
+
}, /*#__PURE__*/React.createElement("header", {
|
|
1883
|
+
className: styles.menuHeader
|
|
1884
|
+
}, /*#__PURE__*/React.createElement(f36Components.SectionHeading, {
|
|
1885
|
+
marginBottom: "none"
|
|
1886
|
+
}, "Richtext commands")), /*#__PURE__*/React.createElement("div", {
|
|
1887
|
+
className: styles.menuList
|
|
1888
|
+
}, /*#__PURE__*/React.createElement(CommandListItems, {
|
|
1889
|
+
commandItems: commandItems,
|
|
1890
|
+
selectedItem: selectedItem
|
|
1891
|
+
})), /*#__PURE__*/React.createElement("footer", {
|
|
1892
|
+
className: styles.menuFooter
|
|
1893
|
+
}, /*#__PURE__*/React.createElement(f36Components.Stack, {
|
|
1894
|
+
as: "ul",
|
|
1895
|
+
margin: "none",
|
|
1896
|
+
padding: "none",
|
|
1897
|
+
spacing: "spacingS",
|
|
1898
|
+
className: styles.footerList
|
|
1899
|
+
}, /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("kbd", null, "\u2191"), /*#__PURE__*/React.createElement("kbd", null, "\u2193"), " to navigate"), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("kbd", null, "\u21B5"), " to confirm"), /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("kbd", null, "esc"), " to close")))))));
|
|
1900
|
+
};
|
|
1901
|
+
|
|
1902
|
+
var CommandPrompt = function CommandPrompt(props) {
|
|
1903
|
+
var query = React.useMemo(function () {
|
|
1904
|
+
return trimLeadingSlash(props.text.text);
|
|
1905
|
+
}, [props.text.text]);
|
|
1906
|
+
var editor = props.editor;
|
|
1907
|
+
var canInsertBlocks = !isNodeTypeSelected(editor, Contentful.BLOCKS.TABLE);
|
|
1908
|
+
return /*#__PURE__*/React.createElement("span", Object.assign({}, props.attributes), props.children, canInsertBlocks && /*#__PURE__*/React.createElement(CommandList, {
|
|
1909
|
+
query: query,
|
|
1910
|
+
editor: editor
|
|
1911
|
+
}));
|
|
1912
|
+
};
|
|
1913
|
+
|
|
1914
|
+
var createOnKeyDown = function createOnKeyDown() {
|
|
1915
|
+
return function (editor) {
|
|
1916
|
+
return function (event) {
|
|
1917
|
+
if (isHotkey('/', event)) {
|
|
1918
|
+
var _setMarks;
|
|
1919
|
+
|
|
1920
|
+
plateCore.setMarks(editor, (_setMarks = {}, _setMarks[COMMAND_PROMPT] = true, _setMarks));
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
var isActive = plateCore.isMarkActive(editor, COMMAND_PROMPT);
|
|
1924
|
+
|
|
1925
|
+
if (isActive) {
|
|
1926
|
+
if (isHotkey('enter', event)) {
|
|
1927
|
+
event.preventDefault();
|
|
1928
|
+
} else if (isHotkey('backspace', event)) {
|
|
1929
|
+
var _getAbove = plateCore.getAbove(editor),
|
|
1930
|
+
path = _getAbove[1];
|
|
1931
|
+
|
|
1932
|
+
var range = slate.Editor.range(editor, path); // if it is the last character in the command string
|
|
1933
|
+
|
|
1934
|
+
if (range.focus.offset - range.anchor.offset === 1) {
|
|
1935
|
+
plateCore.removeMark(editor, {
|
|
1936
|
+
key: COMMAND_PROMPT,
|
|
1937
|
+
at: range
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
} else if (isHotkey('escape', event)) {
|
|
1941
|
+
var _getAbove2 = plateCore.getAbove(editor),
|
|
1942
|
+
_path = _getAbove2[1];
|
|
1943
|
+
|
|
1944
|
+
var _range = slate.Editor.range(editor, _path);
|
|
1945
|
+
|
|
1946
|
+
plateCore.removeMark(editor, {
|
|
1947
|
+
key: COMMAND_PROMPT,
|
|
1948
|
+
at: _range
|
|
1949
|
+
});
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
};
|
|
1953
|
+
};
|
|
1954
|
+
};
|
|
1955
|
+
|
|
1956
|
+
/**
|
|
1957
|
+
* A command palette plugin (aka slash commands)
|
|
1958
|
+
*
|
|
1959
|
+
* How does it work?
|
|
1960
|
+
* * When the user presses the slash key, the editor will show a command palette
|
|
1961
|
+
* * When the user presses a key, the command palette will show the command suggestions
|
|
1962
|
+
* * When the user presses enter, the command palette will execute the command
|
|
1963
|
+
* * When the user presses escape, the command palette will hide
|
|
1964
|
+
* * When the user presses a letter, number, or space, the command palette will show the command suggestions
|
|
1965
|
+
* * When the user presses backspace, the command palette will remove the last character from the command string
|
|
1966
|
+
*/
|
|
1967
|
+
|
|
1968
|
+
var createCommandPalettePlugin = function createCommandPalettePlugin() {
|
|
1969
|
+
return {
|
|
1970
|
+
key: COMMAND_PROMPT,
|
|
1971
|
+
type: COMMAND_PROMPT,
|
|
1972
|
+
isLeaf: true,
|
|
1973
|
+
component: CommandPrompt,
|
|
1974
|
+
handlers: {
|
|
1975
|
+
onKeyDown: createOnKeyDown()
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
};
|
|
1979
|
+
|
|
1980
|
+
function createDragAndDropPlugin() {
|
|
1981
|
+
var DRAGGABLE_TYPES = [Contentful.BLOCKS.EMBEDDED_ENTRY, Contentful.BLOCKS.EMBEDDED_ASSET, Contentful.BLOCKS.HR, Contentful.INLINES.EMBEDDED_ENTRY];
|
|
1982
|
+
/**
|
|
1983
|
+
* HTML node names where dropping should be allowed
|
|
1984
|
+
* Usually for elements where `Transforms.removeNodes` is needed
|
|
1985
|
+
* 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
|
|
1986
|
+
*/
|
|
1987
|
+
|
|
1988
|
+
var ON_DROP_ALLOWED_TYPES = {
|
|
1989
|
+
TABLE: [Contentful.INLINES.EMBEDDED_ENTRY]
|
|
1990
|
+
};
|
|
1991
|
+
return {
|
|
1992
|
+
key: 'DragAndDropPlugin',
|
|
1993
|
+
handlers: {
|
|
1994
|
+
// If true, the next handlers will be skipped.
|
|
1995
|
+
onDrop: function onDrop(editor) {
|
|
1996
|
+
return function (event) {
|
|
1997
|
+
var _Array$from = Array.from(plateCore.getNodes(editor, {
|
|
1998
|
+
match: function match(node) {
|
|
1999
|
+
return DRAGGABLE_TYPES.includes(node == null ? void 0 : node.type);
|
|
2000
|
+
}
|
|
2001
|
+
})),
|
|
2002
|
+
draggingBlock = _Array$from[0];
|
|
2003
|
+
|
|
2004
|
+
if (!draggingBlock) return false;
|
|
2005
|
+
var draggingNode = draggingBlock[0];
|
|
2006
|
+
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
|
|
2007
|
+
|
|
2008
|
+
var dropDisallowed = getParents(event.nativeEvent.target).some(function (node) {
|
|
2009
|
+
var _ON_DROP_ALLOWED_TYPE;
|
|
2010
|
+
|
|
2011
|
+
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;
|
|
2012
|
+
});
|
|
2013
|
+
|
|
2014
|
+
if (!dropDisallowed) {
|
|
2015
|
+
// Move the drop event to a new undo batch mitigating the bug where undo not only moves it back,
|
|
2016
|
+
// but also undoes a previous action: https://github.com/ianstormtaylor/slate/issues/4694
|
|
2017
|
+
editor.history.undos.push([]);
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
return dropDisallowed;
|
|
2021
|
+
};
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
function getParents(el) {
|
|
2028
|
+
var parents = [];
|
|
2029
|
+
parents.push(el);
|
|
2030
|
+
|
|
2031
|
+
while (el.parentNode) {
|
|
2032
|
+
parents.unshift(el.parentNode);
|
|
2033
|
+
el = el.parentNode;
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
return parents;
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
function withLinkTracking(Component) {
|
|
2040
|
+
return function ComponentWithTracking(props) {
|
|
2041
|
+
var editor = useContentfulEditorRef();
|
|
2042
|
+
var onEntityFetchComplete = React__default.useCallback(function () {
|
|
2043
|
+
return editor.tracking.onViewportAction('linkRendered');
|
|
2044
|
+
}, [editor]);
|
|
2045
|
+
return /*#__PURE__*/React__default.createElement(Component, Object.assign({}, props, {
|
|
2046
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2047
|
+
}));
|
|
2048
|
+
};
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
function useFetchedEntity(_ref) {
|
|
2052
|
+
var type = _ref.type,
|
|
2053
|
+
id = _ref.id,
|
|
2054
|
+
onEntityFetchComplete = _ref.onEntityFetchComplete;
|
|
2055
|
+
|
|
2056
|
+
var _useEntities = fieldEditorReference.useEntities(),
|
|
2057
|
+
entries = _useEntities.entries,
|
|
2058
|
+
assets = _useEntities.assets,
|
|
2059
|
+
getOrLoadEntry = _useEntities.getOrLoadEntry,
|
|
2060
|
+
getOrLoadAsset = _useEntities.getOrLoadAsset;
|
|
2061
|
+
|
|
2062
|
+
var store = type === 'Entry' ? entries : assets;
|
|
2063
|
+
|
|
2064
|
+
var _useState = React.useState(store[id]),
|
|
2065
|
+
entity = _useState[0],
|
|
2066
|
+
setEntity = _useState[1]; // Deep compare the entity value to keep re-rendering to minimal
|
|
2067
|
+
|
|
2068
|
+
|
|
2069
|
+
React.useEffect(function () {
|
|
2070
|
+
var newValue = store[id];
|
|
2071
|
+
|
|
2072
|
+
if (!areEqual(entity, newValue)) {
|
|
2073
|
+
setEntity(newValue);
|
|
2074
|
+
}
|
|
2075
|
+
}, [store, entity, id]); // Fetch the entity if needed
|
|
2076
|
+
|
|
2077
|
+
React.useEffect(function () {
|
|
2078
|
+
(type === 'Entry' ? getOrLoadEntry : getOrLoadAsset)(id); // "getOrLoadEntry" and "getOrLoadAsset" instances change with every
|
|
2079
|
+
// entity store update causing page lag on initial load
|
|
2080
|
+
// TODO: consider rewriting useEntities() hook to avoid that happening in
|
|
2081
|
+
// first place.
|
|
2082
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: explain this disable
|
|
2083
|
+
}, [type, id]);
|
|
2084
|
+
React.useEffect(function () {
|
|
2085
|
+
if (entity) {
|
|
2086
|
+
onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
|
|
2087
|
+
}
|
|
2088
|
+
}, [onEntityFetchComplete, entity]);
|
|
2089
|
+
return entity;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
var InternalAssetCard = /*#__PURE__*/React.memo(function (props) {
|
|
2093
|
+
if (props.asset === undefined) {
|
|
2094
|
+
return /*#__PURE__*/React.createElement(f36Components.AssetCard, {
|
|
2095
|
+
size: "default",
|
|
2096
|
+
isLoading: true
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
if (props.asset === 'failed') {
|
|
2101
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.MissingEntityCard, {
|
|
2102
|
+
entityType: "Asset",
|
|
2103
|
+
isDisabled: props.isDisabled,
|
|
2104
|
+
onRemove: props.onRemove
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.WrappedAssetCard, {
|
|
2109
|
+
getEntityScheduledActions: props.loadEntityScheduledActions,
|
|
2110
|
+
size: "small",
|
|
2111
|
+
isSelected: props.isSelected,
|
|
2112
|
+
isDisabled: props.isDisabled,
|
|
2113
|
+
localeCode: props.locale,
|
|
2114
|
+
defaultLocaleCode: props.sdk.locales["default"],
|
|
2115
|
+
asset: props.asset,
|
|
2116
|
+
onEdit: props.onEdit,
|
|
2117
|
+
onRemove: props.isDisabled ? undefined : props.onRemove,
|
|
2118
|
+
isClickable: false
|
|
2119
|
+
});
|
|
2120
|
+
}, areEqual);
|
|
2121
|
+
InternalAssetCard.displayName = 'InternalAssetCard';
|
|
2122
|
+
function FetchingWrappedAssetCard(props) {
|
|
2123
|
+
var onEntityFetchComplete = props.onEntityFetchComplete,
|
|
2124
|
+
assetId = props.assetId;
|
|
2125
|
+
|
|
2126
|
+
var _useEntities = fieldEditorReference.useEntities(),
|
|
2127
|
+
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
|
|
2128
|
+
|
|
2129
|
+
var asset = useFetchedEntity({
|
|
2130
|
+
type: 'Asset',
|
|
2131
|
+
id: assetId,
|
|
2132
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2133
|
+
});
|
|
2134
|
+
return /*#__PURE__*/React.createElement(InternalAssetCard, {
|
|
2135
|
+
asset: asset,
|
|
2136
|
+
sdk: props.sdk,
|
|
2137
|
+
isDisabled: props.isDisabled,
|
|
2138
|
+
isSelected: props.isSelected,
|
|
2139
|
+
loadEntityScheduledActions: loadEntityScheduledActions,
|
|
2140
|
+
locale: props.locale,
|
|
2141
|
+
onEdit: props.onEdit,
|
|
2142
|
+
onRemove: props.onRemove
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
var InternalEntryCard = /*#__PURE__*/React.memo(function (props) {
|
|
2147
|
+
var entry = props.entry,
|
|
2148
|
+
sdk = props.sdk,
|
|
2149
|
+
loadEntityScheduledActions = props.loadEntityScheduledActions;
|
|
2150
|
+
|
|
2151
|
+
if (entry === undefined) {
|
|
2152
|
+
return /*#__PURE__*/React.createElement(f36Components.EntryCard, {
|
|
2153
|
+
isLoading: true
|
|
2154
|
+
});
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
if (entry === 'failed') {
|
|
2158
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.MissingEntityCard, {
|
|
2159
|
+
entityType: "Entry",
|
|
2160
|
+
isDisabled: props.isDisabled,
|
|
2161
|
+
onRemove: props.onRemove
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
var contentType = sdk.space.getCachedContentTypes().find(function (contentType) {
|
|
2166
|
+
return contentType.sys.id === entry.sys.contentType.sys.id;
|
|
2167
|
+
});
|
|
2168
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.WrappedEntryCard, {
|
|
2169
|
+
size: "default",
|
|
2170
|
+
getAsset: props.sdk.space.getAsset,
|
|
2171
|
+
getEntityScheduledActions: loadEntityScheduledActions,
|
|
2172
|
+
isSelected: props.isSelected,
|
|
2173
|
+
isDisabled: props.isDisabled,
|
|
2174
|
+
localeCode: props.locale,
|
|
2175
|
+
defaultLocaleCode: props.sdk.locales["default"],
|
|
2176
|
+
contentType: contentType,
|
|
2177
|
+
entry: entry,
|
|
2178
|
+
onEdit: props.onEdit,
|
|
2179
|
+
onRemove: props.isDisabled ? undefined : props.onRemove,
|
|
2180
|
+
isClickable: false
|
|
2181
|
+
});
|
|
2182
|
+
}, areEqual);
|
|
2183
|
+
InternalEntryCard.displayName = 'ReferenceCard';
|
|
2184
|
+
var FetchingWrappedEntryCard = function FetchingWrappedEntryCard(props) {
|
|
2185
|
+
var entryId = props.entryId,
|
|
2186
|
+
onEntityFetchComplete = props.onEntityFetchComplete;
|
|
1557
2187
|
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
}; // Regardless of whether this script is executing as a CommonJS module
|
|
1561
|
-
// or not, return the runtime object so that we can declare the variable
|
|
1562
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1563
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
2188
|
+
var _useEntities = fieldEditorReference.useEntities(),
|
|
2189
|
+
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
|
|
1564
2190
|
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
2191
|
+
var entry = useFetchedEntity({
|
|
2192
|
+
type: 'Entry',
|
|
2193
|
+
id: entryId,
|
|
2194
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2195
|
+
});
|
|
2196
|
+
return /*#__PURE__*/React.createElement(InternalEntryCard, {
|
|
2197
|
+
entry: entry,
|
|
2198
|
+
sdk: props.sdk,
|
|
2199
|
+
locale: props.locale,
|
|
2200
|
+
isDisabled: props.isDisabled,
|
|
2201
|
+
isSelected: props.isSelected,
|
|
2202
|
+
onEdit: props.onEdit,
|
|
2203
|
+
onRemove: props.onRemove,
|
|
2204
|
+
loadEntityScheduledActions: loadEntityScheduledActions
|
|
2205
|
+
});
|
|
2206
|
+
};
|
|
1571
2207
|
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
//
|
|
1579
|
-
//
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
2208
|
+
var styles$1 = {
|
|
2209
|
+
root: /*#__PURE__*/emotion.css({
|
|
2210
|
+
marginBottom: '1.25rem !important',
|
|
2211
|
+
display: 'block'
|
|
2212
|
+
}),
|
|
2213
|
+
container: /*#__PURE__*/emotion.css({
|
|
2214
|
+
// The next 2 properties ensure Entity card won't be aligned above
|
|
2215
|
+
// a list item marker (i.e. bullet)
|
|
2216
|
+
display: 'inline-block',
|
|
2217
|
+
verticalAlign: 'text-top',
|
|
2218
|
+
width: '100%'
|
|
2219
|
+
})
|
|
2220
|
+
};
|
|
2221
|
+
function LinkedEntityBlock(props) {
|
|
2222
|
+
var attributes = props.attributes,
|
|
2223
|
+
children = props.children,
|
|
2224
|
+
element = props.element,
|
|
2225
|
+
onEntityFetchComplete = props.onEntityFetchComplete;
|
|
2226
|
+
var isSelected = Slate.useSelected();
|
|
2227
|
+
var editor = useContentfulEditor();
|
|
2228
|
+
var sdk = useSdkContext();
|
|
2229
|
+
var isDisabled = Slate.useReadOnly();
|
|
2230
|
+
var _element$data$target$ = element.data.target.sys,
|
|
2231
|
+
entityId = _element$data$target$.id,
|
|
2232
|
+
entityType = _element$data$target$.linkType;
|
|
2233
|
+
var handleEditClick = React__default.useCallback(function () {
|
|
2234
|
+
var openEntity = entityType === 'Asset' ? sdk.navigator.openAsset : sdk.navigator.openEntry;
|
|
2235
|
+
return openEntity(entityId, {
|
|
2236
|
+
slideIn: true
|
|
2237
|
+
});
|
|
2238
|
+
}, [sdk, entityId, entityType]);
|
|
2239
|
+
var handleRemoveClick = React__default.useCallback(function () {
|
|
2240
|
+
if (!editor) return;
|
|
2241
|
+
var pathToElement = Slate.ReactEditor.findPath(editor, element);
|
|
2242
|
+
slate.Transforms.removeNodes(editor, {
|
|
2243
|
+
at: pathToElement
|
|
2244
|
+
});
|
|
2245
|
+
}, [editor, element]);
|
|
2246
|
+
return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
|
|
2247
|
+
className: styles$1.root,
|
|
2248
|
+
"data-entity-type": entityType,
|
|
2249
|
+
"data-entity-id": entityId,
|
|
2250
|
+
// COMPAT: This makes copy & paste work for Firefox
|
|
2251
|
+
contentEditable: IS_CHROME ? undefined : false,
|
|
2252
|
+
draggable: IS_CHROME ? true : undefined
|
|
2253
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
2254
|
+
// COMPAT: This makes copy & paste work for Chromium/Blink browsers and Safari
|
|
2255
|
+
contentEditable: IS_CHROME ? false : undefined,
|
|
2256
|
+
draggable: IS_CHROME ? true : undefined,
|
|
2257
|
+
className: styles$1.container
|
|
2258
|
+
}, entityType === 'Entry' && /*#__PURE__*/React__default.createElement(FetchingWrappedEntryCard, {
|
|
2259
|
+
sdk: sdk,
|
|
2260
|
+
entryId: entityId,
|
|
2261
|
+
locale: sdk.field.locale,
|
|
2262
|
+
isDisabled: isDisabled,
|
|
2263
|
+
isSelected: isSelected,
|
|
2264
|
+
onRemove: handleRemoveClick,
|
|
2265
|
+
onEdit: handleEditClick,
|
|
2266
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2267
|
+
}), entityType === 'Asset' && /*#__PURE__*/React__default.createElement(FetchingWrappedAssetCard, {
|
|
2268
|
+
sdk: sdk,
|
|
2269
|
+
assetId: entityId,
|
|
2270
|
+
locale: sdk.field.locale,
|
|
2271
|
+
isDisabled: isDisabled,
|
|
2272
|
+
isSelected: isSelected,
|
|
2273
|
+
onRemove: handleRemoveClick,
|
|
2274
|
+
onEdit: handleEditClick,
|
|
2275
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2276
|
+
})), children);
|
|
2277
|
+
}
|
|
1587
2278
|
|
|
1588
2279
|
/* eslint-disable you-dont-need-lodash-underscore/find */
|
|
1589
2280
|
/**
|
|
@@ -1695,7 +2386,7 @@ function _selectEntityAndInsert() {
|
|
|
1695
2386
|
|
|
1696
2387
|
case 12:
|
|
1697
2388
|
slate.Transforms.select(editor, selection);
|
|
1698
|
-
insertBlock(editor, nodeType, entity);
|
|
2389
|
+
insertBlock$1(editor, nodeType, entity);
|
|
1699
2390
|
ensureFollowingParagraph(editor);
|
|
1700
2391
|
logAction('insert', {
|
|
1701
2392
|
nodeType: nodeType
|
|
@@ -1748,7 +2439,7 @@ function ensureFollowingParagraph(editor) {
|
|
|
1748
2439
|
moveToTheNextChar(editor);
|
|
1749
2440
|
}
|
|
1750
2441
|
|
|
1751
|
-
var createNode = function createNode(nodeType, entity) {
|
|
2442
|
+
var createNode$1 = function createNode(nodeType, entity) {
|
|
1752
2443
|
return {
|
|
1753
2444
|
type: nodeType,
|
|
1754
2445
|
data: {
|
|
@@ -1768,9 +2459,9 @@ var createNode = function createNode(nodeType, entity) {
|
|
|
1768
2459
|
}; // TODO: DRY up copied code from HR
|
|
1769
2460
|
|
|
1770
2461
|
|
|
1771
|
-
function insertBlock(editor, nodeType, entity) {
|
|
2462
|
+
function insertBlock$1(editor, nodeType, entity) {
|
|
1772
2463
|
if (!(editor != null && editor.selection)) return;
|
|
1773
|
-
var linkedEntityBlock = createNode(nodeType, entity);
|
|
2464
|
+
var linkedEntityBlock = createNode$1(nodeType, entity);
|
|
1774
2465
|
var hasText = editor.selection && !!plateCore.getText(editor, editor.selection.focus.path);
|
|
1775
2466
|
|
|
1776
2467
|
if (hasText) {
|
|
@@ -1782,7 +2473,7 @@ function insertBlock(editor, nodeType, entity) {
|
|
|
1782
2473
|
focus(editor);
|
|
1783
2474
|
}
|
|
1784
2475
|
|
|
1785
|
-
var styles$
|
|
2476
|
+
var styles$2 = {
|
|
1786
2477
|
icon: /*#__PURE__*/emotion.css({
|
|
1787
2478
|
marginRight: '10px'
|
|
1788
2479
|
})
|
|
@@ -1830,7 +2521,7 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
|
|
|
1830
2521
|
flexDirection: "row"
|
|
1831
2522
|
}, /*#__PURE__*/React__default.createElement(f36Components.Icon, {
|
|
1832
2523
|
as: type === 'Asset' ? f36Icons.AssetIcon : f36Icons.EmbeddedEntryBlockIcon,
|
|
1833
|
-
className: "rich-text__embedded-entry-list-icon " + styles$
|
|
2524
|
+
className: "rich-text__embedded-entry-list-icon " + styles$2.icon,
|
|
1834
2525
|
variant: "secondary"
|
|
1835
2526
|
}), /*#__PURE__*/React__default.createElement("span", null, type)));
|
|
1836
2527
|
}
|
|
@@ -1929,7 +2620,7 @@ var createEmbeddedAssetBlockPlugin = /*#__PURE__*/createEmbeddedEntityPlugin(Con
|
|
|
1929
2620
|
|
|
1930
2621
|
var getEntryTitle = fieldEditorShared.entityHelpers.getEntryTitle,
|
|
1931
2622
|
getEntryStatus = fieldEditorShared.entityHelpers.getEntryStatus;
|
|
1932
|
-
var styles$
|
|
2623
|
+
var styles$3 = {
|
|
1933
2624
|
scheduledIcon: /*#__PURE__*/emotion.css({
|
|
1934
2625
|
verticalAlign: 'text-bottom',
|
|
1935
2626
|
marginRight: tokens.spacing2Xs
|
|
@@ -2024,13 +2715,13 @@ function FetchingWrappedInlineEntryCard(props) {
|
|
|
2024
2715
|
entityType: "Entry",
|
|
2025
2716
|
entityId: entry.sys.id
|
|
2026
2717
|
}, /*#__PURE__*/React__default.createElement(f36Icons.ClockIcon, {
|
|
2027
|
-
className: styles$
|
|
2718
|
+
className: styles$3.scheduledIcon,
|
|
2028
2719
|
variant: "muted",
|
|
2029
2720
|
testId: "scheduled-icon"
|
|
2030
2721
|
})), /*#__PURE__*/React__default.createElement(f36Components.Text, null, title));
|
|
2031
2722
|
}
|
|
2032
2723
|
|
|
2033
|
-
function createInlineEntryNode(id) {
|
|
2724
|
+
function createInlineEntryNode$1(id) {
|
|
2034
2725
|
return {
|
|
2035
2726
|
type: Contentful.INLINES.EMBEDDED_ENTRY,
|
|
2036
2727
|
children: [{
|
|
@@ -2048,7 +2739,7 @@ function createInlineEntryNode(id) {
|
|
|
2048
2739
|
};
|
|
2049
2740
|
}
|
|
2050
2741
|
|
|
2051
|
-
var styles$
|
|
2742
|
+
var styles$4 = {
|
|
2052
2743
|
icon: /*#__PURE__*/emotion.css({
|
|
2053
2744
|
marginRight: '10px'
|
|
2054
2745
|
}),
|
|
@@ -2084,7 +2775,7 @@ function EmbeddedEntityInline(props) {
|
|
|
2084
2775
|
}
|
|
2085
2776
|
|
|
2086
2777
|
return /*#__PURE__*/React.createElement("span", Object.assign({}, props.attributes, {
|
|
2087
|
-
className: styles$
|
|
2778
|
+
className: styles$4.root,
|
|
2088
2779
|
"data-embedded-entity-inline-id": entryId,
|
|
2089
2780
|
// COMPAT: This makes copy & paste work for Firefox
|
|
2090
2781
|
contentEditable: IS_CHROME ? undefined : false,
|
|
@@ -2140,7 +2831,7 @@ function _selectEntityAndInsert$1() {
|
|
|
2140
2831
|
return _context2.abrupt("return");
|
|
2141
2832
|
|
|
2142
2833
|
case 10:
|
|
2143
|
-
inlineEntryNode = createInlineEntryNode(entry.sys.id);
|
|
2834
|
+
inlineEntryNode = createInlineEntryNode$1(entry.sys.id);
|
|
2144
2835
|
logAction('insert', {
|
|
2145
2836
|
nodeType: Contentful.INLINES.EMBEDDED_ENTRY
|
|
2146
2837
|
}); // Got to wait until focus is really back on the editor or setSelection() won't work.
|
|
@@ -2214,7 +2905,7 @@ function ToolbarEmbeddedEntityInlineButton(props) {
|
|
|
2214
2905
|
flexDirection: "row"
|
|
2215
2906
|
}, /*#__PURE__*/React.createElement(f36Icons.EmbeddedEntryInlineIcon, {
|
|
2216
2907
|
variant: "secondary",
|
|
2217
|
-
className: "rich-text__embedded-entry-list-icon " + styles$
|
|
2908
|
+
className: "rich-text__embedded-entry-list-icon " + styles$4.icon
|
|
2218
2909
|
}), /*#__PURE__*/React.createElement("span", null, "Inline entry")));
|
|
2219
2910
|
}
|
|
2220
2911
|
function createEmbeddedEntityInlinePlugin(sdk) {
|
|
@@ -2238,7 +2929,7 @@ function createEmbeddedEntityInlinePlugin(sdk) {
|
|
|
2238
2929
|
}],
|
|
2239
2930
|
withoutChildren: true,
|
|
2240
2931
|
getNode: function getNode(el) {
|
|
2241
|
-
return createInlineEntryNode(el.getAttribute(htmlAttributeName));
|
|
2932
|
+
return createInlineEntryNode$1(el.getAttribute(htmlAttributeName));
|
|
2242
2933
|
}
|
|
2243
2934
|
}
|
|
2244
2935
|
};
|
|
@@ -2290,7 +2981,7 @@ var isMarkEnabled = function isMarkEnabled(field, mark) {
|
|
|
2290
2981
|
};
|
|
2291
2982
|
|
|
2292
2983
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _dropdown, _LABELS;
|
|
2293
|
-
var styles$
|
|
2984
|
+
var styles$5 = {
|
|
2294
2985
|
dropdown: (_dropdown = {
|
|
2295
2986
|
root: /*#__PURE__*/emotion.css(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-weight: ", ";\n "])), tokens.fontWeightDemiBold)
|
|
2296
2987
|
}, _dropdown[Contentful.BLOCKS.PARAGRAPH] = /*#__PURE__*/emotion.css(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: ", ";\n "])), tokens.fontSizeL), _dropdown[Contentful.BLOCKS.HEADING_1] = /*#__PURE__*/emotion.css(_templateObject3 || (_templateObject3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.625rem;\n "]))), _dropdown[Contentful.BLOCKS.HEADING_2] = /*#__PURE__*/emotion.css(_templateObject4 || (_templateObject4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.4375rem;\n "]))), _dropdown[Contentful.BLOCKS.HEADING_3] = /*#__PURE__*/emotion.css(_templateObject5 || (_templateObject5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.25rem;\n "]))), _dropdown[Contentful.BLOCKS.HEADING_4] = /*#__PURE__*/emotion.css(_templateObject6 || (_templateObject6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.125rem;\n "]))), _dropdown[Contentful.BLOCKS.HEADING_5] = /*#__PURE__*/emotion.css(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1rem;\n "]))), _dropdown[Contentful.BLOCKS.HEADING_6] = /*#__PURE__*/emotion.css(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 0.875rem;\n "]))), _dropdown)
|
|
@@ -2385,7 +3076,7 @@ function ToolbarHeadingButton(props) {
|
|
|
2385
3076
|
testId: "dropdown-option-" + nodeType,
|
|
2386
3077
|
disabled: props.isDisabled
|
|
2387
3078
|
}, /*#__PURE__*/React.createElement("span", {
|
|
2388
|
-
className: emotion.cx(styles$
|
|
3079
|
+
className: emotion.cx(styles$5.dropdown.root, styles$5.dropdown[nodeType])
|
|
2389
3080
|
}, LABELS[nodeType]));
|
|
2390
3081
|
}).filter(Boolean)));
|
|
2391
3082
|
}
|
|
@@ -2455,7 +3146,7 @@ var transformLift = function transformLift(editor, _ref4) {
|
|
|
2455
3146
|
};
|
|
2456
3147
|
|
|
2457
3148
|
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;
|
|
2458
|
-
var styles$
|
|
3149
|
+
var styles$6 = {
|
|
2459
3150
|
dropdown: (_dropdown$1 = {
|
|
2460
3151
|
root: /*#__PURE__*/emotion.css(_templateObject$1 || (_templateObject$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-weight: ", ";\n "])), tokens.fontWeightDemiBold)
|
|
2461
3152
|
}, _dropdown$1[Contentful.BLOCKS.PARAGRAPH] = /*#__PURE__*/emotion.css(_templateObject2$1 || (_templateObject2$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: ", ";\n "])), tokens.fontSizeL), _dropdown$1[Contentful.BLOCKS.HEADING_1] = /*#__PURE__*/emotion.css(_templateObject3$1 || (_templateObject3$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.625rem;\n "]))), _dropdown$1[Contentful.BLOCKS.HEADING_2] = /*#__PURE__*/emotion.css(_templateObject4$1 || (_templateObject4$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.4375rem;\n "]))), _dropdown$1[Contentful.BLOCKS.HEADING_3] = /*#__PURE__*/emotion.css(_templateObject5$1 || (_templateObject5$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.25rem;\n "]))), _dropdown$1[Contentful.BLOCKS.HEADING_4] = /*#__PURE__*/emotion.css(_templateObject6$1 || (_templateObject6$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.125rem;\n "]))), _dropdown$1[Contentful.BLOCKS.HEADING_5] = /*#__PURE__*/emotion.css(_templateObject7$1 || (_templateObject7$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1rem;\n "]))), _dropdown$1[Contentful.BLOCKS.HEADING_6] = /*#__PURE__*/emotion.css(_templateObject8$1 || (_templateObject8$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 0.875rem;\n "]))), _dropdown$1),
|
|
@@ -2467,7 +3158,7 @@ var styles$5 = {
|
|
|
2467
3158
|
function createHeading(Tag, block) {
|
|
2468
3159
|
return function Heading(props) {
|
|
2469
3160
|
return /*#__PURE__*/React.createElement(Tag, Object.assign({}, props.attributes, {
|
|
2470
|
-
className: emotion.cx(styles$
|
|
3161
|
+
className: emotion.cx(styles$6.headings.root, styles$6.headings[block])
|
|
2471
3162
|
}), props.children);
|
|
2472
3163
|
};
|
|
2473
3164
|
}
|
|
@@ -2563,7 +3254,7 @@ var createHeadingPlugin = function createHeadingPlugin() {
|
|
|
2563
3254
|
};
|
|
2564
3255
|
};
|
|
2565
3256
|
|
|
2566
|
-
var styles$
|
|
3257
|
+
var styles$7 = {
|
|
2567
3258
|
button: /*#__PURE__*/emotion.css({
|
|
2568
3259
|
height: '30px',
|
|
2569
3260
|
width: '30px',
|
|
@@ -2589,7 +3280,7 @@ function ToolbarButton(props) {
|
|
|
2589
3280
|
};
|
|
2590
3281
|
|
|
2591
3282
|
var button = /*#__PURE__*/React__default.createElement(f36Components.Button, {
|
|
2592
|
-
className: emotion.cx(styles$
|
|
3283
|
+
className: emotion.cx(styles$7.button, className),
|
|
2593
3284
|
isDisabled: isDisabled,
|
|
2594
3285
|
startIcon: children,
|
|
2595
3286
|
onClick: handleClick,
|
|
@@ -2600,7 +3291,7 @@ function ToolbarButton(props) {
|
|
|
2600
3291
|
|
|
2601
3292
|
if (title) {
|
|
2602
3293
|
return /*#__PURE__*/React__default.createElement(f36Components.Tooltip, {
|
|
2603
|
-
className: styles$
|
|
3294
|
+
className: styles$7.tooltip,
|
|
2604
3295
|
placement: "bottom",
|
|
2605
3296
|
content: title
|
|
2606
3297
|
}, button);
|
|
@@ -2610,7 +3301,7 @@ function ToolbarButton(props) {
|
|
|
2610
3301
|
}
|
|
2611
3302
|
|
|
2612
3303
|
var _templateObject$2, _templateObject2$2, _templateObject3$2;
|
|
2613
|
-
var styles$
|
|
3304
|
+
var styles$8 = {
|
|
2614
3305
|
container: /*#__PURE__*/emotion.css(_templateObject$2 || (_templateObject$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0 0 ", ";\n "])), tokens.spacingL),
|
|
2615
3306
|
hr: /*#__PURE__*/emotion.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),
|
|
2616
3307
|
hrSelected: /*#__PURE__*/emotion.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)
|
|
@@ -2668,14 +3359,14 @@ function Hr(props) {
|
|
|
2668
3359
|
var isSelected = Slate.useSelected();
|
|
2669
3360
|
var isFocused = Slate.useFocused();
|
|
2670
3361
|
return /*#__PURE__*/React.createElement("div", Object.assign({}, props.attributes, {
|
|
2671
|
-
className: styles$
|
|
3362
|
+
className: styles$8.container,
|
|
2672
3363
|
"data-void-element": Contentful.BLOCKS.HR
|
|
2673
3364
|
}), /*#__PURE__*/React.createElement("div", {
|
|
2674
3365
|
draggable: true,
|
|
2675
3366
|
// Moving `contentEditable` to this div makes it to be selectable when being the first void element, e.g pressing ctrl + a to select everything
|
|
2676
3367
|
contentEditable: false
|
|
2677
3368
|
}, /*#__PURE__*/React.createElement("hr", {
|
|
2678
|
-
className: emotion.cx(styles$
|
|
3369
|
+
className: emotion.cx(styles$8.hr, isSelected && isFocused ? styles$8.hrSelected : undefined)
|
|
2679
3370
|
})), props.children);
|
|
2680
3371
|
}
|
|
2681
3372
|
var createHrPlugin = function createHrPlugin() {
|
|
@@ -2702,7 +3393,7 @@ var createHrPlugin = function createHrPlugin() {
|
|
|
2702
3393
|
};
|
|
2703
3394
|
|
|
2704
3395
|
var _templateObject$3, _SYS_LINK_TYPES, _LINK_TYPE_SELECTION_;
|
|
2705
|
-
var styles$
|
|
3396
|
+
var styles$9 = {
|
|
2706
3397
|
removeSelectionLabel: /*#__PURE__*/emotion.css(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-left: ", ";\n "])), tokens.spacingS)
|
|
2707
3398
|
};
|
|
2708
3399
|
var SYS_LINK_TYPES = (_SYS_LINK_TYPES = {}, _SYS_LINK_TYPES[Contentful.INLINES.ENTRY_HYPERLINK] = 'Entry', _SYS_LINK_TYPES[Contentful.INLINES.ASSET_HYPERLINK] = 'Asset', _SYS_LINK_TYPES);
|
|
@@ -2885,7 +3576,7 @@ function HyperlinkModal(props) {
|
|
|
2885
3576
|
}, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? /*#__PURE__*/React.createElement(React.Fragment, null, !props.readonly && /*#__PURE__*/React.createElement(f36Components.TextLink, {
|
|
2886
3577
|
testId: "entity-selection-link",
|
|
2887
3578
|
onClick: resetLinkEntity,
|
|
2888
|
-
className: styles$
|
|
3579
|
+
className: styles$9.removeSelectionLabel
|
|
2889
3580
|
}, "Remove selection"), /*#__PURE__*/React.createElement("div", null, linkType === Contentful.INLINES.ENTRY_HYPERLINK && /*#__PURE__*/React.createElement(FetchingWrappedEntryCard, {
|
|
2890
3581
|
sdk: props.sdk,
|
|
2891
3582
|
locale: props.sdk.field.locale,
|
|
@@ -3226,7 +3917,7 @@ function useEntityInfo(props) {
|
|
|
3226
3917
|
return getEntityInfo(status.data);
|
|
3227
3918
|
}
|
|
3228
3919
|
|
|
3229
|
-
var styles$
|
|
3920
|
+
var styles$a = {
|
|
3230
3921
|
hyperlinkWrapper: /*#__PURE__*/emotion.css({
|
|
3231
3922
|
display: 'inline',
|
|
3232
3923
|
position: 'static',
|
|
@@ -3271,13 +3962,13 @@ function EntityHyperlink(props) {
|
|
|
3271
3962
|
|
|
3272
3963
|
return /*#__PURE__*/React.createElement(f36Components.Tooltip, {
|
|
3273
3964
|
content: tooltipContent,
|
|
3274
|
-
targetWrapperClassName: styles$
|
|
3965
|
+
targetWrapperClassName: styles$a.hyperlinkWrapper,
|
|
3275
3966
|
placement: "bottom",
|
|
3276
3967
|
maxWidth: "auto"
|
|
3277
3968
|
}, /*#__PURE__*/React.createElement(f36Components.TextLink, {
|
|
3278
3969
|
as: "a",
|
|
3279
3970
|
onClick: handleClick,
|
|
3280
|
-
className: styles$
|
|
3971
|
+
className: styles$a.hyperlink,
|
|
3281
3972
|
"data-link-type": target.sys.linkType,
|
|
3282
3973
|
"data-link-id": target.sys.id
|
|
3283
3974
|
}, props.children));
|
|
@@ -3301,7 +3992,7 @@ function UrlHyperlink(props) {
|
|
|
3301
3992
|
|
|
3302
3993
|
return /*#__PURE__*/React.createElement(f36Components.Tooltip, {
|
|
3303
3994
|
content: uri,
|
|
3304
|
-
targetWrapperClassName: styles$
|
|
3995
|
+
targetWrapperClassName: styles$a.hyperlinkWrapper,
|
|
3305
3996
|
placement: "bottom",
|
|
3306
3997
|
maxWidth: "auto"
|
|
3307
3998
|
}, /*#__PURE__*/React.createElement(f36Components.TextLink, {
|
|
@@ -3309,7 +4000,7 @@ function UrlHyperlink(props) {
|
|
|
3309
4000
|
href: uri,
|
|
3310
4001
|
rel: "noopener noreferrer",
|
|
3311
4002
|
onClick: handleClick,
|
|
3312
|
-
className: styles$
|
|
4003
|
+
className: styles$a.hyperlink
|
|
3313
4004
|
}, props.children));
|
|
3314
4005
|
}
|
|
3315
4006
|
|
|
@@ -3435,12 +4126,12 @@ var createHyperlinkPlugin = function createHyperlinkPlugin(sdk) {
|
|
|
3435
4126
|
|
|
3436
4127
|
var _templateObject$4, _templateObject2$3, _templateObject3$3, _styles;
|
|
3437
4128
|
var baseStyle = /*#__PURE__*/emotion.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);
|
|
3438
|
-
var styles$
|
|
4129
|
+
var styles$b = (_styles = {}, _styles[Contentful.BLOCKS.UL_LIST] = /*#__PURE__*/emotion.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[Contentful.BLOCKS.OL_LIST] = /*#__PURE__*/emotion.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);
|
|
3439
4130
|
|
|
3440
4131
|
function createList(Tag, block) {
|
|
3441
4132
|
return function List(props) {
|
|
3442
4133
|
return /*#__PURE__*/React.createElement(Tag, Object.assign({}, props.attributes, {
|
|
3443
|
-
className: emotion.cx(baseStyle, styles$
|
|
4134
|
+
className: emotion.cx(baseStyle, styles$b[block])
|
|
3444
4135
|
}), props.children);
|
|
3445
4136
|
};
|
|
3446
4137
|
}
|
|
@@ -4421,14 +5112,14 @@ var ToolbarBoldButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
4421
5112
|
mark: Contentful.MARKS.BOLD,
|
|
4422
5113
|
icon: /*#__PURE__*/React.createElement(f36Icons.FormatBoldIcon, null)
|
|
4423
5114
|
});
|
|
4424
|
-
var styles$
|
|
5115
|
+
var styles$c = {
|
|
4425
5116
|
bold: /*#__PURE__*/emotion.css({
|
|
4426
5117
|
fontWeight: 600
|
|
4427
5118
|
})
|
|
4428
5119
|
};
|
|
4429
5120
|
function Bold(props) {
|
|
4430
5121
|
return /*#__PURE__*/React.createElement("strong", Object.assign({}, props.attributes, {
|
|
4431
|
-
className: styles$
|
|
5122
|
+
className: styles$c.bold
|
|
4432
5123
|
}), props.children);
|
|
4433
5124
|
}
|
|
4434
5125
|
|
|
@@ -4468,7 +5159,7 @@ var ToolbarCodeButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
4468
5159
|
mark: Contentful.MARKS.CODE,
|
|
4469
5160
|
icon: /*#__PURE__*/React.createElement(f36Icons.CodeIcon, null)
|
|
4470
5161
|
});
|
|
4471
|
-
var styles$
|
|
5162
|
+
var styles$d = {
|
|
4472
5163
|
code: /*#__PURE__*/emotion.css({
|
|
4473
5164
|
fontFamily: 'monospace',
|
|
4474
5165
|
fontSize: '.9em'
|
|
@@ -4476,7 +5167,7 @@ var styles$c = {
|
|
|
4476
5167
|
};
|
|
4477
5168
|
function Code(props) {
|
|
4478
5169
|
return /*#__PURE__*/React.createElement("code", Object.assign({}, props.attributes, {
|
|
4479
|
-
className: styles$
|
|
5170
|
+
className: styles$d.code
|
|
4480
5171
|
}), props.children);
|
|
4481
5172
|
}
|
|
4482
5173
|
var createCodePlugin = function createCodePlugin() {
|
|
@@ -4506,14 +5197,14 @@ var ToolbarItalicButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
4506
5197
|
mark: Contentful.MARKS.ITALIC,
|
|
4507
5198
|
icon: /*#__PURE__*/React.createElement(f36Icons.FormatItalicIcon, null)
|
|
4508
5199
|
});
|
|
4509
|
-
var styles$
|
|
5200
|
+
var styles$e = {
|
|
4510
5201
|
italic: /*#__PURE__*/emotion.css({
|
|
4511
5202
|
fontStyle: 'italic'
|
|
4512
5203
|
})
|
|
4513
5204
|
};
|
|
4514
5205
|
function Italic(props) {
|
|
4515
5206
|
return /*#__PURE__*/React.createElement("em", Object.assign({}, props.attributes, {
|
|
4516
|
-
className: styles$
|
|
5207
|
+
className: styles$e.italic
|
|
4517
5208
|
}), props.children);
|
|
4518
5209
|
}
|
|
4519
5210
|
var createItalicPlugin = function createItalicPlugin() {
|
|
@@ -4789,10 +5480,10 @@ var createNormalizerPlugin = function createNormalizerPlugin() {
|
|
|
4789
5480
|
};
|
|
4790
5481
|
|
|
4791
5482
|
var _templateObject$6, _styles$1;
|
|
4792
|
-
var styles$
|
|
5483
|
+
var styles$f = (_styles$1 = {}, _styles$1[Contentful.BLOCKS.PARAGRAPH] = /*#__PURE__*/emotion.css(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: ", ";\n margin-bottom: 1.5em;\n "])), tokens.lineHeightDefault), _styles$1);
|
|
4793
5484
|
function Paragraph(props) {
|
|
4794
5485
|
return /*#__PURE__*/React.createElement("div", Object.assign({}, props.attributes, {
|
|
4795
|
-
className: styles$
|
|
5486
|
+
className: styles$f[Contentful.BLOCKS.PARAGRAPH]
|
|
4796
5487
|
}), props.children);
|
|
4797
5488
|
}
|
|
4798
5489
|
|
|
@@ -5205,185 +5896,6 @@ var createSelectOnBackspacePlugin = function createSelectOnBackspacePlugin() {
|
|
|
5205
5896
|
});
|
|
5206
5897
|
};
|
|
5207
5898
|
|
|
5208
|
-
function getCaretTopPoint() {
|
|
5209
|
-
var sel = document.getSelection();
|
|
5210
|
-
if (!sel) return;
|
|
5211
|
-
var r = sel.getRangeAt(0);
|
|
5212
|
-
var rect;
|
|
5213
|
-
var r2; // supposed to be textNode in most cases
|
|
5214
|
-
// but div[contenteditable] when empty
|
|
5215
|
-
|
|
5216
|
-
var node = r.startContainer;
|
|
5217
|
-
var offset = r.startOffset;
|
|
5218
|
-
|
|
5219
|
-
if (offset > 0) {
|
|
5220
|
-
// new range, don't influence DOM state
|
|
5221
|
-
r2 = document.createRange();
|
|
5222
|
-
r2.setStart(node, offset - 1);
|
|
5223
|
-
r2.setEnd(node, offset); // https://developer.mozilla.org/en-US/docs/Web/API/range.getBoundingClientRect
|
|
5224
|
-
// IE9, Safari?(but look good in Safari 8)
|
|
5225
|
-
|
|
5226
|
-
rect = r2.getBoundingClientRect();
|
|
5227
|
-
return {
|
|
5228
|
-
left: rect.right,
|
|
5229
|
-
top: rect.top
|
|
5230
|
-
}; // @ts-expect-error
|
|
5231
|
-
} else if (offset < node.length) {
|
|
5232
|
-
r2 = document.createRange(); // similar but select next on letter
|
|
5233
|
-
|
|
5234
|
-
r2.setStart(node, offset);
|
|
5235
|
-
r2.setEnd(node, offset + 1);
|
|
5236
|
-
rect = r2.getBoundingClientRect();
|
|
5237
|
-
return {
|
|
5238
|
-
left: rect.left,
|
|
5239
|
-
top: rect.top
|
|
5240
|
-
};
|
|
5241
|
-
} else {
|
|
5242
|
-
// textNode has length
|
|
5243
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Element.getBoundingClientRect
|
|
5244
|
-
// @ts-expect-error
|
|
5245
|
-
rect = node.getBoundingClientRect(); // @ts-expect-error
|
|
5246
|
-
|
|
5247
|
-
var styles = getComputedStyle(node);
|
|
5248
|
-
var lineHeight = parseInt(styles.lineHeight);
|
|
5249
|
-
var fontSize = parseInt(styles.fontSize); // roughly half the whitespace... but not exactly
|
|
5250
|
-
|
|
5251
|
-
var delta = (lineHeight - fontSize) / 2;
|
|
5252
|
-
return {
|
|
5253
|
-
left: rect.left,
|
|
5254
|
-
top: rect.top + delta
|
|
5255
|
-
};
|
|
5256
|
-
}
|
|
5257
|
-
}
|
|
5258
|
-
function closePanel(editorId) {
|
|
5259
|
-
document.dispatchEvent(new CustomEvent('close-rte-palette-commands', {
|
|
5260
|
-
detail: {
|
|
5261
|
-
editorId: editorId
|
|
5262
|
-
}
|
|
5263
|
-
}));
|
|
5264
|
-
}
|
|
5265
|
-
function openPanel(editorId) {
|
|
5266
|
-
document.dispatchEvent(new CustomEvent('open-rte-palette-commands', {
|
|
5267
|
-
detail: {
|
|
5268
|
-
editorId: editorId
|
|
5269
|
-
}
|
|
5270
|
-
}));
|
|
5271
|
-
}
|
|
5272
|
-
|
|
5273
|
-
// import debounce from 'lodash/debounce';
|
|
5274
|
-
var SLASH_COMMANDS_PLUGIN_KEY = 'SlashCommands'; // TODO: Explore a solution using marks and ReactDOM.createPortal to activate the commands panel
|
|
5275
|
-
|
|
5276
|
-
function createSlashCommandsPlugin() {
|
|
5277
|
-
return {
|
|
5278
|
-
key: SLASH_COMMANDS_PLUGIN_KEY,
|
|
5279
|
-
type: SLASH_COMMANDS_PLUGIN_KEY,
|
|
5280
|
-
handlers: {
|
|
5281
|
-
onClick: function onClick(editor) {
|
|
5282
|
-
return function () {
|
|
5283
|
-
closePanel(editor.id);
|
|
5284
|
-
};
|
|
5285
|
-
},
|
|
5286
|
-
onKeyDown: function onKeyDown(editor) {
|
|
5287
|
-
return function (event) {
|
|
5288
|
-
closePanel(editor.id);
|
|
5289
|
-
|
|
5290
|
-
if (event.key === '/') {
|
|
5291
|
-
openPanel(editor.id);
|
|
5292
|
-
}
|
|
5293
|
-
};
|
|
5294
|
-
}
|
|
5295
|
-
}
|
|
5296
|
-
};
|
|
5297
|
-
}
|
|
5298
|
-
|
|
5299
|
-
var style$2 = {
|
|
5300
|
-
container: function container(_ref) {
|
|
5301
|
-
var top = _ref.top,
|
|
5302
|
-
left = _ref.left;
|
|
5303
|
-
return emotion.css({
|
|
5304
|
-
position: 'fixed',
|
|
5305
|
-
top: top - 14,
|
|
5306
|
-
left: left + 10,
|
|
5307
|
-
zIndex: 1,
|
|
5308
|
-
boxShadow: '0 5px 15px rgba(0, 0, 0, 0.15)',
|
|
5309
|
-
borderRadius: '8px',
|
|
5310
|
-
userSelect: 'none'
|
|
5311
|
-
});
|
|
5312
|
-
}
|
|
5313
|
-
};
|
|
5314
|
-
function SlashCommandsPalette(_ref2) {
|
|
5315
|
-
var editorId = _ref2.editorId;
|
|
5316
|
-
|
|
5317
|
-
var _React$useState = React.useState(null),
|
|
5318
|
-
position = _React$useState[0],
|
|
5319
|
-
setPosition = _React$useState[1];
|
|
5320
|
-
|
|
5321
|
-
var _React$useState2 = React.useState(false),
|
|
5322
|
-
isOpen = _React$useState2[0],
|
|
5323
|
-
setIsOpen = _React$useState2[1]; // The user is not annoyed every time they type `/`
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
var MAX_TRIES = 3;
|
|
5327
|
-
|
|
5328
|
-
var _React$useState3 = React.useState(0),
|
|
5329
|
-
currentTries = _React$useState3[0],
|
|
5330
|
-
setCurrentTries = _React$useState3[1];
|
|
5331
|
-
|
|
5332
|
-
React.useEffect(function () {
|
|
5333
|
-
function handler(event) {
|
|
5334
|
-
if (editorId !== event.detail.editorId) return;
|
|
5335
|
-
var topLeft = getCaretTopPoint();
|
|
5336
|
-
if (!topLeft) return;
|
|
5337
|
-
setPosition(topLeft);
|
|
5338
|
-
setIsOpen(true);
|
|
5339
|
-
setCurrentTries(function (curr) {
|
|
5340
|
-
return curr + 1;
|
|
5341
|
-
});
|
|
5342
|
-
}
|
|
5343
|
-
|
|
5344
|
-
document.addEventListener('open-rte-palette-commands', handler);
|
|
5345
|
-
return function () {
|
|
5346
|
-
document.removeEventListener('open-rte-palette-commands', handler);
|
|
5347
|
-
};
|
|
5348
|
-
}, [editorId]);
|
|
5349
|
-
React.useEffect(function () {
|
|
5350
|
-
function handler(event) {
|
|
5351
|
-
if (editorId !== event.detail.editorId) return;
|
|
5352
|
-
closePanel();
|
|
5353
|
-
}
|
|
5354
|
-
|
|
5355
|
-
document.addEventListener('close-rte-palette-commands', handler);
|
|
5356
|
-
return function () {
|
|
5357
|
-
return document.removeEventListener('close-rte-palette-commands', handler);
|
|
5358
|
-
};
|
|
5359
|
-
}, [editorId]);
|
|
5360
|
-
React.useEffect(function () {
|
|
5361
|
-
if (!isOpen) return;
|
|
5362
|
-
|
|
5363
|
-
function handler() {
|
|
5364
|
-
closePanel();
|
|
5365
|
-
}
|
|
5366
|
-
|
|
5367
|
-
window.addEventListener('resize', handler);
|
|
5368
|
-
window.addEventListener('scroll', handler, true);
|
|
5369
|
-
return function () {
|
|
5370
|
-
window.removeEventListener('resize', handler);
|
|
5371
|
-
window.removeEventListener('scroll', handler, true);
|
|
5372
|
-
};
|
|
5373
|
-
}, [isOpen]);
|
|
5374
|
-
|
|
5375
|
-
function closePanel() {
|
|
5376
|
-
setIsOpen(false);
|
|
5377
|
-
setPosition(null);
|
|
5378
|
-
}
|
|
5379
|
-
|
|
5380
|
-
if (!isOpen || !position || currentTries > MAX_TRIES) return null;
|
|
5381
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
5382
|
-
className: style$2.container(position),
|
|
5383
|
-
"data-test-id": "rte-slash-commands"
|
|
5384
|
-
}, /*#__PURE__*/React.createElement(f36Components.Card, null, /*#__PURE__*/React.createElement(f36Components.Text, null, "Slash commands are temporarily unavailable.")));
|
|
5385
|
-
}
|
|
5386
|
-
|
|
5387
5899
|
var addRow = function addRow(editor, getNextRowPath) {
|
|
5388
5900
|
if (plateCore.someNode(editor, {
|
|
5389
5901
|
match: {
|
|
@@ -5613,7 +6125,7 @@ var isTable = function isTable(node) {
|
|
|
5613
6125
|
return slate.Element.isElement(node) && node.type === Contentful.BLOCKS.TABLE;
|
|
5614
6126
|
};
|
|
5615
6127
|
|
|
5616
|
-
var styles$
|
|
6128
|
+
var styles$g = {
|
|
5617
6129
|
topRight: /*#__PURE__*/emotion.css({
|
|
5618
6130
|
position: 'absolute',
|
|
5619
6131
|
top: '6px',
|
|
@@ -5702,7 +6214,7 @@ var TableActions = function TableActions() {
|
|
|
5702
6214
|
size: "small",
|
|
5703
6215
|
variant: "transparent",
|
|
5704
6216
|
tabIndex: -1,
|
|
5705
|
-
className: styles$
|
|
6217
|
+
className: styles$g.topRight,
|
|
5706
6218
|
icon: /*#__PURE__*/React__default.createElement(f36Icons.ChevronDownIcon, null),
|
|
5707
6219
|
"aria-label": "Open table menu",
|
|
5708
6220
|
testId: "cf-table-actions-button"
|
|
@@ -5727,38 +6239,38 @@ var TableActions = function TableActions() {
|
|
|
5727
6239
|
};
|
|
5728
6240
|
|
|
5729
6241
|
var _templateObject$7;
|
|
5730
|
-
var style$
|
|
6242
|
+
var style$2 = /*#__PURE__*/emotion.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);
|
|
5731
6243
|
var Cell = function Cell(props) {
|
|
5732
6244
|
var isSelected = Slate.useSelected();
|
|
5733
6245
|
return /*#__PURE__*/React.createElement("td", Object.assign({}, props.attributes, props.element.data, {
|
|
5734
|
-
className: style$
|
|
6246
|
+
className: style$2
|
|
5735
6247
|
}), isSelected && /*#__PURE__*/React.createElement(TableActions, null), props.children);
|
|
5736
6248
|
};
|
|
5737
6249
|
|
|
5738
6250
|
var _templateObject$8;
|
|
5739
|
-
var style$
|
|
6251
|
+
var style$3 = /*#__PURE__*/emotion.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);
|
|
5740
6252
|
var HeaderCell = function HeaderCell(props) {
|
|
5741
6253
|
var isSelected = Slate.useSelected();
|
|
5742
6254
|
return /*#__PURE__*/React.createElement("th", Object.assign({}, props.attributes, props.element.data, {
|
|
5743
|
-
className: style$
|
|
6255
|
+
className: style$3
|
|
5744
6256
|
}), isSelected && /*#__PURE__*/React.createElement(TableActions, null), props.children);
|
|
5745
6257
|
};
|
|
5746
6258
|
|
|
5747
6259
|
var _templateObject$9;
|
|
5748
|
-
var style$
|
|
6260
|
+
var style$4 = /*#__PURE__*/emotion.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);
|
|
5749
6261
|
var Row = function Row(props) {
|
|
5750
6262
|
return /*#__PURE__*/React.createElement("tr", Object.assign({}, props.attributes, {
|
|
5751
|
-
className: style$
|
|
6263
|
+
className: style$4
|
|
5752
6264
|
}), props.children);
|
|
5753
6265
|
};
|
|
5754
6266
|
|
|
5755
6267
|
var _templateObject$a;
|
|
5756
|
-
var style$
|
|
6268
|
+
var style$5 = /*#__PURE__*/emotion.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);
|
|
5757
6269
|
var Table = function Table(props) {
|
|
5758
6270
|
return /*#__PURE__*/React.createElement("div", {
|
|
5759
6271
|
"data-block-type": Contentful.BLOCKS.TABLE
|
|
5760
6272
|
}, /*#__PURE__*/React.createElement("table", Object.assign({
|
|
5761
|
-
className: style$
|
|
6273
|
+
className: style$5
|
|
5762
6274
|
}, props.attributes), /*#__PURE__*/React.createElement("tbody", null, props.children)));
|
|
5763
6275
|
};
|
|
5764
6276
|
|
|
@@ -6505,7 +7017,7 @@ var getPlugins = function getPlugins(sdk, onAction) {
|
|
|
6505
7017
|
return [// AST must come after the HTML deserializer
|
|
6506
7018
|
plateCore.createDeserializeHtmlPlugin(), plateCore.createDeserializeAstPlugin(), plateSerializerDocx.createDeserializeDocxPlugin(), // Tracking - This should come first so all plugins below will have access to `editor.tracking`
|
|
6507
7019
|
createTrackingPlugin(onAction), // Global / Global shortcuts
|
|
6508
|
-
createDragAndDropPlugin(),
|
|
7020
|
+
createDragAndDropPlugin(), createCommandPalettePlugin(), // Block Elements
|
|
6509
7021
|
createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
|
|
6510
7022
|
createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
|
|
6511
7023
|
createMarksPlugin(), // Other
|
|
@@ -6636,7 +7148,7 @@ var normalizeEditorValue = function normalizeEditorValue(value, options) {
|
|
|
6636
7148
|
};
|
|
6637
7149
|
|
|
6638
7150
|
var STYLE_EDITOR_BORDER = "1px solid " + tokens.gray400;
|
|
6639
|
-
var styles$
|
|
7151
|
+
var styles$h = {
|
|
6640
7152
|
root: /*#__PURE__*/emotion.css({
|
|
6641
7153
|
position: 'relative'
|
|
6642
7154
|
}),
|
|
@@ -6753,7 +7265,7 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
|
|
|
6753
7265
|
}, actions) : null;
|
|
6754
7266
|
};
|
|
6755
7267
|
|
|
6756
|
-
var styles$
|
|
7268
|
+
var styles$i = {
|
|
6757
7269
|
toolbar: /*#__PURE__*/emotion.css({
|
|
6758
7270
|
border: "1px solid " + tokens.gray400,
|
|
6759
7271
|
backgroundColor: tokens.gray100,
|
|
@@ -6798,14 +7310,14 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
6798
7310
|
var shouldDisableTables = isDisabled || !canInsertBlocks || isListSelected || isBlockquoteSelected;
|
|
6799
7311
|
return /*#__PURE__*/React__default.createElement(f36Components.Flex, {
|
|
6800
7312
|
testId: "toolbar",
|
|
6801
|
-
className: styles$
|
|
7313
|
+
className: styles$i.toolbar,
|
|
6802
7314
|
alignItems: "center"
|
|
6803
7315
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
6804
|
-
className: styles$
|
|
7316
|
+
className: styles$i.formattingOptionsWrapper
|
|
6805
7317
|
}, /*#__PURE__*/React__default.createElement(ToolbarHeadingButton, {
|
|
6806
7318
|
isDisabled: isDisabled || !canInsertBlocks
|
|
6807
7319
|
}), validationInfo.isAnyMarkEnabled && /*#__PURE__*/React__default.createElement("span", {
|
|
6808
|
-
className: styles$
|
|
7320
|
+
className: styles$i.divider
|
|
6809
7321
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.BOLD) && /*#__PURE__*/React__default.createElement(ToolbarBoldButton, {
|
|
6810
7322
|
isDisabled: isDisabled
|
|
6811
7323
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.ITALIC) && /*#__PURE__*/React__default.createElement(ToolbarItalicButton, {
|
|
@@ -6815,11 +7327,11 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
6815
7327
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.CODE) && /*#__PURE__*/React__default.createElement(ToolbarCodeButton, {
|
|
6816
7328
|
isDisabled: isDisabled
|
|
6817
7329
|
}), validationInfo.isAnyHyperlinkEnabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
|
6818
|
-
className: styles$
|
|
7330
|
+
className: styles$i.divider
|
|
6819
7331
|
}), /*#__PURE__*/React__default.createElement(ToolbarHyperlinkButton, {
|
|
6820
7332
|
isDisabled: isDisabled
|
|
6821
7333
|
})), validationInfo.isAnyBlockFormattingEnabled && /*#__PURE__*/React__default.createElement("span", {
|
|
6822
|
-
className: styles$
|
|
7334
|
+
className: styles$i.divider
|
|
6823
7335
|
}), /*#__PURE__*/React__default.createElement(ToolbarListButton, {
|
|
6824
7336
|
isDisabled: isDisabled || !canInsertBlocks
|
|
6825
7337
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.QUOTE) && /*#__PURE__*/React__default.createElement(ToolbarQuoteButton, {
|
|
@@ -6829,7 +7341,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
6829
7341
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.TABLE) && /*#__PURE__*/React__default.createElement(ToolbarTableButton, {
|
|
6830
7342
|
isDisabled: shouldDisableTables
|
|
6831
7343
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
6832
|
-
className: styles$
|
|
7344
|
+
className: styles$i.embedActionsWrapper
|
|
6833
7345
|
}, /*#__PURE__*/React__default.createElement(EmbedEntityWidget, {
|
|
6834
7346
|
isDisabled: isDisabled,
|
|
6835
7347
|
canInsertBlocks: canInsertBlocks
|
|
@@ -6854,7 +7366,7 @@ function getValidationInfo(field) {
|
|
|
6854
7366
|
}
|
|
6855
7367
|
|
|
6856
7368
|
var _templateObject$b;
|
|
6857
|
-
var styles$
|
|
7369
|
+
var styles$j = {
|
|
6858
7370
|
nativeSticky: /*#__PURE__*/emotion.css(_templateObject$b || (_templateObject$b = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: -webkit-sticky;\n position: sticky;\n top: -1px;\n z-index: 2;\n "])))
|
|
6859
7371
|
};
|
|
6860
7372
|
|
|
@@ -6862,7 +7374,7 @@ var StickyToolbarWrapper = function StickyToolbarWrapper(_ref) {
|
|
|
6862
7374
|
var isDisabled = _ref.isDisabled,
|
|
6863
7375
|
children = _ref.children;
|
|
6864
7376
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
6865
|
-
className: isDisabled ? '' : styles$
|
|
7377
|
+
className: isDisabled ? '' : styles$j.nativeSticky
|
|
6866
7378
|
}, children);
|
|
6867
7379
|
};
|
|
6868
7380
|
|
|
@@ -6878,6 +7390,21 @@ var isRelevantOperation = function isRelevantOperation(op) {
|
|
|
6878
7390
|
return true;
|
|
6879
7391
|
};
|
|
6880
7392
|
|
|
7393
|
+
var removeInternalMarks = function removeInternalMarks(document) {
|
|
7394
|
+
return _extends({}, document, {
|
|
7395
|
+
content: document.content.map(function (node) {
|
|
7396
|
+
if (node.nodeType === 'text') {
|
|
7397
|
+
node.marks = node.marks.filter(function (mark) {
|
|
7398
|
+
return mark.type !== COMMAND_PROMPT;
|
|
7399
|
+
});
|
|
7400
|
+
return node;
|
|
7401
|
+
}
|
|
7402
|
+
|
|
7403
|
+
return removeInternalMarks(node);
|
|
7404
|
+
})
|
|
7405
|
+
});
|
|
7406
|
+
};
|
|
7407
|
+
|
|
6881
7408
|
var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
6882
7409
|
var editorId = _ref.editorId,
|
|
6883
7410
|
handler = _ref.handler,
|
|
@@ -6885,10 +7412,12 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
|
6885
7412
|
onSkip = _ref.onSkip;
|
|
6886
7413
|
var onChange = React.useMemo(function () {
|
|
6887
7414
|
return debounce(function (document) {
|
|
6888
|
-
|
|
7415
|
+
var contentfulDocument = contentfulSlateJSAdapter.toContentfulDocument({
|
|
6889
7416
|
document: document,
|
|
6890
7417
|
schema: schema
|
|
6891
|
-
})
|
|
7418
|
+
});
|
|
7419
|
+
var cleanedDocument = removeInternalMarks(contentfulDocument);
|
|
7420
|
+
handler == null ? void 0 : handler(cleanedDocument);
|
|
6892
7421
|
}, 500);
|
|
6893
7422
|
}, [handler]);
|
|
6894
7423
|
return React.useCallback(function (value) {
|
|
@@ -6957,9 +7486,9 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6957
7486
|
setPendingExternalUpdate(true);
|
|
6958
7487
|
setEditorContent(editor, documentToEditorValue(props.value));
|
|
6959
7488
|
}, [props.value, id]);
|
|
6960
|
-
var classNames = emotion.cx(styles$
|
|
7489
|
+
var classNames = emotion.cx(styles$h.editor, props.minHeight !== undefined ? emotion.css({
|
|
6961
7490
|
minHeight: props.minHeight
|
|
6962
|
-
}) : undefined, props.isDisabled ? styles$
|
|
7491
|
+
}) : undefined, props.isDisabled ? styles$h.disabled : styles$h.enabled, props.isToolbarHidden && styles$h.hiddenToolbar);
|
|
6963
7492
|
React.useEffect(function () {
|
|
6964
7493
|
if (!isFirstRender) {
|
|
6965
7494
|
return;
|
|
@@ -6975,7 +7504,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6975
7504
|
}, /*#__PURE__*/React__default.createElement(ContentfulEditorIdProvider, {
|
|
6976
7505
|
value: id
|
|
6977
7506
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
6978
|
-
className: styles$
|
|
7507
|
+
className: styles$h.root,
|
|
6979
7508
|
"data-test-id": "rich-text-editor"
|
|
6980
7509
|
}, /*#__PURE__*/React__default.createElement(plateCore.Plate, {
|
|
6981
7510
|
id: id,
|
|
@@ -6990,9 +7519,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6990
7519
|
isDisabled: props.isDisabled
|
|
6991
7520
|
}, /*#__PURE__*/React__default.createElement(Toolbar, {
|
|
6992
7521
|
isDisabled: props.isDisabled
|
|
6993
|
-
}))
|
|
6994
|
-
editorId: id
|
|
6995
|
-
})))));
|
|
7522
|
+
}))))));
|
|
6996
7523
|
};
|
|
6997
7524
|
|
|
6998
7525
|
var RichTextEditor = function RichTextEditor(props) {
|