From e972c05ccc3667ef3292f0ebc6f3f9389b3577da Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Tue, 20 May 2025 12:11:07 +0100 Subject: [PATCH] Remove context menu --- .../element-web-module-api.api.md | 19 ++----- .../src/api/custom-components.ts | 53 ++----------------- 2 files changed, 7 insertions(+), 65 deletions(-) diff --git a/packages/element-web-module-api/element-web-module-api.api.md b/packages/element-web-module-api/element-web-module-api.api.md index c86bf9cc60..f9731b1371 100644 --- a/packages/element-web-module-api/element-web-module-api.api.md +++ b/packages/element-web-module-api/element-web-module-api.api.md @@ -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(key?: K): Config | Config[K]; } -// @public (undocumented) -export interface ContextMenuItem { - iconClassName: string; - label: string; - onClick: (e: React.MouseEvent | React.KeyboardEvent | React.FormEvent) => void | Promise; -} - // @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 = ( 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(target: T, renderer: CustomComponentRenderFunction): void; } // @public export enum CustomComponentTarget { - MessageContextMenu = "MessageContextMenu", TextualBody = "TextualBody" } diff --git a/packages/element-web-module-api/src/api/custom-components.ts b/packages/element-web-module-api/src/api/custom-components.ts index 2d1f269409..244757c6e1 100644 --- a/packages/element-web-module-api/src/api/custom-components.ts +++ b/packages/element-web-module-api/src/api/custom-components.ts @@ -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 | React.KeyboardEvent | React.FormEvent, - ) => void | Promise; } /** @@ -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 = ( */ 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(target: T, renderer: CustomComponentRenderFunction): 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; }