mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 12:03:49 +00:00
Add pasteToEditor(text) method that pastes text into the editor via bracketed paste sequences, triggering paste handling (including collapse for large content). Unlike setEditorText which directly replaces content, pasteToEditor routes through handleInput on the active editor component. - Add pasteToEditor to ExtensionUIContext interface - Add handleInput to EditorComponent interface (was missing, all concrete implementations already had it) - Implement in interactive mode via bracketed paste sequence - Add fallback in RPC mode (delegates to setEditorText) - Document in extensions.md
74 lines
2.5 KiB
TypeScript
74 lines
2.5 KiB
TypeScript
import type { AutocompleteProvider } from "./autocomplete.js";
|
|
import type { Component } from "./tui.js";
|
|
|
|
/**
|
|
* Interface for custom editor components.
|
|
*
|
|
* This allows extensions to provide their own editor implementation
|
|
* (e.g., vim mode, emacs mode, custom keybindings) while maintaining
|
|
* compatibility with the core application.
|
|
*/
|
|
export interface EditorComponent extends Component {
|
|
// =========================================================================
|
|
// Core text access (required)
|
|
// =========================================================================
|
|
|
|
/** Get the current text content */
|
|
getText(): string;
|
|
|
|
/** Set the text content */
|
|
setText(text: string): void;
|
|
|
|
/** Handle raw terminal input (key presses, paste sequences, etc.) */
|
|
handleInput(data: string): void;
|
|
|
|
// =========================================================================
|
|
// Callbacks (required)
|
|
// =========================================================================
|
|
|
|
/** Called when user submits (e.g., Enter key) */
|
|
onSubmit?: (text: string) => void;
|
|
|
|
/** Called when text changes */
|
|
onChange?: (text: string) => void;
|
|
|
|
// =========================================================================
|
|
// History support (optional)
|
|
// =========================================================================
|
|
|
|
/** Add text to history for up/down navigation */
|
|
addToHistory?(text: string): void;
|
|
|
|
// =========================================================================
|
|
// Advanced text manipulation (optional)
|
|
// =========================================================================
|
|
|
|
/** Insert text at current cursor position */
|
|
insertTextAtCursor?(text: string): void;
|
|
|
|
/**
|
|
* Get text with any markers expanded (e.g., paste markers).
|
|
* Falls back to getText() if not implemented.
|
|
*/
|
|
getExpandedText?(): string;
|
|
|
|
// =========================================================================
|
|
// Autocomplete support (optional)
|
|
// =========================================================================
|
|
|
|
/** Set the autocomplete provider */
|
|
setAutocompleteProvider?(provider: AutocompleteProvider): void;
|
|
|
|
// =========================================================================
|
|
// Appearance (optional)
|
|
// =========================================================================
|
|
|
|
/** Border color function */
|
|
borderColor?: (str: string) => string;
|
|
|
|
/** Set horizontal padding */
|
|
setPaddingX?(padding: number): void;
|
|
|
|
/** Set max visible items in autocomplete dropdown */
|
|
setAutocompleteMaxVisible?(maxVisible: number): void;
|
|
}
|