docxodus 9.1.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ribbon-chrome.js","sourceRoot":"","sources":["../src/ribbon-chrome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,sFAAsF;AACtF,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAG,6BAA6B,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAypBzB,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAClC,sEAAsE,IAAI,QAAQ,CAAC;AAErF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wFA4D6D,UAAU,CACtF,mLAAmL,CACpL;4FACiF,UAAU,CAC1F,mLAAmL,CACpL;0FAC+E,UAAU,CACxF,mLAAmL,CACpL;wFAC6E,UAAU,CACtF,qLAAqL,CACtL;8FACmF,UAAU,CAC5F,oNAAoN,CACrN;6FACkF,UAAU,CAC3F,kNAAkN,CACnN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0LV,CAAC;AAEF,sEAAsE;AACtE,MAAM,CAAC,MAAM,gBAAgB,GAC3B,uFAAuF;IACvF,sGAAsG;IACtG,qGAAqG;IACrG,yDAAyD,CAAC"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * The ribbon surface — the full editor UI as a mountable module.
3
+ *
4
+ * `DocxEditor` (editor.ts) is the document engine: it owns the live `DocxSession`,
5
+ * the block wiring and every command. It has deliberately no chrome. This module is
6
+ * the chrome — the tabbed ribbon, the anchor rail, the table picker and the loading
7
+ * overlay — wired onto exactly that command surface and nothing else.
8
+ *
9
+ * It exists because the same UI was hand-written three times (the standalone demo,
10
+ * the GitHub Pages landing page, the compact iframe player) and drifted. Now the
11
+ * surface has one owner, and the three hosts differ only in how they obtain the
12
+ * WASM exports and how much of the chrome they turn on:
13
+ *
14
+ * ```ts
15
+ * // Host that already booted the .NET runtime itself:
16
+ * const ribbon = mountRibbon(document.querySelector("#app")!, { exports });
17
+ * ribbon.open(bytes, "contract.docx");
18
+ *
19
+ * // Host that wants one call and a CDN (see embed.ts):
20
+ * await createRibbonEditor("#app", "./contract.docx", { chrome: "auto" });
21
+ * ```
22
+ *
23
+ * Chrome density is measured from the ROOT ELEMENT, not the viewport: a narrow
24
+ * embed on a wide desktop page is narrow. See ribbon-chrome.ts for the layout.
25
+ */
26
+ import { DocxEditor } from "./editor.js";
27
+ import type { DocxEditorExports, DocxEditorOptions } from "./editor.js";
28
+ export { DocxEditor } from "./editor.js";
29
+ export type { DocxEditorExports, DocxEditorOptions } from "./editor.js";
30
+ /** Which layout the chrome uses. "auto" measures the root and switches at `compactBreakpoint`. */
31
+ export type RibbonChromeMode = "full" | "compact" | "auto";
32
+ /** The lifecycle the surface reports on its root as `data-state`. */
33
+ export type RibbonState = "idle" | "loading" | "ready" | "error";
34
+ /** One step of the loading narrative: what is happening, and how far along it is. */
35
+ export interface RibbonLoaderStage {
36
+ title: string;
37
+ copy: string;
38
+ /** 0–100. Drives the progress bar. */
39
+ progress: number;
40
+ /** The short machine-side label under the bar. */
41
+ label: string;
42
+ }
43
+ /** A rotating capability card shown while the engine streams. */
44
+ export interface RibbonLoaderFeature {
45
+ number: string;
46
+ title: string;
47
+ copy: string;
48
+ }
49
+ export interface RibbonLoaderOptions {
50
+ /** Replace the four default stages. */
51
+ stages?: RibbonLoaderStage[];
52
+ /** Replace the rotating cards. Pass `[]` to hide the card entirely. */
53
+ features?: RibbonLoaderFeature[];
54
+ /** Micro-caps line above the title. */
55
+ eyebrow?: string;
56
+ /** Right-hand label under the progress bar. */
57
+ meta?: string;
58
+ /** Milliseconds between card rotations. Default 1750. */
59
+ rotateMs?: number;
60
+ /** What the Retry button does. Default: reload the page. */
61
+ onRetry?: () => void;
62
+ }
63
+ export interface RibbonOptions extends DocxEditorOptions {
64
+ /** WASM exports. Omit to mount chrome first (showing the loader) and call `setExports` later. */
65
+ exports?: DocxEditorExports;
66
+ /** Layout density. Default "auto". */
67
+ chrome?: RibbonChromeMode;
68
+ /** Root width, in px, below which "auto" picks compact. Default 720. */
69
+ compactBreakpoint?: number;
70
+ /** Show the anchor rail (full chrome only). Default true. */
71
+ rail?: boolean;
72
+ /** Show New / Open / Save. Default true. */
73
+ fileActions?: boolean;
74
+ /**
75
+ * Editing hint above the document: false to hide, or a string to replace it.
76
+ * Rendered as HTML (the default copy uses `<kbd>`), so pass author-controlled
77
+ * markup only. Default true.
78
+ */
79
+ hint?: boolean | string;
80
+ /** Loading overlay: false to suppress it, or an object to reword it. Default true. */
81
+ loader?: boolean | RibbonLoaderOptions;
82
+ /** Name shown in the title bar and used for the downloaded file. Default "untitled.docx". */
83
+ documentName?: string;
84
+ /**
85
+ * Element-id prefix. Controls are addressable as `data-dxr="<name>"` always, and
86
+ * additionally get `id = idPrefix + name`. Omit and the surface uses bare ids when
87
+ * they are free on the page, falling back to a generated prefix when they are not —
88
+ * so a second ribbon never collides with the first.
89
+ */
90
+ idPrefix?: string;
91
+ /** Replace the default Save behaviour (download the bytes). */
92
+ onSave?: (bytes: Uint8Array, name: string) => void;
93
+ /** Called after any document opens, with the live editor. */
94
+ onOpen?: (editor: DocxEditor) => void;
95
+ /** Called whenever the status line changes. */
96
+ onStatus?: (text: string) => void;
97
+ /** Called after every ribbon command, with its label and measured duration. */
98
+ onCommand?: (label: string, ms: number) => void;
99
+ }
100
+ /** Drives the loading overlay. Safe to call when the loader is disabled — every method no-ops. */
101
+ export interface RibbonLoader {
102
+ /** Re-show the overlay (e.g. before loading a second document). */
103
+ show(): void;
104
+ /** Jump to a numbered stage, or set one inline. */
105
+ stage(step: number | Partial<RibbonLoaderStage>): void;
106
+ /** Move the bar without changing the copy. */
107
+ progress(percent: number, label?: string): void;
108
+ /** Fade the overlay out and stop the rotation. */
109
+ done(): void;
110
+ /** Show the failure state with a Retry button. */
111
+ fail(error: unknown): void;
112
+ }
113
+ export interface RibbonEditor {
114
+ /** The mounted root element (carries `data-state` and `data-chrome`). */
115
+ readonly element: HTMLElement;
116
+ /** The element the document renders into. */
117
+ readonly surface: HTMLElement;
118
+ /** The live editor, or null before a document is open. */
119
+ readonly editor: DocxEditor | null;
120
+ /** The density actually in effect right now. */
121
+ readonly chrome: "full" | "compact";
122
+ /** The loading overlay controller. */
123
+ readonly loader: RibbonLoader;
124
+ /** Supply (or replace) the WASM exports after mounting. */
125
+ setExports(exports: DocxEditorExports): void;
126
+ /** Open a document, replacing any open one. Throws if exports are not set yet. */
127
+ open(bytes: Uint8Array, name?: string): DocxEditor;
128
+ /** Open a fresh blank document. */
129
+ openBlank(name?: string): DocxEditor;
130
+ /** Lossless DOCX bytes, or null when nothing is open. */
131
+ save(): Uint8Array | null;
132
+ /** Save and hand the bytes to `onSave` (default: browser download). */
133
+ download(name?: string): void;
134
+ /** Set the status line. */
135
+ setStatus(text: string): void;
136
+ /** Activate a ribbon tab by name ("home" | "insert" | "layout" | "table"). */
137
+ selectTab(name: string): void;
138
+ /** Force a density, or hand control back to measurement with "auto". */
139
+ setChrome(mode: RibbonChromeMode): void;
140
+ /** Look up a control by its `data-dxr` name. */
141
+ control<T extends HTMLElement = HTMLElement>(name: string): T | null;
142
+ /** Close the session, drop listeners and empty the container. */
143
+ destroy(): void;
144
+ }
145
+ /**
146
+ * Mount the ribbon surface into `container`.
147
+ *
148
+ * The chrome paints synchronously — including the loading overlay — so a host can
149
+ * mount before its WASM runtime exists, narrate the boot through `loader`, then call
150
+ * `setExports` and `open`.
151
+ */
152
+ export declare function mountRibbon(container: string | HTMLElement, options?: RibbonOptions): RibbonEditor;
153
+ //# sourceMappingURL=ribbon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ribbon.d.ts","sourceRoot":"","sources":["../src/ribbon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAGlB,MAAM,aAAa,CAAC;AAYrB,O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