Core Features
Univer Docs consists of a document editor, a formula engine, a rendering engine, a design system, and a UI component library. Together they form a document processing platform that supports multiple document formats and complex operations.
Features
- Document rendering. Univer Docs renders the document content, the cursor, and the selection.
- Document typesetting. Full-text typesetting covers paragraph settings: spacing before and after a paragraph, alignment, indentation, and hanging indent. Within a paragraph, it also covers punctuation compression, hanging punctuation, character spacing, and Western word breaking.
- Formula calculation. Univer Docs supports adding and calculating Univer formulas. This capability is still in development.
- Tables. Univer Docs supports inserting basic tables and editing them, including adding or deleting rows and editing cells.
- Document styles. Univer Docs supports both traditional document styles similar to Microsoft Word (pagination, headers, and footers) and modern document styles similar to Notion. Modern documents do not paginate: content expands without limit, and official or third-party block-level elements, such as text, images, and tables, can be mixed in the same document (planned).
- Headers and footers. Univer Docs supports inserting a header or footer and editing its content. First pages and odd/even pages can differ (traditional documents only).
- Lists. Univer Docs supports inserting and editing ordered, unordered, and task lists, and indenting or outdenting them.
- Emoji and symbols. Emoji and symbols can be inserted from the Docs ribbon.
- Plugin system. Univer Docs supports custom plugins, such as formula, image, and chart plugins. The plugin system is also one of Univer's core architectural capabilities.
Plugin mode
Installation
pnpm add @univerjs/core @univerjs/engine-render @univerjs/engine-formula @univerjs/design @univerjs/ui @univerjs/docs @univerjs/docs-uinpm install @univerjs/core @univerjs/engine-render @univerjs/engine-formula @univerjs/design @univerjs/ui @univerjs/docs @univerjs/docs-uiyarn add @univerjs/core @univerjs/engine-render @univerjs/engine-formula @univerjs/design @univerjs/ui @univerjs/docs @univerjs/docs-uibun add @univerjs/core @univerjs/engine-render @univerjs/engine-formula @univerjs/design @univerjs/ui @univerjs/docs @univerjs/docs-uiUsage
import { LocaleType, mergeLocales, Univer } from '@univerjs/core'import { FUniver } from '@univerjs/core/facade'import DesignEnUS from '@univerjs/design/locale/en-US'import { UniverDocsPlugin } from '@univerjs/docs'import { UniverDocsUIPlugin } from '@univerjs/docs-ui'import DocsUIEnUS from '@univerjs/docs-ui/lib/locale/en-US'import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula'import { UniverRenderEnginePlugin } from '@univerjs/engine-render'import { UniverUIPlugin } from '@univerjs/ui'import UIEnUS from '@univerjs/ui/locale/en-US'import '@univerjs/docs/facade'import '@univerjs/docs-ui/facade'import '@univerjs/design/lib/index.css'import '@univerjs/ui/lib/index.css'import '@univerjs/docs-ui/lib/index.css'const univer = new Univer({ locale: LocaleType.EN_US, locales: { [LocaleType.EN_US]: mergeLocales(DesignEnUS, UIEnUS, DocsUIEnUS), },})univer.registerPlugin(UniverRenderEnginePlugin)univer.registerPlugin(UniverFormulaEnginePlugin)univer.registerPlugin(UniverUIPlugin, { container: 'app',})univer.registerPlugin(UniverDocsPlugin)univer.registerPlugin(UniverDocsUIPlugin)const univerAPI = FUniver.newAPI(univer)univerAPI.createDocument({})Plugin configuration
@univerjs/core
The core library provides the Univer constructor, together with themes and languages.
import type { IUniverConfig } from '@univerjs/core'import { LocaleType, Univer } from '@univerjs/core'const config: IUniverConfig = { locale: LocaleType.EN_US, darkMode: false,}const univer = new Univer(config)Reference: IUniverConfig
@univerjs/engine-render
The rendering engine is responsible for rendering, scrollbars, the cursor, and the selection. It is registered as UniverRenderEnginePlugin.
Reference: @univerjs/engine-render
@univerjs/engine-formula
The formula engine calculates and processes formulas. It is registered as UniverFormulaEnginePlugin.
Reference: @univerjs/engine-formula
@univerjs/design
The design system provides the base components and styles.
See: UI Chapter
@univerjs/ui
The UI foundation plugin is registered as UniverUIPlugin.
UniverUIPlugin accepts options that configure the basic layout.
containerstring | HTMLElementElement in which the editor is mounted.headerbooleanDefault:trueShow the header.toolbarbooleanDefault:trueShow the toolbar.ribbonTypeRibbonTypeDefault:'classic'Choose the Ribbon layout.contextMenubooleanDefault:trueEnable context menus.disableAutoFocustrueDisable autofocus at startup.override[DependencyIdentifier, Provider | null][]Override injected dependencies.[0]DependencyIdentifierDependency identifier to replace.[1]Provider | nullReplacement provider. Passnullto remove the dependency.
Use menu to show, hide, or otherwise change the state of specific menu items:
univer.registerPlugin(UniverDocsUIPlugin, { menu: { 'doc.command.set-inline-format-bold': { hidden: true, }, 'doc.command.set-inline-format-italic': { hidden: true, disabled: true, }, },})'doc.command.set-inline-format-bold' and 'doc.command.set-inline-format-italic' are command names that identify the corresponding menu items.
Reference: @univerjs/docs-ui
@univerjs/docs
The core Docs plugin is registered as UniverDocsPlugin.
Reference: @univerjs/docs
@univerjs/docs-ui
The Docs UI plugin contains the document editor's UI components and interactions. It is registered as UniverDocsUIPlugin.
Reference: @univerjs/docs-ui
tocbooleanShow the document outline. When omitted, Modern documents show it and Traditional documents hide it.
Preset mode
Installation
pnpm add @univerjs/presets @univerjs/preset-docs-corenpm install @univerjs/presets @univerjs/preset-docs-coreyarn add @univerjs/presets @univerjs/preset-docs-corebun add @univerjs/presets @univerjs/preset-docs-coreUsage
import { UniverDocsCorePreset } from '@univerjs/preset-docs-core'import UniverPresetDocsCoreEnUS from '@univerjs/preset-docs-core/locales/en-US'import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'import '@univerjs/preset-docs-core/lib/index.css'const { univer, univerAPI } = createUniver({ locale: LocaleType.EN_US, locales: { [LocaleType.EN_US]: mergeLocales(UniverPresetDocsCoreEnUS), }, presets: [UniverDocsCorePreset()],})univerAPI.createDocument({})Preset configuration
@univerjs/presets
This preset provides createUniver for creating a Univer application and re-exports every method and object from @univerjs/core and @univerjs/design.
createUniver accepts a configuration object that covers theme, language, presets, and other options. It returns a Univer instance univer and an FUniver instance univerAPI for calling the Facade API.
themeThemeDefault:defaultThemeTheme used by the editor.[palette]object[shade]stringColor palette keyed by name and shade. UsedefaultThemeas the template.
darkModebooleanDefault:falseStart in dark mode.localeLocaleTypeLanguage used by menus and dialogs.regionLocaleTypeDefault:localeRegion used for formatting.localesRecord<string, ILanguagePack>Translations keyed by locale.[locale]ILanguagePackTranslations for one locale. Use the locale value as the key.
logLevelLogLevelDefault:LogLevel.WARNVerbosity of runtime logs.presets(IPreset | [IPreset, IPresetOptions])[]Presets to register.[0]IPresetPreset returned by a preset factory.[1]IPresetOptionsDefers registration of this preset’s plugins.lazybooleanDefers registration of this preset’s plugins.
lazybooleanDefers registration of this preset’s plugins.
plugins(PluginCtor | [PluginCtor, object])[]Additional plugins and their options.[0]PluginCtorPlugin constructor.[1]objectOptions accepted by that plugin’s constructor.
Reference: createUniver
@univerjs/preset-docs-core
This is the core preset for Univer Docs. It bundles the core capabilities that an electronic document requires, such as the document editor, formula engine, and rendering engine.
containerstring | HTMLElementDefault:'app'Element where the editor mounts.headerbooleanDefault:trueShow the header.toolbarbooleanDefault:trueShow the toolbar.ribbonTypeRibbonTypeDefault:'classic'Choose the Ribbon layout.contextMenubooleanDefault:trueEnable context menus.disableAutoFocustrueDisable autofocus at startup.tocbooleanShow the document outline. When omitted, Modern documents show it and Traditional documents hide it.
Use menu to show, hide, or otherwise change the state of specific menu items:
UniverDocsCorePreset({ menu: { 'doc.command.set-inline-format-bold': { hidden: true, }, 'doc.command.set-inline-format-italic': { hidden: true, disabled: true, }, },})'doc.command.set-inline-format-bold' and 'doc.command.set-inline-format-italic' are command names that identify the corresponding menu items.
Reference: @univerjs/preset-docs-core
Viewing controls
The View ribbon contains page settings, zoom, and fullscreen controls. The zoom selector and the zoom bar at the bottom show the same document view scale. Changing that scale does not change text formatting.
Menu order and grid layout
Define a shared MenuConfig with Docs menu IDs, then apply it for the integration mode in use:
import type { MenuConfig } from '@univerjs/ui'const menu: MenuConfig = { 'ribbon.start.format': { order: -1 }, 'doc.command.set-inline-format-bold': { order: 0, gridLayout: { row: 2, column: 2 }, }, 'doc.command.set-inline-format-italic': { gridLayout: { row: 2, column: 1 }, },}Merge these options into the existing initialization for the integration mode in use. Retain the other plugin, locale, theme, and container settings, and do not register the same plugin twice.
import { UniverUIPlugin } from '@univerjs/ui'univer.registerPlugin(UniverUIPlugin, { ribbonType: 'grid', menu,})import { UniverDocsCorePreset } from '@univerjs/preset-docs-core'import { createUniver } from '@univerjs/presets'const { univerAPI } = createUniver({ presets: [ UniverDocsCorePreset({ ribbonType: 'grid', menu, }), ],})Document outline
The outline on the left navigates between headings. It does not insert a table of contents into the document. When toc is omitted, Modern documents show the outline and Traditional documents hide it. An explicit true or false overrides either default. The panel collapses when space is insufficient or a table overlaps it, and reopens when space is available.
Merge this option into the existing initialization, and do not register the same plugin twice.
import { UniverDocsUIPlugin } from '@univerjs/docs-ui'univer.registerPlugin(UniverDocsUIPlugin, { toc: true })import { UniverDocsCorePreset } from '@univerjs/preset-docs-core'import { createUniver } from '@univerjs/presets'const { univerAPI } = createUniver({ presets: [UniverDocsCorePreset({ container: 'app', toc: true })],})Update menus with the Facade API
After initialization, call updateMenuConfig() on the existing instance:
import '@univerjs/ui/facade'univerAPI.updateMenuConfig(menu)order sorts siblings from lowest to highest. gridLayout applies only to the grid Ribbon and uses 1-based coordinates within each two-row group. Runtime updates preserve properties that were not specified and refresh the UI immediately. In plugin mode, pass menu to UniverUIPlugin, and import @univerjs/ui/facade before calling the Facade. The menu layout guide covers grid fields and custom buttons.
Paste options
Docs provides three paste modes: keep source formatting, match destination formatting, and keep text only. Match destination formatting adopts the target text and paragraph styles while keeping supported emphasis such as bold and italic. Text-only paste removes images and hyperlinks, and table content becomes tab-separated text. The post-paste options apply to the most recent paste. If the browser blocks clipboard reads, use the keyboard shortcut or the system paste command.
On desktop, the Ribbon Paste dropdown is located beside undo and redo, and it is hidden while editing shape text. The Paste special submenu is in the formatting group of the context menu on both desktop and mobile.
Header and footer fields
In traditional documents, editing a header or footer opens a contextual Ribbon with insertion and navigation controls, first-page and odd/even-page options, and positioning settings. The Ribbon can insert current-page and total-page fields, or a localized date and time. Page fields show the value for each rendered page. For date and time, enable automatic updating to store a field, and disable it to insert fixed text. Date and time fields refresh when the document opens or when Update fields is selected, and they do not update continuously. Modern documents do not use page headers or footers.
Collapse heading sections
Modern documents (documentStyle.documentFlavor: DocumentFlavor.MODERN) show a triangle beside Heading 1–5 when the heading has section content. Collapsing keeps the heading visible and hides everything up to the next heading of the same or higher level, including nested headings, tables, and images. Each table cell and Modern column has its own heading hierarchy.
Collapse behavior is independent of toc. Traditional documents and embedded text editors do not show collapse controls. Expanding a parent heading preserves the collapse state of its nested headings.
Heading collapse illustration
Fold the nested heading, then fold and reopen its parent. The nested section stays folded.
Headings organize text, tables, and images into sections.
Collapse state is saved with the document and shared with collaborators.
Export and reuse
A heading at the same level starts a new section and remains visible.
IParagraph.headingCollapsed is stored in the Univer snapshot, and only true collapses a section. Content remains in the snapshot, and the state participates in undo/redo and collaboration, so other editors see it. A selection inside hidden content moves to the visible heading. Preservation through Office import and export is not guaranteed.
For programmatic changes, call the registered command with the document ID and a stable paragraphId from the snapshot. Setting collapsed: false expands the section.
import { SetHeadingCollapsedCommand } from '@univerjs/docs'const changed = await univerAPI.executeCommand(SetHeadingCollapsedCommand.id, { unitId: documentId, paragraphId: headingParagraphId, collapsed: true,})The command returns false for an unchanged state or an invalid target, including a Traditional document, a heading hidden by an ancestor, an empty section when collapsing, or missing edit permission. See the command contract.
How is this guide?