@contentful/field-editor-rich-text 3.16.11 → 3.16.12
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/dist/cjs/ContentfulEditorProvider.js +8 -8
- package/dist/cjs/RichTextEditor.js +6 -4
- package/dist/cjs/SdkProvider.js +4 -2
- package/dist/cjs/SyncEditorChanges.js +4 -2
- package/dist/cjs/Toolbar/_tests_/toolbar.test.js +6 -4
- package/dist/cjs/Toolbar/components/EmbedEntityWidget.js +4 -2
- package/dist/cjs/Toolbar/components/EmbeddedEntityDropdownButton.js +4 -2
- package/dist/cjs/Toolbar/components/StickyToolbarWrapper.js +1 -1
- package/dist/cjs/Toolbar/index.js +5 -3
- package/dist/cjs/__fixtures__/FakeSdk.js +3 -3
- package/dist/cjs/__fixtures__/asset/index.js +5 -5
- package/dist/cjs/__fixtures__/entry/index.js +3 -3
- package/dist/cjs/__fixtures__/fixtures.js +3 -1
- package/dist/cjs/dialogs/HypelinkDialog/HyperlinkDialog.js +17 -15
- package/dist/cjs/dialogs/openRichTextDialog.js +4 -2
- package/dist/cjs/dialogs/renderRichTextDialog.js +3 -1
- package/dist/cjs/helpers/__tests__/removeInternalMarks.test.js +1 -1
- package/dist/cjs/helpers/editor.js +42 -42
- package/dist/cjs/helpers/environment.js +3 -3
- package/dist/cjs/helpers/formatDateAndTime.js +3 -3
- package/dist/cjs/helpers/nodeFactory.js +6 -6
- package/dist/cjs/helpers/sdkNavigatorSlideIn.js +1 -1
- package/dist/cjs/helpers/transformers.js +5 -5
- package/dist/cjs/helpers/validations.js +5 -5
- package/dist/cjs/index.js +6 -4
- package/dist/cjs/internal/constants.js +3 -1
- package/dist/cjs/internal/hooks.js +7 -5
- package/dist/cjs/internal/misc.js +12 -10
- package/dist/cjs/internal/queries.js +107 -105
- package/dist/cjs/internal/transforms.js +49 -47
- package/dist/cjs/plugins/Break/createExitBreakPlugin.test.js +1 -1
- package/dist/cjs/plugins/Break/createSoftBreakPlugin.test.js +1 -1
- package/dist/cjs/plugins/CommandPalette/components/CommandList.js +9 -7
- package/dist/cjs/plugins/CommandPalette/components/CommandPrompt.js +3 -1
- package/dist/cjs/plugins/CommandPalette/hooks/useCommandList.js +3 -1
- package/dist/cjs/plugins/CommandPalette/onKeyDown.spec.js +5 -3
- package/dist/cjs/plugins/CommandPalette/useCommands.js +2 -2
- package/dist/cjs/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +6 -4
- package/dist/cjs/plugins/EmbeddedEntityBlock/index.js +3 -3
- package/dist/cjs/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +7 -5
- package/dist/cjs/plugins/EmbeddedEntityInline/LinkedEntityInline.js +6 -4
- package/dist/cjs/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +2 -2
- package/dist/cjs/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +7 -5
- package/dist/cjs/plugins/EmbeddedResourceInline/LinkedResourceInline.js +2 -2
- package/dist/cjs/plugins/Heading/components/Heading.js +3 -1
- package/dist/cjs/plugins/Heading/components/ToolbarHeadingButton.js +3 -1
- package/dist/cjs/plugins/Heading/createHeadingPlugin.js +1 -1
- package/dist/cjs/plugins/Hr/index.js +8 -6
- package/dist/cjs/plugins/Hyperlink/HyperlinkModal.js +7 -5
- package/dist/cjs/plugins/Hyperlink/components/EntityHyperlink.js +6 -4
- package/dist/cjs/plugins/Hyperlink/components/LinkPopover.js +4 -2
- package/dist/cjs/plugins/Hyperlink/components/ResourceHyperlink.js +6 -4
- package/dist/cjs/plugins/Hyperlink/components/ToolbarHyperlinkButton.js +3 -1
- package/dist/cjs/plugins/Hyperlink/components/UrlHyperlink.js +4 -2
- package/dist/cjs/plugins/Hyperlink/components/linkHandlers.js +3 -3
- package/dist/cjs/plugins/Hyperlink/createHyperlinkPlugin.js +4 -2
- package/dist/cjs/plugins/Hyperlink/useEntityInfo.js +3 -3
- package/dist/cjs/plugins/Hyperlink/useResourceEntityInfo.js +5 -3
- package/dist/cjs/plugins/Hyperlink/utils.js +4 -4
- package/dist/cjs/plugins/List/__tests__/insertListBreak.test.js +1 -1
- package/dist/cjs/plugins/List/__tests__/insertListFragment.test.js +1 -1
- package/dist/cjs/plugins/List/components/List.js +6 -4
- package/dist/cjs/plugins/List/components/ListItem.js +3 -1
- package/dist/cjs/plugins/List/components/ToolbarListButton.js +3 -1
- package/dist/cjs/plugins/List/insertListBreak.js +2 -2
- package/dist/cjs/plugins/List/insertListFragment.js +1 -1
- package/dist/cjs/plugins/List/onKeyDownList.js +1 -1
- package/dist/cjs/plugins/List/transforms/moveListItemDown.js +1 -1
- package/dist/cjs/plugins/List/transforms/moveListItems.js +1 -1
- package/dist/cjs/plugins/List/transforms/moveListItems.test.js +1 -1
- package/dist/cjs/plugins/List/transforms/toggleList.js +3 -3
- package/dist/cjs/plugins/List/transforms/toggleList.spec.js +9 -9
- package/dist/cjs/plugins/List/transforms/unwrapList.js +1 -1
- package/dist/cjs/plugins/List/utils.js +11 -11
- package/dist/cjs/plugins/List/withList.js +1 -1
- package/dist/cjs/plugins/Marks/Bold.js +6 -4
- package/dist/cjs/plugins/Marks/Code.js +6 -4
- package/dist/cjs/plugins/Marks/Italic.js +6 -4
- package/dist/cjs/plugins/Marks/Subscript.js +7 -5
- package/dist/cjs/plugins/Marks/Superscript.js +7 -5
- package/dist/cjs/plugins/Marks/Underline.js +3 -1
- package/dist/cjs/plugins/Marks/components/MarkToolbarButton.js +5 -3
- package/dist/cjs/plugins/Marks/helpers.js +4 -4
- package/dist/cjs/plugins/Normalizer/createNormalizerPlugin.test.js +3 -3
- package/dist/cjs/plugins/Normalizer/utils.js +3 -3
- package/dist/cjs/plugins/Normalizer/withNormalizer.js +2 -2
- package/dist/cjs/plugins/Paragraph/Paragraph.js +3 -1
- package/dist/cjs/plugins/Paragraph/createParagraphPlugin.js +1 -1
- package/dist/cjs/plugins/PasteHTML/createPasteHTMLPlugin.js +5 -5
- package/dist/cjs/plugins/Quote/components/Quote.js +3 -1
- package/dist/cjs/plugins/Quote/components/ToolbarQuoteButton.js +3 -1
- package/dist/cjs/plugins/Quote/toggleQuote.js +4 -4
- package/dist/cjs/plugins/Quote/withQuote.js +2 -2
- package/dist/cjs/plugins/Table/__tests__/helpers.test.js +1 -1
- package/dist/cjs/plugins/Table/actions/addColumn.js +4 -4
- package/dist/cjs/plugins/Table/actions/addRow.js +3 -3
- package/dist/cjs/plugins/Table/components/Cell.js +3 -1
- package/dist/cjs/plugins/Table/components/HeaderCell.js +3 -1
- package/dist/cjs/plugins/Table/components/Row.js +3 -1
- package/dist/cjs/plugins/Table/components/Table.js +3 -1
- package/dist/cjs/plugins/Table/components/TableActions.js +6 -4
- package/dist/cjs/plugins/Table/components/ToolbarButton.js +3 -1
- package/dist/cjs/plugins/Table/createTablePlugin.js +1 -1
- package/dist/cjs/plugins/Table/helpers.js +12 -12
- package/dist/cjs/plugins/Table/insertTableFragment.js +1 -1
- package/dist/cjs/plugins/Table/onKeyDownTable.js +2 -2
- package/dist/cjs/plugins/Table/tableTracking.js +6 -6
- package/dist/cjs/plugins/Text/__tests__/createTextPlugin.test.js +2 -2
- package/dist/cjs/plugins/Text/createTextPlugin.js +3 -3
- package/dist/cjs/plugins/Tracking/createTrackingPlugin.js +4 -4
- package/dist/cjs/plugins/Tracking/utils.js +3 -1
- package/dist/cjs/plugins/index.js +3 -3
- package/dist/cjs/plugins/shared/EmbeddedBlockToolbarIcon.js +7 -5
- package/dist/cjs/plugins/shared/EmbeddedBlockUtil.js +5 -5
- package/dist/cjs/plugins/shared/EmbeddedInlineToolbarIcon.js +4 -2
- package/dist/cjs/plugins/shared/EmbeddedInlineUtil.js +4 -4
- package/dist/cjs/plugins/shared/FetchingWrappedAssetCard.js +6 -4
- package/dist/cjs/plugins/shared/FetchingWrappedEntryCard.js +7 -5
- package/dist/cjs/plugins/shared/FetchingWrappedResourceCard.js +6 -4
- package/dist/cjs/plugins/shared/LinkedBlockWrapper.js +1 -1
- package/dist/cjs/plugins/shared/LinkedInlineWrapper.js +4 -2
- package/dist/cjs/plugins/shared/ResourceNewBadge.js +3 -1
- package/dist/cjs/plugins/shared/ToolbarButton.js +4 -2
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +4 -2
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +4 -2
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +9 -7
- package/dist/cjs/test-utils/validation.js +3 -3
- package/dist/esm/ContentfulEditorProvider.js +1 -1
- package/dist/esm/RichTextEditor.js +3 -3
- package/dist/esm/SdkProvider.js +1 -1
- package/dist/esm/SyncEditorChanges.js +1 -1
- package/dist/esm/Toolbar/_tests_/toolbar.test.js +3 -3
- package/dist/esm/Toolbar/components/EmbedEntityWidget.js +1 -1
- package/dist/esm/Toolbar/components/EmbeddedEntityDropdownButton.js +1 -1
- package/dist/esm/Toolbar/components/StickyToolbarWrapper.js +1 -1
- package/dist/esm/Toolbar/index.js +2 -2
- package/dist/esm/__fixtures__/FakeSdk.js +3 -3
- package/dist/esm/dialogs/HypelinkDialog/HyperlinkDialog.js +11 -11
- package/dist/esm/dialogs/openRichTextDialog.js +1 -1
- package/dist/esm/helpers/__tests__/removeInternalMarks.test.js +1 -1
- package/dist/esm/helpers/editor.js +3 -3
- package/dist/esm/helpers/sdkNavigatorSlideIn.js +1 -1
- package/dist/esm/plugins/Break/createExitBreakPlugin.test.js +1 -1
- package/dist/esm/plugins/Break/createSoftBreakPlugin.test.js +1 -1
- package/dist/esm/plugins/CommandPalette/components/CommandList.js +6 -6
- package/dist/esm/plugins/CommandPalette/onKeyDown.spec.js +2 -2
- package/dist/esm/plugins/CommandPalette/useCommands.js +2 -2
- package/dist/esm/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +3 -3
- package/dist/esm/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +4 -4
- package/dist/esm/plugins/EmbeddedEntityInline/LinkedEntityInline.js +3 -3
- package/dist/esm/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +2 -2
- package/dist/esm/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +4 -4
- package/dist/esm/plugins/EmbeddedResourceInline/LinkedResourceInline.js +2 -2
- package/dist/esm/plugins/Heading/createHeadingPlugin.js +1 -1
- package/dist/esm/plugins/Hyperlink/HyperlinkModal.js +4 -4
- package/dist/esm/plugins/Hyperlink/components/EntityHyperlink.js +3 -3
- package/dist/esm/plugins/Hyperlink/components/LinkPopover.js +1 -1
- package/dist/esm/plugins/Hyperlink/components/ResourceHyperlink.js +3 -3
- package/dist/esm/plugins/Hyperlink/components/UrlHyperlink.js +1 -1
- package/dist/esm/plugins/Hyperlink/createHyperlinkPlugin.js +1 -1
- package/dist/esm/plugins/Hyperlink/useEntityInfo.js +3 -3
- package/dist/esm/plugins/Hyperlink/useResourceEntityInfo.js +2 -2
- package/dist/esm/plugins/Hyperlink/utils.js +1 -1
- package/dist/esm/plugins/List/__tests__/insertListBreak.test.js +1 -1
- package/dist/esm/plugins/List/__tests__/insertListFragment.test.js +1 -1
- package/dist/esm/plugins/List/insertListBreak.js +2 -2
- package/dist/esm/plugins/List/insertListFragment.js +1 -1
- package/dist/esm/plugins/List/onKeyDownList.js +1 -1
- package/dist/esm/plugins/List/transforms/moveListItemDown.js +1 -1
- package/dist/esm/plugins/List/transforms/moveListItems.js +1 -1
- package/dist/esm/plugins/List/transforms/moveListItems.test.js +1 -1
- package/dist/esm/plugins/List/transforms/toggleList.js +3 -3
- package/dist/esm/plugins/List/transforms/toggleList.spec.js +9 -9
- package/dist/esm/plugins/List/transforms/unwrapList.js +1 -1
- package/dist/esm/plugins/List/utils.js +1 -1
- package/dist/esm/plugins/List/withList.js +1 -1
- package/dist/esm/plugins/Marks/components/MarkToolbarButton.js +2 -2
- package/dist/esm/plugins/Marks/helpers.js +1 -1
- package/dist/esm/plugins/Normalizer/createNormalizerPlugin.test.js +3 -3
- package/dist/esm/plugins/Normalizer/withNormalizer.js +2 -2
- package/dist/esm/plugins/Paragraph/createParagraphPlugin.js +1 -1
- package/dist/esm/plugins/PasteHTML/createPasteHTMLPlugin.js +1 -1
- package/dist/esm/plugins/Quote/toggleQuote.js +1 -1
- package/dist/esm/plugins/Quote/withQuote.js +2 -2
- package/dist/esm/plugins/Table/__tests__/helpers.test.js +1 -1
- package/dist/esm/plugins/Table/actions/addColumn.js +1 -1
- package/dist/esm/plugins/Table/createTablePlugin.js +1 -1
- package/dist/esm/plugins/Table/insertTableFragment.js +1 -1
- package/dist/esm/plugins/Table/onKeyDownTable.js +2 -2
- package/dist/esm/plugins/Table/tableTracking.js +6 -6
- package/dist/esm/plugins/Text/__tests__/createTextPlugin.test.js +2 -2
- package/dist/esm/plugins/Text/createTextPlugin.js +3 -3
- package/dist/esm/plugins/Tracking/createTrackingPlugin.js +1 -1
- package/dist/esm/plugins/shared/EmbeddedBlockToolbarIcon.js +1 -1
- package/dist/esm/plugins/shared/EmbeddedBlockUtil.js +5 -5
- package/dist/esm/plugins/shared/EmbeddedInlineToolbarIcon.js +1 -1
- package/dist/esm/plugins/shared/EmbeddedInlineUtil.js +4 -4
- package/dist/esm/plugins/shared/FetchingWrappedAssetCard.js +3 -3
- package/dist/esm/plugins/shared/FetchingWrappedEntryCard.js +4 -4
- package/dist/esm/plugins/shared/FetchingWrappedResourceCard.js +3 -3
- package/dist/esm/plugins/shared/LinkedBlockWrapper.js +1 -1
- package/dist/esm/plugins/shared/LinkedInlineWrapper.js +1 -1
- package/dist/esm/plugins/shared/ToolbarButton.js +1 -1
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +1 -1
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +1 -1
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +6 -6
- package/dist/esm/test-utils/validation.js +3 -3
- package/package.json +3 -3
|
@@ -31,7 +31,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
31
31
|
if (cache && cache.has(obj)) {
|
|
32
32
|
return cache.get(obj);
|
|
33
33
|
}
|
|
34
|
-
var newObj = {
|
|
34
|
+
var newObj = {
|
|
35
|
+
__proto__: null
|
|
36
|
+
};
|
|
35
37
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
36
38
|
for(var key in obj){
|
|
37
39
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -38,7 +38,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
38
38
|
if (cache && cache.has(obj)) {
|
|
39
39
|
return cache.get(obj);
|
|
40
40
|
}
|
|
41
|
-
var newObj = {
|
|
41
|
+
var newObj = {
|
|
42
|
+
__proto__: null
|
|
43
|
+
};
|
|
42
44
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
43
45
|
for(var key in obj){
|
|
44
46
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -68,7 +70,7 @@ const styles = {
|
|
|
68
70
|
})
|
|
69
71
|
};
|
|
70
72
|
function ToolbarButton(props) {
|
|
71
|
-
const { title
|
|
73
|
+
const { title, testId, isActive, children, className, isDisabled = false } = props;
|
|
72
74
|
const handleClick = (event)=>{
|
|
73
75
|
event.preventDefault();
|
|
74
76
|
props.onClick();
|
|
@@ -35,7 +35,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
35
35
|
if (cache && cache.has(obj)) {
|
|
36
36
|
return cache.get(obj);
|
|
37
37
|
}
|
|
38
|
-
var newObj = {
|
|
38
|
+
var newObj = {
|
|
39
|
+
__proto__: null
|
|
40
|
+
};
|
|
39
41
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
40
42
|
for(var key in obj){
|
|
41
43
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -86,7 +88,7 @@ beforeEach(()=>{
|
|
|
86
88
|
};
|
|
87
89
|
});
|
|
88
90
|
test('some dropdown actions should be disabled', async ()=>{
|
|
89
|
-
const { getByTestId
|
|
91
|
+
const { getByTestId, queryByTestId } = (0, _react1.render)(_react.createElement(_fieldeditorreference.EntityProvider, {
|
|
90
92
|
sdk: sdk
|
|
91
93
|
}, _react.createElement(_FetchingWrappedAssetCard.FetchingWrappedAssetCard, {
|
|
92
94
|
sdk: sdk,
|
|
@@ -36,7 +36,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
36
36
|
if (cache && cache.has(obj)) {
|
|
37
37
|
return cache.get(obj);
|
|
38
38
|
}
|
|
39
|
-
var newObj = {
|
|
39
|
+
var newObj = {
|
|
40
|
+
__proto__: null
|
|
41
|
+
};
|
|
40
42
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
43
|
for(var key in obj){
|
|
42
44
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -90,7 +92,7 @@ beforeEach(()=>{
|
|
|
90
92
|
};
|
|
91
93
|
});
|
|
92
94
|
test('some dropdown actions should be disabled/removed', async ()=>{
|
|
93
|
-
const { getByTestId
|
|
95
|
+
const { getByTestId, queryByTestId } = (0, _react1.render)(_react.createElement(_fieldeditorreference.EntityProvider, {
|
|
94
96
|
sdk: sdk
|
|
95
97
|
}, _react.createElement(_FetchingWrappedEntryCard.FetchingWrappedEntryCard, {
|
|
96
98
|
sdk: sdk,
|
|
@@ -37,7 +37,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
37
37
|
if (cache && cache.has(obj)) {
|
|
38
38
|
return cache.get(obj);
|
|
39
39
|
}
|
|
40
|
-
var newObj = {
|
|
40
|
+
var newObj = {
|
|
41
|
+
__proto__: null
|
|
42
|
+
};
|
|
41
43
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
42
44
|
for(var key in obj){
|
|
43
45
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -71,7 +73,7 @@ beforeEach(()=>{
|
|
|
71
73
|
get: jest.fn().mockReturnValue(_published_content_typejson.default)
|
|
72
74
|
},
|
|
73
75
|
Entry: {
|
|
74
|
-
get: jest.fn().mockImplementation(({ entryId
|
|
76
|
+
get: jest.fn().mockImplementation(({ entryId })=>{
|
|
75
77
|
if (entryId === 'linked-entry-urn') {
|
|
76
78
|
return Promise.resolve(_published_entryjson.default);
|
|
77
79
|
}
|
|
@@ -108,7 +110,7 @@ beforeEach(()=>{
|
|
|
108
110
|
}
|
|
109
111
|
};
|
|
110
112
|
});
|
|
111
|
-
function renderResourceCard({ linkType ='Contentful:Entry'
|
|
113
|
+
function renderResourceCard({ linkType = 'Contentful:Entry', entryUrn = resolvableEntryUrn } = {}) {
|
|
112
114
|
return (0, _react1.render)(_react.createElement(_fieldeditorreference.EntityProvider, {
|
|
113
115
|
sdk: sdk
|
|
114
116
|
}, _react.createElement(_FetchingWrappedResourceCard.FetchingWrappedResourceCard, {
|
|
@@ -123,23 +125,23 @@ function renderResourceCard({ linkType ='Contentful:Entry' , entryUrn =resolvabl
|
|
|
123
125
|
})));
|
|
124
126
|
}
|
|
125
127
|
test('renders entry card', async ()=>{
|
|
126
|
-
const { getByTestId
|
|
128
|
+
const { getByTestId, getByText } = renderResourceCard();
|
|
127
129
|
await (0, _react1.waitFor)(()=>expect(getByTestId('cf-ui-entry-card')).toBeDefined());
|
|
128
130
|
expect(getByText(_published_entryjson.default.fields.exField.en)).toBeDefined();
|
|
129
131
|
expect(getByText(_spacejson.default.name)).toBeDefined();
|
|
130
132
|
});
|
|
131
133
|
test('renders skeleton when no data is provided', ()=>{
|
|
132
|
-
const { getByTestId
|
|
134
|
+
const { getByTestId } = renderResourceCard();
|
|
133
135
|
expect(getByTestId('cf-ui-skeleton-form')).toBeDefined();
|
|
134
136
|
});
|
|
135
137
|
test('renders unsupported entity card when unsupported link is passed', async ()=>{
|
|
136
|
-
const { getByText
|
|
138
|
+
const { getByText } = renderResourceCard({
|
|
137
139
|
linkType: 'Contentful:UnsupportedLink'
|
|
138
140
|
});
|
|
139
141
|
await (0, _react1.waitFor)(()=>expect(getByText('Resource type Contentful:UnsupportedLink is currently not supported')).toBeDefined());
|
|
140
142
|
});
|
|
141
143
|
test('renders missing entity card when unknown error is returned', async ()=>{
|
|
142
|
-
const { getByTestId
|
|
144
|
+
const { getByTestId } = renderResourceCard({
|
|
143
145
|
entryUrn: unknownEntryUrn
|
|
144
146
|
});
|
|
145
147
|
await (0, _react1.waitFor)(()=>expect(getByTestId('cf-ui-missing-entry-card')).toBeDefined());
|
|
@@ -75,7 +75,7 @@ function buildSchemaErrors(validateSchema, _, errors) {
|
|
|
75
75
|
errors.push(...schemaErrors);
|
|
76
76
|
}
|
|
77
77
|
function resetChildNodes(node) {
|
|
78
|
-
const { content
|
|
78
|
+
const { content } = node;
|
|
79
79
|
if (isLeafNode(node)) {
|
|
80
80
|
return node;
|
|
81
81
|
}
|
|
@@ -84,7 +84,7 @@ function resetChildNodes(node) {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
function resetNode(node) {
|
|
87
|
-
const { nodeType
|
|
87
|
+
const { nodeType } = node;
|
|
88
88
|
if (_richtexttypes.helpers.isText(node)) {
|
|
89
89
|
return {
|
|
90
90
|
nodeType,
|
|
@@ -100,7 +100,7 @@ function resetNode(node) {
|
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
function removeGrandChildNodes(node) {
|
|
103
|
-
const { content
|
|
103
|
+
const { content } = node;
|
|
104
104
|
if (isLeafNode(node)) {
|
|
105
105
|
return node;
|
|
106
106
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
2
|
import { usePlateEditorRef, usePlateEditorState } from './internal/hooks';
|
|
3
3
|
export function getContentfulEditorId(sdk) {
|
|
4
|
-
const { entry
|
|
4
|
+
const { entry, field } = sdk;
|
|
5
5
|
const sys = entry.getSys();
|
|
6
6
|
return `rich-text-editor-${sys.id}-${field.id}-${field.locale}`;
|
|
7
7
|
}
|
|
@@ -16,7 +16,7 @@ import { SyncEditorChanges } from './SyncEditorChanges';
|
|
|
16
16
|
import Toolbar from './Toolbar';
|
|
17
17
|
import StickyToolbarWrapper from './Toolbar/components/StickyToolbarWrapper';
|
|
18
18
|
export const ConnectedRichTextEditor = (props)=>{
|
|
19
|
-
const { sdk
|
|
19
|
+
const { sdk, onAction, restrictedMarks } = props;
|
|
20
20
|
const id = getContentfulEditorId(sdk);
|
|
21
21
|
const plugins = React.useMemo(()=>getPlugins(sdk, onAction ?? noop, restrictedMarks), [
|
|
22
22
|
sdk,
|
|
@@ -65,7 +65,7 @@ export const ConnectedRichTextEditor = (props)=>{
|
|
|
65
65
|
})))));
|
|
66
66
|
};
|
|
67
67
|
const RichTextEditor = (props)=>{
|
|
68
|
-
const { sdk
|
|
68
|
+
const { sdk, isInitiallyDisabled, onAction, restrictedMarks, ...otherProps } = props;
|
|
69
69
|
const isEmptyValue = React.useCallback((value)=>!value || deepEquals(value, Contentful.EMPTY_DOCUMENT), []);
|
|
70
70
|
const id = getContentfulEditorId(props.sdk);
|
|
71
71
|
return React.createElement(EntityProvider, {
|
|
@@ -76,7 +76,7 @@ const RichTextEditor = (props)=>{
|
|
|
76
76
|
isInitiallyDisabled: isInitiallyDisabled,
|
|
77
77
|
isEmptyValue: isEmptyValue,
|
|
78
78
|
isEqualValues: deepEquals
|
|
79
|
-
}, ({ lastRemoteValue
|
|
79
|
+
}, ({ lastRemoteValue, disabled, setValue })=>React.createElement(ConnectedRichTextEditor, {
|
|
80
80
|
...otherProps,
|
|
81
81
|
key: `rich-text-editor-${id}`,
|
|
82
82
|
value: lastRemoteValue,
|
package/dist/esm/SdkProvider.js
CHANGED
|
@@ -40,7 +40,7 @@ const useOnValueChanged = (onChange)=>{
|
|
|
40
40
|
setEditorOnChange
|
|
41
41
|
]);
|
|
42
42
|
};
|
|
43
|
-
export const SyncEditorChanges = ({ incomingValue
|
|
43
|
+
export const SyncEditorChanges = ({ incomingValue, onChange })=>{
|
|
44
44
|
useAcceptIncomingChanges(incomingValue);
|
|
45
45
|
useOnValueChanged(onChange);
|
|
46
46
|
return null;
|
|
@@ -37,7 +37,7 @@ describe('Toolbar', ()=>{
|
|
|
37
37
|
test('everything on the toolbar should be disabled', async ()=>{
|
|
38
38
|
const sdk = mockSdk();
|
|
39
39
|
const id = getContentfulEditorId(sdk);
|
|
40
|
-
const { getByTestId
|
|
40
|
+
const { getByTestId } = render(React.createElement(Plate, {
|
|
41
41
|
id: id
|
|
42
42
|
}, React.createElement(SdkProvider, {
|
|
43
43
|
sdk: sdk
|
|
@@ -71,7 +71,7 @@ describe('Toolbar', ()=>{
|
|
|
71
71
|
MARKS.SUPERSCRIPT
|
|
72
72
|
]);
|
|
73
73
|
const id = getContentfulEditorId(sdk);
|
|
74
|
-
const { queryByTestId
|
|
74
|
+
const { queryByTestId } = render(React.createElement(Plate, {
|
|
75
75
|
id: id
|
|
76
76
|
}, React.createElement(SdkProvider, {
|
|
77
77
|
sdk: sdk
|
|
@@ -89,7 +89,7 @@ describe('Toolbar', ()=>{
|
|
|
89
89
|
MARKS.CODE
|
|
90
90
|
]);
|
|
91
91
|
const id = getContentfulEditorId(sdk);
|
|
92
|
-
const { queryByTestId
|
|
92
|
+
const { queryByTestId } = render(React.createElement(Plate, {
|
|
93
93
|
id: id
|
|
94
94
|
}, React.createElement(SdkProvider, {
|
|
95
95
|
sdk: sdk
|
|
@@ -7,7 +7,7 @@ import { EmbeddedBlockToolbarIcon } from '../../plugins/shared/EmbeddedBlockTool
|
|
|
7
7
|
import { EmbeddedInlineToolbarIcon } from '../../plugins/shared/EmbeddedInlineToolbarIcon';
|
|
8
8
|
import { useSdkContext } from '../../SdkProvider';
|
|
9
9
|
import { EmbeddedEntityDropdownButton } from './EmbeddedEntityDropdownButton';
|
|
10
|
-
export const EmbedEntityWidget = ({ isDisabled
|
|
10
|
+
export const EmbedEntityWidget = ({ isDisabled, canInsertBlocks })=>{
|
|
11
11
|
const sdk = useSdkContext();
|
|
12
12
|
const editor = useContentfulEditor();
|
|
13
13
|
const [isEmbedDropdownOpen, setEmbedDropdownOpen] = useState(false);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Button, Menu } from '@contentful/f36-components';
|
|
3
3
|
import { PlusIcon, ChevronDownIcon } from '@contentful/f36-icons';
|
|
4
|
-
export function EmbeddedEntityDropdownButton({ children
|
|
4
|
+
export function EmbeddedEntityDropdownButton({ children, isDisabled, isOpen, onClose, onToggle }) {
|
|
5
5
|
return React.createElement(Menu, {
|
|
6
6
|
placement: "bottom-end",
|
|
7
7
|
isOpen: isOpen,
|
|
@@ -8,7 +8,7 @@ const styles = {
|
|
|
8
8
|
z-index: 2;
|
|
9
9
|
`
|
|
10
10
|
};
|
|
11
|
-
const StickyToolbarWrapper = ({ isDisabled
|
|
11
|
+
const StickyToolbarWrapper = ({ isDisabled, children })=>React.createElement("div", {
|
|
12
12
|
className: isDisabled ? '' : styles.nativeSticky
|
|
13
13
|
}, children);
|
|
14
14
|
export default StickyToolbarWrapper;
|
|
@@ -67,7 +67,7 @@ const styles = {
|
|
|
67
67
|
marginRight: '20px'
|
|
68
68
|
})
|
|
69
69
|
};
|
|
70
|
-
const Dropdown = ({ sdk
|
|
70
|
+
const Dropdown = ({ sdk, isDisabled })=>{
|
|
71
71
|
const editor = useContentfulEditor();
|
|
72
72
|
const isActive = editor && (isMarkActive(editor, MARKS.SUPERSCRIPT) || isMarkActive(editor, MARKS.SUBSCRIPT) || isMarkActive(editor, MARKS.CODE));
|
|
73
73
|
return React.createElement(Menu, null, React.createElement(Menu.Trigger, null, React.createElement("span", null, React.createElement(IconButton, {
|
|
@@ -86,7 +86,7 @@ const Dropdown = ({ sdk , isDisabled })=>{
|
|
|
86
86
|
isDisabled: isDisabled
|
|
87
87
|
})));
|
|
88
88
|
};
|
|
89
|
-
const Toolbar = ({ isDisabled
|
|
89
|
+
const Toolbar = ({ isDisabled })=>{
|
|
90
90
|
const sdk = useSdkContext();
|
|
91
91
|
const editor = useContentfulEditor();
|
|
92
92
|
const canInsertBlocks = !isNodeTypeSelected(editor, BLOCKS.TABLE);
|
|
@@ -49,7 +49,7 @@ export function newReferenceEditorFakeSdk(props) {
|
|
|
49
49
|
locales,
|
|
50
50
|
cmaAdapter: createFakeCMAAdapter({
|
|
51
51
|
Entry: {
|
|
52
|
-
get: async ({ entryId
|
|
52
|
+
get: async ({ entryId })=>{
|
|
53
53
|
if (props?.fetchDelay) {
|
|
54
54
|
await delay(props.fetchDelay);
|
|
55
55
|
}
|
|
@@ -66,7 +66,7 @@ export function newReferenceEditorFakeSdk(props) {
|
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
Asset: {
|
|
69
|
-
get: async ({ assetId
|
|
69
|
+
get: async ({ assetId })=>{
|
|
70
70
|
if (props?.fetchDelay) {
|
|
71
71
|
await delay(props.fetchDelay);
|
|
72
72
|
}
|
|
@@ -91,7 +91,7 @@ export function newReferenceEditorFakeSdk(props) {
|
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
93
|
ContentType: {
|
|
94
|
-
get: async ({ contentTypeId
|
|
94
|
+
get: async ({ contentTypeId })=>{
|
|
95
95
|
if (contentTypeId === contentTypes.published.sys.id) {
|
|
96
96
|
return contentTypes.published;
|
|
97
97
|
}
|
|
@@ -28,7 +28,7 @@ function isFeaturingEntitySelector(entitySelectorConfigs = {}) {
|
|
|
28
28
|
return !!entitySelectorConfigs.Entry || !!entitySelectorConfigs.Asset;
|
|
29
29
|
}
|
|
30
30
|
function entityToLink(entity) {
|
|
31
|
-
const { id
|
|
31
|
+
const { id, type } = entity.sys;
|
|
32
32
|
return {
|
|
33
33
|
sys: {
|
|
34
34
|
id,
|
|
@@ -48,7 +48,7 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
|
|
|
48
48
|
}));
|
|
49
49
|
}
|
|
50
50
|
getValue() {
|
|
51
|
-
const { text
|
|
51
|
+
const { text, type, uri } = this.state;
|
|
52
52
|
const value = {
|
|
53
53
|
type
|
|
54
54
|
};
|
|
@@ -63,7 +63,7 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
|
|
|
63
63
|
return value;
|
|
64
64
|
}
|
|
65
65
|
isLinkComplete() {
|
|
66
|
-
const { text
|
|
66
|
+
const { text, type, uri, target } = this.getValue();
|
|
67
67
|
const requiresText = !this.props.hideText;
|
|
68
68
|
if (requiresText && !text) {
|
|
69
69
|
return false;
|
|
@@ -71,7 +71,7 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
|
|
|
71
71
|
return type === LINK_TYPES.URI && uri || target;
|
|
72
72
|
}
|
|
73
73
|
render() {
|
|
74
|
-
const { labels
|
|
74
|
+
const { labels } = this.props;
|
|
75
75
|
return React.createElement(EntityProvider, {
|
|
76
76
|
sdk: this.props.sdk
|
|
77
77
|
}, React.createElement(React.Fragment, null, React.createElement(ModalContent, null, this.renderFields()), React.createElement(ModalControls, null, React.createElement(Button, {
|
|
@@ -90,8 +90,8 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
|
|
|
90
90
|
}, labels.confirm))));
|
|
91
91
|
}
|
|
92
92
|
renderFields() {
|
|
93
|
-
const { hideText
|
|
94
|
-
const { uri
|
|
93
|
+
const { hideText, allowedHyperlinkTypes, entitySelectorConfigs } = this.props;
|
|
94
|
+
const { uri, text, type } = this.state;
|
|
95
95
|
const isUriInputAutoFocused = type === LINK_TYPES.URI && (hideText || !!text);
|
|
96
96
|
return React.createElement(Form, null, hideText ? null : React.createElement(FormControl, {
|
|
97
97
|
id: "link-text",
|
|
@@ -134,7 +134,7 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
|
|
|
134
134
|
}), React.createElement(FormControl.HelpText, null, "A protocol may be required, e.g. https://")) : this.renderEntityField());
|
|
135
135
|
}
|
|
136
136
|
renderEntityField() {
|
|
137
|
-
const { type
|
|
137
|
+
const { type, entityLinks } = this.state;
|
|
138
138
|
const resetEntity = ()=>this.setTargetEntity(type, null);
|
|
139
139
|
const entityLink = entityLinks[type];
|
|
140
140
|
const isEntitySelectorVisible = !entityLink;
|
|
@@ -181,7 +181,7 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
|
|
|
181
181
|
this.props.onClose(this.getValue());
|
|
182
182
|
});
|
|
183
183
|
_define_property(this, "selectEntry", async ()=>{
|
|
184
|
-
const { locale
|
|
184
|
+
const { locale, contentTypes } = this.props.entitySelectorConfigs.Entry;
|
|
185
185
|
const entry = await this.props.sdk.dialogs.selectSingleEntry({
|
|
186
186
|
locale,
|
|
187
187
|
contentTypes
|
|
@@ -189,13 +189,13 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
|
|
|
189
189
|
this.setTargetEntity(LINK_TYPES.ENTRY, entry);
|
|
190
190
|
});
|
|
191
191
|
_define_property(this, "selectAsset", async ()=>{
|
|
192
|
-
const { locale
|
|
192
|
+
const { locale } = this.props.entitySelectorConfigs.Asset;
|
|
193
193
|
const asset = await this.props.sdk.dialogs.selectSingleAsset({
|
|
194
194
|
locale
|
|
195
195
|
});
|
|
196
196
|
this.setTargetEntity(LINK_TYPES.ASSET, asset);
|
|
197
197
|
});
|
|
198
|
-
const { text
|
|
198
|
+
const { text, type, uri, target } = props.value;
|
|
199
199
|
const isEntityLink = Boolean(target);
|
|
200
200
|
const entityLinks = {
|
|
201
201
|
[LINK_TYPES.ENTRY]: null,
|
|
@@ -257,7 +257,7 @@ _define_property(HyperlinkDialog, "defaultProps", {
|
|
|
257
257
|
LINK_TYPES.URI
|
|
258
258
|
]
|
|
259
259
|
});
|
|
260
|
-
export const openHyperlinkDialog = (dialogs, { value
|
|
260
|
+
export const openHyperlinkDialog = (dialogs, { value, showTextInput, allowedHyperlinkTypes, entitySelectorConfigs })=>{
|
|
261
261
|
const isNew = !(value.uri || value.target);
|
|
262
262
|
const props = {
|
|
263
263
|
labels: {
|
|
@@ -3,7 +3,7 @@ import { ModalDialogLauncher } from '@contentful/field-editor-shared';
|
|
|
3
3
|
import { HyperlinkDialog } from './HypelinkDialog/HyperlinkDialog';
|
|
4
4
|
export const openRichTextDialog = (sdk)=>(options)=>{
|
|
5
5
|
if (options.parameters?.type === 'rich-text-hyperlink-dialog') {
|
|
6
|
-
return ModalDialogLauncher.openDialog(options, ({ onClose
|
|
6
|
+
return ModalDialogLauncher.openDialog(options, ({ onClose })=>{
|
|
7
7
|
return React.createElement(HyperlinkDialog, {
|
|
8
8
|
...options.parameters,
|
|
9
9
|
onClose: onClose,
|
|
@@ -107,11 +107,11 @@ export function unwrapLink(editor) {
|
|
|
107
107
|
match: (node)=>!isEditor(node) && isElement(node) && LINK_TYPES.includes(node.type)
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
export function wrapLink(editor, { text
|
|
110
|
+
export function wrapLink(editor, { text, url, target, type, path }) {
|
|
111
111
|
if (isLinkActive(editor) && !path) {
|
|
112
112
|
unwrapLink(editor);
|
|
113
113
|
}
|
|
114
|
-
const { selection
|
|
114
|
+
const { selection } = editor;
|
|
115
115
|
const isCollapsed = selection && isSelectionCollapsed(selection);
|
|
116
116
|
const link = {
|
|
117
117
|
type,
|
|
@@ -166,7 +166,7 @@ export function getNextNode(editor) {
|
|
|
166
166
|
from: editor.selection.focus.path
|
|
167
167
|
});
|
|
168
168
|
while(true){
|
|
169
|
-
const { done
|
|
169
|
+
const { done, value } = descendants.next();
|
|
170
170
|
if (done) {
|
|
171
171
|
return null;
|
|
172
172
|
}
|
|
@@ -8,7 +8,7 @@ export function watchCurrentSlide(navigator) {
|
|
|
8
8
|
wasClosed: wasSlideClosed,
|
|
9
9
|
isActive: !wasSlideClosed && lastSlideLevel === initialSlideLevel
|
|
10
10
|
});
|
|
11
|
-
const off = navigator.onSlideInNavigation(({ oldSlideLevel
|
|
11
|
+
const off = navigator.onSlideInNavigation(({ oldSlideLevel, newSlideLevel })=>{
|
|
12
12
|
if (initialSlideLevel === undefined) {
|
|
13
13
|
initialSlideLevel = oldSlideLevel;
|
|
14
14
|
}
|
|
@@ -7,7 +7,7 @@ import { useSdkContext } from '../../../SdkProvider';
|
|
|
7
7
|
import { useCommandList } from '../hooks/useCommandList';
|
|
8
8
|
import { useCommands } from '../useCommands';
|
|
9
9
|
import styles from './CommandList.styles';
|
|
10
|
-
const Group = ({ commandGroup
|
|
10
|
+
const Group = ({ commandGroup, selectedItem })=>React.createElement("section", {
|
|
11
11
|
key: commandGroup.group
|
|
12
12
|
}, React.createElement(SectionHeading, {
|
|
13
13
|
as: "h3",
|
|
@@ -26,7 +26,7 @@ const Group = ({ commandGroup , selectedItem })=>React.createElement("section",
|
|
|
26
26
|
className: styles.menuDivider,
|
|
27
27
|
"aria-orientation": "horizontal"
|
|
28
28
|
}));
|
|
29
|
-
const Asset = ({ command
|
|
29
|
+
const Asset = ({ command, selectedItem })=>React.createElement("button", {
|
|
30
30
|
key: command.id,
|
|
31
31
|
id: command.id,
|
|
32
32
|
className: cx(styles.menuItem, {
|
|
@@ -47,7 +47,7 @@ const Asset = ({ command , selectedItem })=>React.createElement("button", {
|
|
|
47
47
|
height: "30",
|
|
48
48
|
className: styles.thumbnail
|
|
49
49
|
}), React.createElement("span", null, command.label)));
|
|
50
|
-
const Item = ({ command
|
|
50
|
+
const Item = ({ command, selectedItem })=>React.createElement("button", {
|
|
51
51
|
key: command.id,
|
|
52
52
|
id: command.id,
|
|
53
53
|
className: cx(styles.menuItem, {
|
|
@@ -55,7 +55,7 @@ const Item = ({ command , selectedItem })=>React.createElement("button", {
|
|
|
55
55
|
}),
|
|
56
56
|
onClick: command.callback
|
|
57
57
|
}, command.label);
|
|
58
|
-
const CommandListItems = ({ commandItems
|
|
58
|
+
const CommandListItems = ({ commandItems, selectedItem })=>{
|
|
59
59
|
return React.createElement(React.Fragment, null, commandItems.map((command)=>{
|
|
60
60
|
return 'group' in command ? React.createElement(Group, {
|
|
61
61
|
key: command.group,
|
|
@@ -72,14 +72,14 @@ const CommandListItems = ({ commandItems , selectedItem })=>{
|
|
|
72
72
|
});
|
|
73
73
|
}));
|
|
74
74
|
};
|
|
75
|
-
export const CommandList = ({ query
|
|
75
|
+
export const CommandList = ({ query, editor, textContainer })=>{
|
|
76
76
|
const sdk = useSdkContext();
|
|
77
77
|
const popoverContainer = React.useRef(null);
|
|
78
78
|
const popper = usePopper(textContainer, popoverContainer?.current, {
|
|
79
79
|
placement: 'bottom-start'
|
|
80
80
|
});
|
|
81
81
|
const commandItems = useCommands(sdk, query, editor);
|
|
82
|
-
const { selectedItem
|
|
82
|
+
const { selectedItem, isOpen } = useCommandList(commandItems, popoverContainer);
|
|
83
83
|
if (!commandItems.length) {
|
|
84
84
|
return null;
|
|
85
85
|
}
|
|
@@ -9,7 +9,7 @@ jest.mock('../../internal/transforms', ()=>{
|
|
|
9
9
|
};
|
|
10
10
|
});
|
|
11
11
|
describe('onKeyDown', ()=>{
|
|
12
|
-
const { editor
|
|
12
|
+
const { editor } = createTestEditor({});
|
|
13
13
|
const addMark = jest.spyOn(internal, 'addMark');
|
|
14
14
|
const onCommandPaletteAction = jest.spyOn(editor.tracking, 'onCommandPaletteAction');
|
|
15
15
|
afterEach(()=>{
|
|
@@ -27,7 +27,7 @@ describe('onKeyDown', ()=>{
|
|
|
27
27
|
which: 55,
|
|
28
28
|
shiftKey: true
|
|
29
29
|
}}
|
|
30
|
-
`('supports hotKeys for every keyboard layout #{layout}', ({ key
|
|
30
|
+
`('supports hotKeys for every keyboard layout #{layout}', ({ key })=>{
|
|
31
31
|
createOnKeyDown()(editor, {})({
|
|
32
32
|
type: 'keydown',
|
|
33
33
|
...key
|
|
@@ -39,7 +39,7 @@ export function isCommandPromptPluginEnabled(sdk) {
|
|
|
39
39
|
}
|
|
40
40
|
function getCommandPermissions(sdk, editor) {
|
|
41
41
|
const canInsertBlocks = !isNodeTypeSelected(editor, BLOCKS.TABLE);
|
|
42
|
-
const { inlineAllowed
|
|
42
|
+
const { inlineAllowed, entriesAllowed, assetsAllowed } = isCommandPromptPluginEnabled(sdk);
|
|
43
43
|
return {
|
|
44
44
|
inlineAllowed,
|
|
45
45
|
entriesAllowed: entriesAllowed && canInsertBlocks,
|
|
@@ -68,7 +68,7 @@ const getAllowedContentTypesFromValidation = (validations)=>{
|
|
|
68
68
|
};
|
|
69
69
|
export const useCommands = (sdk, query, editor)=>{
|
|
70
70
|
const contentTypes = sdk.space.getCachedContentTypes();
|
|
71
|
-
const { inlineAllowed
|
|
71
|
+
const { inlineAllowed, entriesAllowed, assetsAllowed } = getCommandPermissions(sdk, editor);
|
|
72
72
|
const allowedContentTypesFromValidation = getAllowedContentTypesFromValidation(sdk.field.validations);
|
|
73
73
|
const filterContentTypesByValidation = (type)=>contentTypes.filter((contentType)=>allowedContentTypesFromValidation[type]?.[contentType.sys.id]);
|
|
74
74
|
const filteredBlockContentTypes = filterContentTypesByValidation(BLOCKS.EMBEDDED_ENTRY);
|
|
@@ -9,13 +9,13 @@ import { FetchingWrappedAssetCard } from '../shared/FetchingWrappedAssetCard';
|
|
|
9
9
|
import { FetchingWrappedEntryCard } from '../shared/FetchingWrappedEntryCard';
|
|
10
10
|
import { LinkedBlockWrapper } from '../shared/LinkedBlockWrapper';
|
|
11
11
|
export function LinkedEntityBlock(props) {
|
|
12
|
-
const { attributes
|
|
13
|
-
const { onEntityFetchComplete
|
|
12
|
+
const { attributes, children, element } = props;
|
|
13
|
+
const { onEntityFetchComplete } = useLinkTracking();
|
|
14
14
|
const isSelected = useSelected();
|
|
15
15
|
const editor = useContentfulEditor();
|
|
16
16
|
const sdk = useSdkContext();
|
|
17
17
|
const isDisabled = useReadOnly();
|
|
18
|
-
const { id: entityId
|
|
18
|
+
const { id: entityId, linkType: entityType } = element.data.target.sys;
|
|
19
19
|
const handleEditClick = React.useCallback(()=>{
|
|
20
20
|
const openEntity = entityType === 'Asset' ? sdk.navigator.openAsset : sdk.navigator.openEntry;
|
|
21
21
|
return openEntity(entityId, {
|
|
@@ -6,7 +6,7 @@ import { ScheduledIconWithTooltip, useEntity, useEntityLoader } from '@contentfu
|
|
|
6
6
|
import { entityHelpers } from '@contentful/field-editor-shared';
|
|
7
7
|
import { INLINES } from '@contentful/rich-text-types';
|
|
8
8
|
import { css } from 'emotion';
|
|
9
|
-
const { getEntryTitle
|
|
9
|
+
const { getEntryTitle, getEntryStatus } = entityHelpers;
|
|
10
10
|
const styles = {
|
|
11
11
|
scheduledIcon: css({
|
|
12
12
|
verticalAlign: 'text-bottom',
|
|
@@ -14,11 +14,11 @@ const styles = {
|
|
|
14
14
|
})
|
|
15
15
|
};
|
|
16
16
|
export function FetchingWrappedInlineEntryCard(props) {
|
|
17
|
-
const { data: entry
|
|
18
|
-
const { getEntityScheduledActions
|
|
17
|
+
const { data: entry, status: requestStatus } = useEntity('Entry', props.entryId);
|
|
18
|
+
const { getEntityScheduledActions } = useEntityLoader();
|
|
19
19
|
const loadEntityScheduledActions = ()=>getEntityScheduledActions('Entry', props.entryId);
|
|
20
20
|
const allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
21
|
-
const { onEntityFetchComplete
|
|
21
|
+
const { onEntityFetchComplete } = props;
|
|
22
22
|
const contentType = React.useMemo(()=>{
|
|
23
23
|
if (!entry || !allContentTypes) return undefined;
|
|
24
24
|
return allContentTypes.find((contentType)=>contentType.sys.id === entry.sys.contentType.sys.id);
|
|
@@ -9,13 +9,13 @@ import { useLinkTracking } from '../links-tracking';
|
|
|
9
9
|
import { LinkedInlineWrapper } from '../shared/LinkedInlineWrapper';
|
|
10
10
|
import { FetchingWrappedInlineEntryCard } from './FetchingWrappedInlineEntryCard';
|
|
11
11
|
export function LinkedEntityInline(props) {
|
|
12
|
-
const { attributes
|
|
13
|
-
const { onEntityFetchComplete
|
|
12
|
+
const { attributes, children, element } = props;
|
|
13
|
+
const { onEntityFetchComplete } = useLinkTracking();
|
|
14
14
|
const isSelected = useSelected();
|
|
15
15
|
const editor = useContentfulEditor();
|
|
16
16
|
const sdk = useSdkContext();
|
|
17
17
|
const isDisabled = useReadOnly();
|
|
18
|
-
const { id: entryId
|
|
18
|
+
const { id: entryId } = element.data.target.sys;
|
|
19
19
|
function handleEditClick() {
|
|
20
20
|
return sdk.navigator.openEntry(entryId, {
|
|
21
21
|
slideIn: {
|