Skip to content

create.table + Enter on trailing paragraph duplicates paraId, blocking subsequent Document API mutations #3405

@nathan-ahs

Description

@nathan-ahs

What happened?

editor.doc.create.table({ at: { kind: 'after', nodeId } }) produces a trailing paragraph with a non-null w14:paraId. Pressing Enter on that paragraph triggers ProseMirror's default split-block, which copies attrs onto the new sibling — including the paraId. The document is then in a state where two paragraphs share one paraId.

The next call to any Document API mutation (editor.doc.delete, editor.doc.create.table, editor.doc.styles.paragraph.setStyle, …) throws:

PlanError: DOCUMENT_IDENTITY_CONFLICT — Document contains blocks with duplicate identities.

from assertNoDuplicateBlockIds inside compilePlan. The error's details.remediation names document.repair(), but no such method appears on the Document API surface.

Steps to reproduce

In the browser console :

const doc = sd.activeEditor.doc;
doc.clearContent({});
// Click into the empty paragraph so the caret is set.
const seg = doc.selection.current().target.segments[0];
doc.create.table({
  rows: 3, columns: 3,
  at: { kind: 'after', nodeId: seg.blockId },
});
// Click into the trailing paragraph below the table, then press Enter once.
// Any further Document API mutation now throws DOCUMENT_IDENTITY_CONFLICT.

After the Enter keystroke, walking editor.view.state.doc.descendants(...) shows two paragraphs sharing one paraId:

paragraph at pos 46: paraId="78FF6DBD", sdBlockId="580b559b-…"
paragraph at pos 48: paraId="78FF6DBD", sdBlockId="449664ef-…"

SuperDoc version

1.32.0

Browser

Firefox 150 (via Zen Browser 1.19.13b)

Additional context

Failure shape from a real throw:

{
  "name": "PlanError",
  "code": "DOCUMENT_IDENTITY_CONFLICT",
  "details": {
    "duplicateBlockIds": ["08266E78"],
    "blockCount": 1,
    "remediation": "Re-import the document or call document.repair() to assign unique identities."
  }
}

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions