How It Works
Every block-level node (paragraphs, headings, etc.) automatically receives a uniquesdBlockId attribute. This enables:
- Precise targeting - Manipulate specific blocks even as document changes
- Change tracking - Know exactly which blocks were modified
- Collaborative editing - Reference blocks consistently across clients
- Programmatic updates - Update document structure via APIs
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
The sdBlockId of the node to replace
The replacement ProseMirror node
deleteBlockNodeById
Delete a block node by its ID
Completely removes the node from the document
The sdBlockId of the node to delete
updateBlockNodeAttributes
Update attributes of a block node by its ID
Merges new attributes with existing ones
The sdBlockId of the node to update
Attributes to update
Helpers
getBlockNodes
Get all block nodes in the document
Example:
See BlockNodeInfo type definition
getBlockNodeById
Get a specific block node by its ID
Example:
The sdBlockId to search for
See BlockNodeInfo type definition
getBlockNodesByType
Get all block nodes of a specific type
Example:
The node type name (e.g., ‘paragraph’, ‘heading’)
See BlockNodeInfo type definition
getBlockNodesInRange
Get all block nodes within a position range
Example:
Start position
End position
See BlockNodeInfo type definition

