Skip to main content

Summary

Compound: merge two adjacent list sequences into one. Reassigns numId on the absorbed sequence (no strict abstractNumId check — absorbed items adopt the absorbing definition) and deletes empty paragraphs between the two sequences. Use this instead of lists.join for the user-facing “merge these lists” intent.
  • Operation ID: lists.merge
  • API member path: editor.doc.lists.merge(...)
  • Mutates document: yes
  • Idempotency: conditional
  • Supports tracked mode: no
  • Supports dry run: yes
  • Deterministic target resolution: yes

Expected result

Returns a ListsMergeResult with the merged listId, absorbedCount, and removedEmptyBlocks count.

Input fields

FieldTypeRequiredDescription
directionenumyes"withPrevious", "withNext"
targetListItemAddressyesListItemAddress
target.kind"block"yesConstant: "block"
target.nodeIdstringyes
target.nodeType"listItem"yesConstant: "listItem"

Example request

{
  "direction": "withPrevious",
  "target": {
    "kind": "block",
    "nodeId": "node-def456",
    "nodeType": "listItem"
  }
}

Output fields

Variant 1 (success=true)

FieldTypeRequiredDescription
absorbedCountintegeryes
listIdstringyes
removedEmptyBlocksintegeryes
successtrueyesConstant: true

Variant 2 (success=false)

FieldTypeRequiredDescription
failureobjectyes
failure.codeenumyes"INVALID_TARGET", "NO_ADJACENT_SEQUENCE", "NO_OP"
failure.detailsanyno
failure.messagestringyes
successfalseyesConstant: false

Example response

{
  "absorbedCount": 1,
  "listId": "example",
  "removedEmptyBlocks": 1,
  "success": true
}

Pre-apply throws

  • TARGET_NOT_FOUND
  • CAPABILITY_UNAVAILABLE
  • INVALID_TARGET

Non-applied failure codes

  • INVALID_TARGET
  • NO_ADJACENT_SEQUENCE
  • NO_OP

Raw schemas

{
  "additionalProperties": false,
  "properties": {
    "direction": {
      "enum": [
        "withPrevious",
        "withNext"
      ]
    },
    "target": {
      "$ref": "#/$defs/ListItemAddress"
    }
  },
  "required": [
    "target",
    "direction"
  ],
  "type": "object"
}
{
  "oneOf": [
    {
      "additionalProperties": false,
      "properties": {
        "absorbedCount": {
          "type": "integer"
        },
        "listId": {
          "type": "string"
        },
        "removedEmptyBlocks": {
          "type": "integer"
        },
        "success": {
          "const": true
        }
      },
      "required": [
        "success",
        "listId",
        "absorbedCount",
        "removedEmptyBlocks"
      ],
      "type": "object"
    },
    {
      "additionalProperties": false,
      "properties": {
        "failure": {
          "additionalProperties": false,
          "properties": {
            "code": {
              "enum": [
                "INVALID_TARGET",
                "NO_ADJACENT_SEQUENCE",
                "NO_OP"
              ]
            },
            "details": {},
            "message": {
              "type": "string"
            }
          },
          "required": [
            "code",
            "message"
          ],
          "type": "object"
        },
        "success": {
          "const": false
        }
      },
      "required": [
        "success",
        "failure"
      ],
      "type": "object"
    }
  ]
}
{
  "additionalProperties": false,
  "properties": {
    "absorbedCount": {
      "type": "integer"
    },
    "listId": {
      "type": "string"
    },
    "removedEmptyBlocks": {
      "type": "integer"
    },
    "success": {
      "const": true
    }
  },
  "required": [
    "success",
    "listId",
    "absorbedCount",
    "removedEmptyBlocks"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "enum": [
            "INVALID_TARGET",
            "NO_ADJACENT_SEQUENCE",
            "NO_OP"
          ]
        },
        "details": {},
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "success": {
      "const": false
    }
  },
  "required": [
    "success",
    "failure"
  ],
  "type": "object"
}