Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/cli/scripts/export-sdk-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ const INTENT_NAMES = {
'doc.tables.get': 'get_table',
'doc.tables.getCells': 'get_table_cells',
'doc.tables.getProperties': 'get_table_properties',
'doc.history.get': 'get_history',
'doc.history.undo': 'undo',
'doc.history.redo': 'redo',
} as const satisfies Record<DocBackedCliOpId, string>;

// ---------------------------------------------------------------------------
Expand Down
20 changes: 20 additions & 0 deletions apps/cli/src/__tests__/conformance/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,26 @@ export const SUCCESS_SCENARIOS = {
'doc.tables.get': tableReadScenario('tables.get'),
'doc.tables.getCells': tableReadScenario('tables.getCells'),
'doc.tables.getProperties': tableReadScenario('tables.getProperties'),

// ---------------------------------------------------------------------------
// History operations
// ---------------------------------------------------------------------------

'doc.history.get': async (harness: ConformanceHarness): Promise<ScenarioInvocation> => {
const stateDir = await harness.createStateDir('doc-history-get-success');
await harness.openSessionFixture(stateDir, 'doc-history-get', 'history-get-session');
return { stateDir, args: ['history', 'get', '--session', 'history-get-session'] };
},
'doc.history.undo': async (harness: ConformanceHarness): Promise<ScenarioInvocation> => {
const stateDir = await harness.createStateDir('doc-history-undo-success');
await harness.openSessionFixture(stateDir, 'doc-history-undo', 'history-undo-session');
return { stateDir, args: ['history', 'undo', '--session', 'history-undo-session'] };
},
'doc.history.redo': async (harness: ConformanceHarness): Promise<ScenarioInvocation> => {
const stateDir = await harness.createStateDir('doc-history-redo-success');
await harness.openSessionFixture(stateDir, 'doc-history-redo', 'history-redo-session');
return { stateDir, args: ['history', 'redo', '--session', 'history-redo-session'] };
},
} as const satisfies Record<CliOperationId, (harness: ConformanceHarness) => Promise<ScenarioInvocation>>;

