chore: clean up events
This commit is contained in:
parent
12179e59a2
commit
455bcdc0f2
@ -895,8 +895,6 @@ export class Backend<EF extends BaseField = UnknownField, BC extends BackendClas
|
|||||||
...updatedOptions,
|
...updatedOptions,
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.invokePrePublishEvent(entryDraft.entry);
|
|
||||||
|
|
||||||
await this.implementation.persistEntry(
|
await this.implementation.persistEntry(
|
||||||
{
|
{
|
||||||
dataFiles,
|
dataFiles,
|
||||||
@ -906,7 +904,6 @@ export class Backend<EF extends BaseField = UnknownField, BC extends BackendClas
|
|||||||
);
|
);
|
||||||
|
|
||||||
await this.invokePostSaveEvent(entryDraft.entry);
|
await this.invokePostSaveEvent(entryDraft.entry);
|
||||||
await this.invokePostPublishEvent(entryDraft.entry);
|
|
||||||
|
|
||||||
return slug;
|
return slug;
|
||||||
}
|
}
|
||||||
@ -916,14 +913,6 @@ export class Backend<EF extends BaseField = UnknownField, BC extends BackendClas
|
|||||||
return await invokeEvent({ name: event, data: { entry, author: { login, name } } });
|
return await invokeEvent({ name: event, data: { entry, author: { login, name } } });
|
||||||
}
|
}
|
||||||
|
|
||||||
async invokePrePublishEvent(entry: Entry) {
|
|
||||||
await this.invokeEventWithEntry('prePublish', entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
async invokePostPublishEvent(entry: Entry) {
|
|
||||||
await this.invokeEventWithEntry('postPublish', entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
async invokePreSaveEvent(entry: Entry) {
|
async invokePreSaveEvent(entry: Entry) {
|
||||||
return await this.invokeEventWithEntry('preSave', entry);
|
return await this.invokeEventWithEntry('preSave', entry);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import type {
|
|||||||
WidgetValueSerializer,
|
WidgetValueSerializer,
|
||||||
} from '../interface';
|
} from '../interface';
|
||||||
|
|
||||||
export const allowedEvents = ['prePublish', 'postPublish', 'preSave', 'postSave'] as const;
|
export const allowedEvents = ['preSave', 'postSave'] as const;
|
||||||
export type AllowedEvent = (typeof allowedEvents)[number];
|
export type AllowedEvent = (typeof allowedEvents)[number];
|
||||||
|
|
||||||
const eventHandlers = allowedEvents.reduce((acc, e) => {
|
const eventHandlers = allowedEvents.reduce((acc, e) => {
|
||||||
|
@ -87,12 +87,12 @@ Example usage:
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
CMS.registerEventListener({
|
CMS.registerEventListener({
|
||||||
name: 'prePublish',
|
name: 'postSave',
|
||||||
handler: ({ author, entry }) => console.info(JSON.stringify({ author, data: entry.data })),
|
handler: ({ author, entry }) => console.info(JSON.stringify({ author, data: entry.data })),
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Supported events are `prePublish`, `postPublish`, `preSave` and `postSave`. The `preSave` hook can be used to modify the entry data like so:
|
Supported events are `preSave` and `postSave`. The `preSave` hook can be used to modify the entry data like so:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
CMS.registerEventListener({
|
CMS.registerEventListener({
|
||||||
|
@ -270,6 +270,7 @@ Also the `clearMediaControl` and `removeMediaControl` widget control props have
|
|||||||
- `isHidden` renamed to `hidden`
|
- `isHidden` renamed to `hidden`
|
||||||
- `mediaPaths` is now object of id mapped to an object containing the `path` and optional `alt`
|
- `mediaPaths` is now object of id mapped to an object containing the `path` and optional `alt`
|
||||||
- `useMediaInsert` hook now requires a collection to be passed in. Its callback function now receives an object containing the `path` and optional `alt` instead of a string.
|
- `useMediaInsert` hook now requires a collection to be passed in. Its callback function now receives an object containing the `path` and optional `alt` instead of a string.
|
||||||
|
- `prePublish` and `postPublish` events have been dropped.
|
||||||
|
|
||||||
## Other Changes
|
## Other Changes
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user