Remove context menu
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
```ts
|
||||
|
||||
import { JSX } from 'react';
|
||||
import { MatrixEvent } from 'matrix-js-sdk';
|
||||
import { ModuleApi } from '@matrix-org/react-sdk-module-api';
|
||||
import { RoomEvent } from 'matrix-js-sdk';
|
||||
import { Root } from 'react-dom/client';
|
||||
import { RuntimeModule } from '@matrix-org/react-sdk-module-api';
|
||||
|
||||
@@ -61,41 +61,28 @@ export interface ConfigApi {
|
||||
get<K extends keyof Config = never>(key?: K): Config | Config[K];
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ContextMenuItem {
|
||||
iconClassName: string;
|
||||
label: string;
|
||||
onClick: (e: React.MouseEvent<Element> | React.KeyboardEvent<Element> | React.FormEvent<Element>) => void | Promise<void>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type CustomComponentProps = {
|
||||
[CustomComponentTarget.TextualBody]: {
|
||||
mxEvent: RoomEvent;
|
||||
mxEvent: MatrixEvent;
|
||||
highlights?: string[];
|
||||
showUrlPreview?: boolean;
|
||||
forExport?: boolean;
|
||||
};
|
||||
[CustomComponentTarget.MessageContextMenu]: {
|
||||
mxEvent: RoomEvent;
|
||||
closeMenu: () => void;
|
||||
};
|
||||
};
|
||||
|
||||
// @public
|
||||
export type CustomComponentRenderFunction<T extends CustomComponentTarget> = (
|
||||
props: CustomComponentProps[T],
|
||||
originalComponent: JSX.Element) => JSX.Element | null;
|
||||
originalComponent: () => JSX.Element) => JSX.Element | null;
|
||||
|
||||
// @public
|
||||
export interface CustomComponentsApi {
|
||||
buildContextMenuBlock(items: ContextMenuItem[]): JSX.Element;
|
||||
register<T extends CustomComponentTarget>(target: T, renderer: CustomComponentRenderFunction<T>): void;
|
||||
}
|
||||
|
||||
// @public
|
||||
export enum CustomComponentTarget {
|
||||
MessageContextMenu = "MessageContextMenu",
|
||||
TextualBody = "TextualBody"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { JSX } from "react";
|
||||
import type { RoomEvent } from "matrix-js-sdk";
|
||||
import type { MatrixEvent } from "matrix-js-sdk";
|
||||
|
||||
/**
|
||||
* Targets in Element for custom components.
|
||||
@@ -10,35 +10,6 @@ export enum CustomComponentTarget {
|
||||
* Component that renders "m.room.message" events in the room timeline.
|
||||
*/
|
||||
TextualBody = "TextualBody",
|
||||
/**
|
||||
* "Options" Context menu for a timeline event.
|
||||
* Use `buildContextMenuBlock` to build a section to be used by this component.
|
||||
* @see buildContextMenuBlock
|
||||
*/
|
||||
MessageContextMenu = "MessageContextMenu",
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ContextMenuItem {
|
||||
/**
|
||||
* The human readable label for an event.
|
||||
* TODO: Should this be i18n-d
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
* The icon to use for this item.
|
||||
* https://github.com/vector-im/riot-web/blob/efc6149a8b3362c01b93f52e76e5c4ae8cbcb65c/res/css/views/context_menus/_MessageContextMenu.pcss#L10
|
||||
*/
|
||||
iconClassName: string;
|
||||
/**
|
||||
* Handler for click events on the context menu item.
|
||||
* Does NOT close the menu after execution.
|
||||
*/
|
||||
onClick: (
|
||||
e: React.MouseEvent<Element> | React.KeyboardEvent<Element> | React.FormEvent<Element>,
|
||||
) => void | Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +21,7 @@ export type CustomComponentProps = {
|
||||
/**
|
||||
* The Matrix event for this textual body.
|
||||
*/
|
||||
mxEvent: RoomEvent;
|
||||
mxEvent: MatrixEvent;
|
||||
/**
|
||||
* Words to highlight on (e.g. from search results).
|
||||
* May be undefined if the client does not need to highlight
|
||||
@@ -65,16 +36,6 @@ export type CustomComponentProps = {
|
||||
*/
|
||||
forExport?: boolean;
|
||||
};
|
||||
[CustomComponentTarget.MessageContextMenu]: {
|
||||
/**
|
||||
* The Matrix event which this context menu targets.
|
||||
*/
|
||||
mxEvent: RoomEvent;
|
||||
/**
|
||||
* Function that will close the menu.
|
||||
*/
|
||||
closeMenu: () => void;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Render function. Returning null skips this function and passes it onto the next registered renderer.
|
||||
@@ -86,9 +47,9 @@ export type CustomComponentRenderFunction<T extends CustomComponentTarget> = (
|
||||
*/
|
||||
props: CustomComponentProps[T],
|
||||
/**
|
||||
* The original component.
|
||||
* Render function for the original component.
|
||||
*/
|
||||
originalComponent: JSX.Element,
|
||||
originalComponent: () => JSX.Element,
|
||||
) => JSX.Element | null;
|
||||
|
||||
/**
|
||||
@@ -109,10 +70,4 @@ export interface CustomComponentsApi {
|
||||
* @param renderer - The render method.
|
||||
*/
|
||||
register<T extends CustomComponentTarget>(target: T, renderer: CustomComponentRenderFunction<T>): void;
|
||||
|
||||
/**
|
||||
* Generate a context menu section for a given set of items.
|
||||
* @param items - A set of items to render.
|
||||
*/
|
||||
buildContextMenuBlock(items: ContextMenuItem[]): JSX.Element;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user