export interface EditorTestUtils {
  /** Programmatic PM selection within a block */
  selectText: (blockId: string, from: number, to: number) => void
  /** All data-block-id values currently mounted */
  getBlockIds: () => string[]
  /** Dispatch a PM transaction to insert text (bypasses auto-close & pattern plugins) */
  insertText: (blockId: string, text: string) => void
  /** Replace the block's entire content in a single PM transaction (deterministic undo history) */
  replaceContent: (blockId: string, text: string) => void
  /** Serialize all blocks to unified markdown */
  getContent: () => string
  /** Focus a block with cursor at end of its content (reliable caret positioning) */
  focusAtEnd: (blockId: string) => void
  /** Focus a block with cursor at start of its content */
  focusAtStart: (blockId: string) => void
  /** Click outside the editor to trigger live-preview (blur) */
  toggleBlur: () => Promise<void>
  /** Return the Lezer AST tree snapshot for assertion */
  getParseTree: () => string
  /** Reorder a block by index (synthetic DnD alternative) */
  reorderBlocks: (fromIndex: number, toIndex: number) => void
  /** Fast-forward the coalescing clock without real wait (Phase 2.6) */
  setTimeSource: (fakeMs: number) => void
}

declare global {
  interface Window {
    __testUtils__: EditorTestUtils
  }
}
