Skip to content

selection.extractOoxml fails when nodeEdge endpoints span two paragraphs (SDK 2.27.0–2.31.0) #4162

Open

Description

@ohcedar

Expected: A selection from before one paragraph to after the next extracts both paragraphs’ OOXML, as it does in @superdoc/sdk 2.26.0.

Actual: SDK 2.27.0, 2.28.0, 2.29.0, 2.30.0, and 2.31.0 throw COMMAND_FAILED on that selection. Using before and after on the same paragraph succeeds.

Create plain.docx with four ordinary body paragraphs containing Alpha one., Bravo two., Charlie three., and Delta four. in order. No edits or tracked changes are needed.

import { SuperDocClient } from '@superdoc/sdk';

const client = new SuperDocClient();
try {
  await client.connect();
  const doc = await client.open({ doc: './plain.docx' });
  const { blocks } = await doc.blocks.list({ includeText: true });
  const edge = ({ nodeType, nodeId }, side) => ({
    kind: 'nodeEdge', node: { kind: 'block', nodeType, nodeId }, edge: side,
  });

  for (const last of [1, 2]) {
    const at = {
      kind: 'selection',
      start: edge(blocks[1], 'before'),
      end: edge(blocks[last], 'after'),
    };
    try {
      const { fragment } = await doc.selection.extractOoxml({ at });
      console.log(fragment.xml.includes('Bravo two.'), fragment.xml.includes('Charlie three.'));
    } catch (e) {
      console.log(e.code, e.message);
    }
  }
  await doc.close();
} finally {
  await client.dispose();
}

2.26.0 output

true false
true true

2.31.0 output

true false
COMMAND_FAILED Selection endpoint cannot be resolved to selected source content.

On 2.31.0, text endpoints from offset 0 in the second paragraph to offset 14 in the third extract both paragraphs. The node-edge failure also reproduces when those paragraphs contain pending tracked deletions, whether created with blocks.deleteRange or already present in the imported DOCX. Each deleted paragraph still extracts individually with its w:del markup.

This regression blocks us from upgrading past SDK 2.26, so a fix or a supported workaround for whole-paragraph ranges would be appreciated.

Activity

  1. added
    status: triage
    on Nov 21, 2026
  2. added theissue type on Nov 21, 2026
  3. vivienne-sd commented on Nov 23, 2026

    @vivienne-sd
    Collaborator

    Hey @ohcedar ! Thanks for the callout and letting us know this is blocking your upgrade. I'm working on reproducing and will follow up with more details today.

  4. added
    status: investigating
    and removed
    status: triage
    on Nov 23, 2026
  5. linear-code commented on Nov 23, 2026

    @linear-code
  6. added
    status: queued
    and removed
    status: investigating
    on Nov 23, 2026
  7. caio-pizzol commented on Nov 24, 2026

    @caio-pizzol
    Contributor

    Thanks for the clear repro, @ohcedar! We reproduced it.

    2.27 moved the SDK to a new engine, and its extractOoxml only accepts node edges around a single paragraph or table. Ranges across paragraphs throw. 2.26 converted node edges to text offsets first, and the new engine doesn't.

    Workaround: use text endpoints instead:

    const at = {
      kind: 'selection',
      start: { kind: 'text', blockId: first.nodeId, offset: 0 },
      end: { kind: 'text', blockId: last.nodeId, offset: last.text.length },
    };

    first and last come from blocks.list({ includeText: true }). This also works with tracked deletions: deleted text still comes back with its w:del markup.

    The fix is queued. We'll update here when it ships.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: queued

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions