Skip to main content

Summary

Merge two adjacent paragraphs in the same story. The first paragraph keeps its pPr; the second paragraph is removed. Rejects when either paragraph carries a w:sectPr or when their numbering definitions differ. Available on v2-backed sessions only; v1-backed sessions currently return CAPABILITY_UNAVAILABLE.
  • Operation ID: blocks.merge
  • API member path: editor.doc.blocks.merge(...)
  • Mutates document: yes
  • Idempotency: non-idempotent
  • Supports tracked mode: yes
  • Supports dry run: no
  • Deterministic target resolution: yes

Expected result

Returns a BlocksMergeResult; on success carries the removed paragraph address plus affectedStories, textRangeShifts, and a txId.

Input fields

FieldTypeRequiredDescription
firstBlockNodeAddressyesBlockNodeAddress
first.kind"block"yesConstant: "block"
first.nodeIdstringyes
first.nodeTypeenumyes"paragraph", "heading", "listItem", "table", "tableRow", "tableCell", "tableOfContents", "image", "sdt"
first.storyStoryLocatornoStoryLocator
secondBlockNodeAddressyesBlockNodeAddress
second.kind"block"yesConstant: "block"
second.nodeIdstringyes
second.nodeTypeenumyes"paragraph", "heading", "listItem", "table", "tableRow", "tableCell", "tableOfContents", "image", "sdt"
second.storyStoryLocatornoStoryLocator

Example request

{
  "first": {
    "kind": "block",
    "nodeId": "node-def456",
    "nodeType": "paragraph",
    "story": {
      "kind": "story",
      "storyType": "body"
    }
  },
  "second": {
    "kind": "block",
    "nodeId": "node-def456",
    "nodeType": "paragraph",
    "story": {
      "kind": "story",
      "storyType": "body"
    }
  }
}

Output fields

FieldTypeRequiredDescription
affectedStoriesStoryLocator[]no
remappedRefsAffectedRefRemapping[]no
removedBlockNodeAddressyesBlockNodeAddress
removed.kind"block"yesConstant: "block"
removed.nodeIdstringyes
removed.nodeTypeenumyes"paragraph", "heading", "listItem", "table", "tableRow", "tableCell", "tableOfContents", "image", "sdt"
removed.storyStoryLocatornoStoryLocator
successtrueyesConstant: true
textRangeShiftsTextRangeShift[]no
txIdstringno

Example response

{
  "affectedStories": [
    {
      "kind": "story",
      "storyType": "body"
    }
  ],
  "remappedRefs": [
    {
      "from": {
        "blockId": "block-abc123",
        "kind": "text",
        "range": {
          "end": 10,
          "start": 0
        },
        "story": {
          "kind": "story",
          "storyType": "body"
        }
      },
      "to": {
        "blockId": "block-abc123",
        "kind": "text",
        "range": {
          "end": 10,
          "start": 0
        },
        "story": {
          "kind": "story",
          "storyType": "body"
        }
      }
    }
  ],
  "removed": {
    "kind": "block",
    "nodeId": "node-def456",
    "nodeType": "paragraph",
    "story": {
      "kind": "story",
      "storyType": "body"
    }
  },
  "success": true
}

Pre-apply throws

  • TARGET_NOT_FOUND
  • CAPABILITY_UNAVAILABLE
  • INVALID_TARGET
  • INVALID_INPUT

Non-applied failure codes

  • INVALID_TARGET
  • TARGET_NOT_FOUND
  • CAPABILITY_UNAVAILABLE
  • INVALID_CONTEXT
  • INVALID_INPUT

Raw schemas

{
  "additionalProperties": false,
  "properties": {
    "first": {
      "$ref": "#/$defs/BlockNodeAddress"
    },
    "second": {
      "$ref": "#/$defs/BlockNodeAddress"
    }
  },
  "required": [
    "first",
    "second"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "affectedStories": {
      "items": {
        "$ref": "#/$defs/StoryLocator"
      },
      "type": "array"
    },
    "remappedRefs": {
      "items": {
        "$ref": "#/$defs/AffectedRefRemapping"
      },
      "type": "array"
    },
    "removed": {
      "$ref": "#/$defs/BlockNodeAddress"
    },
    "success": {
      "const": true
    },
    "textRangeShifts": {
      "items": {
        "$ref": "#/$defs/TextRangeShift"
      },
      "type": "array"
    },
    "txId": {
      "type": "string"
    }
  },
  "required": [
    "success",
    "removed"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "affectedStories": {
      "items": {
        "$ref": "#/$defs/StoryLocator"
      },
      "type": "array"
    },
    "remappedRefs": {
      "items": {
        "$ref": "#/$defs/AffectedRefRemapping"
      },
      "type": "array"
    },
    "removed": {
      "$ref": "#/$defs/BlockNodeAddress"
    },
    "success": {
      "const": true
    },
    "textRangeShifts": {
      "items": {
        "$ref": "#/$defs/TextRangeShift"
      },
      "type": "array"
    },
    "txId": {
      "type": "string"
    }
  },
  "required": [
    "success",
    "removed"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "enum": [
            "TARGET_NOT_FOUND",
            "CAPABILITY_UNAVAILABLE",
            "INVALID_TARGET",
            "INVALID_INPUT"
          ]
        },
        "details": {},
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "success": {
      "const": false
    }
  },
  "required": [
    "success",
    "failure"
  ],
  "type": "object"
}