@docx-editor.dev/docx-to-markdown
v2.33.0 · 2 published subpaths with full TypeScript signatures and JSDoc.
Subpaths
Package root
Functions (9)
createFontSourcefunction
Turn font bytes you ALREADY hold into a FontSource — a file input, IndexedDB, a bundler import. loadFonts covers URLs; this covers everything else, so no caller has to hand-assemble the record or reach for a hashing helper.
Returns a typed failure instead of throwing when the descriptor or the bytes are unusable, matching loadFonts: one bad face degrades itself, never its neighbours.
declare function createFontSource(bytes: Uint8Array, request: FontFaceRequest & {
readonly faceIndex?: number;
}, options?: {
readonly id?: string;
readonly maxFontBytes?: number;
}): {
readonly source: FontSource;
} | {
readonly failure: FontLoadFailure;
};createMarkdownZipfunctionSource ↗
Create a portable ZIP containing document.md, document.json, and media files.
declare function createMarkdownZip(result: MarkdownExportResult): Promise<Uint8Array>;defineFontResolverfunction
Mark a function as an on-demand [FontResolver](FontResolver).
Wrap every resolver you put in a fonts list — useFonts(...), useDocxSource's fonts option, composeFontOrigins. The fonts PROP needs no marking, because a function there is always a resolver; a list also accepts the older zero-argument loader form ({ fonts: defaultFonts }), and this is what keeps the two apart.
Returns the same function object, mutated, so the mark survives being passed around and a marked resolver stays === to itself. It does NOT survive .bind() or being wrapped: both make a new function object. Re-mark the result.
ts
const brandFonts = defineFontResolver(async ({ families }) => ({
sources: await loadMine(families),
}));
Throws a TypeError on a frozen or sealed function, which cannot take the mark. That is deliberate: returning it unmarked would compile — the return TYPE says marked — and then lose every font at runtime.
declare function defineFontResolver<T extends FontResolver>(resolve: T): MarkedFontResolver<T>;exportMarkdownfunctionSource ↗
Convert untrusted DOCX bytes with Node-safe resource and shaping defaults.
declare function exportMarkdown(source: ExportDocumentSource, options?: MarkdownExportOptions): Promise<MarkdownExportResult>;exportMarkdownFromfunctionSource ↗
Translate an existing shared export session without reopening or re-laying out it.
declare function exportMarkdownFrom(session: ExportSession, options?: MarkdownProjectionOptions): Promise<MarkdownExportResult>;exportMarkdownLayoutfunctionSource ↗
Translate a detached immutable core layout after its producer session is disposed.
declare function exportMarkdownLayout(layout: ExportSemanticLayout): MarkdownExportResult;forEachSemanticDrawingfunction
Visit every drawing through the canonical root-story and recursive textbox walks.
declare function forEachSemanticDrawing(layout: SemanticLayout, visit: (drawing: SemanticDrawingVisit) => void): void;openDocumentForExportfunctionSource ↗
Open a reusable export session with packaged fonts and HarfBuzz shaping by default.
declare function openDocumentForExport(source: ExportDocumentSource, options?: OpenMarkdownDocumentForExportOptions): Promise<OpenMarkdownDocumentForExportResult>;toMarkdownJSONfunctionSource ↗
Omit image bytes and normalize arbitrary font failure causes to diagnostic strings.
declare function toMarkdownJSON(result: MarkdownExportResult): MarkdownJSONResult;Classes (4)
DocumentOpenErrorclassSource ↗
Typed one-shot failure for bytes that cannot be opened as a supported DOCX.
declare class DocumentOpenError extends Error| Member | Type | Summary |
|---|---|---|
| (constructor) | | Constructs a new instance of the `DocumentOpenError` class |
| detail? | string | undefined | |
| reason | HeadlessDocumentRejection | 'aborted' |
ExportResourceErrorclassSource ↗
Bounded failure from a headless export session.
declare class ExportResourceError extends Error| Member | Type | Summary |
|---|---|---|
| (constructor) | | Constructs a new instance of the `ExportResourceError` class |
| code | 'aborted' | 'timedOut' | 'nonConvergent' | 'disposed' | 'layoutInvariant' | 'layoutFailed' |
MarkdownBundleErrorclassSource ↗
Failure to write a complete portable Markdown bundle.
declare class MarkdownBundleError extends Error| Member | Type | Summary |
|---|---|---|
| (constructor) | | Constructs a new instance of the `MarkdownBundleError` class |
| code | 'invalid-media-path' | 'duplicate-output-path' | 'non-portable-image-url' | 'output-not-empty' | 'write-failed' | 'archive-failed' | |
| name | | |
| path? | string |
MarkdownMediaErrorclassSource ↗
Failure to produce a complete image export.
declare class MarkdownMediaError extends Error| Member | Type | Summary |
|---|---|---|
| (constructor) | | Constructs a new instance of the `MarkdownMediaError` class |
| actualBytes? | number | |
| assetId? | string | |
| code | 'media-limit' | 'url-resolution-failed' | 'invalid-image-url' | 'image-bytes-unavailable' | |
| limitBytes? | number | |
| name | |
Interfaces (58)
AnchoredDrawingRecordinterface
interface AnchoredDrawingRecord extends Omit<InlineDrawingRecord, 'kind' | 'baselineOffset' | 'advanceStart' | 'advanceEnd' | 'distL' | 'distR' | 'distT' | 'distB'>| Member | Type | Summary |
|---|---|---|
| allowOverlap | boolean | |
| anchorParagraphId | string | |
| behindDocument | boolean | |
| horizontalFrame | DrawingHorizontalReferenceFrame | |
| horizontalFrameOrigin | number | |
| kind | 'anchoredDrawing' | |
| layoutFallback? | AnchoredDrawingLayoutFallback | |
| layoutInCell | boolean | Whether the object is laid out in the box it flows in. For an anchor in a table cell this is the layout's reading: `true` from compatibility mode 15, which ignores `layoutInCell="0"`. Everywhere else it is the authored `wp:anchor/@layoutInCell`. |
| relativeHeight | number | |
| sourceOrder? | number | Canonical document traversal index within the owner story part. |
| textArt? | DrawingTextArtRecord | Floating VML text art fitted to the box; paint draws it instead of a resource. |
| verticalFrame | DrawingVerticalReferenceFrame | |
| verticalFrameOrigin | number | |
| wrap | Exclude<ImageWrapTarget, 'inline'> |
DrawingAccessibilityinterface
interface DrawingAccessibility| Member | Type | Summary |
|---|---|---|
| decorative | boolean | |
| label | string | null |
DrawingChartSummaryinterface
The title and plot types of a chart, as text, and how the page shows it.
A drawing record carries it as chart whenever the drawing holds a chart whose chart part can be read, in each of the three states that shownAs names. A visible drawing in a skipped mc:Choice can retain a placeholder when its bounds are usable. Chart metadata is present only when the projection resolves the chart part.
interface DrawingChartSummary| Member | Type | Summary |
|---|---|---|
| plotTypes | readonly DrawingChartPlotType[] | The chart's plot types in document order; a classic combination chart has more than one. A chartex chart reports exactly one plot type, or none when its series layout is not one of the chartex types. |
| shownAs | DrawingChartShownAs | How the page shows the chart. The projection sets it from the renderers installed when the document opened: `chart` (the record has a `vectorShape`), `fallback` (the record paints the fallback content, such as a picture `resource`), or `placeholder` (the record has `placeholderGraphicKind` `'chart'`). Read this field rather than the other fields. |
| title | string | null | The title the chart shows, as plain text: its own title, typed or from a cell, or the name of its only series for an automatic title. Null when it shows none, and when a title with no text of its own sits on a chart with several series. Runs of white space collapse to one space, and the text is cut to at most 200 UTF-16 code units. |
DrawingGeometryinterface
interface DrawingGeometry| Member | Type | Summary |
|---|---|---|
| clipFallback | DrawingClipFallback | |
| clipPolygon | readonly DrawingPoint[] | null | |
| contentBounds | LayoutBox | |
| effectInsets | DrawingInsets | |
| hitBounds | LayoutBox | |
| imageTransformCorners? | readonly DrawingPoint[] | Unclipped image corners for affine encoding; clipping must not stretch the image. |
| paintBounds | LayoutBox | |
| transformedCorners | readonly DrawingPoint[] |
DrawingGroupPictureLayerRecordinterface
One picture member of a drawing group after the first, as a drawing record holds it.
interface DrawingGroupPictureLayerRecord| Member | Type | Summary |
|---|---|---|
| crop | SourceCrop | The picture's own `a:srcRect` crop, as fractions of the image. |
| frameUnit | Readonly<{
x: number;
y: number;
width: number;
height: number;
}> | The picture's frame as fractions of the drawing extent, which is `geometry.contentBounds` of the record. |
| resource | ImageResourceState | The picture's own image resource, resolved like the record's `resource`. |
DrawingGroupPictureRecordinterface
How a drawing record holds the picture member of a shape group.
interface DrawingGroupPictureRecord| Member | Type | Summary |
|---|---|---|
| alternateContent | boolean | Whether the group is the chosen branch of a run-level `mc:AlternateContent`. Failed picture resources show one placeholder for the whole group. |
DrawingTransforminterface
interface DrawingTransform| Member | Type | Summary |
|---|---|---|
| extentEmu | Readonly<{
cx: number;
cy: number;
}> | Source `a:ext` in EMU; zero falls back to `wp:extent` at geometry time. |
| flipHorizontal | boolean | |
| flipVertical | boolean | |
| offsetEmu | Readonly<{
x: number;
y: number;
}> | Source `a:off` in EMU; defaults to origin when absent. |
| rotationDegrees | number |
ExportContentWarninginterface
Source content that cannot be certified by the layout snapshot.
interface ExportContentWarning| Member | Type | Summary |
|---|---|---|
| code | 'legacy-textbox' | 'legacy-drawing' | 'scan-limit' | 'unsupported-style-separator' | Content outside a supported layout subset stays preserved in the DOCX. |
| partName | string | Package part containing the content, or where the bounded scan stopped. |
ExportDestinationAnchorinterface
Model address shared by bookmarks and internal hyperlinks.
interface ExportDestinationAnchor| Member | Type | Summary |
|---|---|---|
| name | string | |
| offset | number | |
| paragraphId | string |
ExportDestinationGeometryinterface
Laid-out jump target in the coordinate spaces export traversal uses.
interface ExportDestinationGeometry| Member | Type | Summary |
|---|---|---|
| anchor | ExportDestinationAnchor | |
| pageContent | Readonly<{
readonly x: number;
readonly y: number;
readonly height: number;
}> | Caret geometry in page-content coordinates (same space as line boxes). |
| pageIndex | number | |
| pageStack | Readonly<{
readonly x: number;
readonly y: number;
}> | Top-left of the caret in stacked page coordinates. |
ExportDroppedEmbeddedFontinterface
One document-embedded face the export mapper refused before composition.
interface ExportDroppedEmbeddedFont| Member | Type | Summary |
|---|---|---|
| partName | string | |
| reason | 'overLimit' | 'malformed' | |
| request | FontRequest |
ExportFontFaceResolutioninterface
One paintable face in an export font-resolution report.
interface ExportFontFaceResolution| Member | Type | Summary |
|---|---|---|
| faceIndex? | number | |
| hash? | string | |
| id? | string | |
| identity? | string | Admitted face identity (`hash#faceIndex`); remains after session disposal. |
| sourceFamily | string | |
| style | 'normal' | 'italic' | |
| substitution? | FontSubstitution | null | Full substitution evidence; `null` when the admitted face answers the request directly. |
| via | 'direct' | 'substitution' | |
| weight | 400 | 700 |
ExportFontFamilyResolutioninterface
Coverage of one family Core layout may request.
interface ExportFontFamilyResolution| Member | Type | Summary |
|---|---|---|
| coverage | 'complete' | 'partial' | 'none' | |
| faces | readonly ExportFontFaceResolution[] | |
| family | string |
ExportFontResolutionReportinterface
Exporter-neutral evidence for the font policy behind one layout session.
interface ExportFontResolutionReport| Member | Type | Summary |
|---|---|---|
| defaultFamily | string | |
| droppedEmbeddedFonts? | readonly ExportDroppedEmbeddedFont[] | Bounded drop evidence from the document-embedded font origin; omitted on legacy mocks. |
| families | readonly ExportFontFamilyResolution[] | |
| originFailures | readonly FontOriginFailure[] | |
| requestedFamilies | readonly string[] |
ExportSemanticLayoutinterface
Export-ready semantic snapshot. Core guarantees normalized review artifacts for every session, including an empty immutable array when the source has none. A resolved snapshot is recursively immutable and remains traversable after its producer session is disposed; disposal only revokes session-owned work and capabilities such as [ExportSession.validatedImageBytes](ExportSession.validatedImageBytes).
interface ExportSemanticLayout extends SemanticLayout| Member | Type | Summary |
|---|---|---|
| contentWarnings? | readonly ExportContentWarning[] | Source omissions that cannot be detected by walking laid-out records. |
| destinations? | readonly ExportDestinationGeometry[] | |
| documentMetadata? | ExportDocumentMetadata | |
| facingPages? | boolean | Whether outside change bars alternate page margins. |
| reviewArtifacts | readonly SemanticReviewArtifactRecord[] | |
| reviewDisplayMode? | ReviewDisplayMode | Requested review view; Simple Markup uses the proposed text projection. |
| revisionAuthorSlots? | Readonly<Record<string, number>> | Stable author color slots captured from the editor session. |
| revisionMarkup? | ResolvedRevisionMarkup | Viewer preferences used for this layout. |
ExportSessioninterface
A single semantic-layout substrate reusable by Markdown and later exporters. Pagination fidelity is determined by the session's measurer; core's default is deterministic, not font-accurate.
interface ExportSession| Member | Type | Summary |
|---|---|---|
| dispose | | Release per-document caches, pending resource work, and image-byte capabilities. Idempotent. Previously resolved layout snapshots remain immutable and traversable after disposal. |
| layout | | Settle resources and return the default revision projection. |
| layoutFor | | Settle resources and cache one explicit revision projection. |
| validatedImageBytes | | Mint a defensive copy only for a ready image published by this session. |
FontOriginFailureinterface
A failed font origin or a partial failure in an otherwise usable fragment.
interface FontOriginFailure| Member | Type | Summary |
|---|---|---|
| cause | unknown | |
| originIndex | number | Zero-based position in the first-wins origin list. |
| originName? | string | Resolver function name when one is safely available. |
FontRequestinterface
A face, as something asks for it: family plus the two axes this engine admits.
Only static weights and slants. Variable-font axes are deliberately outside this vocabulary — the shaper refuses variation axes, and a variable file admitted here would render bold at regular weight.
interface FontRequest| Member | Type | Summary |
|---|---|---|
| family | string | |
| style | 'normal' | 'italic' | |
| weight | number |
FontShapingOptionsinterface
Host-selected execution limits, separate from font admission limits.
interface FontShapingOptions| Member | Type | Summary |
|---|---|---|
| maxFontBytes? | number | Per-face shaping byte ceiling. Defaults to 16 MiB; the hard ceiling is 64 MiB. |
FontSubstitutioninterface
A request that was answered by a DIFFERENT face than the one asked for.
Recorded rather than silently applied, because a substitution changes measurement: it is part of the shaping fingerprint, so a cached run shaped against a substitute is never reused for the real face.
interface FontSubstitution| Member | Type | Summary |
|---|---|---|
| lineMetrics? | {
readonly heightEm: number;
readonly baselineEm: number;
} | |
| requested | FontRequest | |
| resolved | FontRequest |
GroupTextboxStoryRecordinterface
One laid-out group member story.
interface GroupTextboxStoryRecord| Member | Type | Summary |
|---|---|---|
| box | LayoutBox | The member box in points, relative to the drawing extent's top-left corner. |
| memberNodeId | string | Canonical node id of the member `wps:wsp`. |
| rotationDegrees | number | Clockwise turn of the painted member about the center of [box](box), in degrees. The story lays out upright; paint and export turn it. Hit testing never maps into it. |
| story | TextboxStoryLayout | The member's story, in content-box coordinates inside [box](box). |
HeadlessDocumentViewinterface
The read capabilities shared by browser layout, server export, and future renderers.
It deliberately exposes resolved package facts rather than a binding or editor session. An exporter can therefore consume the live document without importing ProseMirror or a DOM.
interface HeadlessDocumentView| Member | Type | Summary |
|---|---|---|
| currentPackage | | |
| documentProperties | | |
| documentThemeFonts | | |
| headerFooterPartsBySection | | |
| headerFooterResolutionBySection | | Occurrence-specific relationship metadata for header/footer stories. |
| numberingRoot | | |
| packageRevision | | |
| part | | |
| relationshipTarget | | |
| settingsRoot | | |
| stylesRoot | |
ImageDecodePortinterface
The injected image decoder.
A port rather than a direct Image/createImageBitmap call, so a worker or server runtime supplies its own and the engine never reaches for a browser global.
interface ImageDecodePort| Member | Type | Summary |
|---|---|---|
| convertPreserved | | Optional conversion of media an `<img>` cannot render (EMF/WMF metafiles, TIFF) into a renderable raster. The returned bytes are untrusted and re-enter the full raster validation path (sniff, header, pixel caps, decode) before they can become a ready resource. A null return declines the format and keeps the labelled placeholder; so does a throw, as `decode-failed`. |
| decode | |
InlineDrawingRecordinterface
interface InlineDrawingRecord| Member | Type | Summary |
|---|---|---|
| accessibility | DrawingAccessibility | |
| advanceEnd | number | Caret/hit advance end (slot + totalWidth). |
| advanceStart | number | Caret/hit advance start (slot left, before distL). |
| baselineOffset | number | |
| bidiLevel? | number | The picture's resolved Unicode bidi level in a right-to-left or mixed-direction paragraph. An odd level reads right to left: its logical start is its right edge. Absent when the paragraph needed no bidi resolution. |
| chart? | DrawingChartSummary | The title and plot types of a drawing that holds a chart whose chart part can be read, and how the page shows it (`shownAs`): drawn, by its saved fallback, or as a placeholder. |
| crop | SourceCrop | |
| distB | number | |
| distL | number | |
| distR | number | |
| distT | number | |
| drawingNodeId | string | |
| effects | DrawingImageEffects | |
| frameEffects? | PictureFrameEffects | A picture's reflection and soft edges, in the extent's EMU; absent when it has none. |
| geometry | DrawingGeometry | |
| groupPicture? | DrawingGroupPictureRecord | Present when the image is the picture member of a drawing group. The image then fills the bounds of `geometry.imageTransformCorners`, not `geometry.contentBounds`, and paints below `vectorShape`, which holds the group's other members. `placeholderGraphicKind` stays non-null, as for a vector shape, so image commands do not treat the group as a picture. The group paints whole or not at all: when the picture cannot paint, an output shows no part of the group. |
| groupPictureLayers? | readonly DrawingGroupPictureLayerRecord[] | The group's other picture members, in document order. Each paints above the record's own image and the layers before it, and below `vectorShape`. Absent for one picture. |
| groupTextboxStories? | readonly GroupTextboxStoryRecord[] | Read-only stories of a group's text box members, each placed in its member box. |
| height | number | |
| hitBounds | LayoutBox | |
| hyperlinkHref | string | null | Sanitized external hyperlink projection; inert until an explicit gesture activates it. |
| kind | 'inlineDrawing' | |
| ownerPartName | string | |
| paintBounds | LayoutBox | |
| paragraphId | string | |
| placeholderGraphicKind | DrawingPlaceholderKind | null | Graphic kind of a non-picture drawing, naming its placeholder; null for pictures. |
| resource | ImageResourceState | |
| revisions? | readonly RevisionAttribution[] | The revision wrappers enclosing the owning run, outermost first — the same stack spans carry, so paint and review chrome give a tracked picture the same cues as tracked text. Absent when the drawing is untracked. |
| start | number | |
| textArt? | DrawingTextArtRecord | Legacy text art on the line, fitted to its box. |
| textboxStory? | TextboxStoryLayout | Laid-out textbox story for a `wps:txbx` drawing; paint renders it clipped inside the extent instead of a placeholder. Absent when the drawing carries no story or the host did not thread story layout (the record then degrades to the placeholder path). An inline text box carries one too: its story sits inside the extent the line reserves. |
| transform | DrawingTransform | |
| vectorShape | VectorShapeProjection | null | Typed solid-geometry payload for a renderable `wps:wsp` shape; null otherwise. |
| width | number | |
| x | number | Left edge of the extent box (slot + distL). |
| y | number |
LayoutBoxinterface
A rectangle in layout POINTS.
Points everywhere in this layer — twips convert at property-read boundaries and CSS pixels at paint. A box carrying either of those would eventually be added to one carrying the other.
interface LayoutBox| Member | Type | Summary |
|---|---|---|
| height | number | |
| width | number | |
| x | number | |
| y | number |
MarkdownExportOptionsinterfaceSource ↗
Layout and resource controls for one-shot Markdown export.
interface MarkdownExportOptions extends OpenMarkdownDocumentForExportOptions, MarkdownProjectionOptionsMarkdownExportResultinterfaceSource ↗
Full logical document plus page-scoped projections.
interface MarkdownExportResult| Member | Type | Summary |
|---|---|---|
| fontResolution | ExportFontResolutionReport | null | Structured font-resolution evidence, or null when the layout's font origin is unavailable. |
| markdown | string | Convenience logical Markdown with split records joined and repeated furniture excluded. |
| media | readonly MarkdownImageAsset[] | Unique extracted images; empty unless images are enabled. |
| pages | readonly MarkdownPage[] | Primary physical page projections, preserving Word layout boundaries and furniture. |
| pagination | MarkdownPaginationInfo | How page numbers and tracked changes were projected for this result. |
| reviewArtifacts | readonly MarkdownReviewArtifact[] | Every normalized comment and tracked change, including artifacts without a page occurrence. Artifact IDs are opaque and stable only within this result. |
| reviewBindings | readonly MarkdownReviewBinding[] | Markdown offsets valid only within this immutable result, with explicit mapping fidelity. |
| warnings | readonly MarkdownWarning[] | Omitted content and font problems that may affect completeness or pagination. |
MarkdownExportSessioninterfaceSource ↗
Reusable Markdown session with the font evidence captured while it opened.
interface MarkdownExportSession extends ExportSession| Member | Type | Summary |
|---|---|---|
| fontResolution | ExportFontResolutionReport | null | Non-null for document-aware byte sessions opened by Markdown or Core; null for detached layouts, caller-supplied measurers, ordinary Core sessions, and live shared-shaping sessions. |
MarkdownImageAssetinterfaceSource ↗
One unique image returned by a Markdown export.
interface MarkdownImageAsset extends MarkdownImageData| Member | Type | Summary |
|---|---|---|
| url | string | Raw URL; Markdown output escapes destination syntax separately. |
MarkdownImageDatainterfaceSource ↗
Image bytes and provenance supplied to a URL resolver.
interface MarkdownImageData| Member | Type | Summary |
|---|---|---|
| byteLength | number | |
| bytes | Uint8Array | Owned bytes. Treat as read-only to preserve the content identifier. |
| id | string | Core's SHA-256 content identifier for the exported bytes. |
| mimeType | string | |
| occurrences | readonly MarkdownImageOccurrence[] | |
| path | string | Portable relative filename, independent of the resolved URL. |
| pixelHeight | number | Intrinsic pixel height of the exported bytes; use occurrence dimensions for display. |
| pixelWidth | number | Intrinsic pixel width of the exported bytes; use occurrence dimensions for display. |
MarkdownImageOccurrenceinterfaceSource ↗
One physical occurrence of an extracted image.
interface MarkdownImageOccurrence| Member | Type | Summary |
|---|---|---|
| alt | string | |
| decorative | boolean | |
| displayHeightPx | number | Word's extent height in CSS pixels (96 px per inch), before crop or rotation. |
| displayWidthPx | number | Word's extent width in CSS pixels (96 px per inch), before crop or rotation. |
| drawingNodeId | string | |
| kind | 'inline' | 'anchored' | Anchored images render at their paragraph position; Markdown does not reproduce text wrapping. |
| pageNumber | number | |
| paragraphId | string | |
| partName | string | |
| rootStory | SemanticDrawingVisit['rootStory'] | |
| start | number | Source offset within the paragraph, in UTF-16 code units. |
| story | SemanticDrawingVisit['story'] |
MarkdownImageOptionsinterfaceSource ↗
Portable image extraction and optional application-owned storage.
interface MarkdownImageOptions| Member | Type | Summary |
|---|---|---|
| maxTotalBytes? | number | Unique extracted bytes; default 64 MiB. Not a total parsing/layout memory limit. |
| resolveUrl? | (image: MarkdownImageData, context: {
readonly signal?: AbortSignal;
}) => string | Promise<string> | Called sequentially once per unique image, after all extraction succeeds. Receives a separate byte copy; mutations cannot change result bytes. Return a relative path or HTTP(S) URL. The application owns completed uploads, their cleanup, and signed-URL expiry. |
| syntax? | 'markdown' | 'html' | Default: `markdown` emits standard image links without dimensions. `html` emits an escaped `<img>` with each occurrence's display width and height, rounded to whole CSS pixels. Your renderer must allow HTML and these attributes. Neither syntax reproduces cropping, rotation, or floating text wrapping. |
MarkdownPageinterfaceSource ↗
Markdown emitted for one physical layout page.
interface MarkdownPage| Member | Type | Summary |
|---|---|---|
| comments | readonly MarkdownComment[] | Membership view of comments occurring on this page. Each entry is the complete document-wide artifact and can contain occurrences from other pages. For page-local provenance, filter with `occurrence.pageIndex === page.number - 1`. |
| footerMarkdown | string | Footer story for this page, kept separate from logical document content. |
| headerMarkdown | string | Header story for this page, kept separate from logical document content. |
| id | string | Identifier for this page within this export result. |
| markdown | string | Body projection, plus local note definitions or labelled continuation blocks. |
| number | number | One-based physical page number. |
| trackedChanges | readonly MarkdownTrackedChange[] | Membership view of tracked changes occurring on this page. Each entry is the complete document-wide artifact and can contain occurrences from other pages. For page-local provenance, filter with `occurrence.pageIndex === page.number - 1`. |
MarkdownPaginationInfointerfaceSource ↗
Machine-readable scope of the page numbers returned by this export.
interface MarkdownPaginationInfo| Member | Type | Summary |
|---|---|---|
| displayMode | RevisionDisplayMode | Tracked-change display mode used to paginate and translate this snapshot. |
| layoutRevision | number | Core store revision from which this layout snapshot was produced. |
| scope | 'export-snapshot' | Page numbers describe this exact export result. |
| source | 'layout-engine' | Pages come from the docx-editor semantic layout engine, not stale DOCX page-break hints. |
MarkdownProjectionOptionsinterfaceSource ↗
Projection controls for an already-open export session.
interface MarkdownProjectionOptions| Member | Type | Summary |
|---|---|---|
| images? | boolean | MarkdownImageOptions | `true` or `{}` extracts images with portable relative URLs. Default: false. |
| signal? | AbortSignal | Cancels export waits; cannot interrupt synchronous parsing or layout. |
MarkdownReviewBindinginterfaceSource ↗
Honest snapshot-local mapping from a Core review occurrence to generated Markdown.
interface MarkdownReviewBinding| Member | Type | Summary |
|---|---|---|
| artifactId | string | ID of the corresponding artifact in this export result; do not join it across snapshots. |
| artifactKind | MarkdownReviewArtifact['kind'] | Discriminant of the corresponding review artifact. |
| coverage | MarkdownReviewCoverage | Whether the ranges represent all, some, or none of the source occurrence. |
| occurrenceIndex | number | Index into this snapshot's immutable artifact `occurrences` array. |
| projection | MarkdownReviewProjection | Generated Markdown string containing this binding. |
| ranges | readonly MarkdownReviewRange[] | Ordered, non-overlapping ranges in the selected projection. |
| unmappedReason? | MarkdownReviewUnmappedReason | Present when the source occurrence has no honest linear range in this projection. |
MarkdownReviewRangeinterfaceSource ↗
A UTF-16 range suitable for slicing the named Markdown projection.
interface MarkdownReviewRange| Member | Type | Summary |
|---|---|---|
| end | number | Exclusive end offset in the selected Markdown string. |
| precision | MarkdownReviewRangePrecision | Whether this is an exact text mapping or the smallest generated construct containing it. |
| start | number | Inclusive start offset in the selected Markdown string. |
| unit | 'utf16-code-unit' | Offsets use JavaScript string indexing and can be passed directly to `String.slice()`. |
MarkdownWarninginterfaceSource ↗
Content or resources that could not be represented fully.
interface MarkdownWarning| Member | Type | Summary |
|---|---|---|
| code | 'omitted-drawing' | 'omitted-textbox' | 'font-origin-failed' | 'incomplete-font' | 'content-scan-limit' | 'image-placement-fallback' | Stable code for filtering warnings without parsing messages. |
| message | string | Human-readable description of the limitation. |
| pageNumber? | number | One-based page number, when the warning concerns a drawing occurrence. |
| partName? | string | Package part when the warning comes from source inspection. |
OpenDocumentForExportOptionsinterface
Shared session options; translators add their own format-specific options.
interface OpenDocumentForExportOptions| Member | Type | Summary |
|---|---|---|
| convertPreservedImage? | PreservedImageConverter | Optional converter for preserved image formats the default decoder cannot inspect. |
| displayMode? | ReviewDisplayMode | Revision projection applied before records reach an exporter. Default: `all-markup`. |
| imageDecodePort? | ImageDecodePort | Host image metadata decoder; omit for the bounded DOM-free Node decoder. |
| measurer? | TextMeasurer | Text measurement used for line wrapping and pagination. Omit only when deterministic approximate pagination is acceptable. Core then uses a fixed-width fallback that neither resolves nor shapes the document's fonts, so line and page breaks can differ from Word. Exporters promising physical-page fidelity must supply a font-backed measurer. For immutable DOCX bytes with document-aware font origins, use [openFontBackedDocumentForExport](openFontBackedDocumentForExport); [acquireSharedExportShaping](acquireSharedExportShaping) is for process-static prepared configurations or a live host that already owns revision-stable shaping. |
| producer? | string | Stable measurement implementation identity used by layout caches and diagnostics. Pair it with the exact shaping policy behind `measurer`; it is not a substitute for matching metrics. |
| resourceTimeoutMs? | number | Maximum time spent waiting for image resources in one layout call. Default: 60 seconds. |
| reuseAcrossRevisions? | boolean | Retain incremental state for a live view. Defaults to true for views and false for bytes. |
| revisionAuthorSlots? | Readonly<Record<string, number>> | Stable author color slots captured from the editor session. |
| revisionMarkup? | RevisionMarkupOptions | Viewer markup applied before layout and export. |
| signal? | AbortSignal | Cancels resource waits and subsequent layouts. |
OpenMarkdownDocumentForExportOptionsinterfaceSource ↗
Layout controls for a reusable Markdown export session.
interface OpenMarkdownDocumentForExportOptions extends OpenDocumentForExportOptions| Member | Type | Summary |
|---|---|---|
| fallbackFonts? | MarkdownFontsSource | Opt-in origins consulted only after caller fonts and bundled substitutes. Put `googleFonts()` here to fetch catalogued families the local origins cannot paint. This has the same immutable-bytes restriction and explicit-measurer precedence as [fonts](fonts). |
| fontPolicy? | 'best-effort' | 'strict' | `strict` refuses failed origins or any requested family missing one of four static faces. |
| fonts? | MarkdownFontsSource | Caller-supplied font bytes or resolvers, in first-wins order. These take precedence over the package's bundled metric-compatible Word substitutes. A resolver is invoked after the DOCX is parsed with the bounded family list layout can render. Custom origins require immutable DOCX bytes; for a live view, supply a revision-stable `measurer` instead. An explicit measurer takes precedence and font origins are not invoked. |
| fontShaping? | FontShapingOptions | Explicit per-face shaping byte ceiling; defaults to 16 MiB. |
| onFontResolution? | (report: ExportFontResolutionReport) => void | Fire-and-forget evidence for the exact direct/substituted faces behind page breaks. Returned promises are observed for rejection but do not delay export. |
| reuseAcrossRevisions? | boolean | Retains incremental state for a live view or caller-measured session. Document-aware byte sessions are immutable and reject `true` instead of silently ignoring it. |
PictureFrameEffectsinterface
Effects that change how a picture itself paints, beyond what its frame draws.
interface PictureFrameEffects| Member | Type | Summary |
|---|---|---|
| reflection? | ShapeReflection | A mirror image of the picture below it. |
| softEdgeEmu? | number | The picture's edge fades out over this distance inside it. |
ResolvedRevisionMarkupinterface
Fully resolved, immutable viewer preferences.
interface ResolvedRevisionMarkup| Member | Type | Summary |
|---|---|---|
| cells | {
readonly inserted: RevisionMarkupNamedColor | 'byAuthor' | 'none';
readonly deleted: RevisionMarkupNamedColor | 'byAuthor' | 'none';
readonly merged: RevisionMarkupNamedColor | 'byAuthor' | 'none';
readonly split: RevisionMarkupNamedColor | 'byAuthor' | 'none';
} | |
| changedLines | RevisionMarkupStyle<RevisionChangedLinesMark> | |
| deletions | RevisionMarkupTextStyle<RevisionDeletionMark> | |
| formatting | RevisionMarkupTextStyle | |
| insertions | RevisionMarkupTextStyle | |
| movedFrom | RevisionMarkupTextStyle<RevisionDeletionMark> | |
| movedTo | RevisionMarkupTextStyle | |
| trackFormatting | boolean | |
| trackMoves | boolean |
RevisionAttributioninterface
One revision wrapper's provenance, as authored.
id is the verbatim @w:id string rather than a number: ST_DecimalNumber restricts xsd:integer with no bounds, so a file may carry a value outside the safe integer range, and parsing it to a number would silently merge two distinct revisions.
date is absent when the file omits it. @w:date is optional on CT_TrackChange, and inventing one is a silent content change.
interface RevisionAttribution| Member | Type | Summary |
|---|---|---|
| author | string | |
| date? | string | |
| id | string | |
| kind | RevisionKind | |
| nodeId | string | The wrapper's node id, so a surface can address this exact site. |
RevisionMarkupStyleinterface
interface RevisionMarkupStyle<Mark extends string = RevisionMarkupMark>| Member | Type | Summary |
|---|---|---|
| color | RevisionMarkupColor | |
| mark | Mark |
RevisionMarkupTextStyleinterface
Viewer-only text styling. Document highlighting remains unchanged.
interface RevisionMarkupTextStyle<Mark extends string = RevisionMarkupMark> extends RevisionMarkupStyle<Mark>| Member | Type | Summary |
|---|---|---|
| background | RevisionMarkupNamedColor | 'byAuthor' | 'none' | Background color behind revision text. Defaults to `none`. |
SemanticCommentArtifactRecordinterface
Normalized comment; all relation ids share the opaque snapshot-local id space.
interface SemanticCommentArtifactRecord| Member | Type | Summary |
|---|---|---|
| author | string | |
| date? | string | |
| id | string | |
| initials | string | |
| kind | 'comment' | |
| occurrences | readonly SemanticReviewArtifactOccurrence[] | |
| orphaned | boolean | |
| parentId? | string | |
| parentRevisionId? | string | |
| replyIds | readonly string[] | |
| resolved | boolean | |
| text | string |
SemanticDrawingVisitinterface
One drawing in bounded graph-enumeration order with exporter-grade provenance.
Enumeration is deliberately not paint order: story anchors (and nested textboxes) are visited before inline line drawings. Renderers use paintLayer plus record geometry to compose layers.
interface SemanticDrawingVisit extends StoryDrawingContext| Member | Type | Summary |
|---|---|---|
| absoluteHitBounds | LayoutBox | Absolute pointer/hit bounds. |
| absolutePaintBounds | LayoutBox | Absolute painted bounds, including effects and clipping. |
| drawing | InlineDrawingRecord | AnchoredDrawingRecord | Published drawing record; inline visits also carry paragraph and line. |
| drawingOrigin | Readonly<{
x: number;
y: number;
}> | Absolute origin of this drawing's extent in page-stack coordinates. |
| noteAreaKind | NoteAreaRecord['kind'] | null | Owning note-area kind for note/separator drawings; null elsewhere. |
| noteScopeId | string | null | Note scope for drawings in note stories; null elsewhere. |
| page | PageRecord | Physical page carrying this drawing occurrence. |
| paintLayer | SemanticDrawingLayer | Layer relative to text in the immediate owning story. |
| root | SemanticStoryVisit | Precise root host and absolute origin for story-relative geometry. |
| rootStory | SemanticRootStoryKind | Root story from which textbox descent began. |
| story | SemanticStoryKind | Immediate story classification; `textbox` after textbox descent. |
SemanticLayoutinterface
A complete layout pass: every page, plus the document-wide indexes derived alongside them.
Stamped with the store revision it was laid out from, so anything holding geometry can tell whether the document has moved underneath it — which is how stale pointer gestures and overlays are refused rather than applied to coordinates that no longer describe anything.
interface SemanticLayout| Member | Type | Summary |
|---|---|---|
| contentControls? | readonly ContentControlBoundaryRecord[] | Every content-control boundary in document order, including multi-page fragment lists. |
| controlContextToken? | string | Fingerprint of wrapper-only control metadata (alias, tag, lock, type, placeholder, binding). |
| displayMode? | RevisionDisplayMode | Revision projection already applied to every published record. |
| pages | readonly PageRecord[] | |
| reviewArtifacts? | readonly SemanticReviewArtifactRecord[] | Normalized comments and tracked changes from the same package revision as these pages. Exporters consume this plain-data stream instead of re-reading OOXML or review state. |
| revision | number | The store revision these records were laid out from. |
| sectionBreaks? | readonly SectionBreakMarkRecord[] | Body section breaks in document order, each named by the section that FOLLOWS it. |
SemanticReviewArtifactOccurrenceinterface
One physical occurrence of a comment or tracked-change source range.
interface SemanticReviewArtifactOccurrence| Member | Type | Summary |
|---|---|---|
| geometry? | SemanticReviewArtifactOccurrenceGeometry | Laid-out bounds when this occurrence can be measured; omitted otherwise. |
| noteAreaKind | 'footnotes' | 'endnotes' | null | |
| noteScopeId | string | null | |
| pageIndex | number | |
| physicalPageNumber | number | |
| revisionRole? | 'replaced' | 'replacement' | 'neutral' | Replacement-half meaning for tracked-change occurrences; absent for comments. |
| rootStory | SemanticArtifactRootStoryKind | |
| source | SemanticReviewArtifactSource | |
| story | SemanticArtifactStoryKind | |
| textboxPath | readonly string[] | Root-to-leaf drawing ids for a textbox occurrence; empty outside textboxes. |
SemanticReviewArtifactOccurrenceGeometryinterface
Laid-out bounds for one review occurrence.
pageContent uses the same space as line boxes. pageStack uses stacked page coordinates. A point occurrence publishes width: 0.
interface SemanticReviewArtifactOccurrenceGeometry| Member | Type | Summary |
|---|---|---|
| pageContent | readonly LayoutBox[] | |
| pageStack | readonly LayoutBox[] |
SemanticReviewArtifactPositioninterface
One model position retained as exporter provenance.
interface SemanticReviewArtifactPosition| Member | Type | Summary |
|---|---|---|
| offset | number | |
| paragraphId | string |
SemanticReviewArtifactSourceinterface
Package-relative snapshot provenance, not durable public identity.
Engine-produced occurrences keep start.paragraphId === end.paragraphId. Cross-paragraph source ranges are sliced into per-paragraph occurrences before geometry attaches.
interface SemanticReviewArtifactSource| Member | Type | Summary |
|---|---|---|
| end | SemanticReviewArtifactPosition | |
| partName | string | |
| start | SemanticReviewArtifactPosition |
SemanticTrackedChangeArtifactRecordinterface
Normalized change; ids are opaque and stable only within the source snapshot.
interface SemanticTrackedChangeArtifactRecord| Member | Type | Summary |
|---|---|---|
| author | string | |
| change | 'insert' | 'delete' | 'replace' | 'moveFrom' | 'moveTo' | 'format' | 'paragraphMark' | 'structural' | |
| date? | string | |
| id | string | |
| kind | 'tracked-change' | |
| markDirection? | 'insert' | 'delete' | 'moveFrom' | 'moveTo' | |
| nesting | number | Nested tracked-change depth, where the innermost decision is operative. |
| occurrences | readonly SemanticReviewArtifactOccurrence[] | |
| pairedWith? | string | |
| readOnly | boolean | |
| replacedRangeCount? | number | Number of leading source ranges belonging to struck text in a replacement. |
| replacedText | string | |
| replyIds | readonly string[] | |
| structuralChanges? | readonly ('rowInsert' | 'rowDelete' | 'cellInsert' | 'cellDelete' | 'cellMerge' | 'numberingInsert')[] | Structural changes represented by this review artifact. |
| text | string |
ShapeReflectioninterface
A mirror image below a picture that fades out downward (a:reflection), as the effects renderer projects it for paint.
interface ShapeReflection| Member | Type | Summary |
|---|---|---|
| blurEmu | number | Blur radius of the mirror image. |
| distanceEmu | number | Gap between the shape and its mirror image. |
| endAlpha | number | Opacity at `endPosition`; below it the mirror image is clear. |
| endPosition | number | Where the fade ends, as a share of the shape's height. |
| startAlpha | number | Opacity where the mirror image meets the shape. |
SourceCropinterface
a:srcRect — how much of each edge of the source image is cropped away, as fractions.
interface SourceCrop| Member | Type | Summary |
|---|---|---|
| bottom | number | |
| left | number | |
| right | number | |
| top | number |
TextboxStoryLayoutinterface
One text box's story laid out inside its extent, in content-box-relative coordinates.
Fragments origin at the content box's top-left; paint places the content box at drawing origin + contentOffset and clips to the extent.
interface TextboxStoryLayout| Member | Type | Summary |
|---|---|---|
| chromeByVector? | true | The drawing's `vectorShape` paints the box; the fill, outline and shadow fields here only describe it, and painters draw just the text. |
| chromeRotationDegrees? | number | Clockwise turn of the fill and outline about the extent centre; absent when upright. |
| clippedResourceToken? | string | Resource identities of the drawings the clip DROPPED, in flow order. |
| contentHeight | number | Content box height (extent minus vertical insets). |
| contentOffset | Readonly<{
x: number;
y: number;
}> | Offset of the content box inside the drawing extent: insets plus vertical anchoring. |
| contentRotation? | Readonly<{
degrees: number;
pivot: Readonly<{
x: number;
y: number;
}>;
}> | Clockwise turn of the content box about `pivot`, in drawing-extent points. Absent when the story is upright: vertical text and text that turns with its shape set it. |
| contentWidth | number | Content box width (extent minus horizontal insets; the widest line when unwrapped). |
| extentHeight? | number | Box height a story that fits its shape sizes it to; absent when the extent height holds. |
| extentWidth? | number | Box width (points) that unwrapped text sizes its shape to: the widest line plus the insets. Placement resolves the shape at this width. Absent when the extent width holds. |
| fallbackReason? | TextboxStoryFallbackReason | True when layout hit a named bound and returned a truncated / empty story. |
| fillHex | string | null | Solid fill of the hosting shape, painted behind the story; null for no fill. |
| flowHeight | number | Height the blocks flow to (points), before vertical anchoring. |
| fragments | readonly BlockFragmentRecord[] | Content-box-relative fragments (origin at the content box's top-left). |
| outline? | TextboxOutlineProjection | Shape outline painted instead of a rectangle; absent for a rectangle. |
| overflowVisible? | true | DrawingML shape text: lines past the box paint outside it, not clipped at the drawing. |
| shadow? | Readonly<{
hex: string;
alpha: number;
dx: number;
dy: number;
obscured: boolean;
}> | Shadow colour, opacity and page offset in points. |
| strokeCap? | 'round' | 'square' | How outline dashes end; absent for flat ends. |
| strokeCentered? | true | The outline is centred on the extent edge rather than inside it. |
| strokeDashPt? | readonly number[] | Outline dash pattern in points; absent for solid. |
| strokeHex | string | null | Solid outline of the hosting shape; null for no outline. |
| strokeWidthPt | number | Outline width in points; 0 when absent. |
TextMeasurerinterface
Text measurement, injected.
A real implementation shapes with the resolved font; the tests supply a deterministic one. Layout never reads the DOM, so this is the only way width and height enter it.
interface TextMeasurer| Member | Type | Summary |
|---|---|---|
| caretAdvances | | Optional whole-span logical caret advances, indexed by UTF-16 offset. Values are nondecreasing, start at zero, and end at the measured advance. Ligature interiors may share an edge. Undefined selects a bounded approximate fallback. |
| hasResolvedFont | | Whether line metrics use an admitted face instead of approximate fallback metrics. |
| inkBounds | | Optional conservative ink bounds for one grapheme, in points from its origin. Includes size and horizontal scale, but not trailing character spacing. Undefined keeps layout on the advance-only path. |
| lineMetrics | | Line metrics for the actual text faces; omitted text measures the primary face. |
| measure | | Advance width of `text` in the resolved style. |
| strikeoutMetrics | | Optional `OS/2` strikeout stroke for the resolved face, at the drawn size. Word paints `w:separator` as a strikeout, so the note rule reads its thickness and offset here rather than assuming one face's numbers. Undefined keeps the caller's own default. |
| textOutline | | Optional glyph outlines of a whole string, for text drawn as a shape (VML text art). Undefined when the face cannot answer; the shape then paints nothing rather than guess. |
VectorShapeProjectioninterface
The renderable subset of a wps:wsp non-picture graphic, or of one bounded wpg:wgp group of them: closed polygon subpaths (a:custGeom with move/line/close/cubicBezTo verbs, or a supported a:prstGeom) with a solid fill and/or stroke. The colour may come from a:srgbClr or from the theme, through a:schemeClr or a wps:style matrix reference. Anything richer (gradient and picture fills, text bodies, rotation, a nested group) projects as null and paints the labelled placeholder instead.
interface VectorShapeProjection| Member | Type | Summary |
|---|---|---|
| components | readonly VectorShapeComponent[] | Independently styled paths, always non-empty. A direct shape has one component. |
| extentEmu | Readonly<{
cx: number;
cy: number;
}> | The drawing extent that frames the subpath coordinate space. |
| fillAlpha? | number | |
| fillHex | string | null | Validated 6-digit sRGB hex (no `#`) of the one component, or null. A group of two or more components has no single fill, so this is null there as well: null means "no one fill to name", not "nothing is filled". Read `components` to paint. |
| overflowVisible? | true | Geometry outside the extent paints too. A drawing canvas does not cut its members at its frame: a member placed past an edge shows whole. |
| strokeAlpha? | number | |
| strokeHex | string | null | As `fillHex`, for the stroke: the one component's stroke, else null. |
| strokeWidthEmu | number | The one component's stroke width in EMU; 0 when absent or when grouped. |
| subpathsEmu | readonly (readonly Readonly<{
x: number;
y: number;
}>[])[] | Every component's subpath polygons, flattened, in extent-EMU space; fill rule is even-odd. Painting reads `components`, which keeps each polygon with its own colours; this stays the geometry summary (bounds, hit tests, wrap holes). |
Type aliases (38)
AnchoredDrawingLayoutFallbacktype
Named fallback when a positioning frame cannot be resolved (OpenSpec 4.6).
type AnchoredDrawingLayoutFallback = 'unresolvable-frame' | 'page-defer-exhausted';DrawingChartPlotTypetype
A chart plot type. A classic chart names it by its element without the Chart suffix: column and bar charts are both bar, and ofPie is a pie-of-pie or bar-of-pie chart. A chartex chart names it by its series layout: waterfall, funnel, boxWhisker, treemap, sunburst and regionMap by their layout id, histogram for a clustered column series, and pareto for a Pareto chart (a clustered column series with its Pareto line).
type DrawingChartPlotType = 'area' | 'area3D' | 'bar' | 'bar3D' | 'bubble' | 'doughnut' | 'line' | 'line3D' | 'ofPie' | 'pie' | 'pie3D' | 'radar' | 'scatter' | 'stock' | 'surface' | 'surface3D' | 'waterfall' | 'funnel' | 'histogram' | 'pareto' | 'boxWhisker' | 'treemap' | 'sunburst' | 'regionMap';DrawingChartShownAstype
How the page shows a chart: chart when the installed chart renderer draws it, fallback when it shows the content saved in its mc:AlternateContent fallback (a picture, a shape, a group or VML), and placeholder when it shows the labeled chart placeholder.
type DrawingChartShownAs = 'chart' | 'fallback' | 'placeholder';DrawingHorizontalReferenceFrametype
type DrawingHorizontalReferenceFrame = 'character' | 'column' | 'insideMargin' | 'leftMargin' | 'margin' | 'outsideMargin' | 'page' | 'rightMargin';DrawingPlaceholderKindtype
The kind of graphic a non-picture drawing holds: chart (a chart), diagram (SmartArt), textbox (a DrawingML shape, with or without text), group (a shape group), canvas (a drawing canvas), shape (a legacy VML drawing, such as WordArt), or graphic (any other graphic). A picture, including an EMF, WMF or TIFF picture that does not convert, has none.
type DrawingPlaceholderKind = 'chart' | 'diagram' | 'shape' | 'group' | 'textbox' | 'canvas' | 'graphic';DrawingVerticalReferenceFrametype
type DrawingVerticalReferenceFrame = 'bottomMargin' | 'insideMargin' | 'line' | 'margin' | 'outsideMargin' | 'page' | 'paragraph' | 'topMargin';ExportDocumentMetadatatype
Bounded package metadata for exporter output dictionaries.
type ExportDocumentMetadata = Readonly<DocumentProperties>;ExportDocumentSourcetype
Source accepted by every exporter: untrusted bytes or an already-open live view.
type ExportDocumentSource = Uint8Array | HeadlessDocumentView;HeadlessDocumentRejectiontype
A bad package is data, not an exceptional control path.
type HeadlessDocumentRejection = OoxmlPackageRejection | 'no-main-document-tree';ImageResourceStatetype
What is known about one embedded image: validated, refused, or still decoding.
Content type is a CLAIM. Signature sniffing, structural header validation and the decode port are authoritative, and bytes that fail them never enter public state.
type ImageResourceState = {
readonly kind: 'ready';
readonly partName: string;
readonly contentId: string;
readonly resourceKey: string;
readonly validatedHandle: ValidatedImageBytesHandle;
readonly mime: RenderableImageMime;
readonly pixelWidth: number;
readonly pixelHeight: number;
readonly dpiX: number;
readonly dpiY: number;
} | {
readonly kind: 'unrenderable';
readonly partName: string | null;
readonly mime: RenderableImageMime | PreservedImageMime | 'unknown';
readonly reason: 'unsupported-format' | 'non-picture-graphic' | 'signature-mismatch' | 'decode-failed' | 'resource-limit';
} | {
readonly kind: 'external';
readonly relationshipId: string;
readonly sinkSafe: boolean;
} | {
readonly kind: 'missing';
readonly relationshipId: string;
} | {
readonly kind: 'pending';
readonly resourceKey: string;
};ImageWrapTargettype
Nine Word wrap menu targets (inline plus eight floating modes).
type ImageWrapTarget = 'inline' | 'square' | 'squareLeft' | 'squareRight' | 'tight' | 'through' | 'topAndBottom' | 'behind' | 'inFront';MarkdownCommenttypeSource ↗
Normalized DOCX comment, independent of editor UI state.
Its ID is opaque and stable only within one [MarkdownExportResult](MarkdownExportResult). Never persist the ID across exports; pair citations with the caller's own document version or content hash.
type MarkdownComment = SemanticCommentArtifactRecord;MarkdownFontOrigintypeSource ↗
One caller-controlled font origin used for headless pagination.
type MarkdownFontOrigin = FontOrigin;MarkdownFontsSourcetypeSource ↗
One font origin, or an ordered first-wins list of origins.
type MarkdownFontsSource = MarkdownFontOrigin | readonly MarkdownFontOrigin[];MarkdownJSONImagetypeSource ↗
JSON-safe image metadata. Binary bytes are delivered separately.
type MarkdownJSONImage = Omit<MarkdownImageAsset, 'bytes'>;MarkdownJSONResulttypeSource ↗
JSON-safe export for HTTP responses and portable bundle manifests.
type MarkdownJSONResult = Omit<MarkdownExportResult, 'media' | 'fontResolution'> & {
readonly media: readonly MarkdownJSONImage[];
readonly fontResolution: (Omit<NonNullable<MarkdownExportResult['fontResolution']>, 'originFailures'> & {
readonly originFailures: readonly {
readonly originIndex: number;
readonly originName?: string;
readonly cause: string;
}[];
}) | null;
};MarkdownReviewArtifacttypeSource ↗
Comment or tracked change returned by Markdown export. IDs are opaque and result-local.
type MarkdownReviewArtifact = SemanticReviewArtifactRecord;MarkdownReviewCoveragetypeSource ↗
How much of one Core source occurrence is represented by the returned ranges.
type MarkdownReviewCoverage = 'complete' | 'partial' | 'none';MarkdownReviewOccurrencetypeSource ↗
Page/story/source provenance for one exported review artifact.
type MarkdownReviewOccurrence = SemanticReviewArtifactRecord['occurrences'][number];MarkdownReviewProjectiontypeSource ↗
Markdown string containing one review binding.
type MarkdownReviewProjection = {
readonly kind: 'document';
} | {
readonly kind: 'page';
readonly pageIndex: number;
readonly pageNumber: number;
readonly field: 'markdown' | 'headerMarkdown' | 'footerMarkdown';
};MarkdownReviewRangePrecisiontypeSource ↗
Precision of a source-to-Markdown review range.
type MarkdownReviewRangePrecision = 'exact' | 'containing-construct';MarkdownReviewUnmappedReasontypeSource ↗
Why a source occurrence has no range in a particular Markdown projection.
type MarkdownReviewUnmappedReason = 'not-represented-in-markdown' | 'non-linear-structural-change' | 'omitted-story-content';MarkdownTrackedChangetypeSource ↗
Normalized DOCX tracked change, independent of editor UI state.
Its ID is opaque and stable only within one [MarkdownExportResult](MarkdownExportResult). Never persist the ID across exports; pair citations with the caller's own document version or content hash.
type MarkdownTrackedChange = SemanticTrackedChangeArtifactRecord;OpenDocumentForExportResulttype
Typed refusal for bytes that cannot become a document view, or an already-aborted open.
type OpenDocumentForExportResult = {
readonly ok: true;
readonly session: ExportSession;
} | {
readonly ok: false;
readonly reason: HeadlessDocumentRejection | 'aborted';
readonly detail?: string;
};OpenMarkdownDocumentForExportResulttypeSource ↗
Open result whose successful session retains its structured font-resolution report.
type OpenMarkdownDocumentForExportResult = {
readonly ok: true;
readonly session: MarkdownExportSession;
} | Exclude<OpenDocumentForExportResult, {
readonly ok: true;
}>;PreservedImageConvertertype
Optional caller conversion for preserved formats such as EMF/WMF/TIFF.
type PreservedImageConverter = (bytes: Uint8Array, mime: PreservedImageMime, limits: ImageResourceLimits,
signal?: AbortSignal) => Promise<Readonly<{
bytes: Uint8Array;
mime: SupportedImageMime;
}> | null>;ReviewDisplayModetype
The views the review chrome offers, in Word's terms: the three layout projections plus Simple Markup, which reads as the proposed result with a red change bar beside every line a change touched — the document as accepting everything would leave it, and where.
type ReviewDisplayMode = RevisionDisplayMode | 'simple-markup';RevisionChangedLinesMarktype
type RevisionChangedLinesMark = 'none' | 'leftBorder' | 'rightBorder' | 'outsideBorder';RevisionDeletionMarktype
type RevisionDeletionMark = RevisionMarkupMark | 'hidden' | 'caret' | 'pound';RevisionDisplayModetype
Which revisions layout resolves before producing pages.
- all-markup shows both halves of every change. - proposed shows what the document becomes if every change is accepted. - original shows what it was before any of them.
The last two are specified as equal to accept-all and reject-all OUTPUT, which is what makes them testable, without either applying an op.
type RevisionDisplayMode = 'all-markup' | 'proposed' | 'original';RevisionMarkupColortype
type RevisionMarkupColor = RevisionMarkupNamedColor | 'byAuthor' | 'auto';RevisionMarkupMarktype
type RevisionMarkupMark = 'none' | 'colorOnly' | 'bold' | 'italic' | 'underline' | 'doubleUnderline' | 'strikethrough' | 'doubleStrikethrough';RevisionMarkupNamedColortype
type RevisionMarkupNamedColor = (typeof REVISION_MARKUP_COLORS)[number];RevisionMarkupOptionstype
Partial viewer preferences. Omitted values keep the previous value.
type RevisionMarkupOptions = {
readonly [K in keyof ResolvedRevisionMarkup]?: ResolvedRevisionMarkup[K] extends boolean ? boolean : Partial<ResolvedRevisionMarkup[K]>;
};SemanticArtifactRootStoryKindtype
Published root story containing an artifact occurrence.
type SemanticArtifactRootStoryKind = 'body' | 'header' | 'footer' | 'footnote' | 'endnote' | 'note-separator';SemanticArtifactStoryKindtype
Exact story in which a review artifact's source anchor was laid out.
type SemanticArtifactStoryKind = SemanticArtifactRootStoryKind | 'textbox';SemanticReviewArtifactRecordtype
Exporter-neutral review artifact normalized by core.
type SemanticReviewArtifactRecord = SemanticTrackedChangeArtifactRecord | SemanticCommentArtifactRecord;TextboxOutlineProjectiontype
Outline geometry of a text box shape. A polygon's points are shares of the box, from 0 at its top-left to 1 at its far side, so the outline stretches with a box that fits its text.
type TextboxOutlineProjection = {
readonly kind: 'ellipse';
}
/** The corner radius is `arc` times the box's shorter side. */
| {
readonly kind: 'roundRect';
readonly arc: number;
} | {
readonly kind: 'polygon';
readonly subpaths: readonly (readonly {
readonly x: number;
readonly y: number;
}[])[];
};Variables (4)
HARD_MAX_AGGREGATE_FONT_BYTESconst
Most bytes all admitted faces may total, whatever a caller configures.
HARD_MAX_AGGREGATE_FONT_BYTES: numberHARD_MAX_FONT_BYTESconst
Largest single face this engine will ever admit, whatever a caller configures.
A CEILING, not a default: a host may set a smaller maxFontBytes, but nothing can raise it past this. Font bytes come from files, and an unbounded face is a memory-exhaustion vector.
HARD_MAX_FONT_BYTES: numberHARD_MAX_FONT_SOURCESconst
Most faces one snapshot may hold, whatever a caller configures.
HARD_MAX_FONT_SOURCES = 256REVISION_MARKUP_COLORSconst
Named revision colors. Identifiers are stable and never contain CSS.
REVISION_MARKUP_COLORS: readonly ['black', 'blue', 'turquoise', 'green', 'pink', 'red', 'yellow', 'white', 'darkBlue', 'teal', 'darkGreen', 'violet', 'darkRed', 'darkYellow', 'gray50', 'gray25', 'lightBlue', 'lightYellow', 'lightOrange', 'lightPurple', 'lightGreen', 'gray']