Basic concepts
Univer Sheets is built on a small set of concepts: Units, Plugins, Snapshots, Commands, and the Facade API. This page explains what each term means. To see these concepts working in an editor, continue with installation and basic usage.
Basic concepts
Five terms recur throughout Univer:
- Unit
- Plugin
- Snapshot
- Command
- Facade API
Unit (content unit)
A Unit is a complete content instance managed by Univer: a workbook, a document, a presentation, a Base, a board, or a PDF. Each Unit has its own ID (unitId), so two documents of the same type are two distinct Units.
A workbook that contains several worksheets remains one Unit. Its worksheets, cell ranges, and cells are internal objects rather than Units of their own. A slide follows the same rule and belongs to the presentation Unit that contains it.
One Univer instance can load several Units. A Snapshot is serializable data that describes the content state of a Unit, and it is not the same object as the live Unit being edited. Permissions set on a Unit apply to the entire content instance, while object permissions apply to the content inside it.
Plugins
Univer's features are provided as plugins. Plugins are the building blocks, and the set you register defines the Univer application.
Plugins perform two kinds of work:
- They add a feature.
@univerjs/sheets-filter, for example, provides filtering. - They supply the basic capabilities that other plugins depend on.
@univerjs/engine-renderprovides rendering.
Combining plugins lets you shape the application around your requirements and exclude code you do not need. When Univer has no plugin for a requirement, you can write your own.
Related links
- Write a CSV import plugin explains how to build one.
- Univer Architecture describes how the components fit together.
Snapshot
Univer loads a document by loading its snapshot. Each document type has its own snapshot format, so the snapshot must match the API types:
- A spreadsheet snapshot uses
IWorkbookData. - A document snapshot uses
IDocumentData.
Feature plugins store resources such as images in the resources field. Plugin Custom Model explains how that works.
Caution
A snapshot only stores data. While Univer is running, it does not reflect the current state of the document. To capture the current state as a snapshot, use the save-snapshot method on the Facade API.
Command
Every change to document data in Univer goes through a command. Commands give Univer a single place to observe what changed, which is the basis of undo, redo, and collaborative editing. They also let Univer resolve the dependencies between features.
To dispatch commands directly, see How to Find Command ID. When you change data through the Facade API, it prepares the command parameters and dispatches the command.
Caution
Do not modify the snapshot directly. Changes made that way have no effect and do not refresh the view or the UI. Change data through a command or the Facade API.
Facade API
Office applications are complex, and so is Univer's architecture. The Facade API wraps Univer's first-party plugins in simpler interfaces, so you do not need to learn the whole architecture before you can complete a task.
Facade API coverage continues to grow. If you encounter a gap or something is unclear, open an issue on GitHub.
The Facade API is a high-level API that hides the underlying details. Common tasks become shorter. Complex tasks may still require an understanding of Univer's architecture and direct calls to the lower-level API.
Related links
Preset mode and plugin mode
A preset is a bundle of plugins that are already configured. When both modes receive the same plugins, they expose the same capabilities. The difference lies in how much configuration the application must provide. Use a preset for a quick start, and plugin mode when you need explicit control over composition and loading.
Keep every Univer dependency on the same version. If a preset already includes a plugin, do not register it again; otherwise plugin conflicts or feature malfunctions may occur.
| Plugin mode | Preset mode |
|---|---|
| Import Facade extensions explicitly | Facade extensions are included |
| Control plugin registration order | The preset manages its included plugins |
| Load plugins on demand | Configured presets load during initialization |
How is this guide?