@forevka/wordcanvas 0.7.0 → 0.7.2
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.
- package/README.md +48 -1
- package/dist-lib/assets/{worker-BsOsK39A.js → worker-4HYrkNrG.js} +12276 -11981
- package/dist-lib/assets/worker-CJpwUzKh.js +2403 -0
- package/dist-lib/blockFactory-B_CLnkUh.js +106 -0
- package/dist-lib/browser-p_rkUcqE.js +1339 -0
- package/dist-lib/builder.js +365 -109
- package/dist-lib/editorApp-mTD0YNv-.js +9863 -0
- package/dist-lib/export.js +4670 -4567
- package/dist-lib/generate-toc.js +5 -5
- package/dist-lib/import.js +4 -1538
- package/dist-lib/{lists-BegzmTmD.js → lists-Sc5I40JO.js} +2 -2
- package/dist-lib/measure.js +2 -2
- package/dist-lib/{measureHost-CMiJKdlk.js → measureHost-B2aKX7lF.js} +1 -1
- package/dist-lib/metrics-BUMIC9Mv.js +164 -0
- package/dist-lib/pipeline-DD0nxAYM.js +1850 -0
- package/dist-lib/recalc-docx.js +2 -2
- package/dist-lib/recalcToc-CFCGCgij.js +3985 -0
- package/dist-lib/styleProps-DhqDEfvc.js +149 -0
- package/dist-lib/stylesheet-B6oczA-L.js +141 -0
- package/dist-lib/toc-Dj57zdz-.js +213 -0
- package/dist-lib/{webmcp-B7Gvd58E.js → webmcp-CXghUon_.js} +2 -2
- package/dist-lib/{wordcanvas-BAxBeErX.js → wordcanvas-D5DI9ZR1.js} +49 -23
- package/dist-lib/wordcanvas.js +1 -1
- package/dist-node/{chunk-GXFDF7UY.js → chunk-57L5XMCL.js} +327 -59
- package/dist-node/chunk-57L5XMCL.js.map +7 -0
- package/dist-node/{chunk-TBSXA2I4.js → chunk-EGSAVPCC.js} +1 -1
- package/dist-node/chunk-EGSAVPCC.js.map +7 -0
- package/dist-node/{chunk-4PDVRJF6.js → chunk-EMY2P524.js} +32 -2
- package/dist-node/chunk-EMY2P524.js.map +7 -0
- package/dist-node/{chunk-2RCPB7UZ.js → chunk-KJV7GJ3H.js} +1 -1
- package/dist-node/chunk-KJV7GJ3H.js.map +7 -0
- package/dist-node/{chunk-XDUDPPJW.js → chunk-PIMVQULL.js} +93 -24
- package/dist-node/chunk-PIMVQULL.js.map +7 -0
- package/dist-node/{chunk-BRAPV465.js → chunk-SA26UVIJ.js} +2 -2
- package/dist-node/{chunk-IJLL6IFJ.js → chunk-T3253N22.js} +202 -13
- package/dist-node/{chunk-IJLL6IFJ.js.map → chunk-T3253N22.js.map} +2 -2
- package/dist-node/{chunk-4ICCHZX4.js → chunk-U27EBKBG.js} +37 -1
- package/dist-node/chunk-U27EBKBG.js.map +7 -0
- package/dist-node/{engine-FRCX7PXF.js → engine-5F7DUU4W.js} +4 -4
- package/dist-node/export.js +178 -52
- package/dist-node/export.js.map +2 -2
- package/dist-node/generate-toc.js +7 -7
- package/dist-node/import.js +3 -3
- package/dist-node/measure.js +2 -2
- package/dist-node/recalc-docx.js +5 -5
- package/dist-node/recalc-docx.js.map +1 -1
- package/package.json +1 -1
- package/types/model.d.ts +277 -225
- package/types/recalc-docx.d.ts +27 -27
- package/types/wordcanvas.d.ts +212 -157
- package/dist-lib/assets/worker-BbFAIxdy.js +0 -2163
- package/dist-lib/blockFactory-Bcy0U40y.js +0 -178
- package/dist-lib/browser-5Sv4CuNy.js +0 -1284
- package/dist-lib/editorApp-DvjFPHiy.js +0 -7582
- package/dist-lib/metrics-CkAo4zh8.js +0 -143
- package/dist-lib/recalcToc-uaLWt59L.js +0 -3835
- package/dist-lib/styleProps-Db5pEkG8.js +0 -127
- package/dist-lib/toc-CZel_Kk3.js +0 -127
- package/dist-node/chunk-2RCPB7UZ.js.map +0 -7
- package/dist-node/chunk-4ICCHZX4.js.map +0 -7
- package/dist-node/chunk-4PDVRJF6.js.map +0 -7
- package/dist-node/chunk-GXFDF7UY.js.map +0 -7
- package/dist-node/chunk-TBSXA2I4.js.map +0 -7
- package/dist-node/chunk-XDUDPPJW.js.map +0 -7
- /package/dist-node/{chunk-BRAPV465.js.map → chunk-SA26UVIJ.js.map} +0 -0
- /package/dist-node/{engine-FRCX7PXF.js.map → engine-5F7DUU4W.js.map} +0 -0
package/types/wordcanvas.d.ts
CHANGED
|
@@ -1,157 +1,212 @@
|
|
|
1
|
-
// Public type surface for the @forevka/wordcanvas (WordCanvas) package.
|
|
2
|
-
// Hand-written so the published types stay small, self-contained, and stable
|
|
3
|
-
// regardless of internal refactors — no dependency on internal workspace types.
|
|
4
|
-
|
|
5
|
-
import type { Document } from "./model";
|
|
6
|
-
|
|
7
|
-
export type { Document } from "./model";
|
|
8
|
-
|
|
9
|
-
/** Caller-supplied identity, used for change attribution and presence. */
|
|
10
|
-
export interface UserInfo {
|
|
11
|
-
id: string;
|
|
12
|
-
firstName: string;
|
|
13
|
-
lastName: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** One other collaborator currently in the document (online mode). */
|
|
17
|
-
export interface Participant {
|
|
18
|
-
siteId: string;
|
|
19
|
-
user?: UserInfo;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface WordCanvasOptions {
|
|
23
|
-
/** Element to mount the editor into. */
|
|
24
|
-
container: HTMLElement;
|
|
25
|
-
/** Backend base URL (e.g. "https://api.example.com"). Online iff provided;
|
|
26
|
-
* omit for a fully offline editor (no sync, publish, or share). */
|
|
27
|
-
backendUrl?: string;
|
|
28
|
-
/** Open this document on load (online only) — e.g. the id returned by an
|
|
29
|
-
* upload. Canonical name; `collabId` is the deprecated alias. */
|
|
30
|
-
docId?: string;
|
|
31
|
-
/** @deprecated Use `docId`. Join an existing collaboration session on load. */
|
|
32
|
-
collabId?: string;
|
|
33
|
-
/** Caller-supplied identity (attribution + presence). The embedder owns auth. */
|
|
34
|
-
user?: UserInfo;
|
|
35
|
-
/** Override how a share link is surfaced (default: a built-in dialog). */
|
|
36
|
-
onShareLink?: (url: string, docId: string) => void;
|
|
37
|
-
/** Resolve a custom (developer-defined) field's content from your backend. When
|
|
38
|
-
* set, right-clicking a custom field offers "Update Field (<name>)"; the
|
|
39
|
-
* callback receives the field's name + verbatim instruction and returns the new
|
|
40
|
-
* result to splice in (see FieldResult). */
|
|
41
|
-
resolveField?: FieldResolver;
|
|
42
|
-
/** Expose this editor to AI agents over WebMCP (https://webmcp.dev), the standard
|
|
43
|
-
* `navigator.modelContext` API. `true` registers the full tool set — read &
|
|
44
|
-
* inspect (including a layout-geometry dump for debugging rendering / text-
|
|
45
|
-
* placement issues), plus suggestions, comments, and direct edits. Pass an
|
|
46
|
-
* object to restrict capabilities or namespace the tool names. The WebMCP
|
|
47
|
-
* polyfill is lazy-loaded only when this is set, so it adds nothing for
|
|
48
|
-
* embedders that don't opt in. Connect an agent via the WebMCP browser
|
|
49
|
-
* extension / Chrome DevTools MCP. */
|
|
50
|
-
agentTools?: boolean | AgentToolsOptions;
|
|
51
|
-
/** Track first-load progress so you can show a loader while the big chunks
|
|
52
|
-
* stream. Fires for the editor JS chunk download (`phase: "bundle"`,
|
|
53
|
-
* indeterminate) and the bundled font fetch (`phase: "fonts"`, the dominant
|
|
54
|
-
* ~9 MB cost — a smooth, size-weighted bar), then once at `phase: "ready"`
|
|
55
|
-
* with `percent: 1`. Read `percent` (0..1, monotonic) to drive a progress bar. */
|
|
56
|
-
onLoadProgress?: (progress: LoadProgress) => void;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** First-load progress (see WordCanvasOptions.onLoadProgress). */
|
|
60
|
-
export interface LoadProgress {
|
|
61
|
-
/** Coarse stage: "bundle" = downloading the editor JS chunk (indeterminate —
|
|
62
|
-
* a dynamic import can't be byte-measured); "fonts" = fetching the bundled
|
|
63
|
-
* fonts (measurable); "ready" = mount complete. */
|
|
64
|
-
phase: "bundle" | "fonts" | "ready";
|
|
65
|
-
/** Overall startup progress, 0..1, monotonic. Drive a progress bar with this. */
|
|
66
|
-
percent: number;
|
|
67
|
-
/** Bytes fetched / total for the current measurable phase (fonts). Both 0 when
|
|
68
|
-
* the phase is indeterminate (bundle). Informational. */
|
|
69
|
-
loaded: number;
|
|
70
|
-
total: number;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** Opt-in WebMCP agent tooling (see WordCanvasOptions.agentTools). */
|
|
74
|
-
export interface AgentToolsOptions {
|
|
75
|
-
/** Which tool buckets to register. Default: all three.
|
|
76
|
-
* - `read` — read & inspect (get_document, get_selection, search_document,
|
|
77
|
-
* inspect_layout, get_document_stats);
|
|
78
|
-
* - `suggest` — set_mode, comments, tracked-change suggestions, accept/reject;
|
|
79
|
-
* - `edit` — replace_text, insert_text, format_text, set_alignment,
|
|
80
|
-
* select_range, undo/redo, set_document. */
|
|
81
|
-
capabilities?: ("read" | "suggest" | "edit")[];
|
|
82
|
-
/** Optional prefix so several editors on one page don't collide
|
|
83
|
-
* (e.g. "doc1" → "doc1_get_document"). */
|
|
84
|
-
name?: string;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** Request passed to a custom-field resolver (see WordCanvasOptions.resolveField). */
|
|
88
|
-
export interface FieldResolveRequest {
|
|
89
|
-
/** The field's id within the document. */
|
|
90
|
-
fieldId: string;
|
|
91
|
-
/** Field keyword, uppercased (e.g. "MYCHART"). */
|
|
92
|
-
name: string;
|
|
93
|
-
/** The verbatim field instruction (e.g. ` MYCHART "sales-2026" `). */
|
|
94
|
-
instruction: string;
|
|
95
|
-
/** The collaboration doc id, when the session has one. */
|
|
96
|
-
docId?: string;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** What a field resolver returns:
|
|
100
|
-
* - a full **.docx** (ArrayBuffer / Uint8Array / Blob) — RECOMMENDED: imported
|
|
101
|
-
* through the same pipeline as opening a document, so images, tables, lists and
|
|
102
|
-
* styles come through (media survives export);
|
|
103
|
-
* - or an **OOXML fragment string** (w:p / w:tbl, or a w:document) for simple,
|
|
104
|
-
* text-only results (no embedded media). */
|
|
105
|
-
export type FieldResult = string | ArrayBuffer | Uint8Array | Blob;
|
|
106
|
-
|
|
107
|
-
/** Host hook producing a field's result for a resolve request. */
|
|
108
|
-
export type FieldResolver = (req: FieldResolveRequest) => Promise<FieldResult>;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
export
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
export interface
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
1
|
+
// Public type surface for the @forevka/wordcanvas (WordCanvas) package.
|
|
2
|
+
// Hand-written so the published types stay small, self-contained, and stable
|
|
3
|
+
// regardless of internal refactors — no dependency on internal workspace types.
|
|
4
|
+
|
|
5
|
+
import type { Block, Document, ParaStyle, Run } from "./model";
|
|
6
|
+
|
|
7
|
+
export type { Document } from "./model";
|
|
8
|
+
|
|
9
|
+
/** Caller-supplied identity, used for change attribution and presence. */
|
|
10
|
+
export interface UserInfo {
|
|
11
|
+
id: string;
|
|
12
|
+
firstName: string;
|
|
13
|
+
lastName: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** One other collaborator currently in the document (online mode). */
|
|
17
|
+
export interface Participant {
|
|
18
|
+
siteId: string;
|
|
19
|
+
user?: UserInfo;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface WordCanvasOptions {
|
|
23
|
+
/** Element to mount the editor into. */
|
|
24
|
+
container: HTMLElement;
|
|
25
|
+
/** Backend base URL (e.g. "https://api.example.com"). Online iff provided;
|
|
26
|
+
* omit for a fully offline editor (no sync, publish, or share). */
|
|
27
|
+
backendUrl?: string;
|
|
28
|
+
/** Open this document on load (online only) — e.g. the id returned by an
|
|
29
|
+
* upload. Canonical name; `collabId` is the deprecated alias. */
|
|
30
|
+
docId?: string;
|
|
31
|
+
/** @deprecated Use `docId`. Join an existing collaboration session on load. */
|
|
32
|
+
collabId?: string;
|
|
33
|
+
/** Caller-supplied identity (attribution + presence). The embedder owns auth. */
|
|
34
|
+
user?: UserInfo;
|
|
35
|
+
/** Override how a share link is surfaced (default: a built-in dialog). */
|
|
36
|
+
onShareLink?: (url: string, docId: string) => void;
|
|
37
|
+
/** Resolve a custom (developer-defined) field's content from your backend. When
|
|
38
|
+
* set, right-clicking a custom field offers "Update Field (<name>)"; the
|
|
39
|
+
* callback receives the field's name + verbatim instruction and returns the new
|
|
40
|
+
* result to splice in (see FieldResult). */
|
|
41
|
+
resolveField?: FieldResolver;
|
|
42
|
+
/** Expose this editor to AI agents over WebMCP (https://webmcp.dev), the standard
|
|
43
|
+
* `navigator.modelContext` API. `true` registers the full tool set — read &
|
|
44
|
+
* inspect (including a layout-geometry dump for debugging rendering / text-
|
|
45
|
+
* placement issues), plus suggestions, comments, and direct edits. Pass an
|
|
46
|
+
* object to restrict capabilities or namespace the tool names. The WebMCP
|
|
47
|
+
* polyfill is lazy-loaded only when this is set, so it adds nothing for
|
|
48
|
+
* embedders that don't opt in. Connect an agent via the WebMCP browser
|
|
49
|
+
* extension / Chrome DevTools MCP. */
|
|
50
|
+
agentTools?: boolean | AgentToolsOptions;
|
|
51
|
+
/** Track first-load progress so you can show a loader while the big chunks
|
|
52
|
+
* stream. Fires for the editor JS chunk download (`phase: "bundle"`,
|
|
53
|
+
* indeterminate) and the bundled font fetch (`phase: "fonts"`, the dominant
|
|
54
|
+
* ~9 MB cost — a smooth, size-weighted bar), then once at `phase: "ready"`
|
|
55
|
+
* with `percent: 1`. Read `percent` (0..1, monotonic) to drive a progress bar. */
|
|
56
|
+
onLoadProgress?: (progress: LoadProgress) => void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** First-load progress (see WordCanvasOptions.onLoadProgress). */
|
|
60
|
+
export interface LoadProgress {
|
|
61
|
+
/** Coarse stage: "bundle" = downloading the editor JS chunk (indeterminate —
|
|
62
|
+
* a dynamic import can't be byte-measured); "fonts" = fetching the bundled
|
|
63
|
+
* fonts (measurable); "ready" = mount complete. */
|
|
64
|
+
phase: "bundle" | "fonts" | "ready";
|
|
65
|
+
/** Overall startup progress, 0..1, monotonic. Drive a progress bar with this. */
|
|
66
|
+
percent: number;
|
|
67
|
+
/** Bytes fetched / total for the current measurable phase (fonts). Both 0 when
|
|
68
|
+
* the phase is indeterminate (bundle). Informational. */
|
|
69
|
+
loaded: number;
|
|
70
|
+
total: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Opt-in WebMCP agent tooling (see WordCanvasOptions.agentTools). */
|
|
74
|
+
export interface AgentToolsOptions {
|
|
75
|
+
/** Which tool buckets to register. Default: all three.
|
|
76
|
+
* - `read` — read & inspect (get_document, get_selection, search_document,
|
|
77
|
+
* inspect_layout, get_document_stats);
|
|
78
|
+
* - `suggest` — set_mode, comments, tracked-change suggestions, accept/reject;
|
|
79
|
+
* - `edit` — replace_text, insert_text, format_text, set_alignment,
|
|
80
|
+
* select_range, undo/redo, set_document. */
|
|
81
|
+
capabilities?: ("read" | "suggest" | "edit")[];
|
|
82
|
+
/** Optional prefix so several editors on one page don't collide
|
|
83
|
+
* (e.g. "doc1" → "doc1_get_document"). */
|
|
84
|
+
name?: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Request passed to a custom-field resolver (see WordCanvasOptions.resolveField). */
|
|
88
|
+
export interface FieldResolveRequest {
|
|
89
|
+
/** The field's id within the document. */
|
|
90
|
+
fieldId: string;
|
|
91
|
+
/** Field keyword, uppercased (e.g. "MYCHART"). */
|
|
92
|
+
name: string;
|
|
93
|
+
/** The verbatim field instruction (e.g. ` MYCHART "sales-2026" `). */
|
|
94
|
+
instruction: string;
|
|
95
|
+
/** The collaboration doc id, when the session has one. */
|
|
96
|
+
docId?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** What a field resolver returns:
|
|
100
|
+
* - a full **.docx** (ArrayBuffer / Uint8Array / Blob) — RECOMMENDED: imported
|
|
101
|
+
* through the same pipeline as opening a document, so images, tables, lists and
|
|
102
|
+
* styles come through (media survives export);
|
|
103
|
+
* - or an **OOXML fragment string** (w:p / w:tbl, or a w:document) for simple,
|
|
104
|
+
* text-only results (no embedded media). */
|
|
105
|
+
export type FieldResult = string | ArrayBuffer | Uint8Array | Blob;
|
|
106
|
+
|
|
107
|
+
/** Host hook producing a field's result for a resolve request. */
|
|
108
|
+
export type FieldResolver = (req: FieldResolveRequest) => Promise<FieldResult>;
|
|
109
|
+
|
|
110
|
+
/** What to render into a child-document surface (see WordCanvas.createChild). */
|
|
111
|
+
export type ChildContent =
|
|
112
|
+
| { kind: "blocks"; blocks: Block[] }
|
|
113
|
+
| { kind: "fragment"; fragment: { blocks: { runs: Run[]; style: ParaStyle }[]; inline?: boolean } }
|
|
114
|
+
| { kind: "runs"; runs: Run[]; paraStyle?: ParaStyle }
|
|
115
|
+
/** Body OOXML (w:p / w:tbl, or a w:document). Media-free (no images by r:id). */
|
|
116
|
+
| { kind: "ooxml"; ooxml: string }
|
|
117
|
+
/** A real sample of a named style ("AaBbCc" in the style's resolved formatting). */
|
|
118
|
+
| { kind: "styleSample"; styleId: string; sampleText?: string };
|
|
119
|
+
|
|
120
|
+
export interface ChildRenderOptions {
|
|
121
|
+
/** Layout/wrap width in CSS px. Default: target.clientWidth. */
|
|
122
|
+
widthPx?: number;
|
|
123
|
+
/** Child section margins (all sides), CSS px. Default 0. */
|
|
124
|
+
padding?: number;
|
|
125
|
+
/** Cap the displayed height; content beyond it is clipped. */
|
|
126
|
+
maxHeightPx?: number;
|
|
127
|
+
/** Fixed presentational scale (1 = 100%). Ignored when `fit` is set. */
|
|
128
|
+
zoom?: number;
|
|
129
|
+
/** Auto-scale the content to fit `widthPx` × `maxHeightPx` (compact swatches). */
|
|
130
|
+
fit?: boolean;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** A live interactive editor over a child slice (canvas-native editing). */
|
|
134
|
+
export interface ChildEditorHandle {
|
|
135
|
+
/** The edited content as model blocks (hand back to splice into the parent). */
|
|
136
|
+
getBlocks(): Block[];
|
|
137
|
+
getDocument(): Document;
|
|
138
|
+
/** Insert an image at the caret. The bytes are registered in the parent
|
|
139
|
+
* document's shared media store (content-addressed), so the image renders here,
|
|
140
|
+
* survives serialize/export, and resolves after commit-back. Dimensions default
|
|
141
|
+
* to the image's natural size. */
|
|
142
|
+
insertImage(bytes: Uint8Array, mime: string, opts?: { widthPx?: number; heightPx?: number }): Promise<void>;
|
|
143
|
+
destroy(): void;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** A lightweight sibling document that shares the parent editor's live styles,
|
|
147
|
+
* fonts and theme and renders/edits a content slice on canvas. */
|
|
148
|
+
export interface ChildDocument {
|
|
149
|
+
/** Paint a static preview of `content` into `target`. Safe to call repeatedly. */
|
|
150
|
+
render(target: HTMLElement, content: ChildContent, opts?: ChildRenderOptions): void;
|
|
151
|
+
/** Mount an interactive editor over `content` inside `target`. */
|
|
152
|
+
mountEditor(target: HTMLElement, content: ChildContent, opts?: ChildRenderOptions): ChildEditorHandle;
|
|
153
|
+
/** Tear down every surface/editor this child created. */
|
|
154
|
+
destroy(): void;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Event name → payload, for `on(...)`/`off(...)`. */
|
|
158
|
+
export interface WordCanvasEventMap {
|
|
159
|
+
ready: Record<string, never>;
|
|
160
|
+
shared: { docId: string; url: string };
|
|
161
|
+
userEntered: { siteId: string; user?: UserInfo };
|
|
162
|
+
userLeave: { siteId: string; user?: UserInfo };
|
|
163
|
+
presence: { participants: Participant[] };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Handle resolved once the editor is mounted (via `whenReady()`). */
|
|
167
|
+
export interface EditorHandle {
|
|
168
|
+
/** Snapshot of the current document (plain data). */
|
|
169
|
+
getDocument(): Document;
|
|
170
|
+
/** Create a child document sharing this editor's live styles/fonts/theme. */
|
|
171
|
+
createChild(): ChildDocument;
|
|
172
|
+
/** Replace the open document with a programmatically-built one (e.g. a
|
|
173
|
+
* DocumentBuilder result). Cloned; drops undo history and any live collab
|
|
174
|
+
* session; preserves zoom + scroll. */
|
|
175
|
+
setDocument(doc: Document): void;
|
|
176
|
+
/** Open a .docx (auto-publishes when online); resolves when loaded. */
|
|
177
|
+
openDocx(file: File | ArrayBuffer): Promise<void>;
|
|
178
|
+
/** Publish the current document and resolve its shareable link (online only). */
|
|
179
|
+
share(): Promise<string>;
|
|
180
|
+
getDocId(): string | null;
|
|
181
|
+
getShareLink(): string | null;
|
|
182
|
+
destroy(): void;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export declare class WordCanvas {
|
|
186
|
+
constructor(opts: WordCanvasOptions);
|
|
187
|
+
/** Subscribe to a collaboration event. Returns an unsubscribe function. */
|
|
188
|
+
on<E extends keyof WordCanvasEventMap>(event: E, handler: (data: WordCanvasEventMap[E]) => void): () => void;
|
|
189
|
+
/** Unsubscribe a handler previously passed to `on()`. */
|
|
190
|
+
off<E extends keyof WordCanvasEventMap>(event: E, handler: (data: WordCanvasEventMap[E]) => void): void;
|
|
191
|
+
/** Resolves once the editor is mounted and ready. */
|
|
192
|
+
whenReady(): Promise<EditorHandle>;
|
|
193
|
+
/** Create a child document that shares this editor's live styles, fonts and
|
|
194
|
+
* theme — render a real, document-styled preview of a content slice onto a
|
|
195
|
+
* canvas (instead of an HTML approximation), or mount a canvas-native editor
|
|
196
|
+
* over a slice. Returned synchronously; render() before ready is buffered.
|
|
197
|
+
* (mountEditor() requires the editor to be ready — await whenReady() first.) */
|
|
198
|
+
createChild(): ChildDocument;
|
|
199
|
+
/** Open a .docx. When online, auto-publishes it and surfaces a share link. */
|
|
200
|
+
openDocx(file: File | ArrayBuffer): Promise<void>;
|
|
201
|
+
/** Replace the open document with a programmatically-built one (e.g. a
|
|
202
|
+
* DocumentBuilder result). The input is cloned. Like openDocx, this starts a
|
|
203
|
+
* NEW document: undo history and any live collab session are dropped (the
|
|
204
|
+
* next share() forks). Zoom and scroll are preserved, so calling this on
|
|
205
|
+
* every data change gives a stable live preview. */
|
|
206
|
+
setDocument(doc: Document): Promise<void>;
|
|
207
|
+
/** Publish the current document and resolve its shareable link (online only). */
|
|
208
|
+
share(): Promise<string>;
|
|
209
|
+
getDocId(): string | null;
|
|
210
|
+
getShareLink(): string | null;
|
|
211
|
+
destroy(): void;
|
|
212
|
+
}
|