General API
The root Facade API combines the common Univer runtime with the Slides plugins that the application registers. This page covers commands, events, history, and the unit lifecycle, and does not assume experience with another Univer document type. For presentation objects, see Univer Slides API.
Create the API object
Create a single FUniver wrapper after the Univer instance and the required plugins are registered:
import { FUniver } from '@univerjs/core/facade'const univerAPI = FUniver.newAPI(univer)Facade entries imported before this call add Slides methods to the same object.
Commands
executeCommand() runs a registered command asynchronously. Use syncExecuteCommand() only when the command explicitly supports synchronous execution. For common Slides operations, prefer the Facade methods.
Events
const commandLog = univerAPI.addEvent( univerAPI.Event.CommandExecuted, ({ id }) => console.log('Executed:', id))// Later, remove the listener.commandLog.dispose()Listen to BeforeCommandExecute when the application needs to inspect or cancel a command. LifeCycleChanged fires when the editor enters stages such as Rendered and Steady.
Undo and redo
Undo and redo act on the focused Univer unit and return promises:
await univerAPI.undo()await univerAPI.redo()Slides Facade mutations pass through the command pipeline, so supported changes enter the same history.
System clipboard
After UniverSlidesUIPlugin is registered and the Slides canvas has focus, copy() copies the current selection and paste() inserts clipboard content through the Slides UI commands.
import '@univerjs/ui/facade'await univerAPI.copy()await univerAPI.paste()The canvas context menu supports normal paste, paste as text, and paste as image. Text mode creates an editable text box from the clipboard text. Image mode uses image files or image resources in the clipboard HTML; it does not convert arbitrary content into an image.
While editing text in a shape or table, the editor provides Keep source formatting, Match destination formatting, and Keep text only, along with a formatting menu after pasting.
These operations require a focused browser editor and clipboard permission, so they are unavailable in a model-only Node.js runtime. If the browser blocks clipboard reads, use the system paste shortcut.
UI
The UI Facade displays messages, opens dialogs or sidebars, registers components, and controls the built-in UI parts:
univerAPI .showMessage({ content: 'Presentation saved', type: 'success' }) .setUIVisible(univerAPI.Enum.BuiltInUIPart.TOOLBAR, true)These methods require UniverUIPlugin; the Slides editing controls also require UniverSlidesUIPlugin.
WebSocket
WebSocket support is optional and provided by the Network Facade:
import { UniverNetworkPlugin } from '@univerjs/network'import '@univerjs/network/facade'univer.registerPlugin(UniverNetworkPlugin)const socket = univerAPI.createSocket('wss://example.com/slides')socket.open$.subscribe(() => socket.send('ready'))Message protocols, authentication, reconnection, and collaboration conflict handling remain the responsibility of the host application.
Enums
univerAPI.Enum exposes the common runtime enums and the enums that Slides adds:
const lifecycle = univerAPI.Enum.LifecycleStages.Steadyconst transition = univerAPI.Enum.SlideTransitionTypeEnum.Fadeconst elementType = univerAPI.Enum.SlidePageElementTypeEnum.ShapeUtilities
univerAPI.Util provides shared helpers such as number formatting, rectangle operations, and general tools:
const payload = univerAPI.Util.tools.deepClone({ slideId: 'slide-1', selectedElementIds: ['element-1'],})How is this guide?