From 5cc84db4c4d388fa16cf848fefec96417db34b61 Mon Sep 17 00:00:00 2001 From: can1357 Date: Tue, 30 Jun 2026 16:16:39 +0200 Subject: [PATCH] feat(tui): enabled programmatic form submission via editor APIs - Added a public `submit()` method to the `Editor` class to trigger form submission. - Updated the `EditorComponent` interface to expose an optional `submit()` method. --- packages/tui/src/components/editor.ts | 4 ++++ packages/tui/src/editor-component.ts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/packages/tui/src/components/editor.ts b/packages/tui/src/components/editor.ts index cda6387da..5fa01fd7b 100644 --- a/packages/tui/src/components/editor.ts +++ b/packages/tui/src/components/editor.ts @@ -1594,6 +1594,10 @@ export class Editor implements Component, Focusable { this.#resetKillSequence(); this.#setTextInternal(text); } + submit(): void { + if (this.disableSubmit) return; + this.#submitValue(); + } #exitHistoryForEditing(): void { if (this.#historyIndex === -1) return; diff --git a/packages/tui/src/editor-component.ts b/packages/tui/src/editor-component.ts index 2ea958898..247768432 100644 --- a/packages/tui/src/editor-component.ts +++ b/packages/tui/src/editor-component.ts @@ -29,6 +29,9 @@ export interface EditorComponent extends Component { /** Called when user submits (e.g., Enter key) */ onSubmit?: (text: string) => void; + /** Programmatically trigger submission (optional, e.g. for voice submit). */ + submit?(): void; + /** Called when text changes */ onChange?: (text: string) => void;