import type { VRange } from '../types.js'; import type { BaseTextAttributes } from '../utils/base-attributes.js'; import type { VEditor } from '../virgo.js'; export interface VBeforeinputHookCtx< TextAttributes extends BaseTextAttributes, > { vEditor: VEditor; raw: InputEvent; vRange: VRange; data: string | null; attributes: TextAttributes; } export interface VCompositionEndHookCtx< TextAttributes extends BaseTextAttributes, > { vEditor: VEditor; raw: CompositionEvent; vRange: VRange; data: string | null; attributes: TextAttributes; } export type VHookContext = | VBeforeinputHookCtx | VCompositionEndHookCtx; export class VirgoHookService { constructor( public readonly editor: VEditor, public readonly hooks: { beforeinput?: ( props: VBeforeinputHookCtx ) => VBeforeinputHookCtx | null; compositionEnd?: ( props: VCompositionEndHookCtx ) => VCompositionEndHookCtx | null; } = {} ) {} }