Browse Source

Add callback type to RTE

type-event-callbacks
Artur Arseniev 1 month ago
parent
commit
257a2bfcaf
  1. 5
      packages/core/src/editor/types.ts
  2. 2
      packages/core/src/rich_text_editor/index.ts
  3. 16
      packages/core/src/rich_text_editor/types.ts

5
packages/core/src/editor/types.ts

@ -12,7 +12,7 @@ import { ModalEvent, ModalEventCallback } from '../modal_dialog/types';
import { LayerEvent, LayerEventCallback } from '../navigator/types'; import { LayerEvent, LayerEventCallback } from '../navigator/types';
import { PageEvent, PagesEventCallback } from '../pages/types'; import { PageEvent, PagesEventCallback } from '../pages/types';
import { ParserEvent, ParserEventCallback } from '../parser/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 { SelectorEvent } from '../selector_manager';
import { StyleManagerEvent } from '../style_manager'; import { StyleManagerEvent } from '../style_manager';
import { EditorConfig } from './config/config'; import { EditorConfig } from './config/config';
@ -58,7 +58,8 @@ export interface EditorEventCallbacks
LayerEventCallback, LayerEventCallback,
ModalEventCallback, ModalEventCallback,
PagesEventCallback, PagesEventCallback,
ParserEventCallback ParserEventCallback,
RichTextEditorEventCallback
{ {
[key: string]: any[]; [key: string]: any[];
} }

2
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 RichTextEditor, { RichTextEditorAction } from './model/RichTextEditor';
import { ModelRTE, RichTextEditorEvents, RteDisableResult } from './types'; 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}`; const eventsUp = `${CanvasEvents.refresh} frame:scroll ${ComponentsEvents.update}`;

16
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 { export interface ModelRTE {
currentView?: ComponentTextView; currentView?: ComponentTextView;
@ -10,6 +12,12 @@ export interface RteDisableResult {
forceSync?: boolean; forceSync?: boolean;
} }
export interface RichTextEditorCustomEventProps {
enabled: boolean;
container: HTMLElement;
actions: RichTextEditorAction[];
}
/**{START_EVENTS}*/ /**{START_EVENTS}*/
export enum RichTextEditorEvents { export enum RichTextEditorEvents {
/** /**
@ -35,5 +43,11 @@ export enum RichTextEditorEvents {
} }
/**{END_EVENTS}*/ /**{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 // need this to avoid the TS documentation generator to break
export default RichTextEditorEvents; export default RichTextEditorEvents;

Loading…
Cancel
Save