General API
Use common commands, events, history, clipboard, UI, WebSocket, enums, and utilities in a PDF application.
The root Facade API combines the shared Univer runtime with the plugins registered by the PDF application. This page covers mechanisms that behave the same way across Univer products, and it does not assume experience with another Univer document type. For PDF Units and page entry points, continue with Univer PDFs API.
Create the API object
Create a single FUniver wrapper after registering the Univer instance and the required plugins:
import { FUniver } from '@univerjs/core/facade'const univerAPI = FUniver.newAPI(univer)Facade entries imported before this call add their methods to the same object.
Commands
executeCommand() runs a registered command asynchronously. Use syncExecuteCommand() only when the command explicitly supports synchronous execution. For common PDF operations, Facade methods remain the preferred entry point.
Events
const commandLog = univerAPI.addEvent( univerAPI.Event.CommandExecuted, ({ id }) => console.log('Executed:', id))// Later, remove the listener.commandLog.dispose()Use BeforeCommandExecute when the application needs to inspect or cancel a command. LifeCycleChanged reports common editor stages such as Rendered and Steady.
Undo and redo
Undo and redo apply to the Univer Unit that currently has focus, and both return promises:
await univerAPI.undo()await univerAPI.redo()PDF Facade changes with an inverse operation enter the history of the focused PDF Unit.
System clipboard
When UniverPdfsUIPlugin is registered and PDF editing is enabled, the copy() and paste() methods of the UI Facade send clipboard commands to the focused PDF Unit:
import '@univerjs/ui/facade'await univerAPI.copy()await univerAPI.paste()For editable PDF objects, the PDF UI plugin keeps the copied payload in the current browser session rather than writing it to the operating system clipboard. Native text editing in the browser still follows the clipboard behavior of the browser.
UI
The UI Facade displays messages, opens dialogs and sidebars, registers components, and controls built-in UI parts:
univerAPI.setUIVisible(univerAPI.Enum.BuiltInUIPart.TOOLBAR, true)These methods require UniverUIPlugin, and the PDF editing controls also require UniverPdfsUIPlugin.
WebSocket
WebSocket support is optional. Register the Network plugin and import its Facade entry before creating the API object:
import { UniverNetworkPlugin } from '@univerjs/network'import '@univerjs/network/facade'univer.registerPlugin(UniverNetworkPlugin)const socket = univerAPI.createSocket('wss://example.com/pdfs')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 runtime enums and the enums added by the PDF Facade:
const lifecycle = univerAPI.Enum.LifecycleStages.Steadyconst annotationType = univerAPI.Enum.PdfAnnotationType.HIGHLIGHTUtilities
univerAPI.Util exposes shared helpers such as number formatting, rectangle operations, and common tools:
const payload = univerAPI.Util.tools.deepClone({ pageId: 'page-1', selectedElementIds: ['element-1'],})The complete common API is documented in the Facade reference.
How is this guide?