Enhanced List
Enhanced lists extend Univer Docs with nested levels, custom glyphs, and list structure editing.
Introduction
In Univer Docs, enhanced lists provide the following capabilities:
- Multiple nesting levels.
- A choice of bullet symbols and numbering styles.
- Promote, demote, and reorder operations on list items.
Plugin mode
Installation
Shell
pnpm add @univerjs-pro/docs-list @univerjs-pro/docs-list-uiShell
npm install @univerjs-pro/docs-list @univerjs-pro/docs-list-uiShell
yarn add @univerjs-pro/docs-list @univerjs-pro/docs-list-uiShell
bun add @univerjs-pro/docs-list @univerjs-pro/docs-list-uiUsage
TypeScript
import { UniverDocsListPlugin } from '@univerjs-pro/docs-list'import { UniverDocsListUIPlugin } from '@univerjs-pro/docs-list-ui'import DocsListUIEnUS from '@univerjs-pro/docs-list-ui/locale/en-US'import { LocaleType, mergeLocales, Univer } from '@univerjs/core'import '@univerjs-pro/docs-list-ui/lib/index.css'const univer = new Univer({ locale: LocaleType.EN_US, locales: { [LocaleType.EN_US]: mergeLocales( DocsListUIEnUS, ), },})univer.registerPlugin(UniverDocsListPlugin)univer.registerPlugin(UniverDocsListUIPlugin)If you use a commercial license, configure it as described in Using License in Client.
Mobile support
Set up the mobile editor first. In the plugin-mode setup described on this page, replace the desktop registration shown below with the mobile export from the same package, and complete the replacement before you open a document. Keep the model plugins, styles, locales, and Facade imports, and do not register both variants.
| Package | Desktop registration | Mobile registration |
|---|---|---|
@univerjs-pro/docs-list-ui | UniverDocsListUIPlugin | UniverDocsListMobileUIPlugin |
Facade API
Import the facade before calling any of the following APIs:
TypeScript
import '@univerjs-pro/docs-list/facade'Insert a list
TypeScript
import { PresetListType } from '@univerjs/core'const doc = univerAPI.getActiveDocument()doc?.insertList({ startOffset: 0, endOffset: 10, listType: PresetListType.BULLET_LIST,})Get all lists
TypeScript
const doc = univerAPI.getActiveDocument()const lists = doc?.getLists() ?? []Set list glyph type
TypeScript
const doc = univerAPI.getActiveDocument()doc?.setListGlyphType(0, ListGlyphType.DECIMAL)Set list level
TypeScript
const doc = univerAPI.getActiveDocument()doc?.setListLevel(0, 1)How is this guide?