You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(ui): adds new editMenuItems custom component (#12649)
## What
Adds a new custom component called `editMenuItems` that can be used in
the document view.
This options allows users to inject their own custom components into the
dropdown menu found in the document controls (the 3 dot menu), the
provided component(s) will be added below the default existing actions
(Create New, Duplicate, Delete and so on).
## Why
To increase flexibility and customization for users who wish to add
functionality to this menu. This provides a clean and consistent way to
add additional actions without needing to override or duplicate existing
UI logic.
## How
- Introduced the `editMenuItems` slot in the document controls dropdown
(three-dot menu) - in edit and preview tabs.
- Added documentation and tests to cover this new custom component
#### Testing
Use the `admin` test suite and go to the `edit menu items` collection
|`SaveButton`| Replace the default Save Button within the Edit View. [Drafts](../versions/drafts) must be disabled. [More details](../custom-components/edit-view#savebutton). |
200
-
|`SaveDraftButton`| Replace the default Save Draft Button within the Edit View. [Drafts](../versions/drafts) must be enabled and autosave must be disabled. [More details](../custom-components/edit-view#savedraftbutton). |
201
-
|`PublishButton`| Replace the default Publish Button within the Edit View. [Drafts](../versions/drafts) must be enabled. [More details](../custom-components/edit-view#publishbutton). |
202
-
|`PreviewButton`| Replace the default Preview Button within the Edit View. [Preview](../admin/preview) must be enabled. [More details](../custom-components/edit-view#previewbutton). |
203
-
|`Upload`| Replace the default Upload component within the Edit View. [Upload](../upload/overview) must be enabled. [More details](../custom-components/edit-view#upload). |
|`beforeDocumentControls`| Inject custom components before the Save / Publish buttons. [More details](../custom-components/edit-view#beforedocumentcontrols). |
200
+
|`editMenuItems`| Inject custom components within the 3-dot menu dropdown located in the document controls bar. [More details](../custom-components/edit-view#editmenuitems). |
201
+
|`SaveButton`| Replace the default Save Button within the Edit View. [Drafts](../versions/drafts) must be disabled. [More details](../custom-components/edit-view#savebutton). |
202
+
|`SaveDraftButton`| Replace the default Save Draft Button within the Edit View. [Drafts](../versions/drafts) must be enabled and autosave must be disabled. [More details](../custom-components/edit-view#savedraftbutton). |
203
+
|`PublishButton`| Replace the default Publish Button within the Edit View. [Drafts](../versions/drafts) must be enabled. [More details](../custom-components/edit-view#publishbutton). |
204
+
|`PreviewButton`| Replace the default Preview Button within the Edit View. [Preview](../admin/preview) must be enabled. [More details](../custom-components/edit-view#previewbutton). |
205
+
|`Upload`| Replace the default Upload component within the Edit View. [Upload](../upload/overview) must be enabled. [More details](../custom-components/edit-view#upload). |
204
206
205
207
<Bannertype="success">
206
208
**Note:** For details on how to build Custom Components, see [Building Custom
|`beforeDocumentControls`| Inject custom components before the Save / Publish buttons. [More details](#beforedocumentcontrols). |
141
+
|`editMenuItems`| Inject custom components within the 3-dot menu dropdown located in the document control bar. [More details](#editmenuitems). |
142
+
|`SaveButton`| A button that saves the current document. [More details](#savebutton). |
143
+
|`SaveDraftButton`| A button that saves the current document as a draft. [More details](#savedraftbutton). |
144
+
|`PublishButton`| A button that publishes the current document. [More details](#publishbutton). |
145
+
|`PreviewButton`| A button that previews the current document. [More details](#previewbutton). |
146
+
|`Description`| A description of the Global. [More details](#description). |
145
147
146
148
### SaveButton
147
149
@@ -260,6 +262,92 @@ export function MyCustomDocumentControlButton(
260
262
}
261
263
```
262
264
265
+
### editMenuItems
266
+
267
+
The `editMenuItems` property allows you to inject custom components into the 3-dot menu dropdown located in the document controls bar. This dropdown contains default options including `Create New`, `Duplicate`, `Delete`, and other options when additional features are enabled. Any custom components you add will appear below these default items.
268
+
269
+
To add `editMenuItems`, use the `components.edit.editMenuItems` property in your [Collection Config](../configuration/collections):
270
+
271
+
#### Config Example
272
+
273
+
```ts
274
+
importtype { CollectionConfig } from'payload'
275
+
276
+
exportconst Pages:CollectionConfig= {
277
+
slug: 'pages',
278
+
admin: {
279
+
components: {
280
+
edit: {
281
+
// highlight-start
282
+
editMenuItems: ['/path/to/CustomEditMenuItem'],
283
+
// highlight-end
284
+
},
285
+
},
286
+
},
287
+
}
288
+
```
289
+
290
+
Here's an example of a custom `editMenuItems` component:
0 commit comments