Skip to content

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 ​

ClassDescription
OverlayManagerReconciles 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.
UDocBaseThe 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 ​

InterfaceDescription
Affine2D affine transformation matrix, stored in PDF / SVG [a b c d e f] tuple order.
AnnotationOne annotation: the entries every annotation dictionary carries (Table 164), and its subtype's own in kind.
DocumentLayoutA snapshot of a document's layout: composed page count and total scrollable size.
FitA fit configuration: the [FitMode] plus the zoom ceiling the derived zoom is clamped to.
FontDescriptorOne family in one bold / italic style — the atomic unit font resolution works in, and the only selection input the font system takes.
GoogleFontFamilyOne family from the host's Google font catalog, in the shape the Google Fonts Developer API returns it.
LocalCollaborationServiceOptionsOptions 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.
MessagesEvery 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.
OpenOptionsOptions for UDocBase.open. Every field is optional; each says its default.
OverlayFrameOne 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.
OverlayItemOne 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.
OverlayOptionsWhich layer setOverlay puts an overlay in.
PageGapThe 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.
PageViewOne 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.
PrintOptionsOptions for print. Every field is optional; each says its default.
Rect-
RemoteCheckpointResponseA server's answer to a checkpoint: the version of the baseline it wrote.
RenderPageOptionsOptions for UDocBase.renderPage. Every field is optional; each says its default.
SearchMatchOne match: where it is in the model, where it is drawn, and the text around it for a results list.
SearchMatchLocationWhere 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).
SearchOptionsHow a search compares its query with the text — the host's options, beside the query and the doc type's SearchScope.
SearchQuadOne 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.
SheetInfoA sheet of the open workbook, as UDocBase.sheets lists it.
Size-
UDocEventsThe public event map: event name → payload. Subscribe with UDocBase.on.
UDocOptionsOptions for creating a UDocBase. Every field is optional; each says its default.
UrlFontOne font the host offers by URL: which font it is, where to fetch it, and optionally what it covers.
ViewportWhat 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 AliasDescription
AnnotationId-
AnnotationKindAn 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]).
AnnotationPatchAny 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.
DestinationA 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.
DestinationViewHow a destination shows its page (Table 151). Coordinates are that page's page-local space, like every page coordinate; None keeps the current value.
EventHandlerA handler for event K of the event map E, as UDocBase.on takes it: called with that event's payload.
ExportFormatA 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").
FileFormatA file format a session opens and saves back to — the encoding a document arrives in, where [UDocType] is the model family it opens into.
FitModeHow 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).
LayoutModeHow 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.
LeftPanelTabTabs that live in the left side panel.
OverlaySourceMaps one frame to the overlay items to show. Pure and stateless — it runs every painted frame, so derive everything from the frame.
PageExportFormatA format one page is exported to — a rendering of that page. Crosses the host boundary externally tagged ({ png: { scale: 2 } }, "svg").
PanelTabA side panel's tab, left or right.
PortableCommandAn edit intent for a portable document. The editor turns a command into a CRDT modification; it never touches the model directly.
PresentationCommandAn edit intent for a presentation document. The editor turns a command into a CRDT modification; it never touches the model directly.
PrintQualityHow finely a printed page is rendered: 150, 300 or 600 DPI.
RightPanelTabTabs that live in the right side panel.
SaveStrategyHow 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:
ScrollAlignmentWhere a target lands in the viewport when the camera moves to it — a followed link or outline item, a chosen comment, a search match.
ScrollModeHow 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.
ShapeCommandAn 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-
UDocCommandTop-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.
UDocErrorCodeWhat 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.
UDocErrorDetailWhat a refusal carries beside its message: the specifics of its code.
UDocSearchScopeTop-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.
UDocSelectionTop-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).
UDocTypeWhich of the five doc types a document is — the tag every UDoc* union (UDocSelection, UDocCommand, …) carries, with the payload dropped.
ViewControlsPlacementWhere the view-state controls (page nav + zoom + view mode) are docked:
ViewLengthA 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 ​

ModuleDescription
Engine typesThe 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.