> ## Documentation Index
> Fetch the complete documentation index at: https://sdk.revise.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Types

> The exported TypeScript surface.

Everything below is exported from the package root:

```ts theme={null}
import type { ReviseEditorHandle, ReviseToolbarState } from "@reviseio/sdk";
```

## Documents

```ts theme={null}
type ReviseDocumentSource = File | Blob | ArrayBuffer;

/** DOCX is the only format carrying comments and tracked changes. */
type ReviseDocumentFormat = "docx" | "markdown" | "txt" | "html";

interface ReviseDocumentInput {
  id: string;
  docx: ReviseDocumentSource;  // any supported format; name kept for compatibility
  format?: ReviseDocumentFormat;
  title?: string;
  documentMode?: ReviseDocumentMode;
  readOnly?: boolean;
  zoom?: ReviseZoom;
  defaultCommentsOpen?: boolean;
  agent?: ReviseAgentConfig;
}

interface ReviseOpenDocument {
  id: string;
  title: string;
  status: "opening" | "ready" | "error";
  active: boolean;
  error?: string;
}

interface ReviseDocumentCollectionState {
  activeDocumentId: string | null;
  documents: ReviseOpenDocument[];
}

type ReviseDocumentScoped<T> = T & { forDocument(documentId: string): T };
```

## Modes and zoom

```ts theme={null}
type ReviseDocumentMode = "editing" | "suggesting" | "viewing";
type ReviseToolbarMode = "native" | "none";
type ReviseZoom = number | "fit-width";

interface ReviseZoomState {
  zoom: ReviseZoom;
  scale: number; // effective canvas scale; computed for fit-width
}
```

## Toolbar and view state

```ts theme={null}
interface ReviseToolbarState {
  ready: boolean;
  readOnly: boolean;
  documentMode: ReviseDocumentMode;
  activeTab: EditorRibbonTab;
  hasSelection: boolean;
  canUndo: boolean;
  canRedo: boolean;
  formatting: TextMark;
  heading?: 1 | 2 | 3 | 4 | 5 | 6;
  alignment?: "left" | "center" | "right" | "justify";
  lineSpacing?: number;
  fontSizePt?: number;
  blockType: { type: string; variant?: string } | null;
  review: {
    open: boolean;
    targetCount: number;
    currentTargetSuggestionCount: number;
    allOpenSuggestionCount: number;
    showRemovals: boolean;
    viewMode: "all-markup" | "final" | "original";
  };
}

interface ReviseViewState {
  ready: boolean;
  title: string;
  documentMode: ReviseDocumentMode;
  readOnly: boolean;
  commentsOpen: boolean;
  commentCount: number;
  reviewOpen: boolean;
  reviewTargetCount: number;
}
```

## Review and comments

```ts theme={null}
interface ReviseReviewState {
  open: boolean;
  commentsOpen: boolean;
  targetCount: number;
  currentTargetSuggestionCount: number;
  allOpenSuggestionCount: number;
  openSuggestionIds: string[];
  currentSuggestionIds: string[];
  visibleAgentSuggestionIds: string[];
  activeCommentId: string | null;
  showRemovals: boolean;
  viewMode: "all-markup" | "final" | "original";
  commentThreads: ReviseCommentThread[];
}

interface ReviseCommentAnchor {
  blockId: string;
  start: number;
  end: number;
}

interface ReviseCommentThread {
  root: CommentRecord;
  replies: CommentRecord[];
  anchor: ReviseCommentAnchor | null;
  relatedSuggestionIds: string[];
}
```

## Selection

```ts theme={null}
interface ReviseSelectionSnapshot {
  documentId: string | null;
  anchor: ReviseSelectionPosition | null;
  focus: ReviseSelectionPosition | null;
  start: ReviseSelectionPosition | null;
  end: ReviseSelectionPosition | null;
  target: ReviseTextTarget | null;
  selectionTarget: ReviseSelectionTarget | null;
  activeMarks: string[];
  activeCommentIds: string[];
  activeChangeIds: string[];
  quotedText: string;
  text: string;      // alias for quotedText
  collapsed: boolean;
  empty: boolean;    // alias for collapsed
}

type ReviseSelectionCapture = ReviseSelectionSnapshot & {
  documentId: string;
  target: ReviseTextTarget;
  selectionTarget: ReviseSelectionTarget;
};

type ReviseSelectionRestoreResult =
  | { success: true }
  | { success: false; reason: string };
```

## Tools

```ts theme={null}
interface ReviseEditorToolDefinition {
  name: string;
  description: string;
  inputSchema: Record<string, unknown>;
}

interface ReviseEditorToolExecutionOptions {
  documentId?: string;
  directMode?: boolean;
}

interface ReviseEditorToolExecutionResult {
  toolCallId: string;
  name: string;
  success: boolean;
  error?: string;
  errorCode?: string;
  agentFeedback?: string;
  output?: unknown;
  context?: string;
}
```

## Agent

```ts theme={null}
interface ReviseAgentConfig {
  baseUrl?: string;
  token?: string;
  conversationId?: string;
  provider?: string;
  model?: string;
  turnStream?: TurnStreamGenerator;
  disableMetrics?: boolean;
}

interface ReviseAgentEvent {
  state: "idle" | "streaming" | "complete" | "error";
  activeTool: string | null;
  status: string | null;
  error?: string;
  messages: Message[];
}

interface ReviseAgentRunResult extends ReviseAgentEvent {
  actionCount: number;
}
```

## Fonts

```ts theme={null}
interface ReviseFontDefinition {
  family: string;      // canonical, stored in the document and written to DOCX
  label?: string;      // picker label; defaults to family
  cssFamily?: string;  // browser preview stack; defaults to family
  fontWeight?: number | string;
}
```
