| 33 | } |
| 34 | |
| 35 | export interface DocumentAdapter { |
| 36 | /** |
| 37 | * Platform identifier for conditional UI rendering |
| 38 | */ |
| 39 | readonly platform: "overleaf" | "word" | "browser"; |
| 40 | |
| 41 | /** |
| 42 | * Get the full document text |
| 43 | */ |
| 44 | getFullText(): Promise<string>; |
| 45 | |
| 46 | /** |
| 47 | * Get the currently selected text and its context |
| 48 | */ |
| 49 | getSelection(): Promise<SelectionInfo | null>; |
| 50 | |
| 51 | /** |
| 52 | * Insert text at the current cursor position |
| 53 | * @param text - Text to insert |
| 54 | * @param location - Optional: 'cursor' (default), 'start', or 'end' |
| 55 | */ |
| 56 | insertText(text: string, location?: "cursor" | "start" | "end"): Promise<void>; |
| 57 | |
| 58 | /** |
| 59 | * Replace the current selection with new text |
| 60 | * @param text - Text to replace with |
| 61 | * @param rangeId - Optional range identifier from getSelection() |
| 62 | */ |
| 63 | replaceSelection(text: string, rangeId?: string): Promise<void>; |
| 64 | |
| 65 | /** |
| 66 | * Subscribe to selection change events |
| 67 | * @param callback - Called when selection changes |
| 68 | * @returns Cleanup function to unsubscribe |
| 69 | */ |
| 70 | onSelectionChange?(callback: (selection: SelectionInfo | null) => void): () => void; |
| 71 | |
| 72 | /** |
| 73 | * Check if the adapter is ready/connected |
| 74 | */ |
| 75 | isReady(): boolean; |
| 76 | |
| 77 | /** |
| 78 | * Optional: Get project/document identifier |
| 79 | */ |
| 80 | getDocumentId?(): string; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Type for adapter props passed to Web Component |
nothing calls this directly
no outgoing calls
no test coverage detected