Skip to main content
Automatically tracks block-level nodes with unique IDs for precise document manipulation. Essential for collaborative editing, change tracking, and programmatic document updates.

How it works

Every block-level node (paragraphs, headings, etc.) automatically receives a unique sdBlockId attribute. This enables:
  1. Precise targeting - Manipulate specific blocks even as document changes
  2. Change tracking - Know exactly which blocks were modified
  3. Collaborative editing - Reference blocks consistently across clients
  4. Programmatic updates - Update document structure via APIs
sdBlockId is regenerated on every document load. If you need cross-session block references (e.g., headless CLI pipelines, multi-step AI workflows), use the Document API instead. editor.doc.find() returns addresses whose nodeId prefers DOCX-native paraId for imported blocks. This is best-effort stable, not a permanent global ID: Word or other tools can rewrite IDs during structural changes, and SuperDoc may rewrite duplicates on import.

Use case

  • Document APIs - Build REST APIs that manipulate specific blocks
  • Collaboration - Track who edited which blocks in real-time
  • Comments & Annotations - Attach metadata to specific blocks
  • Version Control - Diff documents at the block level
  • Templates - Replace placeholder blocks with dynamic content

Commands

replaceBlockNodeById

Replace a block node by its ID with new content
The replacement node should have the same type as the original
Example:
Parameters:
string
required
The sdBlockId of the node to replace
ProseMirrorNode
required
The replacement ProseMirror node

deleteBlockNodeById

Delete a block node by its ID
Completely removes the node from the document
Example:
Parameters:
string
required
The sdBlockId of the node to delete

updateBlockNodeAttributes

Update attributes of a block node by its ID
Merges new attributes with existing ones
Example:
Parameters:
string
required
The sdBlockId of the node to update
Object
required
Attributes to update

Helpers

getBlockNodes

Get all block nodes in the document Example:
Returns:
Array<BlockNodeInfo>
required
See BlockNodeInfo type definition

getBlockNodeById

Get a specific block node by its ID Example:
Parameters:
string
required
The sdBlockId to search for
Returns:
Array<BlockNodeInfo>
required
See BlockNodeInfo type definition

getBlockNodesByType

Get all block nodes of a specific type Example:
Parameters:
string
required
The node type name (e.g., ‘paragraph’, ‘heading’)
Returns:
Array<BlockNodeInfo>
required
See BlockNodeInfo type definition

getBlockNodesInRange

Get all block nodes within a position range Example:
Parameters:
number
required
Start position
number
required
End position
Returns:
Array<BlockNodeInfo>
required
See BlockNodeInfo type definition

Types

BlockNodeInfo

Block node information object

Source code