@contentful/field-editor-rich-text 3.20.1 → 3.20.3

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.
@@ -69,19 +69,59 @@ const styles = {
69
69
  marginRight: _f36tokens.default.spacing2Xs
70
70
  })
71
71
  };
72
- function FetchingWrappedInlineEntryCard(props) {
73
- const { data: entry, status: requestStatus } = (0, _fieldeditorreference.useEntity)('Entry', props.entryId);
74
- const { getEntityScheduledActions } = (0, _fieldeditorreference.useEntityLoader)();
75
- const loadEntityScheduledActions = ()=>getEntityScheduledActions('Entry', props.entryId);
76
- const allContentTypes = props.sdk.space.getCachedContentTypes();
77
- const { onEntityFetchComplete } = props;
72
+ function InternalFetchingWrappedInlineEntryCard({ entry, allContentTypes, locale, defaultLocale, isSelected, entryStatus, getEntityScheduledActions, onEdit, onRemove, isDisabled }) {
78
73
  const contentType = _react.useMemo(()=>{
79
- if (!entry || !allContentTypes) return undefined;
74
+ if (!allContentTypes) {
75
+ return undefined;
76
+ }
80
77
  return allContentTypes.find((contentType)=>contentType.sys.id === entry.sys.contentType.sys.id);
81
78
  }, [
82
79
  allContentTypes,
83
80
  entry
84
81
  ]);
82
+ const title = _react.useMemo(()=>getEntryTitle({
83
+ entry,
84
+ contentType,
85
+ localeCode: locale,
86
+ defaultLocaleCode: defaultLocale,
87
+ defaultTitle: 'Untitled'
88
+ }), [
89
+ entry,
90
+ contentType,
91
+ locale,
92
+ defaultLocale
93
+ ]);
94
+ return _react.createElement(_f36components.InlineEntryCard, {
95
+ testId: _richtexttypes.INLINES.EMBEDDED_ENTRY,
96
+ isSelected: isSelected,
97
+ title: contentType ? `${contentType.name}: ${title}` : title,
98
+ status: entryStatus,
99
+ actions: [
100
+ _react.createElement(_f36components.MenuItem, {
101
+ key: "edit",
102
+ onClick: onEdit
103
+ }, "Edit"),
104
+ _react.createElement(_f36components.MenuItem, {
105
+ key: "remove",
106
+ onClick: onRemove,
107
+ disabled: isDisabled,
108
+ testId: "delete"
109
+ }, "Remove")
110
+ ]
111
+ }, _react.createElement(_fieldeditorreference.ScheduledIconWithTooltip, {
112
+ getEntityScheduledActions: getEntityScheduledActions,
113
+ entityType: "Entry",
114
+ entityId: entry.sys.id
115
+ }, _react.createElement(_f36icons.ClockIcon, {
116
+ className: styles.scheduledIcon,
117
+ variant: "muted",
118
+ testId: "scheduled-icon"
119
+ })), _react.createElement(_f36components.Text, null, title));
120
+ }
121
+ function FetchingWrappedInlineEntryCard(props) {
122
+ const { data: entry, status: requestStatus } = (0, _fieldeditorreference.useEntity)('Entry', props.entryId);
123
+ const { getEntityScheduledActions } = (0, _fieldeditorreference.useEntityLoader)();
124
+ const { onEntityFetchComplete } = props;
85
125
  _react.useEffect(()=>{
86
126
  if (requestStatus !== 'success') {
87
127
  return;
@@ -91,19 +131,11 @@ function FetchingWrappedInlineEntryCard(props) {
91
131
  requestStatus,
92
132
  onEntityFetchComplete
93
133
  ]);
94
- const contentTypeName = contentType ? contentType.name : '';
95
- const title = _react.useMemo(()=>getEntryTitle({
96
- entry,
97
- contentType,
98
- localeCode: props.sdk.field.locale,
99
- defaultLocaleCode: props.sdk.locales.default,
100
- defaultTitle: 'Untitled'
101
- }), [
102
- entry,
103
- contentType,
104
- props.sdk.field.locale,
105
- props.sdk.locales.default
106
- ]);
134
+ if (requestStatus === 'loading' || requestStatus === 'idle') {
135
+ return _react.createElement(_f36components.InlineEntryCard, {
136
+ isLoading: true
137
+ });
138
+ }
107
139
  if (requestStatus === 'error') {
108
140
  return _react.createElement(_f36components.InlineEntryCard, {
109
141
  title: "Content missing or inaccessible",
@@ -111,11 +143,6 @@ function FetchingWrappedInlineEntryCard(props) {
111
143
  isSelected: props.isSelected
112
144
  });
113
145
  }
114
- if (requestStatus === 'loading') {
115
- return _react.createElement(_f36components.InlineEntryCard, {
116
- isLoading: true
117
- });
118
- }
119
146
  const entryStatus = getEntryStatus(entry.sys);
120
147
  if (entryStatus === 'deleted') {
121
148
  return _react.createElement(_f36components.InlineEntryCard, {
@@ -131,30 +158,16 @@ function FetchingWrappedInlineEntryCard(props) {
131
158
  ]
132
159
  });
133
160
  }
134
- return _react.createElement(_f36components.InlineEntryCard, {
135
- testId: _richtexttypes.INLINES.EMBEDDED_ENTRY,
161
+ return _react.createElement(InternalFetchingWrappedInlineEntryCard, {
162
+ allContentTypes: props.sdk.space.getCachedContentTypes(),
163
+ getEntityScheduledActions: ()=>getEntityScheduledActions('Entry', props.entryId),
164
+ locale: props.sdk.field.locale,
165
+ defaultLocale: props.sdk.locales.default,
166
+ entry: entry,
167
+ entryStatus: entryStatus,
168
+ isDisabled: props.isDisabled,
136
169
  isSelected: props.isSelected,
137
- title: `${contentTypeName}: ${title}`,
138
- status: entryStatus,
139
- actions: [
140
- _react.createElement(_f36components.MenuItem, {
141
- key: "edit",
142
- onClick: props.onEdit
143
- }, "Edit"),
144
- _react.createElement(_f36components.MenuItem, {
145
- key: "remove",
146
- onClick: props.onRemove,
147
- disabled: props.isDisabled,
148
- testId: "delete"
149
- }, "Remove")
150
- ]
151
- }, _react.createElement(_fieldeditorreference.ScheduledIconWithTooltip, {
152
- getEntityScheduledActions: loadEntityScheduledActions,
153
- entityType: "Entry",
154
- entityId: entry.sys.id
155
- }, _react.createElement(_f36icons.ClockIcon, {
156
- className: styles.scheduledIcon,
157
- variant: "muted",
158
- testId: "scheduled-icon"
159
- })), _react.createElement(_f36components.Text, null, title));
170
+ onEdit: props.onEdit,
171
+ onRemove: props.onRemove
172
+ });
160
173
  }
@@ -58,21 +58,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
58
58
  }
59
59
  return newObj;
60
60
  }
61
- const InternalAssetCard = _react.memo((props)=>{
62
- if (props.asset === undefined) {
63
- return _react.createElement(_f36components.AssetCard, {
64
- size: "default",
65
- isLoading: true
66
- });
67
- }
68
- if (props.asset === 'failed') {
69
- return _react.createElement(_fieldeditorreference.MissingEntityCard, {
70
- isDisabled: props.isDisabled,
71
- onRemove: props.onRemove,
72
- providerName: "Contentful"
73
- });
74
- }
75
- return _react.createElement(_fieldeditorreference.WrappedAssetCard, {
61
+ const InternalAssetCard = _react.memo((props)=>_react.createElement(_fieldeditorreference.WrappedAssetCard, {
76
62
  getEntityScheduledActions: props.loadEntityScheduledActions,
77
63
  size: "small",
78
64
  isSelected: props.isSelected,
@@ -83,8 +69,7 @@ const InternalAssetCard = _react.memo((props)=>{
83
69
  onEdit: props.onEdit,
84
70
  onRemove: props.isDisabled ? undefined : props.onRemove,
85
71
  isClickable: false
86
- });
87
- }, _fastdeepequal.default);
72
+ }), _fastdeepequal.default);
88
73
  InternalAssetCard.displayName = 'InternalAssetCard';
89
74
  function FetchingWrappedAssetCard(props) {
90
75
  const { onEntityFetchComplete } = props;
@@ -102,6 +87,19 @@ function FetchingWrappedAssetCard(props) {
102
87
  onEntityFetchComplete,
103
88
  status
104
89
  ]);
90
+ if (status === 'loading' || status === 'idle') {
91
+ return _react.createElement(_f36components.AssetCard, {
92
+ size: "default",
93
+ isLoading: true
94
+ });
95
+ }
96
+ if (status === 'error') {
97
+ return _react.createElement(_fieldeditorreference.MissingEntityCard, {
98
+ isDisabled: props.isDisabled,
99
+ onRemove: props.onRemove,
100
+ providerName: "Contentful"
101
+ });
102
+ }
105
103
  return _react.createElement(InternalAssetCard, {
106
104
  asset: asset,
107
105
  sdk: props.sdk,
@@ -60,18 +60,6 @@ function _interop_require_wildcard(obj, nodeInterop) {
60
60
  }
61
61
  const InternalEntryCard = _react.memo((props)=>{
62
62
  const { entry, sdk, loadEntityScheduledActions } = props;
63
- if (entry === undefined) {
64
- return _react.createElement(_f36components.EntryCard, {
65
- isLoading: true
66
- });
67
- }
68
- if (entry === 'failed') {
69
- return _react.createElement(_fieldeditorreference.MissingEntityCard, {
70
- isDisabled: props.isDisabled,
71
- onRemove: props.onRemove,
72
- providerName: "Contentful"
73
- });
74
- }
75
63
  const contentType = sdk.space.getCachedContentTypes().find((contentType)=>contentType.sys.id === entry.sys.contentType.sys.id);
76
64
  return _react.createElement(_fieldeditorreference.WrappedEntryCard, {
77
65
  size: "default",
@@ -105,6 +93,18 @@ const FetchingWrappedEntryCard = (props)=>{
105
93
  onEntityFetchComplete,
106
94
  status
107
95
  ]);
96
+ if (status === 'loading' || status === 'idle') {
97
+ return _react.createElement(_f36components.EntryCard, {
98
+ isLoading: true
99
+ });
100
+ }
101
+ if (status === 'error') {
102
+ return _react.createElement(_fieldeditorreference.MissingEntityCard, {
103
+ isDisabled: props.isDisabled,
104
+ onRemove: props.onRemove,
105
+ providerName: "Contentful"
106
+ });
107
+ }
108
108
  return _react.createElement(InternalEntryCard, {
109
109
  entry: entry,
110
110
  sdk: props.sdk,
@@ -13,19 +13,59 @@ const styles = {
13
13
  marginRight: tokens.spacing2Xs
14
14
  })
15
15
  };
16
- export function FetchingWrappedInlineEntryCard(props) {
17
- const { data: entry, status: requestStatus } = useEntity('Entry', props.entryId);
18
- const { getEntityScheduledActions } = useEntityLoader();
19
- const loadEntityScheduledActions = ()=>getEntityScheduledActions('Entry', props.entryId);
20
- const allContentTypes = props.sdk.space.getCachedContentTypes();
21
- const { onEntityFetchComplete } = props;
16
+ function InternalFetchingWrappedInlineEntryCard({ entry, allContentTypes, locale, defaultLocale, isSelected, entryStatus, getEntityScheduledActions, onEdit, onRemove, isDisabled }) {
22
17
  const contentType = React.useMemo(()=>{
23
- if (!entry || !allContentTypes) return undefined;
18
+ if (!allContentTypes) {
19
+ return undefined;
20
+ }
24
21
  return allContentTypes.find((contentType)=>contentType.sys.id === entry.sys.contentType.sys.id);
25
22
  }, [
26
23
  allContentTypes,
27
24
  entry
28
25
  ]);
26
+ const title = React.useMemo(()=>getEntryTitle({
27
+ entry,
28
+ contentType,
29
+ localeCode: locale,
30
+ defaultLocaleCode: defaultLocale,
31
+ defaultTitle: 'Untitled'
32
+ }), [
33
+ entry,
34
+ contentType,
35
+ locale,
36
+ defaultLocale
37
+ ]);
38
+ return React.createElement(InlineEntryCard, {
39
+ testId: INLINES.EMBEDDED_ENTRY,
40
+ isSelected: isSelected,
41
+ title: contentType ? `${contentType.name}: ${title}` : title,
42
+ status: entryStatus,
43
+ actions: [
44
+ React.createElement(MenuItem, {
45
+ key: "edit",
46
+ onClick: onEdit
47
+ }, "Edit"),
48
+ React.createElement(MenuItem, {
49
+ key: "remove",
50
+ onClick: onRemove,
51
+ disabled: isDisabled,
52
+ testId: "delete"
53
+ }, "Remove")
54
+ ]
55
+ }, React.createElement(ScheduledIconWithTooltip, {
56
+ getEntityScheduledActions: getEntityScheduledActions,
57
+ entityType: "Entry",
58
+ entityId: entry.sys.id
59
+ }, React.createElement(ClockIcon, {
60
+ className: styles.scheduledIcon,
61
+ variant: "muted",
62
+ testId: "scheduled-icon"
63
+ })), React.createElement(Text, null, title));
64
+ }
65
+ export function FetchingWrappedInlineEntryCard(props) {
66
+ const { data: entry, status: requestStatus } = useEntity('Entry', props.entryId);
67
+ const { getEntityScheduledActions } = useEntityLoader();
68
+ const { onEntityFetchComplete } = props;
29
69
  React.useEffect(()=>{
30
70
  if (requestStatus !== 'success') {
31
71
  return;
@@ -35,19 +75,11 @@ export function FetchingWrappedInlineEntryCard(props) {
35
75
  requestStatus,
36
76
  onEntityFetchComplete
37
77
  ]);
38
- const contentTypeName = contentType ? contentType.name : '';
39
- const title = React.useMemo(()=>getEntryTitle({
40
- entry,
41
- contentType,
42
- localeCode: props.sdk.field.locale,
43
- defaultLocaleCode: props.sdk.locales.default,
44
- defaultTitle: 'Untitled'
45
- }), [
46
- entry,
47
- contentType,
48
- props.sdk.field.locale,
49
- props.sdk.locales.default
50
- ]);
78
+ if (requestStatus === 'loading' || requestStatus === 'idle') {
79
+ return React.createElement(InlineEntryCard, {
80
+ isLoading: true
81
+ });
82
+ }
51
83
  if (requestStatus === 'error') {
52
84
  return React.createElement(InlineEntryCard, {
53
85
  title: "Content missing or inaccessible",
@@ -55,11 +87,6 @@ export function FetchingWrappedInlineEntryCard(props) {
55
87
  isSelected: props.isSelected
56
88
  });
57
89
  }
58
- if (requestStatus === 'loading') {
59
- return React.createElement(InlineEntryCard, {
60
- isLoading: true
61
- });
62
- }
63
90
  const entryStatus = getEntryStatus(entry.sys);
64
91
  if (entryStatus === 'deleted') {
65
92
  return React.createElement(InlineEntryCard, {
@@ -75,30 +102,16 @@ export function FetchingWrappedInlineEntryCard(props) {
75
102
  ]
76
103
  });
77
104
  }
78
- return React.createElement(InlineEntryCard, {
79
- testId: INLINES.EMBEDDED_ENTRY,
105
+ return React.createElement(InternalFetchingWrappedInlineEntryCard, {
106
+ allContentTypes: props.sdk.space.getCachedContentTypes(),
107
+ getEntityScheduledActions: ()=>getEntityScheduledActions('Entry', props.entryId),
108
+ locale: props.sdk.field.locale,
109
+ defaultLocale: props.sdk.locales.default,
110
+ entry: entry,
111
+ entryStatus: entryStatus,
112
+ isDisabled: props.isDisabled,
80
113
  isSelected: props.isSelected,
81
- title: `${contentTypeName}: ${title}`,
82
- status: entryStatus,
83
- actions: [
84
- React.createElement(MenuItem, {
85
- key: "edit",
86
- onClick: props.onEdit
87
- }, "Edit"),
88
- React.createElement(MenuItem, {
89
- key: "remove",
90
- onClick: props.onRemove,
91
- disabled: props.isDisabled,
92
- testId: "delete"
93
- }, "Remove")
94
- ]
95
- }, React.createElement(ScheduledIconWithTooltip, {
96
- getEntityScheduledActions: loadEntityScheduledActions,
97
- entityType: "Entry",
98
- entityId: entry.sys.id
99
- }, React.createElement(ClockIcon, {
100
- className: styles.scheduledIcon,
101
- variant: "muted",
102
- testId: "scheduled-icon"
103
- })), React.createElement(Text, null, title));
114
+ onEdit: props.onEdit,
115
+ onRemove: props.onRemove
116
+ });
104
117
  }
@@ -2,21 +2,7 @@ import * as React from 'react';
2
2
  import { AssetCard } from '@contentful/f36-components';
3
3
  import { useEntity, useEntityLoader, MissingEntityCard, WrappedAssetCard } from '@contentful/field-editor-reference';
4
4
  import areEqual from 'fast-deep-equal';
5
- const InternalAssetCard = React.memo((props)=>{
6
- if (props.asset === undefined) {
7
- return React.createElement(AssetCard, {
8
- size: "default",
9
- isLoading: true
10
- });
11
- }
12
- if (props.asset === 'failed') {
13
- return React.createElement(MissingEntityCard, {
14
- isDisabled: props.isDisabled,
15
- onRemove: props.onRemove,
16
- providerName: "Contentful"
17
- });
18
- }
19
- return React.createElement(WrappedAssetCard, {
5
+ const InternalAssetCard = React.memo((props)=>React.createElement(WrappedAssetCard, {
20
6
  getEntityScheduledActions: props.loadEntityScheduledActions,
21
7
  size: "small",
22
8
  isSelected: props.isSelected,
@@ -27,8 +13,7 @@ const InternalAssetCard = React.memo((props)=>{
27
13
  onEdit: props.onEdit,
28
14
  onRemove: props.isDisabled ? undefined : props.onRemove,
29
15
  isClickable: false
30
- });
31
- }, areEqual);
16
+ }), areEqual);
32
17
  InternalAssetCard.displayName = 'InternalAssetCard';
33
18
  export function FetchingWrappedAssetCard(props) {
34
19
  const { onEntityFetchComplete } = props;
@@ -46,6 +31,19 @@ export function FetchingWrappedAssetCard(props) {
46
31
  onEntityFetchComplete,
47
32
  status
48
33
  ]);
34
+ if (status === 'loading' || status === 'idle') {
35
+ return React.createElement(AssetCard, {
36
+ size: "default",
37
+ isLoading: true
38
+ });
39
+ }
40
+ if (status === 'error') {
41
+ return React.createElement(MissingEntityCard, {
42
+ isDisabled: props.isDisabled,
43
+ onRemove: props.onRemove,
44
+ providerName: "Contentful"
45
+ });
46
+ }
49
47
  return React.createElement(InternalAssetCard, {
50
48
  asset: asset,
51
49
  sdk: props.sdk,
@@ -4,18 +4,6 @@ import { useEntity, MissingEntityCard, WrappedEntryCard, useEntityLoader } from
4
4
  import areEqual from 'fast-deep-equal';
5
5
  const InternalEntryCard = React.memo((props)=>{
6
6
  const { entry, sdk, loadEntityScheduledActions } = props;
7
- if (entry === undefined) {
8
- return React.createElement(EntryCard, {
9
- isLoading: true
10
- });
11
- }
12
- if (entry === 'failed') {
13
- return React.createElement(MissingEntityCard, {
14
- isDisabled: props.isDisabled,
15
- onRemove: props.onRemove,
16
- providerName: "Contentful"
17
- });
18
- }
19
7
  const contentType = sdk.space.getCachedContentTypes().find((contentType)=>contentType.sys.id === entry.sys.contentType.sys.id);
20
8
  return React.createElement(WrappedEntryCard, {
21
9
  size: "default",
@@ -49,6 +37,18 @@ export const FetchingWrappedEntryCard = (props)=>{
49
37
  onEntityFetchComplete,
50
38
  status
51
39
  ]);
40
+ if (status === 'loading' || status === 'idle') {
41
+ return React.createElement(EntryCard, {
42
+ isLoading: true
43
+ });
44
+ }
45
+ if (status === 'error') {
46
+ return React.createElement(MissingEntityCard, {
47
+ isDisabled: props.isDisabled,
48
+ onRemove: props.onRemove,
49
+ providerName: "Contentful"
50
+ });
51
+ }
52
52
  return React.createElement(InternalEntryCard, {
53
53
  entry: entry,
54
54
  sdk: props.sdk,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "3.20.1",
3
+ "version": "3.20.3",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -44,7 +44,7 @@
44
44
  "@contentful/f36-icons": "^4.1.1",
45
45
  "@contentful/f36-tokens": "^4.0.0",
46
46
  "@contentful/f36-utils": "^4.19.0",
47
- "@contentful/field-editor-reference": "^5.27.1",
47
+ "@contentful/field-editor-reference": "^5.27.3",
48
48
  "@contentful/field-editor-shared": "^1.4.8",
49
49
  "@contentful/rich-text-plain-text-renderer": "^16.0.4",
50
50
  "@contentful/rich-text-types": "16.3.0",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "registry": "https://npm.pkg.github.com/"
88
88
  },
89
- "gitHead": "1d7d630fe6f9576ee4cf35feed8badc8440acbf1"
89
+ "gitHead": "4dfb84c2d6e620067bb539985a80e292110e7160"
90
90
  }