@contentful/field-editor-rich-text 6.4.0 → 6.4.1-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +1 -1
- package/dist/cjs/plugins/EmbeddedEntityInline/__tests__/FetchingWrappedInlineEntryCard.test.js +96 -0
- package/dist/cjs/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +2 -1
- package/dist/cjs/plugins/EmbeddedResourceInline/__tests__/FetchingWrappedResourceInlineCard.test.js +91 -0
- package/dist/cjs/plugins/Hyperlink/useResourceEntityInfo.js +2 -1
- package/dist/cjs/plugins/shared/FetchingWrappedAssetCard.js +2 -1
- package/dist/cjs/plugins/shared/FetchingWrappedEntryCard.js +1 -1
- package/dist/cjs/plugins/shared/FetchingWrappedResourceCard.js +2 -1
- package/dist/esm/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +2 -2
- package/dist/esm/plugins/EmbeddedEntityInline/__tests__/FetchingWrappedInlineEntryCard.test.js +51 -0
- package/dist/esm/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +2 -1
- package/dist/esm/plugins/EmbeddedResourceInline/__tests__/FetchingWrappedResourceInlineCard.test.js +46 -0
- package/dist/esm/plugins/Hyperlink/useResourceEntityInfo.js +2 -1
- package/dist/esm/plugins/shared/FetchingWrappedAssetCard.js +2 -1
- package/dist/esm/plugins/shared/FetchingWrappedEntryCard.js +2 -2
- package/dist/esm/plugins/shared/FetchingWrappedResourceCard.js +2 -1
- package/dist/types/plugins/EmbeddedEntityInline/__tests__/FetchingWrappedInlineEntryCard.test.d.ts +1 -0
- package/dist/types/plugins/EmbeddedResourceInline/__tests__/FetchingWrappedResourceInlineCard.test.d.ts +1 -0
- package/package.json +4 -4
|
@@ -127,7 +127,7 @@ function InternalFetchingWrappedInlineEntryCardWrapper(props) {
|
|
|
127
127
|
requestStatus,
|
|
128
128
|
onEntityFetchComplete
|
|
129
129
|
]);
|
|
130
|
-
if (
|
|
130
|
+
if ((0, _reactquery.isLoadingStatus)(requestStatus)) {
|
|
131
131
|
return /*#__PURE__*/ _react.createElement(_f36components.InlineEntryCard, {
|
|
132
132
|
isLoading: true
|
|
133
133
|
});
|
package/dist/cjs/plugins/EmbeddedEntityInline/__tests__/FetchingWrappedInlineEntryCard.test.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
6
|
+
const _react1 = require("@testing-library/react");
|
|
7
|
+
const _vitest = require("vitest");
|
|
8
|
+
const _FetchingWrappedInlineEntryCard = require("../FetchingWrappedInlineEntryCard");
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
10
|
+
if (typeof WeakMap !== "function") return null;
|
|
11
|
+
var cacheBabelInterop = new WeakMap();
|
|
12
|
+
var cacheNodeInterop = new WeakMap();
|
|
13
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
14
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
15
|
+
})(nodeInterop);
|
|
16
|
+
}
|
|
17
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
18
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
19
|
+
return obj;
|
|
20
|
+
}
|
|
21
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
22
|
+
return {
|
|
23
|
+
default: obj
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
27
|
+
if (cache && cache.has(obj)) {
|
|
28
|
+
return cache.get(obj);
|
|
29
|
+
}
|
|
30
|
+
var newObj = {
|
|
31
|
+
__proto__: null
|
|
32
|
+
};
|
|
33
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
34
|
+
for(var key in obj){
|
|
35
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
36
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
37
|
+
if (desc && (desc.get || desc.set)) {
|
|
38
|
+
Object.defineProperty(newObj, key, desc);
|
|
39
|
+
} else {
|
|
40
|
+
newObj[key] = obj[key];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
newObj.default = obj;
|
|
45
|
+
if (cache) {
|
|
46
|
+
cache.set(obj, newObj);
|
|
47
|
+
}
|
|
48
|
+
return newObj;
|
|
49
|
+
}
|
|
50
|
+
_vitest.vi.mock('@contentful/field-editor-reference', async ()=>{
|
|
51
|
+
const actual = await _vitest.vi.importActual('@contentful/field-editor-reference');
|
|
52
|
+
return {
|
|
53
|
+
...actual,
|
|
54
|
+
useEntity: ()=>({
|
|
55
|
+
data: undefined,
|
|
56
|
+
status: 'pending'
|
|
57
|
+
}),
|
|
58
|
+
useEntityLoader: ()=>({
|
|
59
|
+
getEntityScheduledActions: ()=>Promise.resolve([])
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
_vitest.vi.mock('@contentful/field-editor-shared/react-query', async (importOriginal)=>{
|
|
64
|
+
const actual = await importOriginal();
|
|
65
|
+
return {
|
|
66
|
+
...actual,
|
|
67
|
+
useContentType: ()=>({
|
|
68
|
+
data: undefined
|
|
69
|
+
})
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
(0, _react1.configure)({
|
|
73
|
+
testIdAttribute: 'data-test-id'
|
|
74
|
+
});
|
|
75
|
+
const sdk = {
|
|
76
|
+
field: {
|
|
77
|
+
locale: 'en-US'
|
|
78
|
+
},
|
|
79
|
+
locales: {
|
|
80
|
+
default: 'en-US'
|
|
81
|
+
},
|
|
82
|
+
parameters: {
|
|
83
|
+
instance: {}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
(0, _vitest.test)("renders the loading card when useEntity returns status: 'pending' (react-query v5)", ()=>{
|
|
87
|
+
const { container } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_FetchingWrappedInlineEntryCard.FetchingWrappedInlineEntryCard, {
|
|
88
|
+
sdk: sdk,
|
|
89
|
+
entryId: "entry-id",
|
|
90
|
+
isSelected: false,
|
|
91
|
+
isDisabled: false,
|
|
92
|
+
onEdit: ()=>{},
|
|
93
|
+
onRemove: ()=>{}
|
|
94
|
+
}));
|
|
95
|
+
(0, _vitest.expect)(container.querySelector('[data-test-id="cf-ui-skeleton-form"]')).not.toBeNull();
|
|
96
|
+
});
|
|
@@ -12,6 +12,7 @@ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
13
|
const _fieldeditorreference = require("@contentful/field-editor-reference");
|
|
14
14
|
const _fieldeditorshared = require("@contentful/field-editor-shared");
|
|
15
|
+
const _reactquery = require("@contentful/field-editor-shared/react-query");
|
|
15
16
|
const _richtexttypes = require("@contentful/rich-text-types");
|
|
16
17
|
const _utils = require("../../plugins/shared/utils");
|
|
17
18
|
function _getRequireWildcardCache(nodeInterop) {
|
|
@@ -77,7 +78,7 @@ function FetchingWrappedResourceInlineCard(props) {
|
|
|
77
78
|
isSelected: props.isSelected
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
|
-
if (requestStatus
|
|
81
|
+
if ((0, _reactquery.isLoadingStatus)(requestStatus) || data === undefined) {
|
|
81
82
|
return /*#__PURE__*/ _react.createElement(_f36components.InlineEntryCard, {
|
|
82
83
|
isLoading: true
|
|
83
84
|
});
|
package/dist/cjs/plugins/EmbeddedResourceInline/__tests__/FetchingWrappedResourceInlineCard.test.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
6
|
+
const _react1 = require("@testing-library/react");
|
|
7
|
+
const _vitest = require("vitest");
|
|
8
|
+
const _FetchingWrappedResourceInlineCard = require("../FetchingWrappedResourceInlineCard");
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
10
|
+
if (typeof WeakMap !== "function") return null;
|
|
11
|
+
var cacheBabelInterop = new WeakMap();
|
|
12
|
+
var cacheNodeInterop = new WeakMap();
|
|
13
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
14
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
15
|
+
})(nodeInterop);
|
|
16
|
+
}
|
|
17
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
18
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
19
|
+
return obj;
|
|
20
|
+
}
|
|
21
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
22
|
+
return {
|
|
23
|
+
default: obj
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
27
|
+
if (cache && cache.has(obj)) {
|
|
28
|
+
return cache.get(obj);
|
|
29
|
+
}
|
|
30
|
+
var newObj = {
|
|
31
|
+
__proto__: null
|
|
32
|
+
};
|
|
33
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
34
|
+
for(var key in obj){
|
|
35
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
36
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
37
|
+
if (desc && (desc.get || desc.set)) {
|
|
38
|
+
Object.defineProperty(newObj, key, desc);
|
|
39
|
+
} else {
|
|
40
|
+
newObj[key] = obj[key];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
newObj.default = obj;
|
|
45
|
+
if (cache) {
|
|
46
|
+
cache.set(obj, newObj);
|
|
47
|
+
}
|
|
48
|
+
return newObj;
|
|
49
|
+
}
|
|
50
|
+
_vitest.vi.mock('@contentful/field-editor-reference', async ()=>{
|
|
51
|
+
const actual = await _vitest.vi.importActual('@contentful/field-editor-reference');
|
|
52
|
+
return {
|
|
53
|
+
...actual,
|
|
54
|
+
useResource: ()=>({
|
|
55
|
+
data: {
|
|
56
|
+
fake: true
|
|
57
|
+
},
|
|
58
|
+
status: 'pending'
|
|
59
|
+
})
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
(0, _react1.configure)({
|
|
63
|
+
testIdAttribute: 'data-test-id'
|
|
64
|
+
});
|
|
65
|
+
const sdk = {
|
|
66
|
+
field: {
|
|
67
|
+
locale: 'en-US'
|
|
68
|
+
},
|
|
69
|
+
ids: {
|
|
70
|
+
entry: 'entry-id'
|
|
71
|
+
},
|
|
72
|
+
parameters: {
|
|
73
|
+
instance: {}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const link = {
|
|
77
|
+
linkType: 'Contentful:Entry',
|
|
78
|
+
urn: 'crn:contentful:::content:spaces/s/environments/e/entries/target',
|
|
79
|
+
type: 'ResourceLink'
|
|
80
|
+
};
|
|
81
|
+
(0, _vitest.test)("renders the loading card when useResource returns status: 'pending' (react-query v5)", ()=>{
|
|
82
|
+
const { container } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_FetchingWrappedResourceInlineCard.FetchingWrappedResourceInlineCard, {
|
|
83
|
+
link: link,
|
|
84
|
+
sdk: sdk,
|
|
85
|
+
isSelected: false,
|
|
86
|
+
isDisabled: false,
|
|
87
|
+
onRemove: ()=>{}
|
|
88
|
+
}));
|
|
89
|
+
(0, _vitest.expect)(container.firstChild).not.toBeNull();
|
|
90
|
+
(0, _vitest.expect)(container.textContent).not.toContain('Untitled');
|
|
91
|
+
});
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "useResourceEntityInfo", {
|
|
|
10
10
|
});
|
|
11
11
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
const _fieldeditorreference = require("@contentful/field-editor-reference");
|
|
13
|
+
const _reactquery = require("@contentful/field-editor-shared/react-query");
|
|
13
14
|
const _utils = require("../../plugins/shared/utils");
|
|
14
15
|
function _getRequireWildcardCache(nodeInterop) {
|
|
15
16
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -62,7 +63,7 @@ function useResourceEntityInfo({ onEntityFetchComplete, target }) {
|
|
|
62
63
|
status,
|
|
63
64
|
onEntityFetchComplete
|
|
64
65
|
]);
|
|
65
|
-
if (
|
|
66
|
+
if ((0, _reactquery.isLoadingStatus)(status)) {
|
|
66
67
|
return `Loading entry...`;
|
|
67
68
|
}
|
|
68
69
|
if (!data || error) {
|
|
@@ -12,6 +12,7 @@ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
13
|
const _fieldeditorreference = require("@contentful/field-editor-reference");
|
|
14
14
|
const _fieldeditorshared = require("@contentful/field-editor-shared");
|
|
15
|
+
const _reactquery = require("@contentful/field-editor-shared/react-query");
|
|
15
16
|
const _fastdeepequal = /*#__PURE__*/ _interop_require_default(require("fast-deep-equal"));
|
|
16
17
|
function _interop_require_default(obj) {
|
|
17
18
|
return obj && obj.__esModule ? obj : {
|
|
@@ -109,7 +110,7 @@ function FetchingWrappedAssetCard(props) {
|
|
|
109
110
|
onEntityFetchComplete,
|
|
110
111
|
status
|
|
111
112
|
]);
|
|
112
|
-
if (
|
|
113
|
+
if ((0, _reactquery.isLoadingStatus)(status)) {
|
|
113
114
|
return /*#__PURE__*/ _react.createElement(_f36components.AssetCard, {
|
|
114
115
|
size: "default",
|
|
115
116
|
isLoading: true
|
|
@@ -118,7 +118,7 @@ const InternalFetchingWrappedEntryCard = (props)=>{
|
|
|
118
118
|
onEntityFetchComplete,
|
|
119
119
|
status
|
|
120
120
|
]);
|
|
121
|
-
if (
|
|
121
|
+
if ((0, _reactquery.isLoadingStatus)(status)) {
|
|
122
122
|
return /*#__PURE__*/ _react.createElement(_f36components.EntryCard, {
|
|
123
123
|
isLoading: true
|
|
124
124
|
});
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "FetchingWrappedResourceCard", {
|
|
|
11
11
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
13
|
const _fieldeditorreference = require("@contentful/field-editor-reference");
|
|
14
|
+
const _reactquery = require("@contentful/field-editor-shared/react-query");
|
|
14
15
|
const _fastdeepequal = /*#__PURE__*/ _interop_require_default(require("fast-deep-equal"));
|
|
15
16
|
function _interop_require_default(obj) {
|
|
16
17
|
return obj && obj.__esModule ? obj : {
|
|
@@ -59,7 +60,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
59
60
|
return newObj;
|
|
60
61
|
}
|
|
61
62
|
const InternalEntryCard = /*#__PURE__*/ _react.memo((props)=>{
|
|
62
|
-
if (props.data === undefined ||
|
|
63
|
+
if (props.data === undefined || (0, _reactquery.isLoadingStatus)(props.status)) {
|
|
63
64
|
return /*#__PURE__*/ _react.createElement(_f36components.EntryCard, {
|
|
64
65
|
isLoading: true
|
|
65
66
|
});
|
|
@@ -4,7 +4,7 @@ import { ClockIcon } from '@contentful/f36-icons';
|
|
|
4
4
|
import tokens from '@contentful/f36-tokens';
|
|
5
5
|
import { ScheduledIconWithTooltip, useEntity, useEntityLoader } from '@contentful/field-editor-reference';
|
|
6
6
|
import { entityHelpers } from '@contentful/field-editor-shared';
|
|
7
|
-
import { SharedQueryClientProvider, useContentType } from '@contentful/field-editor-shared/react-query';
|
|
7
|
+
import { SharedQueryClientProvider, isLoadingStatus, useContentType } from '@contentful/field-editor-shared/react-query';
|
|
8
8
|
import { INLINES } from '@contentful/rich-text-types';
|
|
9
9
|
import { css } from '@emotion/css';
|
|
10
10
|
const { getEntryTitle, getEntityStatus } = entityHelpers;
|
|
@@ -71,7 +71,7 @@ function InternalFetchingWrappedInlineEntryCardWrapper(props) {
|
|
|
71
71
|
requestStatus,
|
|
72
72
|
onEntityFetchComplete
|
|
73
73
|
]);
|
|
74
|
-
if (requestStatus
|
|
74
|
+
if (isLoadingStatus(requestStatus)) {
|
|
75
75
|
return /*#__PURE__*/ React.createElement(InlineEntryCard, {
|
|
76
76
|
isLoading: true
|
|
77
77
|
});
|
package/dist/esm/plugins/EmbeddedEntityInline/__tests__/FetchingWrappedInlineEntryCard.test.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { configure, render } from '@testing-library/react';
|
|
3
|
+
import { expect, test, vi } from 'vitest';
|
|
4
|
+
vi.mock('@contentful/field-editor-reference', async ()=>{
|
|
5
|
+
const actual = await vi.importActual('@contentful/field-editor-reference');
|
|
6
|
+
return {
|
|
7
|
+
...actual,
|
|
8
|
+
useEntity: ()=>({
|
|
9
|
+
data: undefined,
|
|
10
|
+
status: 'pending'
|
|
11
|
+
}),
|
|
12
|
+
useEntityLoader: ()=>({
|
|
13
|
+
getEntityScheduledActions: ()=>Promise.resolve([])
|
|
14
|
+
})
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
vi.mock('@contentful/field-editor-shared/react-query', async (importOriginal)=>{
|
|
18
|
+
const actual = await importOriginal();
|
|
19
|
+
return {
|
|
20
|
+
...actual,
|
|
21
|
+
useContentType: ()=>({
|
|
22
|
+
data: undefined
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
import { FetchingWrappedInlineEntryCard } from '../FetchingWrappedInlineEntryCard';
|
|
27
|
+
configure({
|
|
28
|
+
testIdAttribute: 'data-test-id'
|
|
29
|
+
});
|
|
30
|
+
const sdk = {
|
|
31
|
+
field: {
|
|
32
|
+
locale: 'en-US'
|
|
33
|
+
},
|
|
34
|
+
locales: {
|
|
35
|
+
default: 'en-US'
|
|
36
|
+
},
|
|
37
|
+
parameters: {
|
|
38
|
+
instance: {}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
test("renders the loading card when useEntity returns status: 'pending' (react-query v5)", ()=>{
|
|
42
|
+
const { container } = render(/*#__PURE__*/ React.createElement(FetchingWrappedInlineEntryCard, {
|
|
43
|
+
sdk: sdk,
|
|
44
|
+
entryId: "entry-id",
|
|
45
|
+
isSelected: false,
|
|
46
|
+
isDisabled: false,
|
|
47
|
+
onEdit: ()=>{},
|
|
48
|
+
onRemove: ()=>{}
|
|
49
|
+
}));
|
|
50
|
+
expect(container.querySelector('[data-test-id="cf-ui-skeleton-form"]')).not.toBeNull();
|
|
51
|
+
});
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { InlineEntryCard, MenuItem, Text } from '@contentful/f36-components';
|
|
3
3
|
import { useResource } from '@contentful/field-editor-reference';
|
|
4
4
|
import { entityHelpers } from '@contentful/field-editor-shared';
|
|
5
|
+
import { isLoadingStatus } from '@contentful/field-editor-shared/react-query';
|
|
5
6
|
import { INLINES } from '@contentful/rich-text-types';
|
|
6
7
|
import { truncateTitle } from '../../plugins/shared/utils';
|
|
7
8
|
const { getEntryTitle, getEntityStatus } = entityHelpers;
|
|
@@ -26,7 +27,7 @@ export function FetchingWrappedResourceInlineCard(props) {
|
|
|
26
27
|
isSelected: props.isSelected
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
|
-
if (requestStatus
|
|
30
|
+
if (isLoadingStatus(requestStatus) || data === undefined) {
|
|
30
31
|
return /*#__PURE__*/ React.createElement(InlineEntryCard, {
|
|
31
32
|
isLoading: true
|
|
32
33
|
});
|
package/dist/esm/plugins/EmbeddedResourceInline/__tests__/FetchingWrappedResourceInlineCard.test.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { configure, render } from '@testing-library/react';
|
|
3
|
+
import { expect, test, vi } from 'vitest';
|
|
4
|
+
vi.mock('@contentful/field-editor-reference', async ()=>{
|
|
5
|
+
const actual = await vi.importActual('@contentful/field-editor-reference');
|
|
6
|
+
return {
|
|
7
|
+
...actual,
|
|
8
|
+
useResource: ()=>({
|
|
9
|
+
data: {
|
|
10
|
+
fake: true
|
|
11
|
+
},
|
|
12
|
+
status: 'pending'
|
|
13
|
+
})
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
import { FetchingWrappedResourceInlineCard } from '../FetchingWrappedResourceInlineCard';
|
|
17
|
+
configure({
|
|
18
|
+
testIdAttribute: 'data-test-id'
|
|
19
|
+
});
|
|
20
|
+
const sdk = {
|
|
21
|
+
field: {
|
|
22
|
+
locale: 'en-US'
|
|
23
|
+
},
|
|
24
|
+
ids: {
|
|
25
|
+
entry: 'entry-id'
|
|
26
|
+
},
|
|
27
|
+
parameters: {
|
|
28
|
+
instance: {}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const link = {
|
|
32
|
+
linkType: 'Contentful:Entry',
|
|
33
|
+
urn: 'crn:contentful:::content:spaces/s/environments/e/entries/target',
|
|
34
|
+
type: 'ResourceLink'
|
|
35
|
+
};
|
|
36
|
+
test("renders the loading card when useResource returns status: 'pending' (react-query v5)", ()=>{
|
|
37
|
+
const { container } = render(/*#__PURE__*/ React.createElement(FetchingWrappedResourceInlineCard, {
|
|
38
|
+
link: link,
|
|
39
|
+
sdk: sdk,
|
|
40
|
+
isSelected: false,
|
|
41
|
+
isDisabled: false,
|
|
42
|
+
onRemove: ()=>{}
|
|
43
|
+
}));
|
|
44
|
+
expect(container.firstChild).not.toBeNull();
|
|
45
|
+
expect(container.textContent).not.toContain('Untitled');
|
|
46
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useResource } from '@contentful/field-editor-reference';
|
|
3
|
+
import { isLoadingStatus } from '@contentful/field-editor-shared/react-query';
|
|
3
4
|
import { truncateTitle } from '../../plugins/shared/utils';
|
|
4
5
|
export function useResourceEntityInfo({ onEntityFetchComplete, target }) {
|
|
5
6
|
const { data, error, status } = useResource(target.sys.linkType, target.sys.urn);
|
|
@@ -11,7 +12,7 @@ export function useResourceEntityInfo({ onEntityFetchComplete, target }) {
|
|
|
11
12
|
status,
|
|
12
13
|
onEntityFetchComplete
|
|
13
14
|
]);
|
|
14
|
-
if (status
|
|
15
|
+
if (isLoadingStatus(status)) {
|
|
15
16
|
return `Loading entry...`;
|
|
16
17
|
}
|
|
17
18
|
if (!data || error) {
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { AssetCard, DragHandle } from '@contentful/f36-components';
|
|
3
3
|
import { useEntity, useEntityLoader, MissingEntityCard, WrappedAssetCard } from '@contentful/field-editor-reference';
|
|
4
4
|
import { useLocalePublishStatus, useActiveLocales, useReleaseStatus } from '@contentful/field-editor-shared';
|
|
5
|
+
import { isLoadingStatus } from '@contentful/field-editor-shared/react-query';
|
|
5
6
|
import areEqual from 'fast-deep-equal';
|
|
6
7
|
const InternalAssetCard = /*#__PURE__*/ React.memo(({ asset, sdk, isDisabled, isSelected, locale, onEdit, onRemove, loadEntityScheduledActions, localesStatusMap, release, releaseStatusMap, releaseEntityStatus })=>{
|
|
7
8
|
const activeLocales = useActiveLocales(sdk);
|
|
@@ -53,7 +54,7 @@ export function FetchingWrappedAssetCard(props) {
|
|
|
53
54
|
onEntityFetchComplete,
|
|
54
55
|
status
|
|
55
56
|
]);
|
|
56
|
-
if (status
|
|
57
|
+
if (isLoadingStatus(status)) {
|
|
57
58
|
return /*#__PURE__*/ React.createElement(AssetCard, {
|
|
58
59
|
size: "default",
|
|
59
60
|
isLoading: true
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { DragHandle, EntryCard } from '@contentful/f36-components';
|
|
3
3
|
import { useEntity, MissingEntityCard, WrappedEntryCard, useEntityLoader } from '@contentful/field-editor-reference';
|
|
4
4
|
import { useLocalePublishStatus, useActiveLocales, useReleaseStatus } from '@contentful/field-editor-shared';
|
|
5
|
-
import { SharedQueryClientProvider, useContentType } from '@contentful/field-editor-shared/react-query';
|
|
5
|
+
import { isLoadingStatus, SharedQueryClientProvider, useContentType } from '@contentful/field-editor-shared/react-query';
|
|
6
6
|
import areEqual from 'fast-deep-equal';
|
|
7
7
|
const InternalEntryCard = /*#__PURE__*/ React.memo(({ entry, sdk, loadEntityScheduledActions, releaseStatusMap, release, releaseEntityStatus, isSelected, isDisabled, locale, contentType, onEdit, onRemove, localesStatusMap })=>{
|
|
8
8
|
const activeLocales = useActiveLocales(sdk);
|
|
@@ -62,7 +62,7 @@ const InternalFetchingWrappedEntryCard = (props)=>{
|
|
|
62
62
|
onEntityFetchComplete,
|
|
63
63
|
status
|
|
64
64
|
]);
|
|
65
|
-
if (status
|
|
65
|
+
if (isLoadingStatus(status)) {
|
|
66
66
|
return /*#__PURE__*/ React.createElement(EntryCard, {
|
|
67
67
|
isLoading: true
|
|
68
68
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DragHandle, EntryCard } from '@contentful/f36-components';
|
|
3
3
|
import { ResourceEntityErrorCard, WrappedEntryCard, useResource } from '@contentful/field-editor-reference';
|
|
4
|
+
import { isLoadingStatus } from '@contentful/field-editor-shared/react-query';
|
|
4
5
|
import areEqual from 'fast-deep-equal';
|
|
5
6
|
const InternalEntryCard = /*#__PURE__*/ React.memo((props)=>{
|
|
6
|
-
if (props.data === undefined || props.status
|
|
7
|
+
if (props.data === undefined || isLoadingStatus(props.status)) {
|
|
7
8
|
return /*#__PURE__*/ React.createElement(EntryCard, {
|
|
8
9
|
isLoading: true
|
|
9
10
|
});
|
package/dist/types/plugins/EmbeddedEntityInline/__tests__/FetchingWrappedInlineEntryCard.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-rich-text",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.1-canary.2+060cdf6a",
|
|
4
4
|
"source": "./src/index.tsx",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@contentful/f36-icons": "^6.7.1",
|
|
46
46
|
"@contentful/f36-tokens": "^6.1.2",
|
|
47
47
|
"@contentful/f36-utils": "^6.1.0",
|
|
48
|
-
"@contentful/field-editor-reference": "^8.4.
|
|
49
|
-
"@contentful/field-editor-shared": "^4.5.
|
|
48
|
+
"@contentful/field-editor-reference": "^8.4.1-canary.2+060cdf6a",
|
|
49
|
+
"@contentful/field-editor-shared": "^4.5.1-canary.2+060cdf6a",
|
|
50
50
|
"@contentful/rich-text-plain-text-renderer": "^17.0.0",
|
|
51
51
|
"@contentful/rich-text-types": "^17.2.5",
|
|
52
52
|
"@emotion/css": "^11.13.5",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"publishConfig": {
|
|
95
95
|
"registry": "https://npm.pkg.github.com/"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "060cdf6a8238b1e17edb97c387686eed72ae7141"
|
|
98
98
|
}
|