Break documents into discrete, lockable parts. Each section is an independent Word SDT (w:sdt) element that preserves state through import/export.

OOXML Structure

<w:sdt>
  <w:sdtPr>
    <w:alias w:val="Legal Terms"/>
    <w:lock w:val="sdtContentLocked"/>
    <w:tag w:val='{"id":"legal-1","type":"documentSection"}'/>
  </w:sdtPr>
  <w:sdtContent>
    <!-- Your content as OOXML -->
  </w:sdtContent>
</w:sdt>

Why you’d use this

  • Contract management - Lock legal clauses, leave business terms editable
  • Multi-team documents - Each team owns their section
  • Form templates - Some parts fixed, some parts fillable

Attributes

id
number
Unique section identifier
title
string
Section display label
description
string
Section metadata
sectionType
string
Business classification (e.g., ‘legal’, ‘pricing’)
isLocked
boolean
Lock state preventing edits

Commands

createDocumentSection

Create a lockable content section
createDocumentSection({
  id: 'legal-1',
  title: 'Terms & Conditions',
  isLocked: true,
  html: '<p>Legal content...</p>'
})
Parameters:
options
SectionCreate
See SectionCreate type definition

removeSectionAtSelection

Remove section wrapper at cursor, preserving its content
Content stays in document, only section wrapper is removed
removeSectionAtSelection()

removeSectionById

Delete section and all its content
removeSectionById(123)
Parameters:
id
number
required
Section to delete

lockSectionById

Lock section against edits
lockSectionById(123)
Parameters:
id
number
required
Section to lock

updateSectionById

Modify section attributes or content
// Toggle lock
updateSectionById({ id: 123, attrs: { isLocked: false } })

// Replace content
updateSectionById({ id: 123, html: '<p>New content</p>' })

// Both
updateSectionById({
  id: 123,
  html: '<p>Updated</p>',
  attrs: { title: 'New Title' }
})
Parameters:
options
SectionUpdate
required
See SectionUpdate type definition

Helpers

getAllSections

Get all sections in the editor document Returns: Array An array of objects containing the node and its position in the document

exportSectionsToHTML

Export all sections to HTML format Returns: Array An array of objects containing section details and their HTML representation

exportSectionsToJSON

Export all sections to JSON format. Parameters:
editor
Editor
required
The editor instance containing the sections.
Returns: Array An array of objects containing section details and their JSON representation.

getLinkedSectionEditor

Get a linked section editor by its ID. This function creates a child editor for a specific section, allowing for editing of that section’s content. Parameters:
id
String
required
The ID of the section to link to.
options
Object
required
Options for the child editor.
editor
Editor
required
The parent editor instance.
Returns: Editor | null The child editor instance for the linked section, or null if the section is not found.

Types

SectionAttributes

Document section attributes

SectionCreate

Create a new document section

SectionUpdate

Update an existing section