@wordpress/editor 14.18.0 → 14.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +2 -0
- package/build/components/document-bar/index.js +3 -2
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/index.js +37 -17
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-outline/item.js +32 -20
- package/build/components/document-outline/item.js.map +1 -1
- package/build/components/entities-saved-states/entity-record-item.js +4 -3
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js +2 -1
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/index.js +66 -42
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/post-actions/index.js +19 -28
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-card-panel/index.js +5 -5
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-featured-image/index.js +4 -2
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-template/block-theme.js +68 -48
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/classic-theme.js +30 -18
- package/build/components/post-template/classic-theme.js.map +1 -1
- package/build/components/post-template/create-new-template-modal.js +3 -1
- package/build/components/post-template/create-new-template-modal.js.map +1 -1
- package/build/components/post-template/panel.js +3 -11
- package/build/components/post-template/panel.js.map +1 -1
- package/build/components/preferences-modal/block-visibility.js +2 -1
- package/build/components/preferences-modal/block-visibility.js.map +1 -1
- package/build/components/preferences-modal/index.js +1 -1
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preview-dropdown/index.js +6 -3
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/index.js +19 -18
- package/build/components/provider/index.js.map +1 -1
- package/build/components/sidebar/header.js +1 -1
- package/build/components/sidebar/header.js.map +1 -1
- package/build/components/sidebar/index.js +1 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/start-page-options/index.js +148 -23
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/visual-editor/edit-template-blocks-notification.js +1 -1
- package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build/store/private-actions.js +29 -2
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +45 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +8 -7
- package/build/store/selectors.js.map +1 -1
- package/build/utils/media-upload/index.js +5 -2
- package/build/utils/media-upload/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +3 -2
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/index.js +38 -18
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-outline/item.js +32 -20
- package/build-module/components/document-outline/item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +4 -3
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js +2 -1
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +67 -43
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/post-actions/index.js +19 -28
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +5 -5
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +4 -2
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +68 -48
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/classic-theme.js +30 -18
- package/build-module/components/post-template/classic-theme.js.map +1 -1
- package/build-module/components/post-template/create-new-template-modal.js +3 -1
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
- package/build-module/components/post-template/panel.js +3 -11
- package/build-module/components/post-template/panel.js.map +1 -1
- package/build-module/components/preferences-modal/block-visibility.js +2 -1
- package/build-module/components/preferences-modal/block-visibility.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +1 -1
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +6 -3
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/index.js +19 -18
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/sidebar/header.js +1 -1
- package/build-module/components/sidebar/header.js.map +1 -1
- package/build-module/components/sidebar/index.js +1 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/start-page-options/index.js +148 -24
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/visual-editor/edit-template-blocks-notification.js +1 -1
- package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
- package/build-module/store/private-actions.js +25 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +44 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +8 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/media-upload/index.js +5 -2
- package/build-module/utils/media-upload/index.js.map +1 -1
- package/build-style/style-rtl.css +51 -9
- package/build-style/style.css +51 -9
- package/build-types/components/document-outline/index.d.ts.map +1 -1
- package/build-types/components/document-outline/item.d.ts +2 -1
- package/build-types/components/document-outline/item.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/index.d.ts +6 -2
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
- package/build-types/components/post-actions/index.d.ts.map +1 -1
- package/build-types/components/post-card-panel/index.d.ts.map +1 -1
- package/build-types/components/post-template/block-theme.d.ts.map +1 -1
- package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
- package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
- package/build-types/components/post-template/panel.d.ts.map +1 -1
- package/build-types/components/preferences-modal/block-visibility.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/start-page-options/index.d.ts +2 -1
- package/build-types/components/start-page-options/index.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +4 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +13 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/media-upload/index.d.ts +3 -1
- package/build-types/utils/media-upload/index.d.ts.map +1 -1
- package/package.json +37 -37
- package/src/components/document-bar/index.js +2 -2
- package/src/components/document-outline/index.js +49 -17
- package/src/components/document-outline/item.js +38 -23
- package/src/components/document-outline/style.scss +2 -0
- package/src/components/entities-saved-states/entity-record-item.js +2 -4
- package/src/components/entities-saved-states/entity-type-list.js +6 -2
- package/src/components/entities-saved-states/index.js +98 -58
- package/src/components/entities-saved-states/style.scss +40 -5
- package/src/components/post-actions/index.js +19 -37
- package/src/components/post-card-panel/index.js +9 -7
- package/src/components/post-featured-image/index.js +2 -0
- package/src/components/post-template/block-theme.js +76 -56
- package/src/components/post-template/classic-theme.js +31 -15
- package/src/components/post-template/create-new-template-modal.js +1 -0
- package/src/components/post-template/panel.js +2 -12
- package/src/components/post-text-editor/style.scss +0 -2
- package/src/components/preferences-modal/block-visibility.js +2 -1
- package/src/components/preferences-modal/index.js +1 -1
- package/src/components/preview-dropdown/index.js +8 -6
- package/src/components/provider/index.js +21 -30
- package/src/components/sidebar/header.js +1 -1
- package/src/components/sidebar/index.js +1 -1
- package/src/components/start-page-options/index.js +149 -23
- package/src/components/start-page-options/style.scss +27 -0
- package/src/components/visual-editor/edit-template-blocks-notification.js +1 -1
- package/src/store/private-actions.js +33 -0
- package/src/store/private-selectors.js +59 -4
- package/src/store/selectors.js +9 -14
- package/src/utils/media-upload/index.js +3 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -14,7 +19,7 @@ import EntityTypeList from './entity-type-list';
|
|
|
14
19
|
import { useIsDirty } from './hooks/use-is-dirty';
|
|
15
20
|
import { store as editorStore } from '../../store';
|
|
16
21
|
import { unlock } from '../../lock-unlock';
|
|
17
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
23
|
function identity(values) {
|
|
19
24
|
return values;
|
|
20
25
|
}
|
|
@@ -25,17 +30,20 @@ function identity(values) {
|
|
|
25
30
|
* @param {Object} props The component props.
|
|
26
31
|
* @param {Function} props.close The function to close the dialog.
|
|
27
32
|
* @param {boolean} props.renderDialog Whether to render the component with modal dialog behavior.
|
|
33
|
+
* @param {string} props.variant Changes the layout of the component. When an `inline` value is provided, the action buttons are rendered at the end of the component instead of at the start.
|
|
28
34
|
*
|
|
29
35
|
* @return {React.ReactNode} The rendered component.
|
|
30
36
|
*/
|
|
31
37
|
export default function EntitiesSavedStates({
|
|
32
38
|
close,
|
|
33
|
-
renderDialog
|
|
39
|
+
renderDialog,
|
|
40
|
+
variant
|
|
34
41
|
}) {
|
|
35
42
|
const isDirtyProps = useIsDirty();
|
|
36
43
|
return /*#__PURE__*/_jsx(EntitiesSavedStatesExtensible, {
|
|
37
44
|
close: close,
|
|
38
45
|
renderDialog: renderDialog,
|
|
46
|
+
variant: variant,
|
|
39
47
|
...isDirtyProps
|
|
40
48
|
});
|
|
41
49
|
}
|
|
@@ -54,6 +62,7 @@ export default function EntitiesSavedStates({
|
|
|
54
62
|
* @param {boolean} props.isDirty Flag indicating if there are dirty entities.
|
|
55
63
|
* @param {Function} props.setUnselectedEntities Function to set unselected entities.
|
|
56
64
|
* @param {Array} props.unselectedEntities Array of unselected entities.
|
|
65
|
+
* @param {string} props.variant Changes the layout of the component. When an `inline` value is provided, the action buttons are rendered at the end of the component instead of at the start.
|
|
57
66
|
*
|
|
58
67
|
* @return {React.ReactNode} The rendered component.
|
|
59
68
|
*/
|
|
@@ -67,7 +76,8 @@ export function EntitiesSavedStatesExtensible({
|
|
|
67
76
|
dirtyEntityRecords,
|
|
68
77
|
isDirty,
|
|
69
78
|
setUnselectedEntities,
|
|
70
|
-
unselectedEntities
|
|
79
|
+
unselectedEntities,
|
|
80
|
+
variant = 'default'
|
|
71
81
|
}) {
|
|
72
82
|
const saveButtonRef = useRef();
|
|
73
83
|
const {
|
|
@@ -100,58 +110,67 @@ export function EntitiesSavedStatesExtensible({
|
|
|
100
110
|
const [saveDialogRef, saveDialogProps] = useDialog({
|
|
101
111
|
onClose: () => dismissPanel()
|
|
102
112
|
});
|
|
103
|
-
const
|
|
104
|
-
const
|
|
113
|
+
const dialogLabelId = useInstanceId(EntitiesSavedStatesExtensible, 'entities-saved-states__panel-label');
|
|
114
|
+
const dialogDescriptionId = useInstanceId(EntitiesSavedStatesExtensible, 'entities-saved-states__panel-description');
|
|
105
115
|
const selectItemsToSaveDescription = !!dirtyEntityRecords.length ? __('Select the items you want to save.') : undefined;
|
|
116
|
+
const isInline = variant === 'inline';
|
|
117
|
+
const actionButtons = /*#__PURE__*/_jsxs(_Fragment, {
|
|
118
|
+
children: [/*#__PURE__*/_jsx(FlexItem, {
|
|
119
|
+
isBlock: isInline ? false : true,
|
|
120
|
+
as: Button,
|
|
121
|
+
variant: isInline ? 'tertiary' : 'secondary',
|
|
122
|
+
size: isInline ? undefined : 'compact',
|
|
123
|
+
onClick: dismissPanel,
|
|
124
|
+
children: __('Cancel')
|
|
125
|
+
}), /*#__PURE__*/_jsx(FlexItem, {
|
|
126
|
+
isBlock: isInline ? false : true,
|
|
127
|
+
as: Button,
|
|
128
|
+
ref: saveButtonRef,
|
|
129
|
+
variant: "primary",
|
|
130
|
+
size: isInline ? undefined : 'compact',
|
|
131
|
+
disabled: !saveEnabled,
|
|
132
|
+
accessibleWhenDisabled: true,
|
|
133
|
+
onClick: () => saveDirtyEntities({
|
|
134
|
+
onSave,
|
|
135
|
+
dirtyEntityRecords,
|
|
136
|
+
entitiesToSkip: unselectedEntities,
|
|
137
|
+
close
|
|
138
|
+
}),
|
|
139
|
+
className: "editor-entities-saved-states__save-button",
|
|
140
|
+
children: saveLabel
|
|
141
|
+
})]
|
|
142
|
+
});
|
|
106
143
|
return /*#__PURE__*/_jsxs("div", {
|
|
107
144
|
ref: renderDialog ? saveDialogRef : undefined,
|
|
108
145
|
...(renderDialog && saveDialogProps),
|
|
109
|
-
className:
|
|
146
|
+
className: clsx('entities-saved-states__panel', {
|
|
147
|
+
'is-inline': isInline
|
|
148
|
+
}),
|
|
110
149
|
role: renderDialog ? 'dialog' : undefined,
|
|
111
|
-
"aria-labelledby": renderDialog ?
|
|
112
|
-
"aria-describedby": renderDialog ?
|
|
113
|
-
children: [/*#__PURE__*/
|
|
150
|
+
"aria-labelledby": renderDialog ? dialogLabelId : undefined,
|
|
151
|
+
"aria-describedby": renderDialog ? dialogDescriptionId : undefined,
|
|
152
|
+
children: [!isInline && /*#__PURE__*/_jsx(Flex, {
|
|
114
153
|
className: "entities-saved-states__panel-header",
|
|
115
154
|
gap: 2,
|
|
116
|
-
children:
|
|
117
|
-
isBlock: true,
|
|
118
|
-
as: Button,
|
|
119
|
-
variant: "secondary",
|
|
120
|
-
size: "compact",
|
|
121
|
-
onClick: dismissPanel,
|
|
122
|
-
children: __('Cancel')
|
|
123
|
-
}), /*#__PURE__*/_jsx(FlexItem, {
|
|
124
|
-
isBlock: true,
|
|
125
|
-
as: Button,
|
|
126
|
-
ref: saveButtonRef,
|
|
127
|
-
variant: "primary",
|
|
128
|
-
size: "compact",
|
|
129
|
-
disabled: !saveEnabled,
|
|
130
|
-
accessibleWhenDisabled: true,
|
|
131
|
-
onClick: () => saveDirtyEntities({
|
|
132
|
-
onSave,
|
|
133
|
-
dirtyEntityRecords,
|
|
134
|
-
entitiesToSkip: unselectedEntities,
|
|
135
|
-
close
|
|
136
|
-
}),
|
|
137
|
-
className: "editor-entities-saved-states__save-button",
|
|
138
|
-
children: saveLabel
|
|
139
|
-
})]
|
|
155
|
+
children: actionButtons
|
|
140
156
|
}), /*#__PURE__*/_jsxs("div", {
|
|
141
157
|
className: "entities-saved-states__text-prompt",
|
|
142
|
-
children: [/*#__PURE__*/
|
|
158
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
143
159
|
className: "entities-saved-states__text-prompt--header-wrapper",
|
|
144
|
-
|
|
145
|
-
|
|
160
|
+
children: /*#__PURE__*/_jsx("strong", {
|
|
161
|
+
id: renderDialog ? dialogLabelId : undefined,
|
|
146
162
|
className: "entities-saved-states__text-prompt--header",
|
|
147
163
|
children: __('Are you ready to save?')
|
|
148
|
-
})
|
|
149
|
-
}), /*#__PURE__*/
|
|
150
|
-
id: renderDialog ?
|
|
151
|
-
children:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
164
|
+
})
|
|
165
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
166
|
+
id: renderDialog ? dialogDescriptionId : undefined,
|
|
167
|
+
children: [additionalPrompt, /*#__PURE__*/_jsx("p", {
|
|
168
|
+
className: "entities-saved-states__text-prompt--changes-count",
|
|
169
|
+
children: isDirty ? createInterpolateElement(sprintf(/* translators: %d: number of site changes waiting to be saved. */
|
|
170
|
+
_n('There is <strong>%d site change</strong> waiting to be saved.', 'There are <strong>%d site changes</strong> waiting to be saved.', dirtyEntityRecords.length), dirtyEntityRecords.length), {
|
|
171
|
+
strong: /*#__PURE__*/_jsx("strong", {})
|
|
172
|
+
}) : selectItemsToSaveDescription
|
|
173
|
+
})]
|
|
155
174
|
})]
|
|
156
175
|
}), sortedPartitionedSavables.map(list => {
|
|
157
176
|
return /*#__PURE__*/_jsx(EntityTypeList, {
|
|
@@ -159,6 +178,11 @@ export function EntitiesSavedStatesExtensible({
|
|
|
159
178
|
unselectedEntities: unselectedEntities,
|
|
160
179
|
setUnselectedEntities: setUnselectedEntities
|
|
161
180
|
}, list[0].name);
|
|
181
|
+
}), isInline && /*#__PURE__*/_jsx(Flex, {
|
|
182
|
+
direction: "row",
|
|
183
|
+
justify: "flex-end",
|
|
184
|
+
className: "entities-saved-states__panel-footer",
|
|
185
|
+
children: actionButtons
|
|
162
186
|
})]
|
|
163
187
|
});
|
|
164
188
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","Flex","FlexItem","__","_n","sprintf","useCallback","useRef","createInterpolateElement","__experimentalUseDialog","useDialog","useInstanceId","useDispatch","EntityTypeList","useIsDirty","store","editorStore","unlock","jsx","_jsx","jsxs","_jsxs","identity","values","EntitiesSavedStates","close","renderDialog","isDirtyProps","EntitiesSavedStatesExtensible","additionalPrompt","undefined","onSave","saveEnabled","saveEnabledProp","saveLabel","dirtyEntityRecords","isDirty","setUnselectedEntities","unselectedEntities","saveButtonRef","saveDirtyEntities","partitionedSavables","reduce","acc","record","name","push","site","siteSavables","wp_template","templateSavables","wp_template_part","templatePartSavables","contentSavables","sortedPartitionedSavables","Object","filter","Array","isArray","dismissPanel","saveDialogRef","saveDialogProps","onClose","dialogLabel","dialogDescription","selectItemsToSaveDescription","length","ref","className","role","children","gap","isBlock","as","variant","size","onClick","disabled","accessibleWhenDisabled","entitiesToSkip","id","strong","map","list"],"sources":["@wordpress/editor/src/components/entities-saved-states/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Flex, FlexItem } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tuseCallback,\n\tuseRef,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport {\n\t__experimentalUseDialog as useDialog,\n\tuseInstanceId,\n} from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport EntityTypeList from './entity-type-list';\nimport { useIsDirty } from './hooks/use-is-dirty';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nfunction identity( values ) {\n\treturn values;\n}\n\n/**\n * Renders the component for managing saved states of entities.\n *\n * @param {Object} props The component props.\n * @param {Function} props.close The function to close the dialog.\n * @param {boolean} props.renderDialog Whether to render the component with modal dialog behavior.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function EntitiesSavedStates( { close, renderDialog } ) {\n\tconst isDirtyProps = useIsDirty();\n\treturn (\n\t\t<EntitiesSavedStatesExtensible\n\t\t\tclose={ close }\n\t\t\trenderDialog={ renderDialog }\n\t\t\t{ ...isDirtyProps }\n\t\t/>\n\t);\n}\n\n/**\n * Renders a panel for saving entities with dirty records.\n *\n * @param {Object} props The component props.\n * @param {string} props.additionalPrompt Additional prompt to display.\n * @param {Function} props.close Function to close the panel.\n * @param {Function} props.onSave Function to call when saving entities.\n * @param {boolean} props.saveEnabled Flag indicating if save is enabled.\n * @param {string} props.saveLabel Label for the save button.\n * @param {boolean} props.renderDialog Whether to render the component with modal dialog behavior.\n * @param {Array} props.dirtyEntityRecords Array of dirty entity records.\n * @param {boolean} props.isDirty Flag indicating if there are dirty entities.\n * @param {Function} props.setUnselectedEntities Function to set unselected entities.\n * @param {Array} props.unselectedEntities Array of unselected entities.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport function EntitiesSavedStatesExtensible( {\n\tadditionalPrompt = undefined,\n\tclose,\n\tonSave = identity,\n\tsaveEnabled: saveEnabledProp = undefined,\n\tsaveLabel = __( 'Save' ),\n\trenderDialog,\n\tdirtyEntityRecords,\n\tisDirty,\n\tsetUnselectedEntities,\n\tunselectedEntities,\n} ) {\n\tconst saveButtonRef = useRef();\n\tconst { saveDirtyEntities } = unlock( useDispatch( editorStore ) );\n\t// To group entities by type.\n\tconst partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => {\n\t\tconst { name } = record;\n\t\tif ( ! acc[ name ] ) {\n\t\t\tacc[ name ] = [];\n\t\t}\n\t\tacc[ name ].push( record );\n\t\treturn acc;\n\t}, {} );\n\n\t// Sort entity groups.\n\tconst {\n\t\tsite: siteSavables,\n\t\twp_template: templateSavables,\n\t\twp_template_part: templatePartSavables,\n\t\t...contentSavables\n\t} = partitionedSavables;\n\tconst sortedPartitionedSavables = [\n\t\tsiteSavables,\n\t\ttemplateSavables,\n\t\ttemplatePartSavables,\n\t\t...Object.values( contentSavables ),\n\t].filter( Array.isArray );\n\n\tconst saveEnabled = saveEnabledProp ?? isDirty;\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\tconst dialogLabel = useInstanceId( EntitiesSavedStatesExtensible, 'label' );\n\tconst dialogDescription = useInstanceId(\n\t\tEntitiesSavedStatesExtensible,\n\t\t'description'\n\t);\n\n\tconst selectItemsToSaveDescription = !! dirtyEntityRecords.length\n\t\t? __( 'Select the items you want to save.' )\n\t\t: undefined;\n\n\treturn (\n\t\t<div\n\t\t\tref={ renderDialog ? saveDialogRef : undefined }\n\t\t\t{ ...( renderDialog && saveDialogProps ) }\n\t\t\tclassName=\"entities-saved-states__panel\"\n\t\t\trole={ renderDialog ? 'dialog' : undefined }\n\t\t\taria-labelledby={ renderDialog ? dialogLabel : undefined }\n\t\t\taria-describedby={ renderDialog ? dialogDescription : undefined }\n\t\t>\n\t\t\t<Flex className=\"entities-saved-states__panel-header\" gap={ 2 }>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tonClick={ dismissPanel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tref={ saveButtonRef }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tdisabled={ ! saveEnabled }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\tsaveDirtyEntities( {\n\t\t\t\t\t\t\tonSave,\n\t\t\t\t\t\t\tdirtyEntityRecords,\n\t\t\t\t\t\t\tentitiesToSkip: unselectedEntities,\n\t\t\t\t\t\t\tclose,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tclassName=\"editor-entities-saved-states__save-button\"\n\t\t\t\t>\n\t\t\t\t\t{ saveLabel }\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"entities-saved-states__text-prompt--header-wrapper\"\n\t\t\t\t\tid={ renderDialog ? dialogLabel : undefined }\n\t\t\t\t>\n\t\t\t\t\t<strong className=\"entities-saved-states__text-prompt--header\">\n\t\t\t\t\t\t{ __( 'Are you ready to save?' ) }\n\t\t\t\t\t</strong>\n\t\t\t\t\t{ additionalPrompt }\n\t\t\t\t</div>\n\t\t\t\t<p id={ renderDialog ? dialogDescription : undefined }>\n\t\t\t\t\t{ isDirty\n\t\t\t\t\t\t? createInterpolateElement(\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %d: number of site changes waiting to be saved. */\n\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t'There is <strong>%d site change</strong> waiting to be saved.',\n\t\t\t\t\t\t\t\t\t\t'There are <strong>%d site changes</strong> waiting to be saved.',\n\t\t\t\t\t\t\t\t\t\tdirtyEntityRecords.length\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tdirtyEntityRecords.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{ strong: <strong /> }\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: selectItemsToSaveDescription }\n\t\t\t\t</p>\n\t\t\t</div>\n\n\t\t\t{ sortedPartitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,uBAAuB;AAC9D,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SACCC,WAAW,EACXC,MAAM,EACNC,wBAAwB,QAClB,oBAAoB;AAC3B,SACCC,uBAAuB,IAAIC,SAAS,EACpCC,aAAa,QACP,oBAAoB;AAC3B,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,SAASC,UAAU,QAAQ,sBAAsB;AACjD,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAClD,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE3C,SAASC,QAAQA,CAAEC,MAAM,EAAG;EAC3B,OAAOA,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,mBAAmBA,CAAE;EAAEC,KAAK;EAAEC;AAAa,CAAC,EAAG;EACtE,MAAMC,YAAY,GAAGb,UAAU,CAAC,CAAC;EACjC,oBACCK,IAAA,CAACS,6BAA6B;IAC7BH,KAAK,EAAGA,KAAO;IACfC,Y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ACtC,IAIhB,CAAC;IAEJ,CAAE,CAAC;EAAA,CACC,CAAC;AAER","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","Button","Flex","FlexItem","__","_n","sprintf","useCallback","useRef","createInterpolateElement","__experimentalUseDialog","useDialog","useInstanceId","useDispatch","EntityTypeList","useIsDirty","store","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","identity","values","EntitiesSavedStates","close","renderDialog","variant","isDirtyProps","EntitiesSavedStatesExtensible","additionalPrompt","undefined","onSave","saveEnabled","saveEnabledProp","saveLabel","dirtyEntityRecords","isDirty","setUnselectedEntities","unselectedEntities","saveButtonRef","saveDirtyEntities","partitionedSavables","reduce","acc","record","name","push","site","siteSavables","wp_template","templateSavables","wp_template_part","templatePartSavables","contentSavables","sortedPartitionedSavables","Object","filter","Array","isArray","dismissPanel","saveDialogRef","saveDialogProps","onClose","dialogLabelId","dialogDescriptionId","selectItemsToSaveDescription","length","isInline","actionButtons","children","isBlock","as","size","onClick","ref","disabled","accessibleWhenDisabled","entitiesToSkip","className","role","gap","id","strong","map","list","direction","justify"],"sources":["@wordpress/editor/src/components/entities-saved-states/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Flex, FlexItem } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tuseCallback,\n\tuseRef,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport {\n\t__experimentalUseDialog as useDialog,\n\tuseInstanceId,\n} from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport EntityTypeList from './entity-type-list';\nimport { useIsDirty } from './hooks/use-is-dirty';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nfunction identity( values ) {\n\treturn values;\n}\n\n/**\n * Renders the component for managing saved states of entities.\n *\n * @param {Object} props The component props.\n * @param {Function} props.close The function to close the dialog.\n * @param {boolean} props.renderDialog Whether to render the component with modal dialog behavior.\n * @param {string} props.variant Changes the layout of the component. When an `inline` value is provided, the action buttons are rendered at the end of the component instead of at the start.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function EntitiesSavedStates( {\n\tclose,\n\trenderDialog,\n\tvariant,\n} ) {\n\tconst isDirtyProps = useIsDirty();\n\treturn (\n\t\t<EntitiesSavedStatesExtensible\n\t\t\tclose={ close }\n\t\t\trenderDialog={ renderDialog }\n\t\t\tvariant={ variant }\n\t\t\t{ ...isDirtyProps }\n\t\t/>\n\t);\n}\n\n/**\n * Renders a panel for saving entities with dirty records.\n *\n * @param {Object} props The component props.\n * @param {string} props.additionalPrompt Additional prompt to display.\n * @param {Function} props.close Function to close the panel.\n * @param {Function} props.onSave Function to call when saving entities.\n * @param {boolean} props.saveEnabled Flag indicating if save is enabled.\n * @param {string} props.saveLabel Label for the save button.\n * @param {boolean} props.renderDialog Whether to render the component with modal dialog behavior.\n * @param {Array} props.dirtyEntityRecords Array of dirty entity records.\n * @param {boolean} props.isDirty Flag indicating if there are dirty entities.\n * @param {Function} props.setUnselectedEntities Function to set unselected entities.\n * @param {Array} props.unselectedEntities Array of unselected entities.\n * @param {string} props.variant Changes the layout of the component. When an `inline` value is provided, the action buttons are rendered at the end of the component instead of at the start.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport function EntitiesSavedStatesExtensible( {\n\tadditionalPrompt = undefined,\n\tclose,\n\tonSave = identity,\n\tsaveEnabled: saveEnabledProp = undefined,\n\tsaveLabel = __( 'Save' ),\n\trenderDialog,\n\tdirtyEntityRecords,\n\tisDirty,\n\tsetUnselectedEntities,\n\tunselectedEntities,\n\tvariant = 'default',\n} ) {\n\tconst saveButtonRef = useRef();\n\tconst { saveDirtyEntities } = unlock( useDispatch( editorStore ) );\n\t// To group entities by type.\n\tconst partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => {\n\t\tconst { name } = record;\n\t\tif ( ! acc[ name ] ) {\n\t\t\tacc[ name ] = [];\n\t\t}\n\t\tacc[ name ].push( record );\n\t\treturn acc;\n\t}, {} );\n\n\t// Sort entity groups.\n\tconst {\n\t\tsite: siteSavables,\n\t\twp_template: templateSavables,\n\t\twp_template_part: templatePartSavables,\n\t\t...contentSavables\n\t} = partitionedSavables;\n\tconst sortedPartitionedSavables = [\n\t\tsiteSavables,\n\t\ttemplateSavables,\n\t\ttemplatePartSavables,\n\t\t...Object.values( contentSavables ),\n\t].filter( Array.isArray );\n\n\tconst saveEnabled = saveEnabledProp ?? isDirty;\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\tconst dialogLabelId = useInstanceId(\n\t\tEntitiesSavedStatesExtensible,\n\t\t'entities-saved-states__panel-label'\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tEntitiesSavedStatesExtensible,\n\t\t'entities-saved-states__panel-description'\n\t);\n\n\tconst selectItemsToSaveDescription = !! dirtyEntityRecords.length\n\t\t? __( 'Select the items you want to save.' )\n\t\t: undefined;\n\n\tconst isInline = variant === 'inline';\n\n\tconst actionButtons = (\n\t\t<>\n\t\t\t<FlexItem\n\t\t\t\tisBlock={ isInline ? false : true }\n\t\t\t\tas={ Button }\n\t\t\t\tvariant={ isInline ? 'tertiary' : 'secondary' }\n\t\t\t\tsize={ isInline ? undefined : 'compact' }\n\t\t\t\tonClick={ dismissPanel }\n\t\t\t>\n\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t</FlexItem>\n\t\t\t<FlexItem\n\t\t\t\tisBlock={ isInline ? false : true }\n\t\t\t\tas={ Button }\n\t\t\t\tref={ saveButtonRef }\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tsize={ isInline ? undefined : 'compact' }\n\t\t\t\tdisabled={ ! saveEnabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsaveDirtyEntities( {\n\t\t\t\t\t\tonSave,\n\t\t\t\t\t\tdirtyEntityRecords,\n\t\t\t\t\t\tentitiesToSkip: unselectedEntities,\n\t\t\t\t\t\tclose,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tclassName=\"editor-entities-saved-states__save-button\"\n\t\t\t>\n\t\t\t\t{ saveLabel }\n\t\t\t</FlexItem>\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tref={ renderDialog ? saveDialogRef : undefined }\n\t\t\t{ ...( renderDialog && saveDialogProps ) }\n\t\t\tclassName={ clsx( 'entities-saved-states__panel', {\n\t\t\t\t'is-inline': isInline,\n\t\t\t} ) }\n\t\t\trole={ renderDialog ? 'dialog' : undefined }\n\t\t\taria-labelledby={ renderDialog ? dialogLabelId : undefined }\n\t\t\taria-describedby={ renderDialog ? dialogDescriptionId : undefined }\n\t\t>\n\t\t\t{ ! isInline && (\n\t\t\t\t<Flex className=\"entities-saved-states__panel-header\" gap={ 2 }>\n\t\t\t\t\t{ actionButtons }\n\t\t\t\t</Flex>\n\t\t\t) }\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<div className=\"entities-saved-states__text-prompt--header-wrapper\">\n\t\t\t\t\t<strong\n\t\t\t\t\t\tid={ renderDialog ? dialogLabelId : undefined }\n\t\t\t\t\t\tclassName=\"entities-saved-states__text-prompt--header\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Are you ready to save?' ) }\n\t\t\t\t\t</strong>\n\t\t\t\t</div>\n\t\t\t\t<div id={ renderDialog ? dialogDescriptionId : undefined }>\n\t\t\t\t\t{ additionalPrompt }\n\t\t\t\t\t<p className=\"entities-saved-states__text-prompt--changes-count\">\n\t\t\t\t\t\t{ isDirty\n\t\t\t\t\t\t\t? createInterpolateElement(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %d: number of site changes waiting to be saved. */\n\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t'There is <strong>%d site change</strong> waiting to be saved.',\n\t\t\t\t\t\t\t\t\t\t\t'There are <strong>%d site changes</strong> waiting to be saved.',\n\t\t\t\t\t\t\t\t\t\t\tdirtyEntityRecords.length\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tdirtyEntityRecords.length\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{ strong: <strong /> }\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: selectItemsToSaveDescription }\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t{ sortedPartitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\n\t\t\t{ isInline && (\n\t\t\t\t<Flex\n\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\tclassName=\"entities-saved-states__panel-footer\"\n\t\t\t\t>\n\t\t\t\t\t{ actionButtons }\n\t\t\t\t</Flex>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,uBAAuB;AAC9D,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SACCC,WAAW,EACXC,MAAM,EACNC,wBAAwB,QAClB,oBAAoB;AAC3B,SACCC,uBAAuB,IAAIC,SAAS,EACpC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OAAO,EAAC,UAAU;MAClBR,SAAS,EAAC,qCAAqC;MAAAT,QAAA,EAE7CD;IAAa,CACV,CACN;EAAA,CACG,CAAC;AAER","ignoreList":[]}
|
|
@@ -18,9 +18,14 @@ const {
|
|
|
18
18
|
Menu,
|
|
19
19
|
kebabCase
|
|
20
20
|
} = unlock(componentsPrivateApis);
|
|
21
|
-
function
|
|
21
|
+
export default function PostActions({
|
|
22
|
+
postType,
|
|
23
|
+
postId,
|
|
24
|
+
onActionPerformed
|
|
25
|
+
}) {
|
|
26
|
+
const [activeModalAction, setActiveModalAction] = useState(null);
|
|
22
27
|
const {
|
|
23
|
-
|
|
28
|
+
item,
|
|
24
29
|
permissions
|
|
25
30
|
} = useSelect(select => {
|
|
26
31
|
const {
|
|
@@ -28,39 +33,25 @@ function useEditedEntityRecordsWithPermissions(postType, postIds) {
|
|
|
28
33
|
getEntityRecordPermissions
|
|
29
34
|
} = unlock(select(coreStore));
|
|
30
35
|
return {
|
|
31
|
-
|
|
32
|
-
permissions:
|
|
36
|
+
item: getEditedEntityRecord('postType', postType, postId),
|
|
37
|
+
permissions: getEntityRecordPermissions('postType', postType, postId)
|
|
33
38
|
};
|
|
34
|
-
}, [
|
|
35
|
-
|
|
36
|
-
return
|
|
39
|
+
}, [postId, postType]);
|
|
40
|
+
const itemWithPermissions = useMemo(() => {
|
|
41
|
+
return {
|
|
37
42
|
...item,
|
|
38
|
-
permissions
|
|
39
|
-
}
|
|
40
|
-
}, [
|
|
41
|
-
}
|
|
42
|
-
export default function PostActions({
|
|
43
|
-
postType,
|
|
44
|
-
postId,
|
|
45
|
-
onActionPerformed
|
|
46
|
-
}) {
|
|
47
|
-
const [activeModalAction, setActiveModalAction] = useState(null);
|
|
48
|
-
const _postIds = useMemo(() => {
|
|
49
|
-
if (Array.isArray(postId)) {
|
|
50
|
-
return postId;
|
|
51
|
-
}
|
|
52
|
-
return postId ? [postId] : [];
|
|
53
|
-
}, [postId]);
|
|
54
|
-
const itemsWithPermissions = useEditedEntityRecordsWithPermissions(postType, _postIds);
|
|
43
|
+
permissions
|
|
44
|
+
};
|
|
45
|
+
}, [item, permissions]);
|
|
55
46
|
const allActions = usePostActions({
|
|
56
47
|
postType,
|
|
57
48
|
onActionPerformed
|
|
58
49
|
});
|
|
59
50
|
const actions = useMemo(() => {
|
|
60
51
|
return allActions.filter(action => {
|
|
61
|
-
return
|
|
52
|
+
return !action.isEligible || action.isEligible(itemWithPermissions);
|
|
62
53
|
});
|
|
63
|
-
}, [allActions,
|
|
54
|
+
}, [allActions, itemWithPermissions]);
|
|
64
55
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
65
56
|
children: [/*#__PURE__*/_jsxs(Menu, {
|
|
66
57
|
placement: "bottom-end",
|
|
@@ -76,13 +67,13 @@ export default function PostActions({
|
|
|
76
67
|
}), /*#__PURE__*/_jsx(Menu.Popover, {
|
|
77
68
|
children: /*#__PURE__*/_jsx(ActionsDropdownMenuGroup, {
|
|
78
69
|
actions: actions,
|
|
79
|
-
items:
|
|
70
|
+
items: [itemWithPermissions],
|
|
80
71
|
setActiveModalAction: setActiveModalAction
|
|
81
72
|
})
|
|
82
73
|
})]
|
|
83
74
|
}), !!activeModalAction && /*#__PURE__*/_jsx(ActionModal, {
|
|
84
75
|
action: activeModalAction,
|
|
85
|
-
items:
|
|
76
|
+
items: [itemWithPermissions],
|
|
86
77
|
closeModal: () => setActiveModalAction(null)
|
|
87
78
|
})]
|
|
88
79
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRegistry","useSelect","useState","useMemo","__","privateApis","componentsPrivateApis","Button","Modal","moreVertical","store","coreStore","unlock","usePostActions","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","Menu","kebabCase","useEditedEntityRecordsWithPermissions","postType","postIds","items","permissions","select","getEditedEntityRecord","getEntityRecordPermissions","map","postId","item","index","PostActions","onActionPerformed","activeModalAction","setActiveModalAction","_postIds","Array","isArray","itemsWithPermissions","allActions","actions","filter","action","isEligible","some","itemWithPermissions","length","supportsBulk","children","placement","TriggerButton","render","size","icon","label","disabled","accessibleWhenDisabled","className","Popover","ActionsDropdownMenuGroup","ActionModal","closeModal","DropdownMenuItemTrigger","onClick","Item","ItemLabel","title","modalHeader","__experimentalHideHeader","hideModalHeader","onRequestClose","focusOnMount","overlayClassName","id","RenderModal","registry","Group","callback"],"sources":["@wordpress/editor/src/components/post-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tprivateApis as componentsPrivateApis,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { usePostActions } from './actions';\n\nconst { Menu, kebabCase } = unlock( componentsPrivateApis );\n\nfunction useEditedEntityRecordsWithPermissions( postType, postIds ) {\n\tconst { items, permissions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getEntityRecordPermissions } =\n\t\t\t\tunlock( select( coreStore ) );\n\t\t\treturn {\n\t\t\t\titems: postIds.map( ( postId ) =>\n\t\t\t\t\tgetEditedEntityRecord( 'postType', postType, postId )\n\t\t\t\t),\n\t\t\t\tpermissions: postIds.map( ( postId ) =>\n\t\t\t\t\tgetEntityRecordPermissions( 'postType', postType, postId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ postIds, postType ]\n\t);\n\n\treturn useMemo( () => {\n\t\treturn items.map( ( item, index ) => ( {\n\t\t\t...item,\n\t\t\tpermissions: permissions[ index ],\n\t\t} ) );\n\t}, [ items, permissions ] );\n}\n\nexport default function PostActions( { postType, postId, onActionPerformed } ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState( null );\n\tconst _postIds = useMemo( () => {\n\t\tif ( Array.isArray( postId ) ) {\n\t\t\treturn postId;\n\t\t}\n\t\treturn postId ? [ postId ] : [];\n\t}, [ postId ] );\n\n\tconst itemsWithPermissions = useEditedEntityRecordsWithPermissions(\n\t\tpostType,\n\t\t_postIds\n\t);\n\tconst allActions = usePostActions( { postType, onActionPerformed } );\n\n\tconst actions = useMemo( () => {\n\t\treturn allActions.filter( ( action ) => {\n\t\t\treturn (\n\t\t\t\t( ! action.isEligible ||\n\t\t\t\t\titemsWithPermissions.some( ( itemWithPermissions ) =>\n\t\t\t\t\t\taction.isEligible( itemWithPermissions )\n\t\t\t\t\t) ) &&\n\t\t\t\t( itemsWithPermissions.length < 2 || action.supportsBulk )\n\t\t\t);\n\t\t} );\n\t}, [ allActions, itemsWithPermissions ] );\n\n\treturn (\n\t\t<>\n\t\t\t<Menu placement=\"bottom-end\">\n\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\trender={\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tclassName=\"editor-all-actions-button\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Menu.Popover>\n\t\t\t\t\t<ActionsDropdownMenuGroup\n\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\titems={ itemsWithPermissions }\n\t\t\t\t\t\tsetActiveModalAction={ setActiveModalAction }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ itemsWithPermissions }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n// From now on all the functions on this file are copied as from the dataviews packages,\n// The editor packages should not be using the dataviews packages directly,\n// and the dataviews package should not be using the editor packages directly,\n// so duplicating the code here seems like the least bad option.\n\nfunction DropdownMenuItemTrigger( { action, onClick, items } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Menu.Item onClick={ onClick }>\n\t\t\t<Menu.ItemLabel>{ label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n}\n\nexport function ActionModal( { action, items, closeModal } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ action.modalHeader || label }\n\t\t\t__experimentalHideHeader={ !! action.hideModalHeader }\n\t\t\tonRequestClose={ closeModal ?? ( () => {} ) }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t\toverlayClassName={ `editor-action-modal editor-action-modal__${ kebabCase(\n\t\t\t\taction.id\n\t\t\t) }` }\n\t\t>\n\t\t\t<action.RenderModal items={ items } closeModal={ closeModal } />\n\t\t</Modal>\n\t);\n}\n\nfunction ActionsDropdownMenuGroup( { actions, items, setActiveModalAction } ) {\n\tconst registry = useRegistry();\n\treturn (\n\t\t<Menu.Group>\n\t\t\t{ actions.map( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownMenuItemTrigger\n\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taction.callback( items, { registry } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\titems={ items }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Menu.Group>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,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K,GAAGZ,MAAM,CAACY,KAAK,CAAEhC,KAAM,CAAC;EACxE,oBACCV,IAAA,CAACP,KAAK;IACL6D,KAAK,EAAGxB,MAAM,CAACyB,WAAW,IAAIb,KAAO;IACrCc,wBAAwB,EAAG,CAAC,CAAE1B,MAAM,CAAC2B,eAAiB;IACtDC,cAAc,EAAGT,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAM,MAAM,CAAC,CAAK;IAC7CU,YAAY,EAAC,qBAAqB;IAClCnB,IAAI,EAAC,QAAQ;IACboB,gBAAgB,EAAG,4CAA6CtD,SAAS,CACxEwB,MAAM,CAAC+B,EACR,CAAC,EAAK;IAAAzB,QAAA,eAENpC,IAAA,CAAC8B,MAAM,CAACgC,WAAW;MAACpD,KAAK,EAAGA,KAAO;MAACuC,UAAU,EAAGA;IAAY,CAAE;EAAC,CAC1D,CAAC;AAEV;AAEA,SAASF,wBAAwBA,CAAE;EAAEnB,OAAO;EAAElB,KAAK;EAAEY;AAAqB,CAAC,EAAG;EAC7E,MAAMyC,QAAQ,GAAG9E,WAAW,CAAC,CAAC;EAC9B,oBACCe,IAAA,CAACK,IAAI,CAAC2D,KAAK;IAAA5B,QAAA,EACRR,OAAO,CAACb,GAAG,CAAIe,MAAM,IAAM;MAC5B,oBACC9B,IAAA,CAACkD,uBAAuB;QAEvBpB,MAAM,EAAGA,MAAQ;QACjBqB,OAAO,EAAGA,CAAA,KAAM;UACf,IAAK,aAAa,IAAIrB,MAAM,EAAG;YAC9BR,oBAAoB,CAAEQ,MAAO,CAAC;YAC9B;UACD;UACAA,MAAM,CAACmC,QAAQ,CAAEvD,KAAK,EAAE;YAAEqD;UAAS,CAAE,CAAC;QACvC,CAAG;QACHrD,KAAK,EAAGA;MAAO,GATToB,MAAM,CAAC+B,EAUb,CAAC;IAEJ,CAAE;EAAC,CACQ,CAAC;AAEf","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useRegistry","useSelect","useState","useMemo","__","privateApis","componentsPrivateApis","Button","Modal","moreVertical","store","coreStore","unlock","usePostActions","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","Menu","kebabCase","PostActions","postType","postId","onActionPerformed","activeModalAction","setActiveModalAction","item","permissions","select","getEditedEntityRecord","getEntityRecordPermissions","itemWithPermissions","allActions","actions","filter","action","isEligible","children","placement","TriggerButton","render","size","icon","label","disabled","length","accessibleWhenDisabled","className","Popover","ActionsDropdownMenuGroup","items","ActionModal","closeModal","DropdownMenuItemTrigger","onClick","Item","ItemLabel","title","modalHeader","__experimentalHideHeader","hideModalHeader","onRequestClose","focusOnMount","overlayClassName","id","RenderModal","registry","Group","map","callback"],"sources":["@wordpress/editor/src/components/post-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tprivateApis as componentsPrivateApis,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { usePostActions } from './actions';\n\nconst { Menu, kebabCase } = unlock( componentsPrivateApis );\n\nexport default function PostActions( { postType, postId, onActionPerformed } ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState( null );\n\n\tconst { item, permissions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getEntityRecordPermissions } =\n\t\t\t\tunlock( select( coreStore ) );\n\t\t\treturn {\n\t\t\t\titem: getEditedEntityRecord( 'postType', postType, postId ),\n\t\t\t\tpermissions: getEntityRecordPermissions(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ postId, postType ]\n\t);\n\tconst itemWithPermissions = useMemo( () => {\n\t\treturn {\n\t\t\t...item,\n\t\t\tpermissions,\n\t\t};\n\t}, [ item, permissions ] );\n\tconst allActions = usePostActions( { postType, onActionPerformed } );\n\n\tconst actions = useMemo( () => {\n\t\treturn allActions.filter( ( action ) => {\n\t\t\treturn (\n\t\t\t\t! action.isEligible || action.isEligible( itemWithPermissions )\n\t\t\t);\n\t\t} );\n\t}, [ allActions, itemWithPermissions ] );\n\n\treturn (\n\t\t<>\n\t\t\t<Menu placement=\"bottom-end\">\n\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\trender={\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tclassName=\"editor-all-actions-button\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Menu.Popover>\n\t\t\t\t\t<ActionsDropdownMenuGroup\n\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\titems={ [ itemWithPermissions ] }\n\t\t\t\t\t\tsetActiveModalAction={ setActiveModalAction }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ [ itemWithPermissions ] }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n// From now on all the functions on this file are copied as from the dataviews packages,\n// The editor packages should not be using the dataviews packages directly,\n// and the dataviews package should not be using the editor packages directly,\n// so duplicating the code here seems like the least bad option.\n\nfunction DropdownMenuItemTrigger( { action, onClick, items } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Menu.Item onClick={ onClick }>\n\t\t\t<Menu.ItemLabel>{ label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n}\n\nexport function ActionModal( { action, items, closeModal } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ action.modalHeader || label }\n\t\t\t__experimentalHideHeader={ !! action.hideModalHeader }\n\t\t\tonRequestClose={ closeModal ?? ( () => {} ) }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t\toverlayClassName={ `editor-action-modal editor-action-modal__${ kebabCase(\n\t\t\t\taction.id\n\t\t\t) }` }\n\t\t>\n\t\t\t<action.RenderModal items={ items } closeModal={ closeModal } />\n\t\t</Modal>\n\t);\n}\n\nfunction ActionsDropdownMenuGroup( { actions, items, setActiveModalAction } ) {\n\tconst registry = useRegistry();\n\treturn (\n\t\t<Menu.Group>\n\t\t\t{ actions.map( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownMenuItemTrigger\n\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taction.callback( items, { registry } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\titems={ items }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Menu.Group>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,WAAW,IAAIC,qBAAqB,EACpCC,MAAM,EACNC,KAAK,QACC,uBAAuB;AAC9B,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,KAAK,I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IAAInB,MAAM,EAAG;YAC9BV,oBAAoB,CAAEU,MAAO,CAAC;YAC9B;UACD;UACAA,MAAM,CAACkC,QAAQ,CAAEnB,KAAK,EAAE;YAAEgB;UAAS,CAAE,CAAC;QACvC,CAAG;QACHhB,KAAK,EAAGA;MAAO,GATTf,MAAM,CAAC6B,EAUb,CAAC;IAEJ,CAAE;EAAC,CACQ,CAAC;AAEf","ignoreList":[]}
|
|
@@ -44,7 +44,7 @@ export default function PostCardPanel({
|
|
|
44
44
|
} = useSelect(select => {
|
|
45
45
|
const {
|
|
46
46
|
getEditedEntityRecord,
|
|
47
|
-
|
|
47
|
+
getCurrentTheme,
|
|
48
48
|
getPostType
|
|
49
49
|
} = select(coreStore);
|
|
50
50
|
const {
|
|
@@ -53,10 +53,10 @@ export default function PostCardPanel({
|
|
|
53
53
|
let _title = '';
|
|
54
54
|
const _record = getEditedEntityRecord('postType', postType, postIds[0]);
|
|
55
55
|
if (postIds.length === 1) {
|
|
56
|
-
var
|
|
56
|
+
var _getCurrentTheme;
|
|
57
57
|
const {
|
|
58
58
|
default_template_types: templateTypes = []
|
|
59
|
-
} = (
|
|
59
|
+
} = (_getCurrentTheme = getCurrentTheme()) !== null && _getCurrentTheme !== void 0 ? _getCurrentTheme : {};
|
|
60
60
|
const _templateInfo = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(postType) ? getTemplateInfo({
|
|
61
61
|
template: _record,
|
|
62
62
|
templateTypes
|
|
@@ -101,9 +101,9 @@ export default function PostCardPanel({
|
|
|
101
101
|
}), pageTypeBadge && postIds.length === 1 && /*#__PURE__*/_jsx(Badge, {
|
|
102
102
|
children: pageTypeBadge
|
|
103
103
|
})]
|
|
104
|
-
}), /*#__PURE__*/_jsx(PostActions, {
|
|
104
|
+
}), postIds.length === 1 && /*#__PURE__*/_jsx(PostActions, {
|
|
105
105
|
postType: postType,
|
|
106
|
-
postId:
|
|
106
|
+
postId: postIds[0],
|
|
107
107
|
onActionPerformed: onActionPerformed
|
|
108
108
|
})]
|
|
109
109
|
}), postIds.length > 1 && /*#__PURE__*/_jsx(Text, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Icon","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalText","Text","privateApis","componentsPrivateApis","store","coreStore","useSelect","useMemo","__","sprintf","__unstableStripHTML","stripHTML","editorStore","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","unlock","PostActions","usePageTypeBadge","getTemplateInfo","jsx","_jsx","jsxs","_jsxs","Badge","PostCardPanel","postType","postId","onActionPerformed","postIds","Array","isArray","postTitle","icon","labels","select","getEditedEntityRecord","
|
|
1
|
+
{"version":3,"names":["Icon","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalText","Text","privateApis","componentsPrivateApis","store","coreStore","useSelect","useMemo","__","sprintf","__unstableStripHTML","stripHTML","editorStore","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","unlock","PostActions","usePageTypeBadge","getTemplateInfo","jsx","_jsx","jsxs","_jsxs","Badge","PostCardPanel","postType","postId","onActionPerformed","postIds","Array","isArray","postTitle","icon","labels","select","getEditedEntityRecord","getCurrentTheme","getPostType","getPostIcon","_title","_record","length","_getCurrentTheme","default_template_types","templateTypes","_templateInfo","includes","template","title","area","pageTypeBadge","name","spacing","className","children","align","numberOfLines","truncate","as","toLowerCase"],"sources":["@wordpress/editor/src/components/post-card-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalText as Text,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../store/constants';\nimport { unlock } from '../../lock-unlock';\nimport PostActions from '../post-actions';\nimport usePageTypeBadge from '../../utils/pageTypeBadge';\nimport { getTemplateInfo } from '../../utils/get-template-info';\nconst { Badge } = unlock( componentsPrivateApis );\n\n/**\n * Renders a title of the post type and the available quick actions available within a 3-dot dropdown.\n *\n * @param {Object} props - Component props.\n * @param {string} [props.postType] - The post type string.\n * @param {string|string[]} [props.postId] - The post id or list of post ids.\n * @param {Function} [props.onActionPerformed] - A callback function for when a quick action is performed.\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostCardPanel( {\n\tpostType,\n\tpostId,\n\tonActionPerformed,\n} ) {\n\tconst postIds = useMemo(\n\t\t() => ( Array.isArray( postId ) ? postId : [ postId ] ),\n\t\t[ postId ]\n\t);\n\tconst { postTitle, icon, labels } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getCurrentTheme, getPostType } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getPostIcon } = unlock( select( editorStore ) );\n\t\t\tlet _title = '';\n\t\t\tconst _record = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostIds[ 0 ]\n\t\t\t);\n\t\t\tif ( postIds.length === 1 ) {\n\t\t\t\tconst { default_template_types: templateTypes = [] } =\n\t\t\t\t\tgetCurrentTheme() ?? {};\n\n\t\t\t\tconst _templateInfo = [\n\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t].includes( postType )\n\t\t\t\t\t? getTemplateInfo( {\n\t\t\t\t\t\t\ttemplate: _record,\n\t\t\t\t\t\t\ttemplateTypes,\n\t\t\t\t\t } )\n\t\t\t\t\t: {};\n\t\t\t\t_title = _templateInfo?.title || _record?.title;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tpostTitle: _title,\n\t\t\t\ticon: getPostIcon( postType, {\n\t\t\t\t\tarea: _record?.area,\n\t\t\t\t} ),\n\t\t\t\tlabels: getPostType( postType )?.labels,\n\t\t\t};\n\t\t},\n\t\t[ postIds, postType ]\n\t);\n\n\tconst pageTypeBadge = usePageTypeBadge( postId );\n\tlet title = __( 'No title' );\n\tif ( labels?.name && postIds.length > 1 ) {\n\t\ttitle = sprintf(\n\t\t\t// translators: %i number of selected items %s: Name of the plural post type e.g: \"Posts\".\n\t\t\t__( '%i %s' ),\n\t\t\tpostId.length,\n\t\t\tlabels?.name\n\t\t);\n\t} else if ( postTitle ) {\n\t\ttitle = stripHTML( postTitle );\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 1 } className=\"editor-post-card-panel\">\n\t\t\t<HStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"editor-post-card-panel__header\"\n\t\t\t\talign=\"flex-start\"\n\t\t\t>\n\t\t\t\t<Icon className=\"editor-post-card-panel__icon\" icon={ icon } />\n\t\t\t\t<Text\n\t\t\t\t\tnumberOfLines={ 2 }\n\t\t\t\t\ttruncate\n\t\t\t\t\tclassName=\"editor-post-card-panel__title\"\n\t\t\t\t\tas=\"h2\"\n\t\t\t\t>\n\t\t\t\t\t<span className=\"editor-post-card-panel__title-name\">\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</span>\n\t\t\t\t\t{ pageTypeBadge && postIds.length === 1 && (\n\t\t\t\t\t\t<Badge>{ pageTypeBadge }</Badge>\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t\t{ postIds.length === 1 && (\n\t\t\t\t\t<PostActions\n\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\tpostId={ postIds[ 0 ] }\n\t\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t{ postIds.length > 1 && (\n\t\t\t\t<Text className=\"editor-post-card-panel__description\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: %s: Name of the plural post type e.g: \"Posts\".\n\t\t\t\t\t\t__( 'Changes will be applied to all selected %s.' ),\n\t\t\t\t\t\tlabels?.name.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,IAAI,EACJC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,kBAAkB,IAAIC,IAAI,EAC1BC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;;AAEjE;AACA;AACA;AACA,SAASP,KAAK,IAAIQ,WAAW,QAAQ,aAAa;AAClD,SACCC,kBAAkB,EAClBC,uBAAuB,QACjB,uBAAuB;AAC9B,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,WAAW,MAAM,iBAAiB;AACzC,OAAOC,gBAAgB,MAAM,2BAA2B;AACxD,SAASC,eAAe,QAAQ,+BAA+B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAChE,MAAM;EAAEC;AAAM,CAAC,GAAGR,MAAM,CAAEZ,qBAAsB,CAAC;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASqB,aAAaA,CAAE;EACtCC,QAAQ;EACRC,MAAM;EACNC;AACD,CAAC,EAAG;EACH,MAAMC,OAAO,GAAGrB,OAAO,CACtB,MAAQsB,KAAK,CAACC,OAAO,CAAEJ,MAAO,CAAC,GAAGA,MAAM,GAAG,CAAEA,MAAM,CAAI,EACvD,CAAEA,MAAM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AACnB,IAAI;MAACoD,SAAS,EAAC,qCAAqC;MAAAC,QAAA,EAClD7C,OAAO;MACR;MACAD,EAAE,CAAE,6CAA8C,CAAC,EACnDyB,MAAM,EAAEkB,IAAI,CAACQ,WAAW,CAAC,CAC1B;IAAC,CACI,CACN;EAAA,CACM,CAAC;AAEX","ignoreList":[]}
|
|
@@ -97,7 +97,8 @@ function PostFeaturedImage({
|
|
|
97
97
|
onError(message) {
|
|
98
98
|
noticeOperations.removeAllNotices();
|
|
99
99
|
noticeOperations.createErrorNotice(message);
|
|
100
|
-
}
|
|
100
|
+
},
|
|
101
|
+
multiple: false
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
104
|
|
|
@@ -253,7 +254,8 @@ const applyWithDispatch = withDispatch((dispatch, {
|
|
|
253
254
|
onError(message) {
|
|
254
255
|
noticeOperations.removeAllNotices();
|
|
255
256
|
noticeOperations.createErrorNotice(message);
|
|
256
|
-
}
|
|
257
|
+
},
|
|
258
|
+
multiple: false
|
|
257
259
|
});
|
|
258
260
|
},
|
|
259
261
|
onRemoveImage() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","__","sprintf","applyFilters","DropZone","Button","Spinner","withNotices","withFilters","__experimentalHStack","HStack","Notice","isBlobURL","useState","useRef","compose","useSelect","withDispatch","withSelect","MediaUpload","MediaUploadCheck","store","blockEditorStore","coreStore","PostFeaturedImageCheck","editorStore","jsx","_jsx","jsxs","_jsxs","ALLOWED_MEDIA_TYPES","DEFAULT_FEATURE_IMAGE_LABEL","DEFAULT_SET_FEATURE_IMAGE_LABEL","instructions","children","getMediaDetails","media","postId","_media$media_details$","_media$media_details$2","defaultSize","id","media_details","sizes","mediaWidth","width","mediaHeight","height","mediaSourceUrl","source_url","fallbackSize","PostFeaturedImage","currentPostId","featuredImageId","onUpdateImage","onRemoveImage","postType","noticeUI","noticeOperations","isRequestingFeaturedImageMedia","returnsFocusRef","isLoading","setIsLoading","getSettings","onDropFiles","filesList","mediaUpload","allowedTypes","onFileChange","image","url","onError","message","removeAllNotices","createErrorNotice","getImageDescription","imageMedia","alt_text","full","file","slug","returnFocus","node","current","focus","isMissingMedia","className","fallback","title","labels","featured_image","onSelect","unstableFeaturedImageFlow","modalClass","render","open","status","isDismissible","__next40pxDefaultSize","ref","onClick","disabled","accessibleWhenDisabled","src","alt","set_featured_image","variant","undefined","isDestructive","onFilesDrop","value","applyWithSelect","select","getMedia","getPostType","hasFinishedResolution","getCurrentPostId","getEditedPostAttribute","context","applyWithDispatch","dispatch","editPost","featured_media","onDropImage"],"sources":["@wordpress/editor/src/components/post-featured-image/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tDropZone,\n\tButton,\n\tSpinner,\n\twithNotices,\n\twithFilters,\n\t__experimentalHStack as HStack,\n\tNotice,\n} from '@wordpress/components';\nimport { isBlobURL } from '@wordpress/blob';\nimport { useState, useRef } from '@wordpress/element';\nimport { compose } from '@wordpress/compose';\nimport { useSelect, withDispatch, withSelect } from '@wordpress/data';\nimport {\n\tMediaUpload,\n\tMediaUploadCheck,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFeaturedImageCheck from './check';\nimport { store as editorStore } from '../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\n// Used when labels from post type were not yet loaded or when they are not present.\nconst DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );\nconst DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Add a featured image' );\n\nconst instructions = (\n\t<p>\n\t\t{ __(\n\t\t\t'To edit the featured image, you need permission to upload media.'\n\t\t) }\n\t</p>\n);\n\nfunction getMediaDetails( media, postId ) {\n\tif ( ! media ) {\n\t\treturn {};\n\t}\n\n\tconst defaultSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'large',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( defaultSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ defaultSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ defaultSize ].height,\n\t\t\tmediaSourceUrl: media.media_details.sizes[ defaultSize ].source_url,\n\t\t};\n\t}\n\n\t// Use fallbackSize when defaultSize is not available.\n\tconst fallbackSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'thumbnail',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( fallbackSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ fallbackSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ fallbackSize ].height,\n\t\t\tmediaSourceUrl:\n\t\t\t\tmedia.media_details.sizes[ fallbackSize ].source_url,\n\t\t};\n\t}\n\n\t// Use full image size when fallbackSize and defaultSize are not available.\n\treturn {\n\t\tmediaWidth: media.media_details.width,\n\t\tmediaHeight: media.media_details.height,\n\t\tmediaSourceUrl: media.source_url,\n\t};\n}\n\nfunction PostFeaturedImage( {\n\tcurrentPostId,\n\tfeaturedImageId,\n\tonUpdateImage,\n\tonRemoveImage,\n\tmedia,\n\tpostType,\n\tnoticeUI,\n\tnoticeOperations,\n\tisRequestingFeaturedImageMedia,\n} ) {\n\tconst returnsFocusRef = useRef( false );\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst { getSettings } = useSelect( blockEditorStore );\n\tconst { mediaSourceUrl } = getMediaDetails( media, currentPostId );\n\n\tfunction onDropFiles( filesList ) {\n\t\tgetSettings().mediaUpload( {\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\tsetIsLoading( true );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( image ) {\n\t\t\t\t\tonUpdateImage( image );\n\t\t\t\t}\n\t\t\t\tsetIsLoading( false );\n\t\t\t},\n\t\t\tonError( message ) {\n\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t},\n\t\t} );\n\t}\n\n\t/**\n\t * Generates the featured image alt text for this editing context.\n\t *\n\t * @param {Object} imageMedia The image media object.\n\t * @param {string} imageMedia.alt_text The alternative text of the image.\n\t * @param {Object} imageMedia.media_details The media details of the image.\n\t * @param {Object} imageMedia.media_details.sizes The sizes of the image.\n\t * @param {Object} imageMedia.media_details.sizes.full The full size details of the image.\n\t * @param {string} imageMedia.media_details.sizes.full.file The file name of the full size image.\n\t * @param {string} imageMedia.slug The slug of the image.\n\t * @return {string} The featured image alt text.\n\t */\n\tfunction getImageDescription( imageMedia ) {\n\t\tif ( imageMedia.alt_text ) {\n\t\t\treturn sprintf(\n\t\t\t\t// Translators: %s: The selected image alt text.\n\t\t\t\t__( 'Current image: %s' ),\n\t\t\t\timageMedia.alt_text\n\t\t\t);\n\t\t}\n\t\treturn sprintf(\n\t\t\t// Translators: %s: The selected image filename.\n\t\t\t__(\n\t\t\t\t'The current image has no alternative text. The file name is: %s'\n\t\t\t),\n\t\t\timageMedia.media_details.sizes?.full?.file || imageMedia.slug\n\t\t);\n\t}\n\n\tfunction returnFocus( node ) {\n\t\tif ( returnsFocusRef.current && node ) {\n\t\t\tnode.focus();\n\t\t\treturnsFocusRef.current = false;\n\t\t}\n\t}\n\n\tconst isMissingMedia =\n\t\t! isRequestingFeaturedImageMedia && !! featuredImageId && ! media;\n\n\treturn (\n\t\t<PostFeaturedImageCheck>\n\t\t\t{ noticeUI }\n\t\t\t<div className=\"editor-post-featured-image\">\n\t\t\t\t{ media && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tid={ `editor-post-featured-image-${ featuredImageId }-describedby` }\n\t\t\t\t\t\tclassName=\"hidden\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ getImageDescription( media ) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<MediaUploadCheck fallback={ instructions }>\n\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\tpostType?.labels?.featured_image ||\n\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t<div className=\"editor-post-featured-image__container\">\n\t\t\t\t\t\t\t\t{ isMissingMedia ? (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Could not retrieve the featured image data.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\tref={ returnFocus }\n\t\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t\t? 'editor-post-featured-image__toggle'\n\t\t\t\t\t\t\t\t\t\t\t\t: 'editor-post-featured-image__preview'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Edit or replace the featured image'\n\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t\t: `editor-post-featured-image-${ featuredImageId }-describedby`\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t\t\tdisabled={ isLoading }\n\t\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ !! featuredImageId && media && (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__preview-image\"\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ mediaSourceUrl }\n\t\t\t\t\t\t\t\t\t\t\t\talt={ getImageDescription(\n\t\t\t\t\t\t\t\t\t\t\t\t\tmedia\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ ( isLoading ||\n\t\t\t\t\t\t\t\t\t\t\tisRequestingFeaturedImageMedia ) && (\n\t\t\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ ! featuredImageId &&\n\t\t\t\t\t\t\t\t\t\t\t! isLoading &&\n\t\t\t\t\t\t\t\t\t\t\t( postType?.labels\n\t\t\t\t\t\t\t\t\t\t\t\t?.set_featured_image ||\n\t\t\t\t\t\t\t\t\t\t\t\tDEFAULT_SET_FEATURE_IMAGE_LABEL ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ !! featuredImageId && (\n\t\t\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t\t'editor-post-featured-image__actions',\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t'editor-post-featured-image__actions-missing-image':\n\t\t\t\t\t\t\t\t\t\t\t\t\tisMissingMedia,\n\t\t\t\t\t\t\t\t\t\t\t\t'editor-post-featured-image__actions-is-requesting-image':\n\t\t\t\t\t\t\t\t\t\t\t\t\tisRequestingFeaturedImageMedia,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__action\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\t\tisMissingMedia\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'secondary'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__action\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tonRemoveImage();\n\t\t\t\t\t\t\t\t\t\t\t\t// Signal that the toggle button should be focused,\n\t\t\t\t\t\t\t\t\t\t\t\t// when it is rendered. Can't focus it directly here\n\t\t\t\t\t\t\t\t\t\t\t\t// because it's rendered conditionally.\n\t\t\t\t\t\t\t\t\t\t\t\treturnsFocusRef.current = true;\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\t\tisMissingMedia\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'secondary'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tisDestructive={ isMissingMedia }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onDropFiles } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ featuredImageId }\n\t\t\t\t\t/>\n\t\t\t\t</MediaUploadCheck>\n\t\t\t</div>\n\t\t</PostFeaturedImageCheck>\n\t);\n}\n\nconst applyWithSelect = withSelect( ( select ) => {\n\tconst { getMedia, getPostType, hasFinishedResolution } =\n\t\tselect( coreStore );\n\tconst { getCurrentPostId, getEditedPostAttribute } = select( editorStore );\n\tconst featuredImageId = getEditedPostAttribute( 'featured_media' );\n\n\treturn {\n\t\tmedia: featuredImageId\n\t\t\t? getMedia( featuredImageId, { context: 'view' } )\n\t\t\t: null,\n\t\tcurrentPostId: getCurrentPostId(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tfeaturedImageId,\n\t\tisRequestingFeaturedImageMedia:\n\t\t\t!! featuredImageId &&\n\t\t\t! hasFinishedResolution( 'getMedia', [\n\t\t\t\tfeaturedImageId,\n\t\t\t\t{ context: 'view' },\n\t\t\t] ),\n\t};\n} );\n\nconst applyWithDispatch = withDispatch(\n\t( dispatch, { noticeOperations }, { select } ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateImage( image ) {\n\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t},\n\t\t\tonDropImage( filesList ) {\n\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t.getSettings()\n\t\t\t\t\t.mediaUpload( {\n\t\t\t\t\t\tallowedTypes: [ 'image' ],\n\t\t\t\t\t\tfilesList,\n\t\t\t\t\t\tonFileChange( [ image ] ) {\n\t\t\t\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t},\n\t\t\tonRemoveImage() {\n\t\t\t\teditPost( { featured_media: 0 } );\n\t\t\t},\n\t\t};\n\t}\n);\n\n/**\n * Renders the component for managing the featured image of a post.\n *\n * @param {Object} props Props.\n * @param {number} props.currentPostId ID of the current post.\n * @param {number} props.featuredImageId ID of the featured image.\n * @param {Function} props.onUpdateImage Function to call when the image is updated.\n * @param {Function} props.onRemoveImage Function to call when the image is removed.\n * @param {Object} props.media The media object representing the featured image.\n * @param {string} props.postType Post type.\n * @param {Element} props.noticeUI UI for displaying notices.\n * @param {Object} props.noticeOperations Operations for managing notices.\n *\n * @return {Element} Component to be rendered .\n */\nexport default compose(\n\twithNotices,\n\tapplyWithSelect,\n\tapplyWithDispatch,\n\twithFilters( 'editor.PostFeaturedImage' )\n)( PostFeaturedImage );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;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CAAC;IACzC,CAAC;IACDkF,WAAWA,CAAE1D,SAAS,EAAG;MACxB+C,MAAM,CAAE1F,gBAAiB,CAAC,CACxByC,WAAW,CAAC,CAAC,CACbG,WAAW,CAAE;QACbC,YAAY,EAAE,CAAE,OAAO,CAAE;QACzBF,SAAS;QACTG,YAAYA,CAAE,CAAEC,KAAK,CAAE,EAAG;UACzBoD,QAAQ,CAAE;YAAEC,cAAc,EAAErD,KAAK,CAAC5B;UAAG,CAAE,CAAC;QACzC,CAAC;QACD8B,OAAOA,CAAEC,OAAO,EAAG;UAClBd,gBAAgB,CAACe,gBAAgB,CAAC,CAAC;UACnCf,gBAAgB,CAACgB,iBAAiB,CAAEF,OAAQ,CAAC;QAC9C;MACD,CAAE,CAAC;IACL,CAAC;IACDjB,aAAaA,CAAA,EAAG;MACfkE,QAAQ,CAAE;QAAEC,cAAc,EAAE;MAAE,CAAE,CAAC;IAClC;EACD,CAAC;AACF,CACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe3G,OAAO,CACrBR,WAAW,EACXwG,eAAe,EACfQ,iBAAiB,EACjB/G,WAAW,CAAE,0BAA2B,CACzC,CAAC,CAAE2C,iBAAkB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","__","sprintf","applyFilters","DropZone","Button","Spinner","withNotices","withFilters","__experimentalHStack","HStack","Notice","isBlobURL","useState","useRef","compose","useSelect","withDispatch","withSelect","MediaUpload","MediaUploadCheck","store","blockEditorStore","coreStore","PostFeaturedImageCheck","editorStore","jsx","_jsx","jsxs","_jsxs","ALLOWED_MEDIA_TYPES","DEFAULT_FEATURE_IMAGE_LABEL","DEFAULT_SET_FEATURE_IMAGE_LABEL","instructions","children","getMediaDetails","media","postId","_media$media_details$","_media$media_details$2","defaultSize","id","media_details","sizes","mediaWidth","width","mediaHeight","height","mediaSourceUrl","source_url","fallbackSize","PostFeaturedImage","currentPostId","featuredImageId","onUpdateImage","onRemoveImage","postType","noticeUI","noticeOperations","isRequestingFeaturedImageMedia","returnsFocusRef","isLoading","setIsLoading","getSettings","onDropFiles","filesList","mediaUpload","allowedTypes","onFileChange","image","url","onError","message","removeAllNotices","createErrorNotice","multiple","getImageDescription","imageMedia","alt_text","full","file","slug","returnFocus","node","current","focus","isMissingMedia","className","fallback","title","labels","featured_image","onSelect","unstableFeaturedImageFlow","modalClass","render","open","status","isDismissible","__next40pxDefaultSize","ref","onClick","disabled","accessibleWhenDisabled","src","alt","set_featured_image","variant","undefined","isDestructive","onFilesDrop","value","applyWithSelect","select","getMedia","getPostType","hasFinishedResolution","getCurrentPostId","getEditedPostAttribute","context","applyWithDispatch","dispatch","editPost","featured_media","onDropImage"],"sources":["@wordpress/editor/src/components/post-featured-image/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tDropZone,\n\tButton,\n\tSpinner,\n\twithNotices,\n\twithFilters,\n\t__experimentalHStack as HStack,\n\tNotice,\n} from '@wordpress/components';\nimport { isBlobURL } from '@wordpress/blob';\nimport { useState, useRef } from '@wordpress/element';\nimport { compose } from '@wordpress/compose';\nimport { useSelect, withDispatch, withSelect } from '@wordpress/data';\nimport {\n\tMediaUpload,\n\tMediaUploadCheck,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFeaturedImageCheck from './check';\nimport { store as editorStore } from '../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\n// Used when labels from post type were not yet loaded or when they are not present.\nconst DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );\nconst DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Add a featured image' );\n\nconst instructions = (\n\t<p>\n\t\t{ __(\n\t\t\t'To edit the featured image, you need permission to upload media.'\n\t\t) }\n\t</p>\n);\n\nfunction getMediaDetails( media, postId ) {\n\tif ( ! media ) {\n\t\treturn {};\n\t}\n\n\tconst defaultSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'large',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( defaultSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ defaultSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ defaultSize ].height,\n\t\t\tmediaSourceUrl: media.media_details.sizes[ defaultSize ].source_url,\n\t\t};\n\t}\n\n\t// Use fallbackSize when defaultSize is not available.\n\tconst fallbackSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'thumbnail',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( fallbackSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ fallbackSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ fallbackSize ].height,\n\t\t\tmediaSourceUrl:\n\t\t\t\tmedia.media_details.sizes[ fallbackSize ].source_url,\n\t\t};\n\t}\n\n\t// Use full image size when fallbackSize and defaultSize are not available.\n\treturn {\n\t\tmediaWidth: media.media_details.width,\n\t\tmediaHeight: media.media_details.height,\n\t\tmediaSourceUrl: media.source_url,\n\t};\n}\n\nfunction PostFeaturedImage( {\n\tcurrentPostId,\n\tfeaturedImageId,\n\tonUpdateImage,\n\tonRemoveImage,\n\tmedia,\n\tpostType,\n\tnoticeUI,\n\tnoticeOperations,\n\tisRequestingFeaturedImageMedia,\n} ) {\n\tconst returnsFocusRef = useRef( false );\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst { getSettings } = useSelect( blockEditorStore );\n\tconst { mediaSourceUrl } = getMediaDetails( media, currentPostId );\n\n\tfunction onDropFiles( filesList ) {\n\t\tgetSettings().mediaUpload( {\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\tsetIsLoading( true );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( image ) {\n\t\t\t\t\tonUpdateImage( image );\n\t\t\t\t}\n\t\t\t\tsetIsLoading( false );\n\t\t\t},\n\t\t\tonError( message ) {\n\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t},\n\t\t\tmultiple: false,\n\t\t} );\n\t}\n\n\t/**\n\t * Generates the featured image alt text for this editing context.\n\t *\n\t * @param {Object} imageMedia The image media object.\n\t * @param {string} imageMedia.alt_text The alternative text of the image.\n\t * @param {Object} imageMedia.media_details The media details of the image.\n\t * @param {Object} imageMedia.media_details.sizes The sizes of the image.\n\t * @param {Object} imageMedia.media_details.sizes.full The full size details of the image.\n\t * @param {string} imageMedia.media_details.sizes.full.file The file name of the full size image.\n\t * @param {string} imageMedia.slug The slug of the image.\n\t * @return {string} The featured image alt text.\n\t */\n\tfunction getImageDescription( imageMedia ) {\n\t\tif ( imageMedia.alt_text ) {\n\t\t\treturn sprintf(\n\t\t\t\t// Translators: %s: The selected image alt text.\n\t\t\t\t__( 'Current image: %s' ),\n\t\t\t\timageMedia.alt_text\n\t\t\t);\n\t\t}\n\t\treturn sprintf(\n\t\t\t// Translators: %s: The selected image filename.\n\t\t\t__(\n\t\t\t\t'The current image has no alternative text. The file name is: %s'\n\t\t\t),\n\t\t\timageMedia.media_details.sizes?.full?.file || imageMedia.slug\n\t\t);\n\t}\n\n\tfunction returnFocus( node ) {\n\t\tif ( returnsFocusRef.current && node ) {\n\t\t\tnode.focus();\n\t\t\treturnsFocusRef.current = false;\n\t\t}\n\t}\n\n\tconst isMissingMedia =\n\t\t! isRequestingFeaturedImageMedia && !! featuredImageId && ! media;\n\n\treturn (\n\t\t<PostFeaturedImageCheck>\n\t\t\t{ noticeUI }\n\t\t\t<div className=\"editor-post-featured-image\">\n\t\t\t\t{ media && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tid={ `editor-post-featured-image-${ featuredImageId }-describedby` }\n\t\t\t\t\t\tclassName=\"hidden\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ getImageDescription( media ) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<MediaUploadCheck fallback={ instructions }>\n\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\tpostType?.labels?.featured_image ||\n\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t<div className=\"editor-post-featured-image__container\">\n\t\t\t\t\t\t\t\t{ isMissingMedia ? (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Could not retrieve the featured image data.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\tref={ returnFocus }\n\t\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t\t? 'editor-post-featured-image__toggle'\n\t\t\t\t\t\t\t\t\t\t\t\t: 'editor-post-featured-image__preview'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Edit or replace the featured image'\n\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t\t: `editor-post-featured-image-${ featuredImageId }-describedby`\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t\t\tdisabled={ isLoading }\n\t\t\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ !! featuredImageId && media && (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__preview-image\"\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ mediaSourceUrl }\n\t\t\t\t\t\t\t\t\t\t\t\talt={ getImageDescription(\n\t\t\t\t\t\t\t\t\t\t\t\t\tmedia\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ ( isLoading ||\n\t\t\t\t\t\t\t\t\t\t\tisRequestingFeaturedImageMedia ) && (\n\t\t\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t{ ! featuredImageId &&\n\t\t\t\t\t\t\t\t\t\t\t! isLoading &&\n\t\t\t\t\t\t\t\t\t\t\t( postType?.labels\n\t\t\t\t\t\t\t\t\t\t\t\t?.set_featured_image ||\n\t\t\t\t\t\t\t\t\t\t\t\tDEFAULT_SET_FEATURE_IMAGE_LABEL ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ !! featuredImageId && (\n\t\t\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t\t'editor-post-featured-image__actions',\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t'editor-post-featured-image__actions-missing-image':\n\t\t\t\t\t\t\t\t\t\t\t\t\tisMissingMedia,\n\t\t\t\t\t\t\t\t\t\t\t\t'editor-post-featured-image__actions-is-requesting-image':\n\t\t\t\t\t\t\t\t\t\t\t\t\tisRequestingFeaturedImageMedia,\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__action\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\t\tisMissingMedia\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'secondary'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__action\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tonRemoveImage();\n\t\t\t\t\t\t\t\t\t\t\t\t// Signal that the toggle button should be focused,\n\t\t\t\t\t\t\t\t\t\t\t\t// when it is rendered. Can't focus it directly here\n\t\t\t\t\t\t\t\t\t\t\t\t// because it's rendered conditionally.\n\t\t\t\t\t\t\t\t\t\t\t\treturnsFocusRef.current = true;\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\t\tisMissingMedia\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'secondary'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tisDestructive={ isMissingMedia }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onDropFiles } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ featuredImageId }\n\t\t\t\t\t/>\n\t\t\t\t</MediaUploadCheck>\n\t\t\t</div>\n\t\t</PostFeaturedImageCheck>\n\t);\n}\n\nconst applyWithSelect = withSelect( ( select ) => {\n\tconst { getMedia, getPostType, hasFinishedResolution } =\n\t\tselect( coreStore );\n\tconst { getCurrentPostId, getEditedPostAttribute } = select( editorStore );\n\tconst featuredImageId = getEditedPostAttribute( 'featured_media' );\n\n\treturn {\n\t\tmedia: featuredImageId\n\t\t\t? getMedia( featuredImageId, { context: 'view' } )\n\t\t\t: null,\n\t\tcurrentPostId: getCurrentPostId(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tfeaturedImageId,\n\t\tisRequestingFeaturedImageMedia:\n\t\t\t!! featuredImageId &&\n\t\t\t! hasFinishedResolution( 'getMedia', [\n\t\t\t\tfeaturedImageId,\n\t\t\t\t{ context: 'view' },\n\t\t\t] ),\n\t};\n} );\n\nconst applyWithDispatch = withDispatch(\n\t( dispatch, { noticeOperations }, { select } ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateImage( image ) {\n\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t},\n\t\t\tonDropImage( filesList ) {\n\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t.getSettings()\n\t\t\t\t\t.mediaUpload( {\n\t\t\t\t\t\tallowedTypes: [ 'image' ],\n\t\t\t\t\t\tfilesList,\n\t\t\t\t\t\tonFileChange( [ image ] ) {\n\t\t\t\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmultiple: false,\n\t\t\t\t\t} );\n\t\t\t},\n\t\t\tonRemoveImage() {\n\t\t\t\teditPost( { featured_media: 0 } );\n\t\t\t},\n\t\t};\n\t}\n);\n\n/**\n * Renders the component for managing the featured image of a post.\n *\n * @param {Object} props Props.\n * @param {number} props.currentPostId ID of the current post.\n * @param {number} props.featuredImageId ID of the featured image.\n * @param {Function} props.onUpdateImage Function to call when the image is updated.\n * @param {Function} props.onRemoveImage Function to call when the image is removed.\n * @param {Object} props.media The media object representing the featured image.\n * @param {string} props.postType Post type.\n * @param {Element} props.noticeUI UI for displaying notices.\n * @param {Object} props.noticeOperations Operations for managing notices.\n *\n * @return {Element} Component to be rendered .\n */\nexport default comp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