Skip to main content
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

{}

Output fields

FieldTypeRequiredDescription
canRedobooleanyes
canUndobooleanyes
historyUnsafeOperationsstring[]yes
redoDepthintegeryes
undoDepthintegeryes

Example response

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

Pre-apply throws

  • None

Non-applied failure codes

  • None

Raw schemas

{
  "additionalProperties": false,
  "properties": {},
  "type": "object"
}
{
  "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"
}