Repository navigation
Description
doc.capabilities.resolve is described as resolving "availability, tracked-mode support, and dry-run support for one concrete operation request". For blocks.merge on two adjacent body paragraphs where the first contains an external hyperlink, it returns available: { kind: "supported" }. doc.blocks.merge with the same paragraph addresses and mode then throws:
CAPABILITY_UNAVAILABLE: typed blocks.merge cannot yet merge paragraphs containing inline objects or field carriers.
A pair of plain paragraphs resolves the same way and merges. Tracked mode gives the same results as direct.
Expected: when both paragraph addresses are supplied, resolve returns available: { kind: "unsupported" } with a reason naming this restriction. contentControls.insertBefore already does this for a row-level content control: it resolves unsupported / TARGET_UNSUPPORTED, and execution throws CAPABILITY_UNAVAILABLE with the same reason. If resolve for blocks.merge is meant to report only operation-level support, a note saying so on capabilities.resolve, and listing the inline-content restriction on blocks.merge, would help.
Repro (npm i @superdoc/sdk@2.31.0 docx@9.7.1, then node cap-repro.mjs):
cap-repro.mjs
// npm i @superdoc/sdk@2.31.0 docx@9.7.1 && node cap-repro.mjs
import { createSuperDocClient } from '@superdoc/sdk';
import { Document, ExternalHyperlink, Packer, Paragraph, TextRun } from 'docx';
import { mkdtemp, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import path from 'node:path';
const docx = await Packer.toBuffer(new Document({ sections: [{ children: [
new Paragraph('Plain one.'),
new Paragraph('Plain two.'),
new Paragraph({ children: [new TextRun('Has '), new ExternalHyperlink({ link: 'https://example.com', children: [new TextRun('a link')] }), new TextRun('.')] }),
new Paragraph('After link.'),
] }] }));
const file = path.join(await mkdtemp(path.join(tmpdir(), 'cap-repro-')), 'fixture.docx');
await writeFile(file, docx);
const client = createSuperDocClient({ user: { name: 'Editor', email: 'editor@example.test' } });
await client.connect();
for (const prefix of ['Plain one', 'Has a link']) {
const doc = await client.open({ doc: file });
try {
const blocks = (await doc.blocks.list({ includeText: true })).blocks;
const i = blocks.findIndex((b) => b.text.startsWith(prefix));
const at = (b) => ({ kind: 'block', nodeType: b.nodeType, nodeId: b.nodeId });
const input = { first: at(blocks[i]), second: at(blocks[i + 1]) };
const resolved = await doc.capabilities.resolve({ operationId: 'blocks.merge', input, options: { changeMode: 'direct' } });
let merge;
try { merge = JSON.stringify(await doc.blocks.merge({ ...input, changeMode: 'direct' })); }
catch (e) { merge = `THREW ${e.code}: ${e.details?.failure?.message ?? e.message}`; }
console.log(`${prefix}\n resolve: ${JSON.stringify(resolved)}\n merge: ${merge}`);
} finally {
await doc.close({ discard: true });
}
}
await client.dispose();Output:
Plain one
resolve: {"operationId":"blocks.merge","available":{"kind":"supported"},"tracked":{"kind":"supported"},"dryRun":{"kind":"unsupported","code":"DRY_RUN_UNAVAILABLE","reason":"This operation does not support dry-run mode on V2."}}
merge: {"success":true,"appliedChangeMode":"direct","removed":{"kind":"block","nodeType":"paragraph","nodeId":"00000002"},"anchor":{"kind":"block","nodeType":"paragraph","nodeId":"00000001"},"joinOffset":10,"remappedRefs":[],"affectedStories":[{"kind":"story","storyType":"body"}],"textRangeShifts":[],"txId":"typed-tx-53c7a257-0e3a-4e95-bfdb-ce7cebbf8a5a"}
Has a link
resolve: {"operationId":"blocks.merge","available":{"kind":"supported"},"tracked":{"kind":"supported"},"dryRun":{"kind":"unsupported","code":"DRY_RUN_UNAVAILABLE","reason":"This operation does not support dry-run mode on V2."}}
merge: THREW CAPABILITY_UNAVAILABLE: typed blocks.merge cannot yet merge paragraphs containing inline objects or field carriers.
Versions: @superdoc/sdk 2.31.0 (embedded engine), docx 9.7.1, Node 24.21.0, macOS arm64.
Activity
linear-code commentedon Nov 23, 2026
SD-8564
vivienne-sd commentedon Nov 23, 2026
Hi @ohcedar ; thank you for the clear reproduction! I reproduced this on my side. The capability check should identify the inline-content restriction before you attempt the merge, so I've got the issue ticketed for the team. I will follow up with you here as soon as a fix lands.
caio-pizzol commentedon Nov 24, 2026
Quick update: this also happens with fields (like an
AUTHORfield), not just hyperlinks, and it's still there in2.32.0-next.10. Untilresolvecatches it, the safest check is to catchCAPABILITY_UNAVAILABLEfromblocks.merge. Don't passdryRuntoblocks.merge. The SDK ignores it, so the merge really runs.