Alpha: Document API is currently alpha and subject to breaking changes.
Summary
Replace content at a contiguous document selection. Text path accepts a SelectionTarget or ref plus replacement text. Structural path accepts a BlockNodeAddress (replaces whole block), SelectionTarget (expands to full covered block boundaries), or ref plus SDFragment content.- Operation ID:
replace - API member path:
editor.doc.replace(...) - Mutates document:
yes - Idempotency:
conditional - Supports tracked mode:
yes - Supports dry run:
yes - Deterministic target resolution:
yes
Expected result
Returns an SDMutationReceipt with applied status; receipt reports NO_OP if the target range already contains identical content.Input fields
Variant 1.1 (target.kind=“selection”)
| Field | Type | Required | Description |
|---|---|---|---|
target | SelectionTarget | yes | SelectionTarget |
target.end | SelectionPoint | yes | SelectionPoint |
target.kind | "selection" | yes | Constant: "selection" |
target.start | SelectionPoint | yes | SelectionPoint |
text | string | yes |
Variant 1.2
| Field | Type | Required | Description |
|---|---|---|---|
ref | string | yes | |
text | string | yes |
Variant 2.1
| Field | Type | Required | Description | |
|---|---|---|---|---|
content | object \ | object[] | yes | One of: object, object[] |
nestingPolicy | object | no | ||
nestingPolicy.tables | enum | no | "forbid", "allow" | |
target | BlockNodeAddress \ | SelectionTarget | yes | One of: BlockNodeAddress, SelectionTarget |
Variant 2.2
| Field | Type | Required | Description | |
|---|---|---|---|---|
content | object \ | object[] | yes | One of: object, object[] |
nestingPolicy | object | no | ||
nestingPolicy.tables | enum | no | "forbid", "allow" | |
ref | string | yes |
Example request
Output fields
Variant 1 (success=true)
| Field | Type | Required | Description | |
|---|---|---|---|---|
evaluatedRevision | object | no | ||
evaluatedRevision.after | string | no | ||
evaluatedRevision.before | string | no | ||
resolution | object | no | ||
resolution.range | TextMutationRange | no | TextMutationRange | |
resolution.range.from | integer | no | ||
resolution.range.to | integer | no | ||
resolution.selectionTarget | SelectionTarget | no | SelectionTarget | |
resolution.selectionTarget.end | SelectionPoint | no | SelectionPoint | |
resolution.selectionTarget.kind | "selection" | no | Constant: "selection" | |
resolution.selectionTarget.start | SelectionPoint | no | SelectionPoint | |
resolution.target | TextAddress \ | BlockNodeAddress | no | One of: TextAddress, BlockNodeAddress |
success | true | yes | Constant: true |
Variant 2 (success=false)
| Field | Type | Required | Description | |
|---|---|---|---|---|
evaluatedRevision | object | no | ||
evaluatedRevision.after | string | no | ||
evaluatedRevision.before | string | no | ||
failure | object | yes | ||
failure.code | enum | yes | "INVALID_TARGET", "NO_OP", "INVALID_NESTING", "INVALID_PLACEMENT", "INVALID_PAYLOAD", "CAPABILITY_UNSUPPORTED", "ADDRESS_STALE", "DUPLICATE_ID", "INVALID_CONTEXT", "RAW_MODE_REQUIRED", "PRESERVE_ONLY_VIOLATION", "INVALID_INPUT" | |
failure.details | any | no | ||
failure.message | string | yes | ||
resolution | object | no | ||
resolution.range | TextMutationRange | no | TextMutationRange | |
resolution.range.from | integer | no | ||
resolution.range.to | integer | no | ||
resolution.selectionTarget | SelectionTarget | no | SelectionTarget | |
resolution.selectionTarget.end | SelectionPoint | no | SelectionPoint | |
resolution.selectionTarget.kind | "selection" | no | Constant: "selection" | |
resolution.selectionTarget.start | SelectionPoint | no | SelectionPoint | |
resolution.target | TextAddress \ | BlockNodeAddress | no | One of: TextAddress, BlockNodeAddress |
success | false | yes | Constant: false |
Example response
Pre-apply throws
TARGET_NOT_FOUNDCAPABILITY_UNAVAILABLEINVALID_TARGETINVALID_INPUTADDRESS_STALEDUPLICATE_IDRAW_MODE_REQUIREDPRESERVE_ONLY_VIOLATIONCAPABILITY_UNSUPPORTED
Non-applied failure codes
INVALID_TARGETNO_OPINVALID_NESTINGINVALID_PLACEMENTINVALID_PAYLOADCAPABILITY_UNSUPPORTEDADDRESS_STALEDUPLICATE_IDINVALID_CONTEXTRAW_MODE_REQUIREDPRESERVE_ONLY_VIOLATIONINVALID_INPUT
Raw schemas
Raw input schema
Raw input schema
Raw output schema
Raw output schema
Raw success schema
Raw success schema
Raw failure schema
Raw failure schema

