Specify options for the original component.

This commit is contained in:
Half-Shot 2025-06-05 09:58:51 +01:00
parent 546861811c
commit e2ae6f2288
3 changed files with 22 additions and 10 deletions

View File

@ -70,16 +70,16 @@ export interface CustomComponentsApi {
export type CustomMessageComponentProps = {
mxEvent: MatrixEvent;
highlights?: string[];
showUrlPreview?: boolean;
forExport?: boolean;
};
// Warning: (ae-incompatible-release-tags) The symbol "CustomMessageRenderFunction" is marked as @beta, but its signature references "CustomMessageComponentProps" which is marked as @alpha
// Warning: (ae-incompatible-release-tags) The symbol "CustomMessageRenderFunction" is marked as @beta, but its signature references "OriginalComponentProps" which is marked as @alpha
//
// @beta
export type CustomMessageRenderFunction = (
props: CustomMessageComponentProps,
originalComponent?: () => React.JSX.Element) => JSX.Element | null;
originalComponent?: (props?: OriginalComponentProps) => React.JSX.Element) => JSX.Element | null;
// @alpha @deprecated (undocumented)
export interface DirectoryCustomisations {
@ -205,6 +205,11 @@ export class ModuleLoader {
start(): Promise<void>;
}
// @alpha
export type OriginalComponentProps = {
showUrlPreview?: boolean;
};
// @alpha @deprecated (undocumented)
export interface RoomListCustomisations<Room> {
isRoomVisible?(room: Room): boolean;

View File

@ -38,21 +38,21 @@
"@types/react-dom": "^19.0.4",
"@types/semver": "^7.5.8",
"@vitest/coverage-v8": "^3.0.4",
"matrix-js-sdk": "^37.5.0",
"matrix-web-i18n": "^3.3.0",
"semver": "^7.6.3",
"typescript": "^5.7.3",
"vite": "^6.1.6",
"vite-plugin-dts": "^4.5.0",
"vitest": "^3.0.5",
"vitest-sonar-reporter": "^2.0.0",
"matrix-js-sdk": "^37.5.0"
"vitest-sonar-reporter": "^2.0.0"
},
"peerDependencies": {
"@matrix-org/react-sdk-module-api": "*",
"@types/react": "*",
"@types/react-dom": "*",
"matrix-web-i18n": "*",
"matrix-js-sdk": "*",
"matrix-web-i18n": "*",
"react": "^19"
},
"peerDependenciesMeta": {

View File

@ -22,16 +22,23 @@ export type CustomMessageComponentProps = {
* May be undefined if the client does not need to highlight
*/
highlights?: string[];
/**
* Should previews be shown for this event
*/
showUrlPreview?: boolean;
/**
* Is this event being rendered to a static export
*/
forExport?: boolean;
};
/**
* Properties to alter the render function of the original component.
* @alpha Subject to change.
*/
export type OriginalComponentProps = {
/**
* Should previews be shown for this event.
*/
showUrlPreview?: boolean;
};
/**
* Function used to render a message component.
* @beta Unlikely to change
@ -44,7 +51,7 @@ export type CustomMessageRenderFunction = (
/**
* Render function for the original component. This may be omitted if the message would not normally be rendered.
*/
originalComponent?: () => React.JSX.Element,
originalComponent?: (props?: OriginalComponentProps) => React.JSX.Element,
) => JSX.Element | null;
/**