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
Quick Start
// Insert inline field for customer name
editor . commands . insertStructuredContentInline ({
attrs: {
id: '1' ,
alias: 'Customer Name'
},
text: 'John Doe'
});
// Insert block field for terms section
editor . commands . insertStructuredContentBlock ({
attrs: {
id: '2' ,
alias: 'Terms & Conditions'
},
html: '<p>Please review the terms...</p>'
});
// Update inline field content
editor . commands . updateStructuredContentById ( '1' , {
text: 'Jane Smith'
});
// Update block field content and attributes
editor . commands . updateStructuredContentById ( '2' , {
html: '<p>Updated terms and conditions...</p>' ,
attrs: { alias: 'Legal Terms' }
});
// Get all structured content tags
const allTags = editor . helpers . structuredContentCommands . getStructuredContentTags ( editor . state );
console . log ( `Document contains ${ allTags . length } SDT fields` );
Options
Configure the extension behavior:
structuredContentClass
string
default: "sd-structured-content-block-tag"
CSS class for the block
HTML attributes for structured content blocks
Attributes
Node attributes that can be set and retrieved:
Unique identifier for the structured content block
Content control tag (e.g., ‘block_table_sdt’)
alias
string
default: "Structured content"
Display name for the block
Commands
insertStructuredContentInline
Inserts a structured content inline at selection.
Parameters:
options
StructuredContentInlineInsert
required
insertStructuredContentBlock
Inserts a structured content block at selection.
Parameters:
options
StructuredContentBlockInsert
required
updateStructuredContentById
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.
Parameters:
Unique identifier of the field
options
StructuredContentUpdate
required
deleteStructuredContent
Removes a structured content.
Parameters:
deleteStructuredContentById
Removes a structured content by ID.
Parameters:
idOrIds
string | Array<string>
required
deleteStructuredContentAtSelection
Removes a structured content at cursor, preserving its content.
appendRowsToStructuredContentTable
Append multiple rows to the end of a table inside a structured content block.
Each inner array represents the cell values for one new row.
Example:
editor . commands . appendRowsToStructuredContentTable ({
id: 'block-123' ,
tableIndex: 0 ,
rows: [[ 'A' , 'B' ], [ 'C' , 'D' ]],
copyRowStyle: true ,
});
Parameters:
options
StructuredContentTableAppendRowsOptions
required
Append configuration
Helpers
getStructuredContentBlockTags
Get all block-level structured content tags in the document
Example:
const blocks = editor . helpers . getStructuredContentBlockTags ( editor . state )
console . log ( `Found ${ blocks . length } structured content blocks` )
Parameters:
getStructuredContentInlineTags
Get all inline structured content tags in the document
Example:
const inlines = editor . helpers . getStructuredContentInlineTags ( editor . state )
console . log ( `Found ${ inlines . length } inline fields` )
Parameters:
getStructuredContentTablesById
Find all tables inside a structured content block by ID
Example:
const tables = editor . helpers . getStructuredContentTablesById ( 'block-123' , editor . state )
console . log ( `Block contains ${ tables . length } table(s)` )
Parameters:
Structured content block ID
getStructuredContentTags
Get all structured content tags (inline and block) in the document
Example:
const allTags = editor . helpers . getStructuredContentTags ( editor . state )
console . log ( `Found ${ allTags . length } structured content elements` )
Parameters:
getStructuredContentTagsById
Get structured content tag(s) by ID
Example:
const field = editor . helpers . getStructuredContentTagsById ( 'field-123' , editor . state )
if ( field . length ) console . log ( 'Found field:' , field [ 0 ]. node . attrs )
Parameters:
idOrIds
string | Array<string>
required
Single ID or array of IDs to find
Types
StructuredContentInlineInsert
StructuredContentBlockInsert
StructuredContentUpdate
Replace content with text (only for structured content inline)
Replace content with HTML (only for structured content block)
Replace content with ProseMirror JSON (overrides html)
Update attributes only (preserves content)
StructuredContentTableAppendRowsOptions
Structured content block identifier
Index of the table inside the block
rows
Array<Array<string>> | Array<string>
required
Cell values to append
Clone the last row’s styling when true
Source Code