@contentful/field-editor-rich-text 2.0.3 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/field-editor-rich-text.cjs.development.js +1117 -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 +1097 -565
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/removeInternalMarks.d.ts +1 -0
- 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/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,920 @@ 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
|
+
|
|
1880
|
+
/* eslint-disable-next-line jsx-a11y/no-autofocus -- we want to keep focus on text input*/
|
|
1881
|
+
autoFocus: false
|
|
1882
|
+
}, /*#__PURE__*/React.createElement(f36Components.Popover.Trigger, null, /*#__PURE__*/React.createElement("span", null)), /*#__PURE__*/React.createElement(f36Components.Popover.Content, {
|
|
1883
|
+
className: styles.menuContent,
|
|
1884
|
+
testId: "rich-text-commands"
|
|
1885
|
+
}, /*#__PURE__*/React.createElement("header", {
|
|
1886
|
+
className: styles.menuHeader
|
|
1887
|
+
}, /*#__PURE__*/React.createElement(f36Components.SectionHeading, {
|
|
1888
|
+
marginBottom: "none"
|
|
1889
|
+
}, "Richtext commands")), /*#__PURE__*/React.createElement("div", {
|
|
1890
|
+
className: styles.menuList,
|
|
1891
|
+
"data-test-id": "rich-text-commands-list"
|
|
1892
|
+
}, /*#__PURE__*/React.createElement(CommandListItems, {
|
|
1893
|
+
commandItems: commandItems,
|
|
1894
|
+
selectedItem: selectedItem
|
|
1895
|
+
})), /*#__PURE__*/React.createElement("footer", {
|
|
1896
|
+
className: styles.menuFooter
|
|
1897
|
+
}, /*#__PURE__*/React.createElement(f36Components.Stack, {
|
|
1898
|
+
as: "ul",
|
|
1899
|
+
margin: "none",
|
|
1900
|
+
padding: "none",
|
|
1901
|
+
spacing: "spacingS",
|
|
1902
|
+
className: styles.footerList
|
|
1903
|
+
}, /*#__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")))))));
|
|
1904
|
+
};
|
|
1905
|
+
|
|
1906
|
+
var CommandPrompt = function CommandPrompt(props) {
|
|
1907
|
+
var query = React.useMemo(function () {
|
|
1908
|
+
return trimLeadingSlash(props.text.text);
|
|
1909
|
+
}, [props.text.text]);
|
|
1910
|
+
var editor = props.editor;
|
|
1911
|
+
var canInsertBlocks = !isNodeTypeSelected(editor, Contentful.BLOCKS.TABLE);
|
|
1912
|
+
return /*#__PURE__*/React.createElement("span", Object.assign({}, props.attributes), props.children, canInsertBlocks && /*#__PURE__*/React.createElement(CommandList, {
|
|
1913
|
+
query: query,
|
|
1914
|
+
editor: editor
|
|
1915
|
+
}));
|
|
1916
|
+
};
|
|
1917
|
+
|
|
1918
|
+
var createOnKeyDown = function createOnKeyDown() {
|
|
1919
|
+
return function (editor) {
|
|
1920
|
+
return function (event) {
|
|
1921
|
+
if (isHotkey('/', event)) {
|
|
1922
|
+
var _setMarks;
|
|
1923
|
+
|
|
1924
|
+
plateCore.setMarks(editor, (_setMarks = {}, _setMarks[COMMAND_PROMPT] = true, _setMarks));
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
var isActive = plateCore.isMarkActive(editor, COMMAND_PROMPT);
|
|
1928
|
+
|
|
1929
|
+
if (isActive) {
|
|
1930
|
+
if (isHotkey('enter', event)) {
|
|
1931
|
+
event.preventDefault();
|
|
1932
|
+
} else if (isHotkey('backspace', event)) {
|
|
1933
|
+
var _getAbove = plateCore.getAbove(editor),
|
|
1934
|
+
path = _getAbove[1];
|
|
1935
|
+
|
|
1936
|
+
var range = slate.Editor.range(editor, path); // if it is the last character in the command string
|
|
1937
|
+
|
|
1938
|
+
if (range.focus.offset - range.anchor.offset === 1) {
|
|
1939
|
+
plateCore.removeMark(editor, {
|
|
1940
|
+
key: COMMAND_PROMPT,
|
|
1941
|
+
at: range
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
} else if (isHotkey('escape', event)) {
|
|
1945
|
+
var _getAbove2 = plateCore.getAbove(editor),
|
|
1946
|
+
_path = _getAbove2[1];
|
|
1947
|
+
|
|
1948
|
+
var _range = slate.Editor.range(editor, _path);
|
|
1949
|
+
|
|
1950
|
+
plateCore.removeMark(editor, {
|
|
1951
|
+
key: COMMAND_PROMPT,
|
|
1952
|
+
at: _range
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
};
|
|
1957
|
+
};
|
|
1958
|
+
};
|
|
1959
|
+
|
|
1960
|
+
/**
|
|
1961
|
+
* A command palette plugin (aka slash commands)
|
|
1962
|
+
*
|
|
1963
|
+
* How does it work?
|
|
1964
|
+
* * When the user presses the slash key, the editor will show a command palette
|
|
1965
|
+
* * When the user presses a key, the command palette will show the command suggestions
|
|
1966
|
+
* * When the user presses enter, the command palette will execute the command
|
|
1967
|
+
* * When the user presses escape, the command palette will hide
|
|
1968
|
+
* * When the user presses a letter, number, or space, the command palette will show the command suggestions
|
|
1969
|
+
* * When the user presses backspace, the command palette will remove the last character from the command string
|
|
1970
|
+
*/
|
|
1971
|
+
|
|
1972
|
+
var createCommandPalettePlugin = function createCommandPalettePlugin() {
|
|
1973
|
+
return {
|
|
1974
|
+
key: COMMAND_PROMPT,
|
|
1975
|
+
type: COMMAND_PROMPT,
|
|
1976
|
+
isLeaf: true,
|
|
1977
|
+
component: CommandPrompt,
|
|
1978
|
+
handlers: {
|
|
1979
|
+
onKeyDown: createOnKeyDown()
|
|
1980
|
+
}
|
|
1981
|
+
};
|
|
1982
|
+
};
|
|
1983
|
+
|
|
1984
|
+
function createDragAndDropPlugin() {
|
|
1985
|
+
var DRAGGABLE_TYPES = [Contentful.BLOCKS.EMBEDDED_ENTRY, Contentful.BLOCKS.EMBEDDED_ASSET, Contentful.BLOCKS.HR, Contentful.INLINES.EMBEDDED_ENTRY];
|
|
1986
|
+
/**
|
|
1987
|
+
* HTML node names where dropping should be allowed
|
|
1988
|
+
* Usually for elements where `Transforms.removeNodes` is needed
|
|
1989
|
+
* 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
|
|
1990
|
+
*/
|
|
1991
|
+
|
|
1992
|
+
var ON_DROP_ALLOWED_TYPES = {
|
|
1993
|
+
TABLE: [Contentful.INLINES.EMBEDDED_ENTRY]
|
|
1994
|
+
};
|
|
1995
|
+
return {
|
|
1996
|
+
key: 'DragAndDropPlugin',
|
|
1997
|
+
handlers: {
|
|
1998
|
+
// If true, the next handlers will be skipped.
|
|
1999
|
+
onDrop: function onDrop(editor) {
|
|
2000
|
+
return function (event) {
|
|
2001
|
+
var _Array$from = Array.from(plateCore.getNodes(editor, {
|
|
2002
|
+
match: function match(node) {
|
|
2003
|
+
return DRAGGABLE_TYPES.includes(node == null ? void 0 : node.type);
|
|
2004
|
+
}
|
|
2005
|
+
})),
|
|
2006
|
+
draggingBlock = _Array$from[0];
|
|
2007
|
+
|
|
2008
|
+
if (!draggingBlock) return false;
|
|
2009
|
+
var draggingNode = draggingBlock[0];
|
|
2010
|
+
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
|
|
2011
|
+
|
|
2012
|
+
var dropDisallowed = getParents(event.nativeEvent.target).some(function (node) {
|
|
2013
|
+
var _ON_DROP_ALLOWED_TYPE;
|
|
2014
|
+
|
|
2015
|
+
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;
|
|
2016
|
+
});
|
|
2017
|
+
|
|
2018
|
+
if (!dropDisallowed) {
|
|
2019
|
+
// Move the drop event to a new undo batch mitigating the bug where undo not only moves it back,
|
|
2020
|
+
// but also undoes a previous action: https://github.com/ianstormtaylor/slate/issues/4694
|
|
2021
|
+
editor.history.undos.push([]);
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
return dropDisallowed;
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
};
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
function getParents(el) {
|
|
2032
|
+
var parents = [];
|
|
2033
|
+
parents.push(el);
|
|
2034
|
+
|
|
2035
|
+
while (el.parentNode) {
|
|
2036
|
+
parents.unshift(el.parentNode);
|
|
2037
|
+
el = el.parentNode;
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
return parents;
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
function withLinkTracking(Component) {
|
|
2044
|
+
return function ComponentWithTracking(props) {
|
|
2045
|
+
var editor = useContentfulEditorRef();
|
|
2046
|
+
var onEntityFetchComplete = React__default.useCallback(function () {
|
|
2047
|
+
return editor.tracking.onViewportAction('linkRendered');
|
|
2048
|
+
}, [editor]);
|
|
2049
|
+
return /*#__PURE__*/React__default.createElement(Component, Object.assign({}, props, {
|
|
2050
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2051
|
+
}));
|
|
2052
|
+
};
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
function useFetchedEntity(_ref) {
|
|
2056
|
+
var type = _ref.type,
|
|
2057
|
+
id = _ref.id,
|
|
2058
|
+
onEntityFetchComplete = _ref.onEntityFetchComplete;
|
|
2059
|
+
|
|
2060
|
+
var _useEntities = fieldEditorReference.useEntities(),
|
|
2061
|
+
entries = _useEntities.entries,
|
|
2062
|
+
assets = _useEntities.assets,
|
|
2063
|
+
getOrLoadEntry = _useEntities.getOrLoadEntry,
|
|
2064
|
+
getOrLoadAsset = _useEntities.getOrLoadAsset;
|
|
2065
|
+
|
|
2066
|
+
var store = type === 'Entry' ? entries : assets;
|
|
2067
|
+
|
|
2068
|
+
var _useState = React.useState(store[id]),
|
|
2069
|
+
entity = _useState[0],
|
|
2070
|
+
setEntity = _useState[1]; // Deep compare the entity value to keep re-rendering to minimal
|
|
2071
|
+
|
|
2072
|
+
|
|
2073
|
+
React.useEffect(function () {
|
|
2074
|
+
var newValue = store[id];
|
|
2075
|
+
|
|
2076
|
+
if (!areEqual(entity, newValue)) {
|
|
2077
|
+
setEntity(newValue);
|
|
2078
|
+
}
|
|
2079
|
+
}, [store, entity, id]); // Fetch the entity if needed
|
|
2080
|
+
|
|
2081
|
+
React.useEffect(function () {
|
|
2082
|
+
(type === 'Entry' ? getOrLoadEntry : getOrLoadAsset)(id); // "getOrLoadEntry" and "getOrLoadAsset" instances change with every
|
|
2083
|
+
// entity store update causing page lag on initial load
|
|
2084
|
+
// TODO: consider rewriting useEntities() hook to avoid that happening in
|
|
2085
|
+
// first place.
|
|
2086
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO: explain this disable
|
|
2087
|
+
}, [type, id]);
|
|
2088
|
+
React.useEffect(function () {
|
|
2089
|
+
if (entity) {
|
|
2090
|
+
onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
|
|
2091
|
+
}
|
|
2092
|
+
}, [onEntityFetchComplete, entity]);
|
|
2093
|
+
return entity;
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
var InternalAssetCard = /*#__PURE__*/React.memo(function (props) {
|
|
2097
|
+
if (props.asset === undefined) {
|
|
2098
|
+
return /*#__PURE__*/React.createElement(f36Components.AssetCard, {
|
|
2099
|
+
size: "default",
|
|
2100
|
+
isLoading: true
|
|
2101
|
+
});
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
if (props.asset === 'failed') {
|
|
2105
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.MissingEntityCard, {
|
|
2106
|
+
entityType: "Asset",
|
|
2107
|
+
isDisabled: props.isDisabled,
|
|
2108
|
+
onRemove: props.onRemove
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.WrappedAssetCard, {
|
|
2113
|
+
getEntityScheduledActions: props.loadEntityScheduledActions,
|
|
2114
|
+
size: "small",
|
|
2115
|
+
isSelected: props.isSelected,
|
|
2116
|
+
isDisabled: props.isDisabled,
|
|
2117
|
+
localeCode: props.locale,
|
|
2118
|
+
defaultLocaleCode: props.sdk.locales["default"],
|
|
2119
|
+
asset: props.asset,
|
|
2120
|
+
onEdit: props.onEdit,
|
|
2121
|
+
onRemove: props.isDisabled ? undefined : props.onRemove,
|
|
2122
|
+
isClickable: false
|
|
2123
|
+
});
|
|
2124
|
+
}, areEqual);
|
|
2125
|
+
InternalAssetCard.displayName = 'InternalAssetCard';
|
|
2126
|
+
function FetchingWrappedAssetCard(props) {
|
|
2127
|
+
var onEntityFetchComplete = props.onEntityFetchComplete,
|
|
2128
|
+
assetId = props.assetId;
|
|
2129
|
+
|
|
2130
|
+
var _useEntities = fieldEditorReference.useEntities(),
|
|
2131
|
+
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
|
|
2132
|
+
|
|
2133
|
+
var asset = useFetchedEntity({
|
|
2134
|
+
type: 'Asset',
|
|
2135
|
+
id: assetId,
|
|
2136
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2137
|
+
});
|
|
2138
|
+
return /*#__PURE__*/React.createElement(InternalAssetCard, {
|
|
2139
|
+
asset: asset,
|
|
2140
|
+
sdk: props.sdk,
|
|
2141
|
+
isDisabled: props.isDisabled,
|
|
2142
|
+
isSelected: props.isSelected,
|
|
2143
|
+
loadEntityScheduledActions: loadEntityScheduledActions,
|
|
2144
|
+
locale: props.locale,
|
|
2145
|
+
onEdit: props.onEdit,
|
|
2146
|
+
onRemove: props.onRemove
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
var InternalEntryCard = /*#__PURE__*/React.memo(function (props) {
|
|
2151
|
+
var entry = props.entry,
|
|
2152
|
+
sdk = props.sdk,
|
|
2153
|
+
loadEntityScheduledActions = props.loadEntityScheduledActions;
|
|
2154
|
+
|
|
2155
|
+
if (entry === undefined) {
|
|
2156
|
+
return /*#__PURE__*/React.createElement(f36Components.EntryCard, {
|
|
2157
|
+
isLoading: true
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
if (entry === 'failed') {
|
|
2162
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.MissingEntityCard, {
|
|
2163
|
+
entityType: "Entry",
|
|
2164
|
+
isDisabled: props.isDisabled,
|
|
2165
|
+
onRemove: props.onRemove
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
var contentType = sdk.space.getCachedContentTypes().find(function (contentType) {
|
|
2170
|
+
return contentType.sys.id === entry.sys.contentType.sys.id;
|
|
2171
|
+
});
|
|
2172
|
+
return /*#__PURE__*/React.createElement(fieldEditorReference.WrappedEntryCard, {
|
|
2173
|
+
size: "default",
|
|
2174
|
+
getAsset: props.sdk.space.getAsset,
|
|
2175
|
+
getEntityScheduledActions: loadEntityScheduledActions,
|
|
2176
|
+
isSelected: props.isSelected,
|
|
2177
|
+
isDisabled: props.isDisabled,
|
|
2178
|
+
localeCode: props.locale,
|
|
2179
|
+
defaultLocaleCode: props.sdk.locales["default"],
|
|
2180
|
+
contentType: contentType,
|
|
2181
|
+
entry: entry,
|
|
2182
|
+
onEdit: props.onEdit,
|
|
2183
|
+
onRemove: props.isDisabled ? undefined : props.onRemove,
|
|
2184
|
+
isClickable: false
|
|
2185
|
+
});
|
|
2186
|
+
}, areEqual);
|
|
2187
|
+
InternalEntryCard.displayName = 'ReferenceCard';
|
|
2188
|
+
var FetchingWrappedEntryCard = function FetchingWrappedEntryCard(props) {
|
|
2189
|
+
var entryId = props.entryId,
|
|
2190
|
+
onEntityFetchComplete = props.onEntityFetchComplete;
|
|
1557
2191
|
|
|
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`.
|
|
2192
|
+
var _useEntities = fieldEditorReference.useEntities(),
|
|
2193
|
+
loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
|
|
1564
2194
|
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
2195
|
+
var entry = useFetchedEntity({
|
|
2196
|
+
type: 'Entry',
|
|
2197
|
+
id: entryId,
|
|
2198
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2199
|
+
});
|
|
2200
|
+
return /*#__PURE__*/React.createElement(InternalEntryCard, {
|
|
2201
|
+
entry: entry,
|
|
2202
|
+
sdk: props.sdk,
|
|
2203
|
+
locale: props.locale,
|
|
2204
|
+
isDisabled: props.isDisabled,
|
|
2205
|
+
isSelected: props.isSelected,
|
|
2206
|
+
onEdit: props.onEdit,
|
|
2207
|
+
onRemove: props.onRemove,
|
|
2208
|
+
loadEntityScheduledActions: loadEntityScheduledActions
|
|
2209
|
+
});
|
|
2210
|
+
};
|
|
1571
2211
|
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
//
|
|
1579
|
-
//
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
2212
|
+
var styles$1 = {
|
|
2213
|
+
root: /*#__PURE__*/emotion.css({
|
|
2214
|
+
marginBottom: '1.25rem !important',
|
|
2215
|
+
display: 'block'
|
|
2216
|
+
}),
|
|
2217
|
+
container: /*#__PURE__*/emotion.css({
|
|
2218
|
+
// The next 2 properties ensure Entity card won't be aligned above
|
|
2219
|
+
// a list item marker (i.e. bullet)
|
|
2220
|
+
display: 'inline-block',
|
|
2221
|
+
verticalAlign: 'text-top',
|
|
2222
|
+
width: '100%'
|
|
2223
|
+
})
|
|
2224
|
+
};
|
|
2225
|
+
function LinkedEntityBlock(props) {
|
|
2226
|
+
var attributes = props.attributes,
|
|
2227
|
+
children = props.children,
|
|
2228
|
+
element = props.element,
|
|
2229
|
+
onEntityFetchComplete = props.onEntityFetchComplete;
|
|
2230
|
+
var isSelected = Slate.useSelected();
|
|
2231
|
+
var editor = useContentfulEditor();
|
|
2232
|
+
var sdk = useSdkContext();
|
|
2233
|
+
var isDisabled = Slate.useReadOnly();
|
|
2234
|
+
var _element$data$target$ = element.data.target.sys,
|
|
2235
|
+
entityId = _element$data$target$.id,
|
|
2236
|
+
entityType = _element$data$target$.linkType;
|
|
2237
|
+
var handleEditClick = React__default.useCallback(function () {
|
|
2238
|
+
var openEntity = entityType === 'Asset' ? sdk.navigator.openAsset : sdk.navigator.openEntry;
|
|
2239
|
+
return openEntity(entityId, {
|
|
2240
|
+
slideIn: true
|
|
2241
|
+
});
|
|
2242
|
+
}, [sdk, entityId, entityType]);
|
|
2243
|
+
var handleRemoveClick = React__default.useCallback(function () {
|
|
2244
|
+
if (!editor) return;
|
|
2245
|
+
var pathToElement = Slate.ReactEditor.findPath(editor, element);
|
|
2246
|
+
slate.Transforms.removeNodes(editor, {
|
|
2247
|
+
at: pathToElement
|
|
2248
|
+
});
|
|
2249
|
+
}, [editor, element]);
|
|
2250
|
+
return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
|
|
2251
|
+
className: styles$1.root,
|
|
2252
|
+
"data-entity-type": entityType,
|
|
2253
|
+
"data-entity-id": entityId,
|
|
2254
|
+
// COMPAT: This makes copy & paste work for Firefox
|
|
2255
|
+
contentEditable: IS_CHROME ? undefined : false,
|
|
2256
|
+
draggable: IS_CHROME ? true : undefined
|
|
2257
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
2258
|
+
// COMPAT: This makes copy & paste work for Chromium/Blink browsers and Safari
|
|
2259
|
+
contentEditable: IS_CHROME ? false : undefined,
|
|
2260
|
+
draggable: IS_CHROME ? true : undefined,
|
|
2261
|
+
className: styles$1.container
|
|
2262
|
+
}, entityType === 'Entry' && /*#__PURE__*/React__default.createElement(FetchingWrappedEntryCard, {
|
|
2263
|
+
sdk: sdk,
|
|
2264
|
+
entryId: entityId,
|
|
2265
|
+
locale: sdk.field.locale,
|
|
2266
|
+
isDisabled: isDisabled,
|
|
2267
|
+
isSelected: isSelected,
|
|
2268
|
+
onRemove: handleRemoveClick,
|
|
2269
|
+
onEdit: handleEditClick,
|
|
2270
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2271
|
+
}), entityType === 'Asset' && /*#__PURE__*/React__default.createElement(FetchingWrappedAssetCard, {
|
|
2272
|
+
sdk: sdk,
|
|
2273
|
+
assetId: entityId,
|
|
2274
|
+
locale: sdk.field.locale,
|
|
2275
|
+
isDisabled: isDisabled,
|
|
2276
|
+
isSelected: isSelected,
|
|
2277
|
+
onRemove: handleRemoveClick,
|
|
2278
|
+
onEdit: handleEditClick,
|
|
2279
|
+
onEntityFetchComplete: onEntityFetchComplete
|
|
2280
|
+
})), children);
|
|
2281
|
+
}
|
|
1587
2282
|
|
|
1588
2283
|
/* eslint-disable you-dont-need-lodash-underscore/find */
|
|
1589
2284
|
/**
|
|
@@ -1695,7 +2390,7 @@ function _selectEntityAndInsert() {
|
|
|
1695
2390
|
|
|
1696
2391
|
case 12:
|
|
1697
2392
|
slate.Transforms.select(editor, selection);
|
|
1698
|
-
insertBlock(editor, nodeType, entity);
|
|
2393
|
+
insertBlock$1(editor, nodeType, entity);
|
|
1699
2394
|
ensureFollowingParagraph(editor);
|
|
1700
2395
|
logAction('insert', {
|
|
1701
2396
|
nodeType: nodeType
|
|
@@ -1748,7 +2443,7 @@ function ensureFollowingParagraph(editor) {
|
|
|
1748
2443
|
moveToTheNextChar(editor);
|
|
1749
2444
|
}
|
|
1750
2445
|
|
|
1751
|
-
var createNode = function createNode(nodeType, entity) {
|
|
2446
|
+
var createNode$1 = function createNode(nodeType, entity) {
|
|
1752
2447
|
return {
|
|
1753
2448
|
type: nodeType,
|
|
1754
2449
|
data: {
|
|
@@ -1768,9 +2463,9 @@ var createNode = function createNode(nodeType, entity) {
|
|
|
1768
2463
|
}; // TODO: DRY up copied code from HR
|
|
1769
2464
|
|
|
1770
2465
|
|
|
1771
|
-
function insertBlock(editor, nodeType, entity) {
|
|
2466
|
+
function insertBlock$1(editor, nodeType, entity) {
|
|
1772
2467
|
if (!(editor != null && editor.selection)) return;
|
|
1773
|
-
var linkedEntityBlock = createNode(nodeType, entity);
|
|
2468
|
+
var linkedEntityBlock = createNode$1(nodeType, entity);
|
|
1774
2469
|
var hasText = editor.selection && !!plateCore.getText(editor, editor.selection.focus.path);
|
|
1775
2470
|
|
|
1776
2471
|
if (hasText) {
|
|
@@ -1782,7 +2477,7 @@ function insertBlock(editor, nodeType, entity) {
|
|
|
1782
2477
|
focus(editor);
|
|
1783
2478
|
}
|
|
1784
2479
|
|
|
1785
|
-
var styles$
|
|
2480
|
+
var styles$2 = {
|
|
1786
2481
|
icon: /*#__PURE__*/emotion.css({
|
|
1787
2482
|
marginRight: '10px'
|
|
1788
2483
|
})
|
|
@@ -1830,7 +2525,7 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
|
|
|
1830
2525
|
flexDirection: "row"
|
|
1831
2526
|
}, /*#__PURE__*/React__default.createElement(f36Components.Icon, {
|
|
1832
2527
|
as: type === 'Asset' ? f36Icons.AssetIcon : f36Icons.EmbeddedEntryBlockIcon,
|
|
1833
|
-
className: "rich-text__embedded-entry-list-icon " + styles$
|
|
2528
|
+
className: "rich-text__embedded-entry-list-icon " + styles$2.icon,
|
|
1834
2529
|
variant: "secondary"
|
|
1835
2530
|
}), /*#__PURE__*/React__default.createElement("span", null, type)));
|
|
1836
2531
|
}
|
|
@@ -1929,7 +2624,7 @@ var createEmbeddedAssetBlockPlugin = /*#__PURE__*/createEmbeddedEntityPlugin(Con
|
|
|
1929
2624
|
|
|
1930
2625
|
var getEntryTitle = fieldEditorShared.entityHelpers.getEntryTitle,
|
|
1931
2626
|
getEntryStatus = fieldEditorShared.entityHelpers.getEntryStatus;
|
|
1932
|
-
var styles$
|
|
2627
|
+
var styles$3 = {
|
|
1933
2628
|
scheduledIcon: /*#__PURE__*/emotion.css({
|
|
1934
2629
|
verticalAlign: 'text-bottom',
|
|
1935
2630
|
marginRight: tokens.spacing2Xs
|
|
@@ -2024,13 +2719,13 @@ function FetchingWrappedInlineEntryCard(props) {
|
|
|
2024
2719
|
entityType: "Entry",
|
|
2025
2720
|
entityId: entry.sys.id
|
|
2026
2721
|
}, /*#__PURE__*/React__default.createElement(f36Icons.ClockIcon, {
|
|
2027
|
-
className: styles$
|
|
2722
|
+
className: styles$3.scheduledIcon,
|
|
2028
2723
|
variant: "muted",
|
|
2029
2724
|
testId: "scheduled-icon"
|
|
2030
2725
|
})), /*#__PURE__*/React__default.createElement(f36Components.Text, null, title));
|
|
2031
2726
|
}
|
|
2032
2727
|
|
|
2033
|
-
function createInlineEntryNode(id) {
|
|
2728
|
+
function createInlineEntryNode$1(id) {
|
|
2034
2729
|
return {
|
|
2035
2730
|
type: Contentful.INLINES.EMBEDDED_ENTRY,
|
|
2036
2731
|
children: [{
|
|
@@ -2048,7 +2743,7 @@ function createInlineEntryNode(id) {
|
|
|
2048
2743
|
};
|
|
2049
2744
|
}
|
|
2050
2745
|
|
|
2051
|
-
var styles$
|
|
2746
|
+
var styles$4 = {
|
|
2052
2747
|
icon: /*#__PURE__*/emotion.css({
|
|
2053
2748
|
marginRight: '10px'
|
|
2054
2749
|
}),
|
|
@@ -2084,7 +2779,7 @@ function EmbeddedEntityInline(props) {
|
|
|
2084
2779
|
}
|
|
2085
2780
|
|
|
2086
2781
|
return /*#__PURE__*/React.createElement("span", Object.assign({}, props.attributes, {
|
|
2087
|
-
className: styles$
|
|
2782
|
+
className: styles$4.root,
|
|
2088
2783
|
"data-embedded-entity-inline-id": entryId,
|
|
2089
2784
|
// COMPAT: This makes copy & paste work for Firefox
|
|
2090
2785
|
contentEditable: IS_CHROME ? undefined : false,
|
|
@@ -2140,7 +2835,7 @@ function _selectEntityAndInsert$1() {
|
|
|
2140
2835
|
return _context2.abrupt("return");
|
|
2141
2836
|
|
|
2142
2837
|
case 10:
|
|
2143
|
-
inlineEntryNode = createInlineEntryNode(entry.sys.id);
|
|
2838
|
+
inlineEntryNode = createInlineEntryNode$1(entry.sys.id);
|
|
2144
2839
|
logAction('insert', {
|
|
2145
2840
|
nodeType: Contentful.INLINES.EMBEDDED_ENTRY
|
|
2146
2841
|
}); // Got to wait until focus is really back on the editor or setSelection() won't work.
|
|
@@ -2214,7 +2909,7 @@ function ToolbarEmbeddedEntityInlineButton(props) {
|
|
|
2214
2909
|
flexDirection: "row"
|
|
2215
2910
|
}, /*#__PURE__*/React.createElement(f36Icons.EmbeddedEntryInlineIcon, {
|
|
2216
2911
|
variant: "secondary",
|
|
2217
|
-
className: "rich-text__embedded-entry-list-icon " + styles$
|
|
2912
|
+
className: "rich-text__embedded-entry-list-icon " + styles$4.icon
|
|
2218
2913
|
}), /*#__PURE__*/React.createElement("span", null, "Inline entry")));
|
|
2219
2914
|
}
|
|
2220
2915
|
function createEmbeddedEntityInlinePlugin(sdk) {
|
|
@@ -2238,7 +2933,7 @@ function createEmbeddedEntityInlinePlugin(sdk) {
|
|
|
2238
2933
|
}],
|
|
2239
2934
|
withoutChildren: true,
|
|
2240
2935
|
getNode: function getNode(el) {
|
|
2241
|
-
return createInlineEntryNode(el.getAttribute(htmlAttributeName));
|
|
2936
|
+
return createInlineEntryNode$1(el.getAttribute(htmlAttributeName));
|
|
2242
2937
|
}
|
|
2243
2938
|
}
|
|
2244
2939
|
};
|
|
@@ -2290,7 +2985,7 @@ var isMarkEnabled = function isMarkEnabled(field, mark) {
|
|
|
2290
2985
|
};
|
|
2291
2986
|
|
|
2292
2987
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _dropdown, _LABELS;
|
|
2293
|
-
var styles$
|
|
2988
|
+
var styles$5 = {
|
|
2294
2989
|
dropdown: (_dropdown = {
|
|
2295
2990
|
root: /*#__PURE__*/emotion.css(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-weight: ", ";\n "])), tokens.fontWeightDemiBold)
|
|
2296
2991
|
}, _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 +3080,7 @@ function ToolbarHeadingButton(props) {
|
|
|
2385
3080
|
testId: "dropdown-option-" + nodeType,
|
|
2386
3081
|
disabled: props.isDisabled
|
|
2387
3082
|
}, /*#__PURE__*/React.createElement("span", {
|
|
2388
|
-
className: emotion.cx(styles$
|
|
3083
|
+
className: emotion.cx(styles$5.dropdown.root, styles$5.dropdown[nodeType])
|
|
2389
3084
|
}, LABELS[nodeType]));
|
|
2390
3085
|
}).filter(Boolean)));
|
|
2391
3086
|
}
|
|
@@ -2455,7 +3150,7 @@ var transformLift = function transformLift(editor, _ref4) {
|
|
|
2455
3150
|
};
|
|
2456
3151
|
|
|
2457
3152
|
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$
|
|
3153
|
+
var styles$6 = {
|
|
2459
3154
|
dropdown: (_dropdown$1 = {
|
|
2460
3155
|
root: /*#__PURE__*/emotion.css(_templateObject$1 || (_templateObject$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-weight: ", ";\n "])), tokens.fontWeightDemiBold)
|
|
2461
3156
|
}, _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 +3162,7 @@ var styles$5 = {
|
|
|
2467
3162
|
function createHeading(Tag, block) {
|
|
2468
3163
|
return function Heading(props) {
|
|
2469
3164
|
return /*#__PURE__*/React.createElement(Tag, Object.assign({}, props.attributes, {
|
|
2470
|
-
className: emotion.cx(styles$
|
|
3165
|
+
className: emotion.cx(styles$6.headings.root, styles$6.headings[block])
|
|
2471
3166
|
}), props.children);
|
|
2472
3167
|
};
|
|
2473
3168
|
}
|
|
@@ -2563,7 +3258,7 @@ var createHeadingPlugin = function createHeadingPlugin() {
|
|
|
2563
3258
|
};
|
|
2564
3259
|
};
|
|
2565
3260
|
|
|
2566
|
-
var styles$
|
|
3261
|
+
var styles$7 = {
|
|
2567
3262
|
button: /*#__PURE__*/emotion.css({
|
|
2568
3263
|
height: '30px',
|
|
2569
3264
|
width: '30px',
|
|
@@ -2589,7 +3284,7 @@ function ToolbarButton(props) {
|
|
|
2589
3284
|
};
|
|
2590
3285
|
|
|
2591
3286
|
var button = /*#__PURE__*/React__default.createElement(f36Components.Button, {
|
|
2592
|
-
className: emotion.cx(styles$
|
|
3287
|
+
className: emotion.cx(styles$7.button, className),
|
|
2593
3288
|
isDisabled: isDisabled,
|
|
2594
3289
|
startIcon: children,
|
|
2595
3290
|
onClick: handleClick,
|
|
@@ -2600,7 +3295,7 @@ function ToolbarButton(props) {
|
|
|
2600
3295
|
|
|
2601
3296
|
if (title) {
|
|
2602
3297
|
return /*#__PURE__*/React__default.createElement(f36Components.Tooltip, {
|
|
2603
|
-
className: styles$
|
|
3298
|
+
className: styles$7.tooltip,
|
|
2604
3299
|
placement: "bottom",
|
|
2605
3300
|
content: title
|
|
2606
3301
|
}, button);
|
|
@@ -2610,7 +3305,7 @@ function ToolbarButton(props) {
|
|
|
2610
3305
|
}
|
|
2611
3306
|
|
|
2612
3307
|
var _templateObject$2, _templateObject2$2, _templateObject3$2;
|
|
2613
|
-
var styles$
|
|
3308
|
+
var styles$8 = {
|
|
2614
3309
|
container: /*#__PURE__*/emotion.css(_templateObject$2 || (_templateObject$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0 0 ", ";\n "])), tokens.spacingL),
|
|
2615
3310
|
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
3311
|
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 +3363,14 @@ function Hr(props) {
|
|
|
2668
3363
|
var isSelected = Slate.useSelected();
|
|
2669
3364
|
var isFocused = Slate.useFocused();
|
|
2670
3365
|
return /*#__PURE__*/React.createElement("div", Object.assign({}, props.attributes, {
|
|
2671
|
-
className: styles$
|
|
3366
|
+
className: styles$8.container,
|
|
2672
3367
|
"data-void-element": Contentful.BLOCKS.HR
|
|
2673
3368
|
}), /*#__PURE__*/React.createElement("div", {
|
|
2674
3369
|
draggable: true,
|
|
2675
3370
|
// 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
3371
|
contentEditable: false
|
|
2677
3372
|
}, /*#__PURE__*/React.createElement("hr", {
|
|
2678
|
-
className: emotion.cx(styles$
|
|
3373
|
+
className: emotion.cx(styles$8.hr, isSelected && isFocused ? styles$8.hrSelected : undefined)
|
|
2679
3374
|
})), props.children);
|
|
2680
3375
|
}
|
|
2681
3376
|
var createHrPlugin = function createHrPlugin() {
|
|
@@ -2702,7 +3397,7 @@ var createHrPlugin = function createHrPlugin() {
|
|
|
2702
3397
|
};
|
|
2703
3398
|
|
|
2704
3399
|
var _templateObject$3, _SYS_LINK_TYPES, _LINK_TYPE_SELECTION_;
|
|
2705
|
-
var styles$
|
|
3400
|
+
var styles$9 = {
|
|
2706
3401
|
removeSelectionLabel: /*#__PURE__*/emotion.css(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-left: ", ";\n "])), tokens.spacingS)
|
|
2707
3402
|
};
|
|
2708
3403
|
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 +3580,7 @@ function HyperlinkModal(props) {
|
|
|
2885
3580
|
}, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? /*#__PURE__*/React.createElement(React.Fragment, null, !props.readonly && /*#__PURE__*/React.createElement(f36Components.TextLink, {
|
|
2886
3581
|
testId: "entity-selection-link",
|
|
2887
3582
|
onClick: resetLinkEntity,
|
|
2888
|
-
className: styles$
|
|
3583
|
+
className: styles$9.removeSelectionLabel
|
|
2889
3584
|
}, "Remove selection"), /*#__PURE__*/React.createElement("div", null, linkType === Contentful.INLINES.ENTRY_HYPERLINK && /*#__PURE__*/React.createElement(FetchingWrappedEntryCard, {
|
|
2890
3585
|
sdk: props.sdk,
|
|
2891
3586
|
locale: props.sdk.field.locale,
|
|
@@ -3226,7 +3921,7 @@ function useEntityInfo(props) {
|
|
|
3226
3921
|
return getEntityInfo(status.data);
|
|
3227
3922
|
}
|
|
3228
3923
|
|
|
3229
|
-
var styles$
|
|
3924
|
+
var styles$a = {
|
|
3230
3925
|
hyperlinkWrapper: /*#__PURE__*/emotion.css({
|
|
3231
3926
|
display: 'inline',
|
|
3232
3927
|
position: 'static',
|
|
@@ -3271,13 +3966,13 @@ function EntityHyperlink(props) {
|
|
|
3271
3966
|
|
|
3272
3967
|
return /*#__PURE__*/React.createElement(f36Components.Tooltip, {
|
|
3273
3968
|
content: tooltipContent,
|
|
3274
|
-
targetWrapperClassName: styles$
|
|
3969
|
+
targetWrapperClassName: styles$a.hyperlinkWrapper,
|
|
3275
3970
|
placement: "bottom",
|
|
3276
3971
|
maxWidth: "auto"
|
|
3277
3972
|
}, /*#__PURE__*/React.createElement(f36Components.TextLink, {
|
|
3278
3973
|
as: "a",
|
|
3279
3974
|
onClick: handleClick,
|
|
3280
|
-
className: styles$
|
|
3975
|
+
className: styles$a.hyperlink,
|
|
3281
3976
|
"data-link-type": target.sys.linkType,
|
|
3282
3977
|
"data-link-id": target.sys.id
|
|
3283
3978
|
}, props.children));
|
|
@@ -3301,7 +3996,7 @@ function UrlHyperlink(props) {
|
|
|
3301
3996
|
|
|
3302
3997
|
return /*#__PURE__*/React.createElement(f36Components.Tooltip, {
|
|
3303
3998
|
content: uri,
|
|
3304
|
-
targetWrapperClassName: styles$
|
|
3999
|
+
targetWrapperClassName: styles$a.hyperlinkWrapper,
|
|
3305
4000
|
placement: "bottom",
|
|
3306
4001
|
maxWidth: "auto"
|
|
3307
4002
|
}, /*#__PURE__*/React.createElement(f36Components.TextLink, {
|
|
@@ -3309,7 +4004,7 @@ function UrlHyperlink(props) {
|
|
|
3309
4004
|
href: uri,
|
|
3310
4005
|
rel: "noopener noreferrer",
|
|
3311
4006
|
onClick: handleClick,
|
|
3312
|
-
className: styles$
|
|
4007
|
+
className: styles$a.hyperlink
|
|
3313
4008
|
}, props.children));
|
|
3314
4009
|
}
|
|
3315
4010
|
|
|
@@ -3435,12 +4130,12 @@ var createHyperlinkPlugin = function createHyperlinkPlugin(sdk) {
|
|
|
3435
4130
|
|
|
3436
4131
|
var _templateObject$4, _templateObject2$3, _templateObject3$3, _styles;
|
|
3437
4132
|
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$
|
|
4133
|
+
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
4134
|
|
|
3440
4135
|
function createList(Tag, block) {
|
|
3441
4136
|
return function List(props) {
|
|
3442
4137
|
return /*#__PURE__*/React.createElement(Tag, Object.assign({}, props.attributes, {
|
|
3443
|
-
className: emotion.cx(baseStyle, styles$
|
|
4138
|
+
className: emotion.cx(baseStyle, styles$b[block])
|
|
3444
4139
|
}), props.children);
|
|
3445
4140
|
};
|
|
3446
4141
|
}
|
|
@@ -4421,14 +5116,14 @@ var ToolbarBoldButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
4421
5116
|
mark: Contentful.MARKS.BOLD,
|
|
4422
5117
|
icon: /*#__PURE__*/React.createElement(f36Icons.FormatBoldIcon, null)
|
|
4423
5118
|
});
|
|
4424
|
-
var styles$
|
|
5119
|
+
var styles$c = {
|
|
4425
5120
|
bold: /*#__PURE__*/emotion.css({
|
|
4426
5121
|
fontWeight: 600
|
|
4427
5122
|
})
|
|
4428
5123
|
};
|
|
4429
5124
|
function Bold(props) {
|
|
4430
5125
|
return /*#__PURE__*/React.createElement("strong", Object.assign({}, props.attributes, {
|
|
4431
|
-
className: styles$
|
|
5126
|
+
className: styles$c.bold
|
|
4432
5127
|
}), props.children);
|
|
4433
5128
|
}
|
|
4434
5129
|
|
|
@@ -4468,7 +5163,7 @@ var ToolbarCodeButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
4468
5163
|
mark: Contentful.MARKS.CODE,
|
|
4469
5164
|
icon: /*#__PURE__*/React.createElement(f36Icons.CodeIcon, null)
|
|
4470
5165
|
});
|
|
4471
|
-
var styles$
|
|
5166
|
+
var styles$d = {
|
|
4472
5167
|
code: /*#__PURE__*/emotion.css({
|
|
4473
5168
|
fontFamily: 'monospace',
|
|
4474
5169
|
fontSize: '.9em'
|
|
@@ -4476,7 +5171,7 @@ var styles$c = {
|
|
|
4476
5171
|
};
|
|
4477
5172
|
function Code(props) {
|
|
4478
5173
|
return /*#__PURE__*/React.createElement("code", Object.assign({}, props.attributes, {
|
|
4479
|
-
className: styles$
|
|
5174
|
+
className: styles$d.code
|
|
4480
5175
|
}), props.children);
|
|
4481
5176
|
}
|
|
4482
5177
|
var createCodePlugin = function createCodePlugin() {
|
|
@@ -4506,14 +5201,14 @@ var ToolbarItalicButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
4506
5201
|
mark: Contentful.MARKS.ITALIC,
|
|
4507
5202
|
icon: /*#__PURE__*/React.createElement(f36Icons.FormatItalicIcon, null)
|
|
4508
5203
|
});
|
|
4509
|
-
var styles$
|
|
5204
|
+
var styles$e = {
|
|
4510
5205
|
italic: /*#__PURE__*/emotion.css({
|
|
4511
5206
|
fontStyle: 'italic'
|
|
4512
5207
|
})
|
|
4513
5208
|
};
|
|
4514
5209
|
function Italic(props) {
|
|
4515
5210
|
return /*#__PURE__*/React.createElement("em", Object.assign({}, props.attributes, {
|
|
4516
|
-
className: styles$
|
|
5211
|
+
className: styles$e.italic
|
|
4517
5212
|
}), props.children);
|
|
4518
5213
|
}
|
|
4519
5214
|
var createItalicPlugin = function createItalicPlugin() {
|
|
@@ -4789,10 +5484,10 @@ var createNormalizerPlugin = function createNormalizerPlugin() {
|
|
|
4789
5484
|
};
|
|
4790
5485
|
|
|
4791
5486
|
var _templateObject$6, _styles$1;
|
|
4792
|
-
var styles$
|
|
5487
|
+
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
5488
|
function Paragraph(props) {
|
|
4794
5489
|
return /*#__PURE__*/React.createElement("div", Object.assign({}, props.attributes, {
|
|
4795
|
-
className: styles$
|
|
5490
|
+
className: styles$f[Contentful.BLOCKS.PARAGRAPH]
|
|
4796
5491
|
}), props.children);
|
|
4797
5492
|
}
|
|
4798
5493
|
|
|
@@ -5205,185 +5900,6 @@ var createSelectOnBackspacePlugin = function createSelectOnBackspacePlugin() {
|
|
|
5205
5900
|
});
|
|
5206
5901
|
};
|
|
5207
5902
|
|
|
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
5903
|
var addRow = function addRow(editor, getNextRowPath) {
|
|
5388
5904
|
if (plateCore.someNode(editor, {
|
|
5389
5905
|
match: {
|
|
@@ -5613,7 +6129,7 @@ var isTable = function isTable(node) {
|
|
|
5613
6129
|
return slate.Element.isElement(node) && node.type === Contentful.BLOCKS.TABLE;
|
|
5614
6130
|
};
|
|
5615
6131
|
|
|
5616
|
-
var styles$
|
|
6132
|
+
var styles$g = {
|
|
5617
6133
|
topRight: /*#__PURE__*/emotion.css({
|
|
5618
6134
|
position: 'absolute',
|
|
5619
6135
|
top: '6px',
|
|
@@ -5702,7 +6218,7 @@ var TableActions = function TableActions() {
|
|
|
5702
6218
|
size: "small",
|
|
5703
6219
|
variant: "transparent",
|
|
5704
6220
|
tabIndex: -1,
|
|
5705
|
-
className: styles$
|
|
6221
|
+
className: styles$g.topRight,
|
|
5706
6222
|
icon: /*#__PURE__*/React__default.createElement(f36Icons.ChevronDownIcon, null),
|
|
5707
6223
|
"aria-label": "Open table menu",
|
|
5708
6224
|
testId: "cf-table-actions-button"
|
|
@@ -5727,38 +6243,38 @@ var TableActions = function TableActions() {
|
|
|
5727
6243
|
};
|
|
5728
6244
|
|
|
5729
6245
|
var _templateObject$7;
|
|
5730
|
-
var style$
|
|
6246
|
+
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
6247
|
var Cell = function Cell(props) {
|
|
5732
6248
|
var isSelected = Slate.useSelected();
|
|
5733
6249
|
return /*#__PURE__*/React.createElement("td", Object.assign({}, props.attributes, props.element.data, {
|
|
5734
|
-
className: style$
|
|
6250
|
+
className: style$2
|
|
5735
6251
|
}), isSelected && /*#__PURE__*/React.createElement(TableActions, null), props.children);
|
|
5736
6252
|
};
|
|
5737
6253
|
|
|
5738
6254
|
var _templateObject$8;
|
|
5739
|
-
var style$
|
|
6255
|
+
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
6256
|
var HeaderCell = function HeaderCell(props) {
|
|
5741
6257
|
var isSelected = Slate.useSelected();
|
|
5742
6258
|
return /*#__PURE__*/React.createElement("th", Object.assign({}, props.attributes, props.element.data, {
|
|
5743
|
-
className: style$
|
|
6259
|
+
className: style$3
|
|
5744
6260
|
}), isSelected && /*#__PURE__*/React.createElement(TableActions, null), props.children);
|
|
5745
6261
|
};
|
|
5746
6262
|
|
|
5747
6263
|
var _templateObject$9;
|
|
5748
|
-
var style$
|
|
6264
|
+
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
6265
|
var Row = function Row(props) {
|
|
5750
6266
|
return /*#__PURE__*/React.createElement("tr", Object.assign({}, props.attributes, {
|
|
5751
|
-
className: style$
|
|
6267
|
+
className: style$4
|
|
5752
6268
|
}), props.children);
|
|
5753
6269
|
};
|
|
5754
6270
|
|
|
5755
6271
|
var _templateObject$a;
|
|
5756
|
-
var style$
|
|
6272
|
+
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
6273
|
var Table = function Table(props) {
|
|
5758
6274
|
return /*#__PURE__*/React.createElement("div", {
|
|
5759
6275
|
"data-block-type": Contentful.BLOCKS.TABLE
|
|
5760
6276
|
}, /*#__PURE__*/React.createElement("table", Object.assign({
|
|
5761
|
-
className: style$
|
|
6277
|
+
className: style$5
|
|
5762
6278
|
}, props.attributes), /*#__PURE__*/React.createElement("tbody", null, props.children)));
|
|
5763
6279
|
};
|
|
5764
6280
|
|
|
@@ -6505,7 +7021,7 @@ var getPlugins = function getPlugins(sdk, onAction) {
|
|
|
6505
7021
|
return [// AST must come after the HTML deserializer
|
|
6506
7022
|
plateCore.createDeserializeHtmlPlugin(), plateCore.createDeserializeAstPlugin(), plateSerializerDocx.createDeserializeDocxPlugin(), // Tracking - This should come first so all plugins below will have access to `editor.tracking`
|
|
6507
7023
|
createTrackingPlugin(onAction), // Global / Global shortcuts
|
|
6508
|
-
createDragAndDropPlugin(),
|
|
7024
|
+
createDragAndDropPlugin(), createCommandPalettePlugin(), // Block Elements
|
|
6509
7025
|
createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
|
|
6510
7026
|
createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
|
|
6511
7027
|
createMarksPlugin(), // Other
|
|
@@ -6636,7 +7152,7 @@ var normalizeEditorValue = function normalizeEditorValue(value, options) {
|
|
|
6636
7152
|
};
|
|
6637
7153
|
|
|
6638
7154
|
var STYLE_EDITOR_BORDER = "1px solid " + tokens.gray400;
|
|
6639
|
-
var styles$
|
|
7155
|
+
var styles$h = {
|
|
6640
7156
|
root: /*#__PURE__*/emotion.css({
|
|
6641
7157
|
position: 'relative'
|
|
6642
7158
|
}),
|
|
@@ -6753,7 +7269,7 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
|
|
|
6753
7269
|
}, actions) : null;
|
|
6754
7270
|
};
|
|
6755
7271
|
|
|
6756
|
-
var styles$
|
|
7272
|
+
var styles$i = {
|
|
6757
7273
|
toolbar: /*#__PURE__*/emotion.css({
|
|
6758
7274
|
border: "1px solid " + tokens.gray400,
|
|
6759
7275
|
backgroundColor: tokens.gray100,
|
|
@@ -6798,14 +7314,14 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
6798
7314
|
var shouldDisableTables = isDisabled || !canInsertBlocks || isListSelected || isBlockquoteSelected;
|
|
6799
7315
|
return /*#__PURE__*/React__default.createElement(f36Components.Flex, {
|
|
6800
7316
|
testId: "toolbar",
|
|
6801
|
-
className: styles$
|
|
7317
|
+
className: styles$i.toolbar,
|
|
6802
7318
|
alignItems: "center"
|
|
6803
7319
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
6804
|
-
className: styles$
|
|
7320
|
+
className: styles$i.formattingOptionsWrapper
|
|
6805
7321
|
}, /*#__PURE__*/React__default.createElement(ToolbarHeadingButton, {
|
|
6806
7322
|
isDisabled: isDisabled || !canInsertBlocks
|
|
6807
7323
|
}), validationInfo.isAnyMarkEnabled && /*#__PURE__*/React__default.createElement("span", {
|
|
6808
|
-
className: styles$
|
|
7324
|
+
className: styles$i.divider
|
|
6809
7325
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.BOLD) && /*#__PURE__*/React__default.createElement(ToolbarBoldButton, {
|
|
6810
7326
|
isDisabled: isDisabled
|
|
6811
7327
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.ITALIC) && /*#__PURE__*/React__default.createElement(ToolbarItalicButton, {
|
|
@@ -6815,11 +7331,11 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
6815
7331
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.CODE) && /*#__PURE__*/React__default.createElement(ToolbarCodeButton, {
|
|
6816
7332
|
isDisabled: isDisabled
|
|
6817
7333
|
}), validationInfo.isAnyHyperlinkEnabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
|
6818
|
-
className: styles$
|
|
7334
|
+
className: styles$i.divider
|
|
6819
7335
|
}), /*#__PURE__*/React__default.createElement(ToolbarHyperlinkButton, {
|
|
6820
7336
|
isDisabled: isDisabled
|
|
6821
7337
|
})), validationInfo.isAnyBlockFormattingEnabled && /*#__PURE__*/React__default.createElement("span", {
|
|
6822
|
-
className: styles$
|
|
7338
|
+
className: styles$i.divider
|
|
6823
7339
|
}), /*#__PURE__*/React__default.createElement(ToolbarListButton, {
|
|
6824
7340
|
isDisabled: isDisabled || !canInsertBlocks
|
|
6825
7341
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.QUOTE) && /*#__PURE__*/React__default.createElement(ToolbarQuoteButton, {
|
|
@@ -6829,7 +7345,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
6829
7345
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.TABLE) && /*#__PURE__*/React__default.createElement(ToolbarTableButton, {
|
|
6830
7346
|
isDisabled: shouldDisableTables
|
|
6831
7347
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
6832
|
-
className: styles$
|
|
7348
|
+
className: styles$i.embedActionsWrapper
|
|
6833
7349
|
}, /*#__PURE__*/React__default.createElement(EmbedEntityWidget, {
|
|
6834
7350
|
isDisabled: isDisabled,
|
|
6835
7351
|
canInsertBlocks: canInsertBlocks
|
|
@@ -6854,7 +7370,7 @@ function getValidationInfo(field) {
|
|
|
6854
7370
|
}
|
|
6855
7371
|
|
|
6856
7372
|
var _templateObject$b;
|
|
6857
|
-
var styles$
|
|
7373
|
+
var styles$j = {
|
|
6858
7374
|
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
7375
|
};
|
|
6860
7376
|
|
|
@@ -6862,10 +7378,26 @@ var StickyToolbarWrapper = function StickyToolbarWrapper(_ref) {
|
|
|
6862
7378
|
var isDisabled = _ref.isDisabled,
|
|
6863
7379
|
children = _ref.children;
|
|
6864
7380
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
6865
|
-
className: isDisabled ? '' : styles$
|
|
7381
|
+
className: isDisabled ? '' : styles$j.nativeSticky
|
|
6866
7382
|
}, children);
|
|
6867
7383
|
};
|
|
6868
7384
|
|
|
7385
|
+
var internalMarks = [COMMAND_PROMPT];
|
|
7386
|
+
var removeInternalMarks = function removeInternalMarks(document) {
|
|
7387
|
+
return _extends({}, document, {
|
|
7388
|
+
content: document.content.map(function (node) {
|
|
7389
|
+
if (node.nodeType === 'text') {
|
|
7390
|
+
node.marks = node.marks.filter(function (mark) {
|
|
7391
|
+
return !internalMarks.includes(mark.type);
|
|
7392
|
+
});
|
|
7393
|
+
return node;
|
|
7394
|
+
}
|
|
7395
|
+
|
|
7396
|
+
return removeInternalMarks(node);
|
|
7397
|
+
})
|
|
7398
|
+
});
|
|
7399
|
+
};
|
|
7400
|
+
|
|
6869
7401
|
/**
|
|
6870
7402
|
* Returns whether a given operation is relevant enough to trigger a save.
|
|
6871
7403
|
*/
|
|
@@ -6885,10 +7417,12 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
|
6885
7417
|
onSkip = _ref.onSkip;
|
|
6886
7418
|
var onChange = React.useMemo(function () {
|
|
6887
7419
|
return debounce(function (document) {
|
|
6888
|
-
|
|
7420
|
+
var contentfulDocument = contentfulSlateJSAdapter.toContentfulDocument({
|
|
6889
7421
|
document: document,
|
|
6890
7422
|
schema: schema
|
|
6891
|
-
})
|
|
7423
|
+
});
|
|
7424
|
+
var cleanedDocument = removeInternalMarks(contentfulDocument);
|
|
7425
|
+
handler == null ? void 0 : handler(cleanedDocument);
|
|
6892
7426
|
}, 500);
|
|
6893
7427
|
}, [handler]);
|
|
6894
7428
|
return React.useCallback(function (value) {
|
|
@@ -6957,9 +7491,9 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6957
7491
|
setPendingExternalUpdate(true);
|
|
6958
7492
|
setEditorContent(editor, documentToEditorValue(props.value));
|
|
6959
7493
|
}, [props.value, id]);
|
|
6960
|
-
var classNames = emotion.cx(styles$
|
|
7494
|
+
var classNames = emotion.cx(styles$h.editor, props.minHeight !== undefined ? emotion.css({
|
|
6961
7495
|
minHeight: props.minHeight
|
|
6962
|
-
}) : undefined, props.isDisabled ? styles$
|
|
7496
|
+
}) : undefined, props.isDisabled ? styles$h.disabled : styles$h.enabled, props.isToolbarHidden && styles$h.hiddenToolbar);
|
|
6963
7497
|
React.useEffect(function () {
|
|
6964
7498
|
if (!isFirstRender) {
|
|
6965
7499
|
return;
|
|
@@ -6975,7 +7509,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6975
7509
|
}, /*#__PURE__*/React__default.createElement(ContentfulEditorIdProvider, {
|
|
6976
7510
|
value: id
|
|
6977
7511
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
6978
|
-
className: styles$
|
|
7512
|
+
className: styles$h.root,
|
|
6979
7513
|
"data-test-id": "rich-text-editor"
|
|
6980
7514
|
}, /*#__PURE__*/React__default.createElement(plateCore.Plate, {
|
|
6981
7515
|
id: id,
|
|
@@ -6990,9 +7524,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
6990
7524
|
isDisabled: props.isDisabled
|
|
6991
7525
|
}, /*#__PURE__*/React__default.createElement(Toolbar, {
|
|
6992
7526
|
isDisabled: props.isDisabled
|
|
6993
|
-
}))
|
|
6994
|
-
editorId: id
|
|
6995
|
-
})))));
|
|
7527
|
+
}))))));
|
|
6996
7528
|
};
|
|
6997
7529
|
|
|
6998
7530
|
var RichTextEditor = function RichTextEditor(props) {
|