export const OPERATION_SCENARIOS = (Object.keys(SUCCESS_SCENARIOS) as CliOperationId[]).map((operationId) => {
Expand Down
1 change: 1 addition & 0 deletions apps/cli/src/cli/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export type CliCategory =
| 'comments'
| 'trackChanges'
| 'capabilities'
| 'history'
| 'lifecycle'
| 'session'
| 'introspection';
Expand Down
4 changes: 4 additions & 0 deletions apps/docs/document-api/available-operations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Use the tables below to see what operations are available and where each one is
| Core | 8 | 0 | 8 | [Reference](/document-api/reference/core/index) |
| Create | 5 | 0 | 5 | [Reference](/document-api/reference/create/index) |
| Format | 44 | 1 | 45 | [Reference](/document-api/reference/format/index) |
| History | 3 | 0 | 3 | [Reference](/document-api/reference/history/index) |
| Lists | 8 | 0 | 8 | [Reference](/document-api/reference/lists/index) |
| Mutations | 2 | 0 | 2 | [Reference](/document-api/reference/mutations/index) |
| Query | 1 | 0 | 1 | [Reference](/document-api/reference/query/index) |
Expand Down Expand Up @@ -96,6 +97,9 @@ Use the tables below to see what operations are available and where each one is
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.contextualAlternates(...)</code></span> | [`format.contextualAlternates`](/document-api/reference/format/contextual-alternates) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.align(...)</code></span> | [`format.align`](/document-api/reference/format/align) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.format.strikethrough(...)</code></span> | [`format.strike`](/document-api/reference/format/strike) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.history.get(...)</code></span> | [`history.get`](/document-api/reference/history/get) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.history.undo(...)</code></span> | [`history.undo`](/document-api/reference/history/undo) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.history.redo(...)</code></span> | [`history.redo`](/document-api/reference/history/redo) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.lists.list(...)</code></span> | [`lists.list`](/document-api/reference/lists/list) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.lists.get(...)</code></span> | [`lists.get`](/document-api/reference/lists/get) |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><code>editor.doc.lists.insert(...)</code></span> | [`lists.insert`](/document-api/reference/lists/insert) |
Expand Down
13 changes: 12 additions & 1 deletion apps/docs/document-api/reference/_generated-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
"apps/docs/document-api/reference/get-node-by-id.mdx",
"apps/docs/document-api/reference/get-node.mdx",
"apps/docs/document-api/reference/get-text.mdx",
"apps/docs/document-api/reference/history/get.mdx",
"apps/docs/document-api/reference/history/index.mdx",
"apps/docs/document-api/reference/history/redo.mdx",
"apps/docs/document-api/reference/history/undo.mdx",
"apps/docs/document-api/reference/index.mdx",
"apps/docs/document-api/reference/info.mdx",
"apps/docs/document-api/reference/insert.mdx",
Expand Down Expand Up @@ -370,6 +374,13 @@
"pagePath": "apps/docs/document-api/reference/tables/index.mdx",
"title": "Tables"
},
{
"aliasMemberPaths": [],
"key": "history",
"operationIds": ["history.get", "history.undo", "history.redo"],
"pagePath": "apps/docs/document-api/reference/history/index.mdx",
"title": "History"
},
{
"aliasMemberPaths": [],
"key": "toc",
Expand All @@ -379,5 +390,5 @@
}
],
"marker": "{/* GENERATED FILE: DO NOT EDIT. Regenerate via `pnpm run docapi:sync`. */}",
"sourceHash": "b347a10d2f82fe516ca8eacd8770c036dabb5b9faf176f7373dd8328aaa4ef98"
"sourceHash": "4b8ed87306be0b1f95fd6cf2786a3ea47f733613eb04413a5877c1d4ff6aa06e"
}
134 changes: 133 additions & 1 deletion apps/docs/document-api/reference/capabilities/get.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,30 @@ _No fields._
],
"tracked": true
},
"history.get": {
"available": true,
"dryRun": true,
"reasons": [
"COMMAND_UNAVAILABLE"
],
"tracked": true
},
"history.redo": {
"available": true,
"dryRun": true,
"reasons": [
"COMMAND_UNAVAILABLE"
],
"tracked": true
},
"history.undo": {
"available": true,
"dryRun": true,
"reasons": [
"COMMAND_UNAVAILABLE"
],
"tracked": true
},
"info": {
"available": true,
"dryRun": true,
Expand Down Expand Up @@ -5204,6 +5228,111 @@ _No fields._
],
"type": "object"
},
"history.get": {
"additionalProperties": false,
"properties": {
"available": {
"type": "boolean"
},
"dryRun": {
"type": "boolean"
},
"reasons": {
"items": {
"enum": [
"COMMAND_UNAVAILABLE",
"HELPER_UNAVAILABLE",
"OPERATION_UNAVAILABLE",
"TRACKED_MODE_UNAVAILABLE",
"DRY_RUN_UNAVAILABLE",
"NAMESPACE_UNAVAILABLE",
"STYLES_PART_MISSING",
"COLLABORATION_ACTIVE"
]
},
"type": "array"
},
"tracked": {
"type": "boolean"
}
},
"required": [
"available",
"tracked",
"dryRun"
],
"type": "object"
},
"history.redo": {
"additionalProperties": false,
"properties": {
"available": {
"type": "boolean"
},
"dryRun": {
"type": "boolean"
},
"reasons": {
"items": {
"enum": [
"COMMAND_UNAVAILABLE",
"HELPER_UNAVAILABLE",
"OPERATION_UNAVAILABLE",
"TRACKED_MODE_UNAVAILABLE",
"DRY_RUN_UNAVAILABLE",
"NAMESPACE_UNAVAILABLE",
"STYLES_PART_MISSING",
"COLLABORATION_ACTIVE"
]
},
"type": "array"
},
"tracked": {
"type": "boolean"
}
},
"required": [
"available",
"tracked",
"dryRun"
],
"type": "object"
},
"history.undo": {
"additionalProperties": false,
"properties": {
"available": {
"type": "boolean"
},
"dryRun": {
"type": "boolean"
},
"reasons": {
"items": {
"enum": [
"COMMAND_UNAVAILABLE",
"HELPER_UNAVAILABLE",
"OPERATION_UNAVAILABLE",
"TRACKED_MODE_UNAVAILABLE",
"DRY_RUN_UNAVAILABLE",
"NAMESPACE_UNAVAILABLE",
"STYLES_PART_MISSING",
"COLLABORATION_ACTIVE"
]
},
"type": "array"
},
"tracked": {
"type": "boolean"
}
},
"required": [
"available",
"tracked",
"dryRun"
],
"type": "object"
},
"info": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -8146,7 +8275,10 @@ _No fields._
"toc.get",
"toc.configure",
"toc.update",
"toc.remove"
"toc.remove",
"history.get",
"history.undo",
"history.redo"
],
"type": "object"
},
Expand Down
117 changes: 117 additions & 0 deletions apps/docs/document-api/reference/history/get.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
title: history.get
sidebarTitle: history.get
description: Query the current undo/redo history state of the active editor.
---

