Skip to main content
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>

Use Case

  • 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

Options

Configure the extension behavior:
htmlAttributes
Object
HTML attributes for document sections

Attributes

Node attributes that can be set and retrieved:
id
number
Unique section identifier
title
string
Section display label (becomes w:alias in Word)
description
string
Additional metadata stored in w:tag
sectionType
string
Business type for filtering/logic (e.g., ‘legal’, ‘pricing’)
isLocked
boolean
default:"false"
Lock state (maps to w:lock=“sdtContentLocked”)

Commands

createDocumentSection

Create a lockable content section Example:
editor.commands.createDocumentSection({
  id: 1,
  title: 'Terms & Conditions',
  isLocked: true,
  html: '<p>Legal content...</p>'
})
Parameters:
options
SectionCreate
required
Section configuration

removeSectionAtSelection

Remove section wrapper at cursor, preserving its content
Content stays in document, only section wrapper is removed
Example:
editor.commands.removeSectionAtSelection()

removeSectionById

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

lockSectionById

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

updateSectionById

Modify section attributes or content Example:
editor.commands.updateSectionById({ id: 123, attrs: { isLocked: false } })
editor.commands.updateSectionById({ id: 123, html: '<p>New content</p>' })
editor.commands.updateSectionById({
  id: 123,
  html: '<p>Updated</p>',
  attrs: { title: 'New Title' }
})
Parameters:
options
SectionUpdate
required
Changes to apply

Types

SectionCreate

Document section creation options

SectionUpdate

Update an existing section

Source Code

I