From 257a2bfcafa583c02cabb99aab3f1be1739a9fa3 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 17 Feb 2026 14:19:07 +0400 Subject: [PATCH] Add callback type to RTE --- packages/core/src/editor/types.ts | 5 +++-- packages/core/src/rich_text_editor/index.ts | 2 +- packages/core/src/rich_text_editor/types.ts | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/core/src/editor/types.ts b/packages/core/src/editor/types.ts index 73f4b417b..6998774fd 100644 --- a/packages/core/src/editor/types.ts +++ b/packages/core/src/editor/types.ts @@ -12,7 +12,7 @@ import { ModalEvent, ModalEventCallback } from '../modal_dialog/types'; import { LayerEvent, LayerEventCallback } from '../navigator/types'; import { PageEvent, PagesEventCallback } from '../pages/types'; import { ParserEvent, ParserEventCallback } from '../parser/types'; -import { RichTextEditorEvent } from '../rich_text_editor'; +import { RichTextEditorEvent, RichTextEditorEventCallback } from '../rich_text_editor'; import { SelectorEvent } from '../selector_manager'; import { StyleManagerEvent } from '../style_manager'; import { EditorConfig } from './config/config'; @@ -58,7 +58,8 @@ export interface EditorEventCallbacks LayerEventCallback, ModalEventCallback, PagesEventCallback, - ParserEventCallback + ParserEventCallback, + RichTextEditorEventCallback { [key: string]: any[]; } diff --git a/packages/core/src/rich_text_editor/index.ts b/packages/core/src/rich_text_editor/index.ts index aa0b6c2d3..92c8e96c1 100644 --- a/packages/core/src/rich_text_editor/index.ts +++ b/packages/core/src/rich_text_editor/index.ts @@ -43,7 +43,7 @@ import defConfig, { CustomRTE, CustomRteOptions, RichTextEditorConfig } from './ import RichTextEditor, { RichTextEditorAction } from './model/RichTextEditor'; import { ModelRTE, RichTextEditorEvents, RteDisableResult } from './types'; -export type { RichTextEditorEvent, RteDisableResult } from './types'; +export type { RichTextEditorEvent, RichTextEditorEventCallback, RteDisableResult } from './types'; const eventsUp = `${CanvasEvents.refresh} frame:scroll ${ComponentsEvents.update}`; diff --git a/packages/core/src/rich_text_editor/types.ts b/packages/core/src/rich_text_editor/types.ts index 53ea30fad..d8be45b1e 100644 --- a/packages/core/src/rich_text_editor/types.ts +++ b/packages/core/src/rich_text_editor/types.ts @@ -1,4 +1,6 @@ -import ComponentTextView from '../dom_components/view/ComponentTextView'; +import type ComponentTextView from '../dom_components/view/ComponentTextView'; +import type RichTextEditor from './model/RichTextEditor'; +import type { RichTextEditorAction } from './model/RichTextEditor'; export interface ModelRTE { currentView?: ComponentTextView; @@ -10,6 +12,12 @@ export interface RteDisableResult { forceSync?: boolean; } +export interface RichTextEditorCustomEventProps { + enabled: boolean; + container: HTMLElement; + actions: RichTextEditorAction[]; +} + /**{START_EVENTS}*/ export enum RichTextEditorEvents { /** @@ -35,5 +43,11 @@ export enum RichTextEditorEvents { } /**{END_EVENTS}*/ +export interface RichTextEditorEventCallback { + [RichTextEditorEvents.enable]: [ComponentTextView, RichTextEditor]; + [RichTextEditorEvents.disable]: [ComponentTextView, RichTextEditor | undefined]; + [RichTextEditorEvents.custom]: [RichTextEditorCustomEventProps]; +} + // need this to avoid the TS documentation generator to break export default RichTextEditorEvents;