import { AcGePoint3dLike, AcGiMTextAttachmentPoint } from '@mlightcad/data-model'; import { MTextInputBox, type MTextToolbarColorPickerFactory } from '@mlightcad/mtext-input-box'; import { AcTrView2d } from '../../../view'; export type AcEdMTextEditorCurrentFormatChangeListener = () => void; export interface AcEdMTextEditorCurrentFormatObservable { addCurrentFormatChangeListener: (listener: AcEdMTextEditorCurrentFormatChangeListener) => void; removeCurrentFormatChangeListener: (listener: AcEdMTextEditorCurrentFormatChangeListener) => void; } export type AcEdMTextEditorActiveInputBox = MTextInputBox & Partial & { /** * Returns keyboard focus to the hidden IME input used by the editor. * * Contextual ribbon controls use this after formatting commands so the * inline editor keeps behaving like its built-in toolbar. */ focusEditor?: () => void; /** Returns whether the current selection is a non-script stacked fraction. */ isStackSelectionActive?: () => boolean; }; export type AcEdMTextEditorActiveInputBoxChangeListener = (inputBox: AcEdMTextEditorActiveInputBox | null) => void; /** * Result payload returned by the MTEXT editor when editing is finished. */ export interface AcEdMTextEditorResult { /** Final MTEXT contents (including inline formatting codes). */ contents: string; /** Final MTEXT insertion location in world coordinates. */ location: AcGePoint3dLike; /** Final text box width in world units. */ width: number; /** Final text box height in world units. */ height: number; /** Line spacing factor used by the MTEXT input box renderer. */ lineSpacingFactor: number; /** MTEXT attachment (DXF group 71) matching the editor justify control. */ attachmentPoint: AcGiMTextAttachmentPoint; } /** * Options used to open an interactive MTEXT editor. */ export interface AcEdMTextEditorOptions { /** Active 2D view where the editor overlay and text box are rendered. */ view: AcTrView2d; /** Insertion location (top-left anchor) in world coordinates. */ location: AcGePoint3dLike; /** * Initial MTEXT attachment (DXF 71). When omitted, the editor uses top-left * until the user changes justify in the ribbon. */ initialAttachmentPoint?: AcGiMTextAttachmentPoint; /** Initial MTEXT box width in world units. */ width: number; /** Default text height in world units. */ textHeight: number; /** Optional initial MTEXT source string. Defaults to empty string. */ initialText?: string; /** * Optional font family list displayed in toolbar font dropdown. * * Empty values are ignored and duplicates are removed before being passed * to `MTextInputBox`. */ toolbarFontFamilies?: string[]; /** * Optional custom toolbar color picker factory. When provided (or when set via * {@link AcEdMTextEditor.setDefaultColorPicker}), replaces the default native * color input in the MTEXT toolbar. */ toolbarColorPicker?: MTextToolbarColorPickerFactory; /** * Controls the built-in MTEXT input box toolbar for this editor instance. * Defaults to {@link AcEdMTextEditor.defaultToolbarEnabled}. */ toolbarEnabled?: boolean; } /** * Lightweight wrapper around `MTextInputBox` for CAD editor integration. * * This class binds the MTEXT input component to the current `AcTrView2d` * render loop and handles lifecycle cleanup when the editor is closed. */ export declare class AcEdMTextEditor { static readonly defaultLineSpacingFactor = 0.3; private static activeInputBox; private static readonly activeInputBoxChangeListeners; /** * Default toolbar color picker factory used when opening the editor if * per-call options do not provide {@link AcEdMTextEditorOptions.toolbarColorPicker}. * Set via {@link AcEdMTextEditor.setDefaultColorPicker}. */ static defaultColorPicker: MTextToolbarColorPickerFactory | null; /** * Default visibility for the built-in MTEXT input box toolbar. Applications * with their own contextual ribbon can disable this while keeping the input * box editor active. */ static defaultToolbarEnabled: boolean; /** * Registers a default toolbar color picker factory. The factory is used for * every subsequent {@link open} call unless overridden by * {@link AcEdMTextEditorOptions.toolbarColorPicker}. * * @param factory - Factory to use, or `null` to clear and use the built-in picker. */ static setDefaultColorPicker(factory: MTextToolbarColorPickerFactory | null): void; /** * Registers the default built-in toolbar visibility for subsequent * {@link open} calls. * * @param enabled - `true` to show the MTEXT input box toolbar by default. */ static setDefaultToolbarEnabled(enabled: boolean): void; /** * Returns the MTEXT input box currently being edited, if any. */ static getActiveInputBox(): AcEdMTextEditorActiveInputBox | null; /** * Subscribes to active MTEXT input box changes. */ static addActiveInputBoxChangeListener(listener: AcEdMTextEditorActiveInputBoxChangeListener): void; /** * Removes an active MTEXT input box listener. */ static removeActiveInputBoxChangeListener(listener: AcEdMTextEditorActiveInputBoxChangeListener): void; private static setActiveInputBox; private static createHiddenToolbarContainer; private static attachFormatBridge; private static detachFormatBridge; /** * Opens the MTEXT editor and resolves when user closes the editor UI. * * The method: * - creates a `MTextInputBox` at the requested world location * - configures default text style and toolbar options * - updates editor state on each view render frame * - disposes resources and event listeners on close * * @param options - Runtime options used to initialize the editor instance. * @returns A promise resolving to final MTEXT result; resolves to `null` only * when future cancel flows are introduced. */ open(options: AcEdMTextEditorOptions): Promise; } //# sourceMappingURL=AcEdMTextEditor.d.ts.map