API reference / Common
Common
The base class the viewer and the editor extend, and the types their calls take and return. Both packages export all of it: import it from whichever you use, not from @docmentis/udoc-ui.
Classes
| Class | Description |
|---|---|
| OverlayManager | Reconciles the registered OverlaySources against a container element each painted frame: creates newly-appeared items, repositions and refreshes the rest, and removes items whose key vanished (a page scrolled off). Sources render in registration order, which is also their stacking order (later sources paint above earlier ones). Positioning is a single transform per item — the cheap path the browser can keep on the compositor. |
| UDocBase | The document UI every docMentis package's public class extends — driven with open / close / destroy. E is the package's event map, the common one and any of its own. |
| UDocError | - |
Interfaces
| Interface | Description |
|---|---|
| Affine | 2D affine transformation matrix, stored in PDF / SVG [a b c d e f] tuple order. |
| Annotation | One annotation: the entries every annotation dictionary carries (Table 164), and its subtype's own in kind. |
| DocumentLayout | A snapshot of a document's layout: composed page count and total scrollable size. |
| Fit | A fit configuration: the [FitMode] plus the zoom ceiling the derived zoom is clamped to. |
| FontDescriptor | One family in one bold / italic style — the atomic unit font resolution works in, and the only selection input the font system takes. |
| GoogleFontFamily | One family from the host's Google font catalog, in the shape the Google Fonts Developer API returns it. |
| LocalCollaborationServiceOptions | Options for startLocalCollaborationService: the license the service's session is started under, and where to find the WASM — as a client's are — and the name of the document's file. |
| Messages | Every string the chrome shows, by key: the shape of a language pack, and of the translations option. A {name} in a string is a value filled in. A key ending in a plural category — .one, .few, .other, … — is one form of a counted message, chosen by the count's category in the language; .other is the one every language has, and the rest are given where the language has them. |
| OpenOptions | Options for UDocBase.open. Every field is optional; each says its default. |
| OverlayFrame | One painted frame, as the overlay layer sees it: the on-screen pages in viewport (CSS px) space, plus the frame's scale (CSS px per document point — the zoom). A source uses scale to project page-local coordinates, or to scale an item with the content via OverlayItem.scale; chrome meant to stay constant on screen simply ignores it. |
| OverlayItem | One piece of overlay chrome for a single frame. The manager pools the DOM element by key across frames, so a stable key (e.g. "pill:3") means "the same element, moved" rather than a teardown + rebuild. |
| OverlayOptions | Which layer setOverlay puts an overlay in. |
| PageGap | The gaps the arrangement leaves between adjacent pages, in document points. Page-fixed, so they scale with zoom and page positions stay zoom-independent. horizontal separates the pages of one spread, side by side; vertical separates one spread from the next. |
| PageView | One on-screen page projected into viewport space (CSS px), the unit an HTML overlay layer positions page chrome from: a corner button from a page's box, an inter-page divider from the gap between two consecutive boxes. Unlike everything else here, x/y/width/height are CSS px, not document points — the worker has already applied the current scroll/zoom — so an absolutely-positioned element drops straight onto the page. Recomputed each painted frame and streamed from the worker; see the overlay layer. |
| PrintOptions | Options for print. Every field is optional; each says its default. |
| Rect | - |
| RemoteCheckpointResponse | A server's answer to a checkpoint: the version of the baseline it wrote. |
| RenderPageOptions | Options for UDocBase.renderPage. Every field is optional; each says its default. |
| SearchMatch | One match: where it is in the model, where it is drawn, and the text around it for a results list. |
| SearchMatchLocation | Where a match is in the model — its first and last positions as indices down the doc type's model tree. Opaque to the caller, read only by the match's conversion to a selection (Editor::search_match_selection). |
| SearchOptions | How a search compares its query with the text — the host's options, beside the query and the doc type's SearchScope. |
| SearchQuad | One piece of a match's highlight: four corners in page-local points, the form a PDF text markup annotation keeps — rotation and skew survive, and the host draws a polygon with no transform of its own. |
| SheetInfo | A sheet of the open workbook, as UDocBase.sheets lists it. |
| Size | - |
| UDocEvents | The public event map: event name → payload. Subscribe with UDocBase.on. |
| UDocOptions | Options for creating a UDocBase. Every field is optional; each says its default. |
| UrlFont | One font the host offers by URL: which font it is, where to fetch it, and optionally what it covers. |
| Viewport | What the engine should paint: a window into document space plus the output surface metrics. The canvas is pinned to the viewport (synthetic scroll), so scrollX/scrollY are a document-space offset, not DOM scroll. |
| WasmLocateOptions | - |
Type Aliases
| Type Alias | Description |
|---|---|
| AnnotationId | - |
| AnnotationKind | An annotation's /Subtype (§12.5.6) with the entries only that subtype carries. Subtypes the spec groups under one table share one payload: the four text-markup subtypes ([TextMarkupAnnotation]). |
| AnnotationPatch | Any of an annotation's fields, and any of theirs, all the way down; an array whole. undefined stands for a field left as it is. |
| Destination | A place in a document (§12.3.2): a page and how to show it, or a name resolved through the document's /Dests or /Names tree. |
| DestinationView | How a destination shows its page (Table 151). Coordinates are that page's page-local space, like every page coordinate; None keeps the current value. |
| EventHandler | A handler for event K of the event map E, as UDocBase.on takes it: called with that event's payload. |
| ExportFormat | A format a session's whole document is exported to — a rendering of its laid-out pages: fixed, and one-way. Crosses the host boundary by name ("pdf"). |
| FileFormat | A file format a session opens and saves back to — the encoding a document arrives in, where [UDocType] is the model family it opens into. |
| FitMode | How the camera derives its zoom from the viewport and the current spread — the set of pages shown together as a unit (one page in a single-page layout; a facing pair in a double-page one). |
| LayoutMode | How the arrangement groups pages into spreads — the pages shown side by side as one unit, stacked one spread under the next. A layout setting the host declares on the plane, like the page gap; a plane with no page stack ignores it. Orthogonal to the camera's ScrollMode, which only decides whether the view scrolls through the spreads or shows one at a time. |
| LeftPanelTab | Tabs that live in the left side panel. |
| OverlaySource | Maps one frame to the overlay items to show. Pure and stateless — it runs every painted frame, so derive everything from the frame. |
| PageExportFormat | A format one page is exported to — a rendering of that page. Crosses the host boundary externally tagged ({ png: { scale: 2 } }, "svg"). |
| PanelTab | A side panel's tab, left or right. |
| PortableCommand | An edit intent for a portable document. The editor turns a command into a CRDT modification; it never touches the model directly. |
| PresentationCommand | An edit intent for a presentation document. The editor turns a command into a CRDT modification; it never touches the model directly. |
| PrintQuality | How finely a printed page is rendered: 150, 300 or 600 DPI. |
| RightPanelTab | Tabs that live in the right side panel. |
| SaveStrategy | How a save writes the document — how much of the file the session was opened from (the original) the saved bytes keep. Each keeps strictly more of it than the one before: |
| ScrollAlignment | Where a target lands in the viewport when the camera moves to it — a followed link or outline item, a chosen comment, a search match. |
| ScrollMode | How the camera scrolls the document plane. Orthogonal to the plane's arrangement (the stack and its spreads — the layout's job): both modes glide over the same arranged plane, so switching never relayouts. |
| ShapeCommand | An edit intent for a shape tree. The embedding doc type's editor turns one into CRDT writes (via execute) over the tree's root container; it never touches the model directly. |
| ThemeMode | - |
| UDocCommand | Top-level edit intent for a loaded document — a format-agnostic enum over the per-doc-type commands. A command is issued by the UI or the host and routed to the matching editor + engine by UDocSession::execute. |
| UDocErrorCode | What a failure is, for code to branch on: core's kinds, the refusals the engine adds at its seam, and crashed — a trap that took the engine, and the session with it. |
| UDocErrorDetail | What a refusal carries beside its message: the specifics of its code. |
| UDocSearchScope | Top-level search scope for a loaded document — the part of it a search covers, a format-agnostic enum over the per-doc-type scopes, externally tagged by doc type like [UDocSelection] — e.g. {"portable":{"pages":{"start":0,"end":5}}}. A search naming none covers the whole document. |
| UDocSelection | Top-level selection for a loaded document — a format-agnostic enum over the per-doc-type selections, mirroring [UDocCommand]. Presence state beside the document: setting it is not a command and not undoable (see Editor::set_selection). |
| UDocType | Which of the five doc types a document is — the tag every UDoc* union (UDocSelection, UDocCommand, …) carries, with the payload dropped. |
| ViewControlsPlacement | Where the view-state controls (page nav + zoom + view mode) are docked: |
| ViewLength | A view-space length: fixed in document points (so it scales with zoom, reading as part of the paper) or fixed in device pixels (so it stays constant on screen while the content scales — sized for screen chrome like a page-controls overlay). |
Engine types
| Module | Description |
|---|---|
| Engine types | The engine's types the API's values are built from — its document model — which the packages don't export, documented so every one in a signature links to a page. Code that has to name one imports it from @docmentis/udoc-wasm. |