Content Editor
The content editor lets users edit text and images directly on the PDF page — add text, add images, and modify existing content. It is coordinated by the engine's content_edit_manager with a dedicated history manager, exposed to the UI through the core bridge.
The content-editing engine lives in the closed-source Core (
packages/core/src/editor/). The UI layer drives it through the bridge and mirrors state in the stores.
UI APIs
Save / save-as enable/disable
UI.disableDocumentEditorSave(); // useViewer.setDocumentEditorSaveStatus(false)
UI.enableDocumentEditorSave(); // useViewer.setDocumentEditorSaveStatus(true)
UI.disableDocumentEditorSaveAs(); // useViewer.setDocumentEditorSaveAsStatus(false)
UI.enableDocumentEditorSaveAs(); // useViewer.setDocumentEditorSaveAsStatus(true)Toggle the documentEditorSaveStatus / documentEditorSaveAsStatus flags in the viewer store, controlling whether the Save / Save-As actions are available in the document editor.
UI.saveDocumentEditor() (async)
Persist the document-editor changes and reload the document.
await UI.saveDocumentEditor();Internally (in apis/saveDocumentEditor.js):
- Calls
core.saveDocumentEdit()to get anewUrl; returns early if falsy. - Resets editor state:
useDocument.resetSetting(),useDocument.setToolState(''). - Switches the viewer back to view mode:
setActiveToolMode('view'),setToolbarGroup('toolbarGroup-View'),setActiveHeaderGroup('default'). - Triggers upload (
setUpload(true),setUploadLoading(true)), preserves the old scale. - Sets
useDocument.setCurrentPdfData(newUrl), refreshestotalPagesviacore.getPagesCount(), outlines viacore.getOutlines(), resets page to 1. - Re-applies scroll/spread mode and scale via
core.switchScrollMode/core.switchSpreadMode/core.scaleChanged. setUploadLoading(false).
Content editor state
| Store | Field | Purpose |
|---|---|---|
| viewer | contentEditorType | Editor type ('text'). |
| viewer | documentEditorSaveStatus / documentEditorSaveAsStatus | Save / save-as availability. |
| document | documentEditor | { operationList[], pageList[], selectedPageList[] }. |
| document | canUndo / canRedo | { content, annotation } undo/redo flags. |
useHistoryListener (in HeaderItemsListener.js) bridges the engine's contentEditHistoryChanged / historyChanged events into useDocument.setCanUndo / setCanRedo.
Content editor components
DocumentEditorContainer— the page editor surface, shown when the active tool mode isdocument.ContentEditorPanel— content-editor selection properties (right panel, eager-loaded).ContentEditorToolBar— content-editor toolbar.ContentEditorPopup— the content-editor context menu (see Popups).
Related dialogs: ContentEditorPreventDialog, DocEditorPreventDialog.
Core bridge (content-editor surface)
The core bridge exposes on instance.Core:
| Function | Purpose |
|---|---|
switchAnnotationEditorMode | Switch the editor mode. |
setContentEditorProperty | Set a content-editor property. |
getContentEditManager | Get the content-edit coordinator. |
getContentEditHistoryManager | Get the content-edit history manager. |
addEditorImage | Add an image to the editor. |
getCropedPageImage | Get a cropped page image. |
saveDocumentEdit | Save edits and return a new URL. |
Examples
Disable save-as in the editor
UI.disableDocumentEditorSaveAs();Save and reload
await UI.saveDocumentEditor();Related
- Header & Toolbar — the editor toolbar group.
- Popups — the content-editor popup.
- Core Bridge
- API Reference