Native Word SDT (w:sdt) fields for documents. Supports inline and block structured content tags for dynamic templates with full Word compatibility.
Use case
Form templates: Create fillable documents with inline text fields and block content areas
Contract generation: Dynamic clauses and terms that map to Word content controls
Document automation: Programmatically update specific sections while preserving structure
Protected fields: Lock modes control which fields users can edit or delete (ECMA-376 w:lock)
Quick start
// Insert inline field with sdtLocked: users can edit content but not delete the fieldeditor.commands.insertStructuredContentInline({ attrs: { id: '1', alias: 'Customer Name', lockMode: 'sdtLocked', }, text: 'John Doe'});// Insert a read-only system fieldeditor.commands.insertStructuredContentInline({ attrs: { id: '3', alias: 'Account ID', lockMode: 'sdtContentLocked', // fully protected: no edits, no deletion }, text: 'ACC-00042'});// Insert block field with sdtLocked: content is editable, wrapper is protectededitor.commands.insertStructuredContentBlock({ attrs: { id: '2', alias: 'Terms & Conditions', lockMode: 'sdtLocked', }, html: '<p>Please review the terms...</p>'});// Update field contenteditor.commands.updateStructuredContentById('1', { text: 'Jane Smith'});// Change lock mode without changing contenteditor.commands.updateStructuredContentById('1', { attrs: { lockMode: 'contentLocked' }});// Get all structured content tagsconst allTags = editor.helpers.structuredContentCommands.getStructuredContentTags(editor.state);console.log(`Document contains ${allTags.length} SDT fields`);
Options
Configure the extension behavior:
string
default:"sd-structured-content-block-tag"
CSS class for the block
Object
HTML attributes for structured content blocks
Attributes
Node attributes that can be set and retrieved:
string
Unique identifier for the structured content block
The id attribute must be a numeric string for valid DOCX output (per
ECMA-376
§17.5.2.18).
Use Date.now().toString() or sequential integers instead of UUIDs.
string
Content control tag (e.g., ‘block_table_sdt’)
string
default:"Structured content"
Display name for the block
StructuredContentLockMode
default:"unlocked"
Controls editing and deletion restrictions on the structured content node. See Lock modes below.
Lock modes
Structured content nodes support four lock modes based on the OOXML w:lock element (ISO/IEC 29500 §17.5.2.23). Lock modes control whether users can edit the content inside a field and whether they can delete the field wrapper itself.
Lock modes are enforced at the editor plugin level using a three-layer defense:
Key interception — Delete, Backspace, and Cut are blocked before a transaction is created, preventing cursor jumps
Text input blocking — Typing is silently blocked in content-locked nodes
Transaction filter — Safety net that catches paste, drag-drop, and programmatic edits
Users can still place their cursor inside locked content and select text for copying. Only modifications are blocked.
Lock modes round-trip through DOCX. A document with w:lock elements in
its SDT properties will import with the correct lock mode and export the
w:lock element back to the saved file.
Commands
insertStructuredContentInline
Inserts a structured content inline at the current selection.Example:
Updates a single structured content field by its unique ID.
IDs are unique identifiers, so this will update at most one field.
If the updated node does not match the schema, it will not be updated.Pass attrs alone to change attributes (like lockMode) without replacing content:Example: