@contentful/field-editor-rich-text 3.20.2 → 3.20.4

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,22 +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 (requestStatus !== 'success' || !entry || !allContentTypes) {
74
+ if (!allContentTypes) {
80
75
  return undefined;
81
76
  }
82
77
  return allContentTypes.find((contentType)=>contentType.sys.id === entry.sys.contentType.sys.id);
83
78
  }, [
84
79
  allContentTypes,
80
+ entry
81
+ ]);
82
+ const title = _react.useMemo(()=>getEntryTitle({
83
+ entry,
84
+ contentType,
85
+ localeCode: locale,
86
+ defaultLocaleCode: defaultLocale,
87
+ defaultTitle: 'Untitled'
88
+ }), [
85
89
  entry,
86
- requestStatus
90
+ contentType,
91
+ locale,
92
+ defaultLocale
87
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;
88
125
  _react.useEffect(()=>{
89
126
  if (requestStatus !== 'success') {
90
127
  return;
@@ -94,20 +131,11 @@ function FetchingWrappedInlineEntryCard(props) {
94
131
  requestStatus,
95
132
  onEntityFetchComplete
96
133
  ]);
97
- const contentTypeName = contentType ? contentType.name : '';
98
- const title = _react.useMemo(()=>requestStatus === 'success' && getEntryTitle({
99
- entry,
100
- contentType,
101
- localeCode: props.sdk.field.locale,
102
- defaultLocaleCode: props.sdk.locales.default,
103
- defaultTitle: 'Untitled'
104
- }), [
105
- entry,
106
- requestStatus,
107
- contentType,
108
- props.sdk.field.locale,
109
- props.sdk.locales.default
110
- ]);
134
+ if (requestStatus === 'loading' || requestStatus === 'idle') {
135
+ return _react.createElement(_f36components.InlineEntryCard, {
136
+ isLoading: true
137
+ });
138
+ }
111
139
  if (requestStatus === 'error') {
112
140
  return _react.createElement(_f36components.InlineEntryCard, {
113
141
  title: "Content missing or inaccessible",
@@ -115,11 +143,6 @@ function FetchingWrappedInlineEntryCard(props) {
115
143
  isSelected: props.isSelected
116
144
  });
117
145
  }
118
- if (requestStatus === 'loading') {
119
- return _react.createElement(_f36components.InlineEntryCard, {
120
- isLoading: true
121
- });
122
- }
123
146
  const entryStatus = getEntryStatus(entry.sys);
124
147
  if (entryStatus === 'deleted') {
125
148
  return _react.createElement(_f36components.InlineEntryCard, {
@@ -135,30 +158,16 @@ function FetchingWrappedInlineEntryCard(props) {
135
158
  ]
136
159
  });
137
160
  }
138
- return _react.createElement(_f36components.InlineEntryCard, {
139
- 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,
140
169
  isSelected: props.isSelected,
141
- title: `${contentTypeName}: ${title}`,
142
- status: entryStatus,
143
- actions: [
144
- _react.createElement(_f36components.MenuItem, {
145
- key: "edit",
146
- onClick: props.onEdit
147
- }, "Edit"),
148
- _react.createElement(_f36components.MenuItem, {
149
- key: "remove",
150
- onClick: props.onRemove,
151
- disabled: props.isDisabled,
152
- testId: "delete"
153
- }, "Remove")
154
- ]
155
- }, _react.createElement(_fieldeditorreference.ScheduledIconWithTooltip, {
156
- getEntityScheduledActions: loadEntityScheduledActions,
157
- entityType: "Entry",
158
- entityId: entry.sys.id
159
- }, _react.createElement(_f36icons.ClockIcon, {
160
- className: styles.scheduledIcon,
161
- variant: "muted",
162
- testId: "scheduled-icon"
163
- })), _react.createElement(_f36components.Text, null, title));
170
+ onEdit: props.onEdit,
171
+ onRemove: props.onRemove
172
+ });
164
173
  }
@@ -73,8 +73,8 @@ function _interop_require_wildcard(obj, nodeInterop) {
73
73
  const styles = {
74
74
  topRight: (0, _emotion.css)({
75
75
  position: 'absolute',
76
- top: '6px',
77
- right: '5px'
76
+ insetBlockStart: '6px',
77
+ insetInlineEnd: '5px'
78
78
  })
79
79
  };
80
80
  const getCurrentTableSize = (editor)=>{
@@ -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.status === 'error') {
63
- return _react.createElement(_fieldeditorreference.MissingEntityCard, {
64
- isDisabled: props.isDisabled,
65
- onRemove: props.onRemove,
66
- providerName: "Contentful"
67
- });
68
- }
69
- if (!props.asset) {
70
- return _react.createElement(_f36components.AssetCard, {
71
- size: "default",
72
- isLoading: true
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,9 +87,21 @@ 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
- status: status,
108
105
  sdk: props.sdk,
109
106
  isDisabled: props.isDisabled,
110
107
  isSelected: props.isSelected,
@@ -59,19 +59,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
59
59
  return newObj;
60
60
  }
61
61
  const InternalEntryCard = _react.memo((props)=>{
62
- const { entry, sdk, loadEntityScheduledActions, status } = props;
63
- if (status === 'error') {
64
- return _react.createElement(_fieldeditorreference.MissingEntityCard, {
65
- isDisabled: props.isDisabled,
66
- onRemove: props.onRemove,
67
- providerName: "Contentful"
68
- });
69
- }
70
- if (entry === undefined) {
71
- return _react.createElement(_f36components.EntryCard, {
72
- isLoading: true
73
- });
74
- }
62
+ const { entry, sdk, loadEntityScheduledActions } = props;
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,8 +93,19 @@ 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
- status: status,
110
109
  entry: entry,
111
110
  sdk: props.sdk,
112
111
  locale: props.locale,
@@ -13,22 +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 (requestStatus !== 'success' || !entry || !allContentTypes) {
18
+ if (!allContentTypes) {
24
19
  return undefined;
25
20
  }
26
21
  return allContentTypes.find((contentType)=>contentType.sys.id === entry.sys.contentType.sys.id);
27
22
  }, [
28
23
  allContentTypes,
24
+ entry
25
+ ]);
26
+ const title = React.useMemo(()=>getEntryTitle({
27
+ entry,
28
+ contentType,
29
+ localeCode: locale,
30
+ defaultLocaleCode: defaultLocale,
31
+ defaultTitle: 'Untitled'
32
+ }), [
29
33
  entry,
30
- requestStatus
34
+ contentType,
35
+ locale,
36
+ defaultLocale
31
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;
32
69
  React.useEffect(()=>{
33
70
  if (requestStatus !== 'success') {
34
71
  return;
@@ -38,20 +75,11 @@ export function FetchingWrappedInlineEntryCard(props) {
38
75
  requestStatus,
39
76
  onEntityFetchComplete
40
77
  ]);
41
- const contentTypeName = contentType ? contentType.name : '';
42
- const title = React.useMemo(()=>requestStatus === 'success' && getEntryTitle({
43
- entry,
44
- contentType,
45
- localeCode: props.sdk.field.locale,
46
- defaultLocaleCode: props.sdk.locales.default,
47
- defaultTitle: 'Untitled'
48
- }), [
49
- entry,
50
- requestStatus,
51
- contentType,
52
- props.sdk.field.locale,
53
- props.sdk.locales.default
54
- ]);
78
+ if (requestStatus === 'loading' || requestStatus === 'idle') {
79
+ return React.createElement(InlineEntryCard, {
80
+ isLoading: true
81
+ });
82
+ }
55
83
  if (requestStatus === 'error') {
56
84
  return React.createElement(InlineEntryCard, {
57
85
  title: "Content missing or inaccessible",
@@ -59,11 +87,6 @@ export function FetchingWrappedInlineEntryCard(props) {
59
87
  isSelected: props.isSelected
60
88
  });
61
89
  }
62
- if (requestStatus === 'loading') {
63
- return React.createElement(InlineEntryCard, {
64
- isLoading: true
65
- });
66
- }
67
90
  const entryStatus = getEntryStatus(entry.sys);
68
91
  if (entryStatus === 'deleted') {
69
92
  return React.createElement(InlineEntryCard, {
@@ -79,30 +102,16 @@ export function FetchingWrappedInlineEntryCard(props) {
79
102
  ]
80
103
  });
81
104
  }
82
- return React.createElement(InlineEntryCard, {
83
- 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,
84
113
  isSelected: props.isSelected,
85
- title: `${contentTypeName}: ${title}`,
86
- status: entryStatus,
87
- actions: [
88
- React.createElement(MenuItem, {
89
- key: "edit",
90
- onClick: props.onEdit
91
- }, "Edit"),
92
- React.createElement(MenuItem, {
93
- key: "remove",
94
- onClick: props.onRemove,
95
- disabled: props.isDisabled,
96
- testId: "delete"
97
- }, "Remove")
98
- ]
99
- }, React.createElement(ScheduledIconWithTooltip, {
100
- getEntityScheduledActions: loadEntityScheduledActions,
101
- entityType: "Entry",
102
- entityId: entry.sys.id
103
- }, React.createElement(ClockIcon, {
104
- className: styles.scheduledIcon,
105
- variant: "muted",
106
- testId: "scheduled-icon"
107
- })), React.createElement(Text, null, title));
114
+ onEdit: props.onEdit,
115
+ onRemove: props.onRemove
116
+ });
108
117
  }
@@ -14,8 +14,8 @@ import { isTableHeaderEnabled } from '../helpers';
14
14
  export const styles = {
15
15
  topRight: css({
16
16
  position: 'absolute',
17
- top: '6px',
18
- right: '5px'
17
+ insetBlockStart: '6px',
18
+ insetInlineEnd: '5px'
19
19
  })
20
20
  };
21
21
  const getCurrentTableSize = (editor)=>{
@@ -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.status === 'error') {
7
- return React.createElement(MissingEntityCard, {
8
- isDisabled: props.isDisabled,
9
- onRemove: props.onRemove,
10
- providerName: "Contentful"
11
- });
12
- }
13
- if (!props.asset) {
14
- return React.createElement(AssetCard, {
15
- size: "default",
16
- isLoading: true
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,9 +31,21 @@ 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
- status: status,
52
49
  sdk: props.sdk,
53
50
  isDisabled: props.isDisabled,
54
51
  isSelected: props.isSelected,
@@ -3,19 +3,7 @@ import { EntryCard } from '@contentful/f36-components';
3
3
  import { useEntity, MissingEntityCard, WrappedEntryCard, useEntityLoader } from '@contentful/field-editor-reference';
4
4
  import areEqual from 'fast-deep-equal';
5
5
  const InternalEntryCard = React.memo((props)=>{
6
- const { entry, sdk, loadEntityScheduledActions, status } = props;
7
- if (status === 'error') {
8
- return React.createElement(MissingEntityCard, {
9
- isDisabled: props.isDisabled,
10
- onRemove: props.onRemove,
11
- providerName: "Contentful"
12
- });
13
- }
14
- if (entry === undefined) {
15
- return React.createElement(EntryCard, {
16
- isLoading: true
17
- });
18
- }
6
+ const { entry, sdk, loadEntityScheduledActions } = props;
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,8 +37,19 @@ 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
- status: status,
54
53
  entry: entry,
55
54
  sdk: props.sdk,
56
55
  locale: props.locale,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "3.20.2",
3
+ "version": "3.20.4",
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.2",
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": "0d8d60dde84e039189af98d4e746d27588ed10ff"
89
+ "gitHead": "13c539d7f825adbb82804d7e0e5d79e4e762ac1f"
90
90
  }