Content Controls
Content controls (SDT) support rich text, plain text, checkboxes, dates, lists, pictures, groups, repeating sections, and document parts. Register the Docs core and Pro license plugins, then the two packages below before creating the document. Merge the UI locale into locales and load the stylesheet. The Docs advanced preset does not include these packages.
pnpm add @univerjs-pro/docs-sdt @univerjs-pro/docs-sdt-uinpm install @univerjs-pro/docs-sdt @univerjs-pro/docs-sdt-uiyarn add @univerjs-pro/docs-sdt @univerjs-pro/docs-sdt-uibun add @univerjs-pro/docs-sdt @univerjs-pro/docs-sdt-uiimport { UniverDocsSdtPlugin } from '@univerjs-pro/docs-sdt'import { UniverDocsSdtUIPlugin } from '@univerjs-pro/docs-sdt-ui'import FeatureLocale from '@univerjs-pro/docs-sdt-ui/locale/en-US'import { LocaleType } from '@univerjs/core'import '@univerjs-pro/docs-sdt-ui/lib/index.css'univerAPI.loadLocales(LocaleType.EN_US, FeatureLocale)univer.registerPlugin(UniverDocsSdtPlugin)univer.registerPlugin(UniverDocsSdtUIPlugin)Insert at the selection
The command uses the active text selection. Existing selected content is wrapped where the control supports it. Repeating-section items are created through their parent section.
import { InsertSdtCommand } from '@univerjs-pro/docs-sdt-ui'await univerAPI.executeCommand(InsertSdtCommand.id, { kind: 'checkbox' })Locks and persistence
Controls are stored as CustomRangeType.SDT ranges in IDocumentBody.customRanges, with metadata in ISdtCustomRange.properties. Content locks prevent value edits; control locks prevent wrapper removal. Repeating sections can disallow item insertion and deletion. Use commands for value, property, and repeating-item changes so undo/redo remains consistent.
See the model commands and UI API. DOCX conversion belongs to Exchange; editor support does not imply lossless support for every Word property or custom XML binding.
How is this guide?