mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Add support for custom JS embeds in the App (#16650)
* add embed hook definitions * inject embeds in the App html * fixed typo * removed unnecessary env parameter * Added comment marking the custom embeds * attempt to add test for createApp * mock db in app test * temporarily set log style to raw in test * one more round Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
This commit is contained in:
@@ -16,3 +16,4 @@ export type FilterHandler<T = unknown> = (
|
||||
export type ActionHandler = (meta: Record<string, any>, context: EventContext) => void;
|
||||
export type InitHandler = (meta: Record<string, any>) => void;
|
||||
export type ScheduleHandler = () => void | Promise<void>;
|
||||
export type EmbedHandler = () => string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ActionHandler, FilterHandler, InitHandler, ScheduleHandler } from './events';
|
||||
import { ActionHandler, FilterHandler, InitHandler, ScheduleHandler, EmbedHandler } from './events';
|
||||
import { ApiExtensionContext } from './extensions';
|
||||
|
||||
type HookExtensionContext = ApiExtensionContext & {
|
||||
@@ -10,6 +10,7 @@ type RegisterFunctions = {
|
||||
action: (event: string, handler: ActionHandler) => void;
|
||||
init: (event: string, handler: InitHandler) => void;
|
||||
schedule: (cron: string, handler: ScheduleHandler) => void;
|
||||
embed: (position: 'head' | 'body', code: string | EmbedHandler) => void;
|
||||
};
|
||||
|
||||
type HookConfigFunction = (register: RegisterFunctions, context: HookExtensionContext) => void;
|
||||
|
||||
Reference in New Issue
Block a user