{/* GENERATED FILE: DO NOT EDIT. Regenerate via `pnpm run docapi:sync`. */}

> Alpha: Document API is currently alpha and subject to breaking changes.

## Summary

Query the current undo/redo history state of the active editor.

- Operation ID: `history.get`
- API member path: `editor.doc.history.get(...)`
- Mutates document: `no`
- Idempotency: `idempotent`
- Supports tracked mode: `no`
- Supports dry run: `no`
- Deterministic target resolution: `yes`

## Expected result

Returns a HistoryState object with undoDepth, redoDepth, canUndo, canRedo, and a list of history-unsafe operations.

## Input fields

_No fields._

### Example request

```json
{}
```

## Output fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `canRedo` | boolean | yes | |
| `canUndo` | boolean | yes | |
| `historyUnsafeOperations` | string[] | yes | |
| `redoDepth` | integer | yes | |
| `undoDepth` | integer | yes | |

### Example response

```json
{
"canRedo": true,
"canUndo": true,
"historyUnsafeOperations": [
"example"
],
"redoDepth": 1,
"undoDepth": 1
}
```

## Pre-apply throws

- None

## Non-applied failure codes

- None

## Raw schemas

<Accordion title="Raw input schema">
```json
{
"additionalProperties": false,
"properties": {},
"type": "object"
}
```
</Accordion>

<Accordion title="Raw output schema">
```json
{
"additionalProperties": false,
"properties": {
"canRedo": {
"type": "boolean"
},
"canUndo": {
"type": "boolean"
},
"historyUnsafeOperations": {
"items": {
"type": "string"
},
"type": "array"
},
"redoDepth": {
"minimum": 0,
"type": "integer"
},
"undoDepth": {
"minimum": 0,
"type": "integer"
}
},
"required": [
"undoDepth",
"redoDepth",
"canUndo",
"canRedo",
"historyUnsafeOperations"
],
"type": "object"
}
```
</Accordion>
20 changes: 20 additions & 0 deletions apps/docs/document-api/reference/history/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: History operations
sidebarTitle: History
description: History operation reference from the canonical Document API contract.
---

{/* GENERATED FILE: DO NOT EDIT. Regenerate via `pnpm run docapi:sync`. */}

> Alpha: Document API is currently alpha and subject to breaking changes.

[Back to full reference](../index)

Undo/redo history state and navigation.

| Operation | Member path | Mutates | Idempotency | Tracked | Dry run |
| --- | --- | --- | --- | --- | --- |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/history/get"><code>history.get</code></a></span> | `history.get` | No | `idempotent` | No | No |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/history/undo"><code>history.undo</code></a></span> | `history.undo` | Yes | `non-idempotent` | No | No |
| <span style={{ whiteSpace: 'nowrap', wordBreak: 'normal', overflowWrap: 'normal' }}><a href="/document-api/reference/history/redo"><code>history.redo</code></a></span> | `history.redo` | Yes | `non-idempotent` | No | No |

Loading
Loading