@betteroffice/docx 0.0.1
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/LICENSE +201 -0
- package/README.md +41 -0
- package/dist/Subscribable-DOz6Ohoo.d.mts +33 -0
- package/dist/agent/index.d.mts +531 -0
- package/dist/agent/index.mjs +1 -0
- package/dist/chunk-34K66SY4.mjs +1 -0
- package/dist/chunk-3UBMCDME.mjs +1 -0
- package/dist/chunk-4RCISPPE.mjs +1 -0
- package/dist/chunk-4UD54UM5.mjs +1 -0
- package/dist/chunk-52GB3Y42.mjs +1 -0
- package/dist/chunk-6NEKRDXF.mjs +1 -0
- package/dist/chunk-6PW4CWUG.mjs +1 -0
- package/dist/chunk-7DEIW7FL.mjs +1 -0
- package/dist/chunk-7PCO5I2O.mjs +1 -0
- package/dist/chunk-BI3B33LI.mjs +1 -0
- package/dist/chunk-BIQWVK5P.mjs +2 -0
- package/dist/chunk-CIRN3LZA.mjs +1 -0
- package/dist/chunk-DXKG3HQ5.mjs +16 -0
- package/dist/chunk-EUUIJVM6.mjs +0 -0
- package/dist/chunk-FPZBTOD6.mjs +1 -0
- package/dist/chunk-FZIA7OFY.mjs +1 -0
- package/dist/chunk-GWKJ2Y4Y.mjs +1 -0
- package/dist/chunk-H3JCIGWK.mjs +1 -0
- package/dist/chunk-HJGAQIU7.mjs +2 -0
- package/dist/chunk-I6KKMUUC.mjs +1 -0
- package/dist/chunk-IL5JZJT7.mjs +1 -0
- package/dist/chunk-JY6ILTNS.mjs +1 -0
- package/dist/chunk-KEE52TT5.mjs +1 -0
- package/dist/chunk-KVKLLTDP.mjs +58 -0
- package/dist/chunk-KXNZFTTK.mjs +1 -0
- package/dist/chunk-L5ISVQ3W.mjs +1 -0
- package/dist/chunk-LDUWIM7M.mjs +1 -0
- package/dist/chunk-N5Q3YN64.mjs +1 -0
- package/dist/chunk-NEWOMDTX.mjs +1 -0
- package/dist/chunk-O2QSE2I7.mjs +1 -0
- package/dist/chunk-OBQGPMPQ.mjs +1 -0
- package/dist/chunk-OJOHXQNQ.mjs +1 -0
- package/dist/chunk-OMR3TWCD.mjs +2 -0
- package/dist/chunk-P3KDV4M2.mjs +1 -0
- package/dist/chunk-Q7PO7V73.mjs +1 -0
- package/dist/chunk-QOUFE3VX.mjs +1 -0
- package/dist/chunk-SINEY6ZF.mjs +1 -0
- package/dist/chunk-T4EZMUXM.mjs +1 -0
- package/dist/chunk-TTRUPDAB.mjs +1 -0
- package/dist/chunk-TYHI7RAD.mjs +1 -0
- package/dist/chunk-UIEJWORW.mjs +1 -0
- package/dist/chunk-VAOUFAUH.mjs +1 -0
- package/dist/chunk-VBOTMRXV.mjs +1 -0
- package/dist/chunk-VCER63GQ.mjs +1 -0
- package/dist/chunk-WAUF2UC7.mjs +2 -0
- package/dist/chunk-WRWRCBLK.mjs +1 -0
- package/dist/chunk-X4XDO3LZ.mjs +1 -0
- package/dist/chunk-XQBCCJBO.mjs +9 -0
- package/dist/chunk-XWUOLYRQ.mjs +2 -0
- package/dist/chunk-XYH6XWP3.mjs +10 -0
- package/dist/chunk-YBIM6UJV.mjs +8 -0
- package/dist/chunk-YCIH2Q3E.mjs +1 -0
- package/dist/chunk-YUOKI2HB.mjs +1 -0
- package/dist/chunk-ZOV5KL7C.mjs +1 -0
- package/dist/colorResolver-n0o7H7ep.d.mts +290 -0
- package/dist/content-sSHuWw49.d.mts +2202 -0
- package/dist/core-plugins.d.mts +37 -0
- package/dist/core-plugins.mjs +1 -0
- package/dist/core.d.mts +451 -0
- package/dist/core.mjs +1 -0
- package/dist/displayListQueries-p-ijSzdh.d.mts +222 -0
- package/dist/docx/index.d.mts +618 -0
- package/dist/docx/index.mjs +2 -0
- package/dist/docx/parser.d.mts +41 -0
- package/dist/docx/parser.mjs +1 -0
- package/dist/docx/rezip.d.mts +148 -0
- package/dist/docx/rezip.mjs +1 -0
- package/dist/docx/serializer/index.d.mts +42 -0
- package/dist/docx/serializer/index.mjs +1 -0
- package/dist/docx/wrapTypes.d.mts +19 -0
- package/dist/docx/wrapTypes.mjs +1 -0
- package/dist/docxInput-DTbCa48g.d.mts +21 -0
- package/dist/editor/index.d.mts +170 -0
- package/dist/editor/index.mjs +1 -0
- package/dist/editorTree-DO5PyDK8.d.mts +37 -0
- package/dist/executor-7O2RBJ2B.mjs +1 -0
- package/dist/fontLoader-Bx6DK6-2.d.mts +327 -0
- package/dist/formatting-DoL7KBSL.d.mts +823 -0
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/headerFooterLayout-0zPT64Qc.d.mts +316 -0
- package/dist/headless.d.mts +69 -0
- package/dist/headless.mjs +1 -0
- package/dist/layout/flow/index.d.mts +149 -0
- package/dist/layout/flow/index.mjs +1 -0
- package/dist/layout/index.d.mts +307 -0
- package/dist/layout/index.mjs +1 -0
- package/dist/layout/measure/index.d.mts +324 -0
- package/dist/layout/measure/index.mjs +1 -0
- package/dist/layout/pagination/index.d.mts +60 -0
- package/dist/layout/pagination/index.mjs +1 -0
- package/dist/layout/pagination/types.d.mts +4 -0
- package/dist/layout/pagination/types.mjs +1 -0
- package/dist/layout/render/index.d.mts +733 -0
- package/dist/layout/render/index.mjs +1 -0
- package/dist/loadWasmAsset-CMvnVkfA.d.mts +3 -0
- package/dist/managers/AutoSaveManager.d.mts +81 -0
- package/dist/managers/AutoSaveManager.mjs +1 -0
- package/dist/managers/TableSelectionManager.d.mts +74 -0
- package/dist/managers/TableSelectionManager.mjs +1 -0
- package/dist/managers/types.d.mts +113 -0
- package/dist/managers/types.mjs +0 -0
- package/dist/mcp-cli.mjs +142 -0
- package/dist/mcp.d.mts +162 -0
- package/dist/mcp.mjs +16 -0
- package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +109 -0
- package/dist/measuredBlock-DZwz8zhD.d.mts +26 -0
- package/dist/plugin-api/RenderedDomContext.d.mts +114 -0
- package/dist/plugin-api/RenderedDomContext.mjs +1 -0
- package/dist/plugin-api/index.d.mts +7 -0
- package/dist/plugin-api/index.mjs +0 -0
- package/dist/plugin-api/resolveItemPositions.d.mts +39 -0
- package/dist/plugin-api/resolveItemPositions.mjs +1 -0
- package/dist/plugin-api/types.d.mts +193 -0
- package/dist/plugin-api/types.mjs +0 -0
- package/dist/processTemplate-HDUIZFJ5.mjs +1 -0
- package/dist/registry-DMM5VTdT.d.mts +165 -0
- package/dist/rustDisplayList-dqunvwxH.d.mts +1036 -0
- package/dist/rustPagination-Bj2hq013.d.mts +106 -0
- package/dist/sectionConfigs-DW3J8q0X.d.mts +55 -0
- package/dist/selectionContext-Buc9BCU1.d.mts +570 -0
- package/dist/selectiveSave-oFBJ1n71.d.mts +16 -0
- package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +23 -0
- package/dist/settingsParser-CcGvtmCK.d.mts +33 -0
- package/dist/styles/index.d.mts +162 -0
- package/dist/styles/index.mjs +1 -0
- package/dist/styles-VxNcXLdi.d.mts +189 -0
- package/dist/types/agentApi.d.mts +456 -0
- package/dist/types/agentApi.mjs +1 -0
- package/dist/types/content.d.mts +3 -0
- package/dist/types/content.mjs +1 -0
- package/dist/types/document.d.mts +117 -0
- package/dist/types/document.mjs +1 -0
- package/dist/types-DNrYr6yQ.d.mts +1754 -0
- package/dist/types-dYdjUZMo.d.mts +311 -0
- package/dist/units-O5Y02RKQ.d.mts +34 -0
- package/dist/utils/autoScroll.d.mts +24 -0
- package/dist/utils/autoScroll.mjs +1 -0
- package/dist/utils/cardStyles.d.mts +22 -0
- package/dist/utils/cardStyles.mjs +1 -0
- package/dist/utils/comments.d.mts +120 -0
- package/dist/utils/comments.mjs +4 -0
- package/dist/utils/findReplace.d.mts +114 -0
- package/dist/utils/findReplace.mjs +2 -0
- package/dist/utils/findVerticalScrollParent.d.mts +25 -0
- package/dist/utils/findVerticalScrollParent.mjs +1 -0
- package/dist/utils/fontOptions.d.mts +21 -0
- package/dist/utils/fontOptions.mjs +1 -0
- package/dist/utils/headingCollector.d.mts +28 -0
- package/dist/utils/headingCollector.mjs +1 -0
- package/dist/utils/highlightColors.d.mts +14 -0
- package/dist/utils/highlightColors.mjs +1 -0
- package/dist/utils/index.d.mts +956 -0
- package/dist/utils/index.mjs +84 -0
- package/dist/utils/listState.d.mts +27 -0
- package/dist/utils/listState.mjs +1 -0
- package/dist/utils/reportIssue.d.mts +23 -0
- package/dist/utils/reportIssue.mjs +2 -0
- package/dist/utils/sidebarConstants.d.mts +10 -0
- package/dist/utils/sidebarConstants.mjs +1 -0
- package/dist/utils/stylePreview.d.mts +70 -0
- package/dist/utils/stylePreview.mjs +1 -0
- package/dist/utils/textSelection.d.mts +92 -0
- package/dist/utils/textSelection.mjs +1 -0
- package/dist/utils/units.d.mts +78 -0
- package/dist/utils/units.mjs +1 -0
- package/dist/variableDetector-Borj29SF.d.mts +115 -0
- package/dist/wasm-FZQ5XB2Y.mjs +1 -0
- package/dist/wasm-SA237OSP.mjs +1 -0
- package/dist/wasm-edit.d.mts +473 -0
- package/dist/wasm-edit.mjs +1 -0
- package/dist/wasm-layout.d.mts +112 -0
- package/dist/wasm-layout.mjs +1 -0
- package/dist/wasm-opc.d.mts +16 -0
- package/dist/wasm-opc.mjs +1 -0
- package/dist/wasm-parse.d.mts +18 -0
- package/dist/wasm-parse.mjs +1 -0
- package/dist/watermarkApi-DCxjutkg.d.mts +38 -0
- package/dist/yrs/index.d.mts +882 -0
- package/dist/yrs/index.mjs +1 -0
- package/dist/yrs/residentEngineWorker.d.mts +2 -0
- package/dist/yrs/residentEngineWorker.mjs +1 -0
- package/package.json +365 -0
|
@@ -0,0 +1,882 @@
|
|
|
1
|
+
import { Document } from '../types/document.mjs';
|
|
2
|
+
import '../content-sSHuWw49.mjs';
|
|
3
|
+
import '../formatting-DoL7KBSL.mjs';
|
|
4
|
+
import '../docx/wrapTypes.mjs';
|
|
5
|
+
import '../styles-VxNcXLdi.mjs';
|
|
6
|
+
import '../settingsParser-CcGvtmCK.mjs';
|
|
7
|
+
|
|
8
|
+
/** One native paragraph in the yrs-backed display-position projection. */
|
|
9
|
+
interface YrsInputParagraphSpan {
|
|
10
|
+
paraId: string;
|
|
11
|
+
/** Number of UTF-16/inline units before the paragraph's pilcrow. */
|
|
12
|
+
length: number;
|
|
13
|
+
/** Block start emitted by the yrs display-position projection. */
|
|
14
|
+
displayStart: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Live converter between display-list positions and public yrs Locs.
|
|
18
|
+
*
|
|
19
|
+
* A native paragraph of length N occupies N+2 display positions (open token,
|
|
20
|
+
* content, close token), so this map can be rebuilt directly from the live yrs
|
|
21
|
+
* paragraph spans after every structural edit.
|
|
22
|
+
*/
|
|
23
|
+
interface YrsInputPositionMap {
|
|
24
|
+
story: string;
|
|
25
|
+
paragraphs: readonly YrsInputParagraphSpan[];
|
|
26
|
+
}
|
|
27
|
+
interface YrsInputParagraphSeed {
|
|
28
|
+
paraId: string;
|
|
29
|
+
length: number;
|
|
30
|
+
}
|
|
31
|
+
declare function createYrsInputPositionMap(story: string, seeds: readonly YrsInputParagraphSeed[]): YrsInputPositionMap;
|
|
32
|
+
/** Convert a live yrs location to the position used by display-list geometry. */
|
|
33
|
+
declare function yrsLocToDisplayPosition(map: YrsInputPositionMap, loc: YrsLoc): number;
|
|
34
|
+
/** Convert a display-list hit position to a paragraph-keyed yrs location. */
|
|
35
|
+
declare function displayPositionToYrsLoc(map: YrsInputPositionMap, position: number): YrsLoc | null;
|
|
36
|
+
/** Compare two Locs in document order using one live map. */
|
|
37
|
+
declare function compareYrsLocs(map: YrsInputPositionMap, a: YrsLoc, b: YrsLoc): number;
|
|
38
|
+
|
|
39
|
+
interface ResidentEngineWorkerFrame {
|
|
40
|
+
frame: Uint8Array;
|
|
41
|
+
updates: Uint8Array[];
|
|
42
|
+
engineMs: number;
|
|
43
|
+
workerTotalMs: number;
|
|
44
|
+
engineProfile?: YrsEngineApplyProfile;
|
|
45
|
+
replayMs: number;
|
|
46
|
+
replayedPages: number;
|
|
47
|
+
layoutRevision: number;
|
|
48
|
+
}
|
|
49
|
+
interface ResidentEngineOffscreenPage {
|
|
50
|
+
pageId: string;
|
|
51
|
+
canvas: OffscreenCanvas;
|
|
52
|
+
}
|
|
53
|
+
interface ResidentEngineWorkerApplyResult extends ResidentEngineWorkerFrame {
|
|
54
|
+
applied: true;
|
|
55
|
+
}
|
|
56
|
+
/** Dedicated-worker owner for resident input, pagination, and FrameDelta output. */
|
|
57
|
+
declare class ResidentEngineWorkerClient {
|
|
58
|
+
private readonly worker;
|
|
59
|
+
private readonly pending;
|
|
60
|
+
private nextId;
|
|
61
|
+
private destroyed;
|
|
62
|
+
private ready;
|
|
63
|
+
private revision;
|
|
64
|
+
constructor();
|
|
65
|
+
isReady(): boolean;
|
|
66
|
+
layoutRevision(): number;
|
|
67
|
+
bootstrap(snapshot: YrsResidentWorkerSnapshot, extras: string): Promise<ResidentEngineWorkerFrame>;
|
|
68
|
+
sync(snapshot: YrsResidentWorkerSnapshot, extras: string, expectedFrameEpoch: number): Promise<ResidentEngineWorkerFrame>;
|
|
69
|
+
buildFrame(extras: string, expectedFrameEpoch: number): Promise<ResidentEngineWorkerFrame>;
|
|
70
|
+
applyInput(text: string, selection: YrsSelection, expectedFrameEpoch: number, profile?: boolean): Promise<ResidentEngineWorkerApplyResult | {
|
|
71
|
+
applied: false;
|
|
72
|
+
}>;
|
|
73
|
+
applyDelete(direction: 'backward' | 'forward', selection: YrsSelection, expectedFrameEpoch: number, profile?: boolean): Promise<ResidentEngineWorkerApplyResult | {
|
|
74
|
+
applied: false;
|
|
75
|
+
}>;
|
|
76
|
+
invalidate(update: Uint8Array, selection: YrsSelection | null): void;
|
|
77
|
+
attachCanvases(pages: ResidentEngineOffscreenPage[], activePageIds: string[], devicePixelRatio: number, zoom: number): Promise<void>;
|
|
78
|
+
destroy(): void;
|
|
79
|
+
private request;
|
|
80
|
+
private failAll;
|
|
81
|
+
}
|
|
82
|
+
declare function canUseResidentEngineWorker(): boolean;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Direct Document -> yrs load projection.
|
|
86
|
+
*
|
|
87
|
+
* This is the Document-model twin of the coexistence seed path. It emits the
|
|
88
|
+
* same flat story vocabulary as `seedFromPm`, but never constructs a
|
|
89
|
+
* ProseMirror node: text becomes attributed Y.Text, paragraphs become pilcrow
|
|
90
|
+
* embeds, tables/block SDTs become structural embeds with child stories, and
|
|
91
|
+
* comments become root-story side-map entries.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Seeds every yrs-owned editable story directly from a parsed Document.
|
|
96
|
+
*
|
|
97
|
+
* Stories are `body`, `hf:{rId}`, `fn:{id}`, and recursively generated table
|
|
98
|
+
* cell / block-SDT stories. The target session must not already contain any of
|
|
99
|
+
* those story ids.
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
declare function documentToYrs(session: YrsSession, document: Document): void;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* yrs -> OOXML Document save projection.
|
|
107
|
+
*
|
|
108
|
+
* The yrs coexistence model stores each editable container as a flat story:
|
|
109
|
+
* text carries inline formatting attributes, pilcrows carry paragraph
|
|
110
|
+
* properties, and structural/inline atoms are map embeds. This module reads
|
|
111
|
+
* that representation directly and rebuilds the serializer-facing Document.
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Rebuild all yrs-owned editable stories into the serializer-facing Document
|
|
116
|
+
* while preserving every package part the editor does not own.
|
|
117
|
+
*/
|
|
118
|
+
interface YrsToDocumentOptions {
|
|
119
|
+
/**
|
|
120
|
+
* Root stories to project. Omit to rebuild every editable story. A `body`
|
|
121
|
+
* projection includes its nested table/content-control stories.
|
|
122
|
+
*/
|
|
123
|
+
storyIds?: ReadonlySet<string>;
|
|
124
|
+
}
|
|
125
|
+
declare function yrsToDocument(session: YrsSession, base: Document, options?: YrsToDocumentOptions): Document;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Typed facade over the Rust yrs editing core (`crates/docx-edit`).
|
|
129
|
+
*
|
|
130
|
+
* This module is the ONLY JS entry to that crate — the `docx/zipContainer.ts`
|
|
131
|
+
* facade precedent. It is types + JSON marshaling only; every editing
|
|
132
|
+
* semantic (pilcrow-as-character stories, explicit-attribute inserts,
|
|
133
|
+
* suggesting mode, sticky comment anchors) lives in Rust.
|
|
134
|
+
*
|
|
135
|
+
* `createYrsSession()` lazily loads the embedded wasm (`./wasm`) on first call.
|
|
136
|
+
*
|
|
137
|
+
* Addressing is the op-contract public vocabulary: a {@link YrsLoc} is
|
|
138
|
+
* `(story, paraId, offset)` with UTF-16 offsets scoped to one paragraph
|
|
139
|
+
* (`offset ∈ [0, paragraphLength]`; the paragraph's own pilcrow is excluded
|
|
140
|
+
* from its offset space). Story-global indices never cross this boundary.
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
/** Durable authorship metadata for one suggested (tracked-change) operation. */
|
|
144
|
+
interface YrsAuthor {
|
|
145
|
+
name: string;
|
|
146
|
+
/** ISO timestamp supplied by the host so all peers share one clock policy. */
|
|
147
|
+
date: string;
|
|
148
|
+
}
|
|
149
|
+
/** One position: `(story, paraId, offset)` — offsets are UTF-16 units within the paragraph. */
|
|
150
|
+
interface YrsLoc {
|
|
151
|
+
story: string;
|
|
152
|
+
paraId: string;
|
|
153
|
+
offset: number;
|
|
154
|
+
}
|
|
155
|
+
/** A paragraph-addressed position without the story (used inside {@link YrsStoryRange}). */
|
|
156
|
+
interface YrsParaOffset {
|
|
157
|
+
paraId: string;
|
|
158
|
+
offset: number;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* A half-open range `[start, end)` inside one story. Ends may sit in
|
|
162
|
+
* different paragraphs; the boundary pilcrows are then part of the range
|
|
163
|
+
* (deleting such a range merges paragraphs).
|
|
164
|
+
*/
|
|
165
|
+
interface YrsStoryRange {
|
|
166
|
+
story: string;
|
|
167
|
+
start: YrsParaOffset;
|
|
168
|
+
end: YrsParaOffset;
|
|
169
|
+
}
|
|
170
|
+
/** One run-level mark for {@link YrsSession.toggleMark}. */
|
|
171
|
+
type YrsRunMark = {
|
|
172
|
+
type: 'bold';
|
|
173
|
+
} | {
|
|
174
|
+
type: 'italic';
|
|
175
|
+
} | {
|
|
176
|
+
type: 'underline';
|
|
177
|
+
} | {
|
|
178
|
+
type: 'fontFamily';
|
|
179
|
+
value: string;
|
|
180
|
+
} | {
|
|
181
|
+
type: 'fontSize';
|
|
182
|
+
value: number;
|
|
183
|
+
} | {
|
|
184
|
+
type: 'color';
|
|
185
|
+
value: string;
|
|
186
|
+
};
|
|
187
|
+
/** A direct text color written by {@link YrsSession.formatRange}. */
|
|
188
|
+
type YrsTextColor = {
|
|
189
|
+
rgb: string;
|
|
190
|
+
themeColor?: never;
|
|
191
|
+
} | {
|
|
192
|
+
rgb?: never;
|
|
193
|
+
themeColor: string;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Set-valued inline formatting for {@link YrsSession.formatRange}. Omitted
|
|
197
|
+
* fields are left unchanged; `null` clears a field. Boolean `false` also
|
|
198
|
+
* clears the corresponding mark.
|
|
199
|
+
*/
|
|
200
|
+
interface YrsInlineFormatDelta {
|
|
201
|
+
bold?: boolean | null;
|
|
202
|
+
italic?: boolean | null;
|
|
203
|
+
underline?: boolean | {
|
|
204
|
+
style?: string;
|
|
205
|
+
color?: string;
|
|
206
|
+
} | null;
|
|
207
|
+
strike?: boolean | {
|
|
208
|
+
double?: boolean;
|
|
209
|
+
} | null;
|
|
210
|
+
color?: YrsTextColor | null;
|
|
211
|
+
highlight?: string | null;
|
|
212
|
+
/** Font size in points; Rust writes both OOXML half-point size fields. */
|
|
213
|
+
fontSize?: number | null;
|
|
214
|
+
fontFamily?: {
|
|
215
|
+
ascii: string;
|
|
216
|
+
hAnsi?: string;
|
|
217
|
+
} | null;
|
|
218
|
+
/** Passive run properties not covered by the typed fields. `null` clears. */
|
|
219
|
+
other?: Readonly<Record<string, unknown | null>>;
|
|
220
|
+
}
|
|
221
|
+
interface YrsHyperlinkAttrs {
|
|
222
|
+
href: string;
|
|
223
|
+
tooltip?: string | null;
|
|
224
|
+
rId?: string | null;
|
|
225
|
+
}
|
|
226
|
+
/** Seed shape for {@link YrsSession.loadStories}. */
|
|
227
|
+
interface YrsParagraphSeed {
|
|
228
|
+
/** Paragraph text; must not contain paragraph breaks. */
|
|
229
|
+
text: string;
|
|
230
|
+
/** Defaults to `"Normal"`. */
|
|
231
|
+
pStyle?: string;
|
|
232
|
+
/** Defaults to `"left"`. */
|
|
233
|
+
alignment?: string;
|
|
234
|
+
}
|
|
235
|
+
/** One story to seed via {@link YrsSession.loadStories}. */
|
|
236
|
+
interface YrsStorySeed {
|
|
237
|
+
storyId: string;
|
|
238
|
+
/** At least one paragraph. */
|
|
239
|
+
paragraphs: readonly YrsParagraphSeed[];
|
|
240
|
+
}
|
|
241
|
+
/** Snapshot of one paragraph from {@link YrsSession.paragraphs}. */
|
|
242
|
+
interface YrsParagraph {
|
|
243
|
+
paraId: string;
|
|
244
|
+
text: string;
|
|
245
|
+
/** pStyle / alignment plus any op-set extras. */
|
|
246
|
+
properties: Record<string, unknown>;
|
|
247
|
+
}
|
|
248
|
+
/** One direct numbering reference (`w:numPr`) on a paragraph. */
|
|
249
|
+
interface YrsNumberingProperties {
|
|
250
|
+
numId?: number;
|
|
251
|
+
ilvl?: number;
|
|
252
|
+
}
|
|
253
|
+
/** One paragraph tab stop, measured in twips from the left margin. */
|
|
254
|
+
interface YrsParagraphTabStop {
|
|
255
|
+
position: number;
|
|
256
|
+
alignment: 'left' | 'center' | 'right' | 'decimal' | 'bar' | 'clear' | 'num';
|
|
257
|
+
leader?: 'none' | 'dot' | 'hyphen' | 'underscore' | 'heavy' | 'middleDot';
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Tri-state properties for {@link YrsSession.setParagraphAttrs}. Omitted
|
|
261
|
+
* fields are kept and `null` clears. Numeric spacing and indents are OOXML
|
|
262
|
+
* twips/line-spacing units, never CSS pixels.
|
|
263
|
+
*/
|
|
264
|
+
interface YrsParagraphAttrs {
|
|
265
|
+
alignment?: 'left' | 'center' | 'right' | 'both' | 'distribute' | 'mediumKashida' | 'highKashida' | 'lowKashida' | 'thaiDistribute' | null;
|
|
266
|
+
lineSpacing?: number | null;
|
|
267
|
+
lineSpacingRule?: 'auto' | 'exact' | 'atLeast' | null;
|
|
268
|
+
spaceBefore?: number | null;
|
|
269
|
+
spaceAfter?: number | null;
|
|
270
|
+
indentLeft?: number | null;
|
|
271
|
+
indentRight?: number | null;
|
|
272
|
+
indentFirstLine?: number | null;
|
|
273
|
+
hangingIndent?: boolean | null;
|
|
274
|
+
bidi?: boolean | null;
|
|
275
|
+
tabs?: readonly YrsParagraphTabStop[] | null;
|
|
276
|
+
defaultTextFormatting?: Readonly<Record<string, unknown>> | null;
|
|
277
|
+
numPr?: YrsNumberingProperties | null;
|
|
278
|
+
numPrFromStyle?: YrsNumberingProperties | null;
|
|
279
|
+
listNumFmt?: string | null;
|
|
280
|
+
listIsBullet?: boolean | null;
|
|
281
|
+
listMarker?: string | null;
|
|
282
|
+
listMarkerHidden?: boolean | null;
|
|
283
|
+
listMarkerFontFamily?: string | null;
|
|
284
|
+
listMarkerFontSize?: number | null;
|
|
285
|
+
listMarkerSuffix?: 'tab' | 'space' | 'nothing' | null;
|
|
286
|
+
listLevelNumFmts?: readonly string[] | null;
|
|
287
|
+
listAbstractNumId?: number | null;
|
|
288
|
+
listStartOverride?: number | null;
|
|
289
|
+
/** Passive pPr/model properties not covered by the typed fields. */
|
|
290
|
+
other?: Readonly<Record<string, unknown | null>>;
|
|
291
|
+
}
|
|
292
|
+
/** Typed value stored on a structured document tag (content control). */
|
|
293
|
+
type YrsContentControlValue = {
|
|
294
|
+
kind: 'dropdown';
|
|
295
|
+
value: string;
|
|
296
|
+
} | {
|
|
297
|
+
kind: 'checkbox';
|
|
298
|
+
checked: boolean;
|
|
299
|
+
} | {
|
|
300
|
+
kind: 'date';
|
|
301
|
+
date: string;
|
|
302
|
+
} | string;
|
|
303
|
+
/** Image geometry authored in OOXML EMUs plus wrapping/position metadata. */
|
|
304
|
+
interface YrsImageGeometry {
|
|
305
|
+
widthEmu: number;
|
|
306
|
+
heightEmu: number;
|
|
307
|
+
wrap?: 'inline' | 'square' | 'tight' | 'through' | 'topAndBottom' | 'behind' | 'inFront';
|
|
308
|
+
hOffsetEmu?: number | null;
|
|
309
|
+
vOffsetEmu?: number | null;
|
|
310
|
+
distTopEmu?: number | null;
|
|
311
|
+
distBottomEmu?: number | null;
|
|
312
|
+
distLeftEmu?: number | null;
|
|
313
|
+
distRightEmu?: number | null;
|
|
314
|
+
relativeFromHorizontal?: string | null;
|
|
315
|
+
relativeFromVertical?: string | null;
|
|
316
|
+
/** Additional image payload fields; `null` clears an existing field. */
|
|
317
|
+
other?: Readonly<Record<string, unknown | null>>;
|
|
318
|
+
}
|
|
319
|
+
/** A text or picture watermark payload for {@link YrsSession.insertWatermark}. */
|
|
320
|
+
type YrsWatermark = {
|
|
321
|
+
kind: 'text';
|
|
322
|
+
text: string;
|
|
323
|
+
font: string;
|
|
324
|
+
color: string;
|
|
325
|
+
semitransparent: boolean;
|
|
326
|
+
layout: 'diagonal' | 'horizontal';
|
|
327
|
+
fontSize?: number;
|
|
328
|
+
decorative?: boolean;
|
|
329
|
+
} | {
|
|
330
|
+
kind: 'picture';
|
|
331
|
+
relId?: string;
|
|
332
|
+
mediaPath?: string;
|
|
333
|
+
dataUrl?: string;
|
|
334
|
+
contentType?: string;
|
|
335
|
+
scale: number;
|
|
336
|
+
washout: boolean;
|
|
337
|
+
widthEmu?: number;
|
|
338
|
+
heightEmu?: number;
|
|
339
|
+
decorative?: boolean;
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* One formatted segment from {@link YrsSession.storySegments} — the render
|
|
343
|
+
* bridge's input. `attributes` carries run marks plus `ins` / `del` revision
|
|
344
|
+
* values (suggested deletions are retained text with a `del` attribute).
|
|
345
|
+
*/
|
|
346
|
+
type YrsStorySegment = {
|
|
347
|
+
kind: 'text';
|
|
348
|
+
text: string;
|
|
349
|
+
attributes: Record<string, unknown>;
|
|
350
|
+
} | {
|
|
351
|
+
kind: 'pilcrow';
|
|
352
|
+
paraId: string;
|
|
353
|
+
properties: Record<string, unknown>;
|
|
354
|
+
attributes: Record<string, unknown>;
|
|
355
|
+
} | {
|
|
356
|
+
kind: 'embed';
|
|
357
|
+
/** Map-backed embed discriminator (`table`, `noteRef`, `image`, …). */
|
|
358
|
+
embedKind: string;
|
|
359
|
+
/** Authored map entries excluding the discriminator. */
|
|
360
|
+
payload: Record<string, unknown>;
|
|
361
|
+
attributes: Record<string, unknown>;
|
|
362
|
+
};
|
|
363
|
+
/** Current offsets of one sticky comment anchor. */
|
|
364
|
+
interface YrsResolvedCommentAnchor {
|
|
365
|
+
story: string;
|
|
366
|
+
start: number;
|
|
367
|
+
end: number;
|
|
368
|
+
}
|
|
369
|
+
/** A paragraph's story span; `end` is its pilcrow, so `end - start` is the paragraph length. */
|
|
370
|
+
interface YrsParagraphSpan {
|
|
371
|
+
start: number;
|
|
372
|
+
end: number;
|
|
373
|
+
}
|
|
374
|
+
/** Compact paragraph entry used to build the live input-position projection. */
|
|
375
|
+
interface YrsParagraphLength {
|
|
376
|
+
paraId: string;
|
|
377
|
+
/** UTF-16 text and inline embed units before the paragraph's pilcrow. */
|
|
378
|
+
length: number;
|
|
379
|
+
}
|
|
380
|
+
/** Receipt of an op that minted a paragraph id. */
|
|
381
|
+
interface YrsParagraphReceipt {
|
|
382
|
+
paraId: string;
|
|
383
|
+
}
|
|
384
|
+
/** Receipt of an op that may have minted a tracked-change revision (suggesting mode). */
|
|
385
|
+
interface YrsRevisionReceipt {
|
|
386
|
+
revisionId: string | null;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Receipt of {@link YrsSession.splitParagraph}. Under the S1 split the FIRST
|
|
390
|
+
* half keeps the original paraId and the SECOND half is re-minted; suggesting
|
|
391
|
+
* mode stamps a `pPrIns` revision on the first half.
|
|
392
|
+
*/
|
|
393
|
+
interface YrsSplitReceipt {
|
|
394
|
+
firstParaId: string;
|
|
395
|
+
secondParaId: string;
|
|
396
|
+
revisionId: string | null;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* One low-level story mirror operation for {@link YrsSession.applyRawOps}. The
|
|
400
|
+
* coexistence bridge lowers a ProseMirror transaction to a list of these and
|
|
401
|
+
* applies them in one yrs transaction. Indices are UTF-16 story units, each read
|
|
402
|
+
* against the story state after all prior ops in the batch.
|
|
403
|
+
*/
|
|
404
|
+
type YrsRawOp = {
|
|
405
|
+
op: 'insert';
|
|
406
|
+
index: number;
|
|
407
|
+
text: string;
|
|
408
|
+
attrs?: Record<string, unknown>;
|
|
409
|
+
} | {
|
|
410
|
+
op: 'delete';
|
|
411
|
+
index: number;
|
|
412
|
+
len: number;
|
|
413
|
+
} | {
|
|
414
|
+
op: 'format';
|
|
415
|
+
index: number;
|
|
416
|
+
len: number;
|
|
417
|
+
attrs?: Record<string, unknown>;
|
|
418
|
+
} | {
|
|
419
|
+
op: 'insertEmbed';
|
|
420
|
+
index: number;
|
|
421
|
+
kind: string;
|
|
422
|
+
payload?: Record<string, unknown>;
|
|
423
|
+
attrs?: Record<string, unknown>;
|
|
424
|
+
} | {
|
|
425
|
+
op: 'setEmbedAttr';
|
|
426
|
+
index: number;
|
|
427
|
+
key: string;
|
|
428
|
+
value: unknown;
|
|
429
|
+
} | {
|
|
430
|
+
/**
|
|
431
|
+
* Upserts the side-map comment keyed by `id`, (re-)anchoring it to
|
|
432
|
+
* `ranges` — non-empty `[start, end)` story-unit spans in the batch's
|
|
433
|
+
* story (sticky `Assoc::After` starts / `Assoc::Before` ends). The
|
|
434
|
+
* coexistence bridge keys by the PM comment id so identity survives the
|
|
435
|
+
* mirror.
|
|
436
|
+
*/
|
|
437
|
+
op: 'setComment';
|
|
438
|
+
id: string;
|
|
439
|
+
ranges: ReadonlyArray<readonly [number, number]>;
|
|
440
|
+
author?: string;
|
|
441
|
+
date?: string;
|
|
442
|
+
body?: unknown;
|
|
443
|
+
} | {
|
|
444
|
+
/** Removes the side-map comment keyed by `id`; errors when missing. */
|
|
445
|
+
op: 'removeComment';
|
|
446
|
+
id: string;
|
|
447
|
+
};
|
|
448
|
+
/** Host context for {@link YrsSession.yrsBlocksForStory} (theme + list numbering). */
|
|
449
|
+
interface YrsRenderEnv {
|
|
450
|
+
/** Theme color name → hex (`accent1` → `4472C4`), for theme-color resolution. */
|
|
451
|
+
themeColors?: Record<string, string>;
|
|
452
|
+
/** The document default tab stop in twips. */
|
|
453
|
+
defaultTabStopTwips?: number | null;
|
|
454
|
+
/** Current page content height in CSS px, for proportional drawing constraints. */
|
|
455
|
+
pageContentHeight?: number | null;
|
|
456
|
+
/** yrs revision/paragraph id → dense numeric layout id (list markers, revisions). */
|
|
457
|
+
numericIds?: Record<string, number>;
|
|
458
|
+
}
|
|
459
|
+
/** Receipt of {@link YrsSession.addComment}. */
|
|
460
|
+
interface YrsCommentReceipt {
|
|
461
|
+
commentId: string;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Target of {@link YrsSession.acceptChange} / {@link YrsSession.rejectChange}:
|
|
465
|
+
* one coalesced revision id (resolved at every site, in any story — the
|
|
466
|
+
* `acceptChangeById` twin) or an explicit story range (the range-command twin;
|
|
467
|
+
* every tracked change overlapping the range resolves, no id filtering).
|
|
468
|
+
*/
|
|
469
|
+
type YrsChangeTarget = {
|
|
470
|
+
revisionId: string;
|
|
471
|
+
} | YrsStoryRange;
|
|
472
|
+
/** Receipt of {@link YrsSession.acceptChange} / {@link YrsSession.rejectChange}. */
|
|
473
|
+
interface YrsResolveReceipt {
|
|
474
|
+
/** The revision ids resolved by the op (resolution order, deduplicated). */
|
|
475
|
+
revisionIds: string[];
|
|
476
|
+
}
|
|
477
|
+
/** This peer's awareness selection, resolved from two yrs sticky positions. */
|
|
478
|
+
interface YrsSelection {
|
|
479
|
+
anchor: YrsLoc;
|
|
480
|
+
head: YrsLoc;
|
|
481
|
+
}
|
|
482
|
+
/** Opt-in internal stage timings for one resident engine input. @internal */
|
|
483
|
+
interface YrsEngineApplyProfile {
|
|
484
|
+
selectionMs: number;
|
|
485
|
+
editMs: number;
|
|
486
|
+
lowerMs: number;
|
|
487
|
+
measureMs: number;
|
|
488
|
+
paginateMs: number;
|
|
489
|
+
displayInputMs: number;
|
|
490
|
+
displayBuildMs: number;
|
|
491
|
+
displayFinalizeMs: number;
|
|
492
|
+
displayMs: number;
|
|
493
|
+
encodeMs: number;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Serializable bootstrap state for the dedicated resident-layout worker.
|
|
497
|
+
* The main-thread yrs replica records the inputs that established resident
|
|
498
|
+
* render, measurement, and pagination state; the worker replays them once and
|
|
499
|
+
* then owns every ordinary input-to-frame transaction.
|
|
500
|
+
*
|
|
501
|
+
* @internal
|
|
502
|
+
*/
|
|
503
|
+
interface YrsResidentWorkerSnapshot {
|
|
504
|
+
clientId: number;
|
|
505
|
+
state: Uint8Array;
|
|
506
|
+
selection: YrsSelection | null;
|
|
507
|
+
fonts: Uint8Array[];
|
|
508
|
+
renderInputs: Array<{
|
|
509
|
+
story: string;
|
|
510
|
+
env: YrsRenderEnv;
|
|
511
|
+
}>;
|
|
512
|
+
measureInputs: string[];
|
|
513
|
+
layoutInput: string;
|
|
514
|
+
layoutRevision: number;
|
|
515
|
+
}
|
|
516
|
+
/** A range-aggregated toggle mark. @public */
|
|
517
|
+
type YrsTriState = boolean | 'mixed';
|
|
518
|
+
/**
|
|
519
|
+
* Read-only toolbar/a11y state aggregated from yrs over one story range.
|
|
520
|
+
* Toggle marks are tri-state; value marks are `null` when absent or mixed.
|
|
521
|
+
*
|
|
522
|
+
* @public
|
|
523
|
+
*/
|
|
524
|
+
interface YrsSelectionContext {
|
|
525
|
+
bold: YrsTriState;
|
|
526
|
+
italic: YrsTriState;
|
|
527
|
+
underline: YrsTriState;
|
|
528
|
+
strike: YrsTriState;
|
|
529
|
+
/** Uniform ASCII font family, or `null` when absent/mixed. */
|
|
530
|
+
fontFamily: string | null;
|
|
531
|
+
/** Uniform font size in half-points (the PM/OOXML `w:sz` unit). */
|
|
532
|
+
fontSize: number | null;
|
|
533
|
+
/** Uniform RGB hex or theme-color name, or `null` when absent/mixed. */
|
|
534
|
+
color: string | null;
|
|
535
|
+
/** Paragraph containing the range start. */
|
|
536
|
+
paraId: string;
|
|
537
|
+
styleId: string | null;
|
|
538
|
+
alignment: string | null;
|
|
539
|
+
/**
|
|
540
|
+
* Full authored pilcrow property bag. Known toolbar fields retain their PM
|
|
541
|
+
* names (`indentLeft`, `spaceBefore`, `lineSpacing`, `numPr`, and so on);
|
|
542
|
+
* paragraph style is stored as `pStyle`.
|
|
543
|
+
*/
|
|
544
|
+
paragraphProperties: {
|
|
545
|
+
[key: string]: unknown;
|
|
546
|
+
pStyle?: string;
|
|
547
|
+
alignment?: string;
|
|
548
|
+
indentLeft?: number;
|
|
549
|
+
indentRight?: number;
|
|
550
|
+
indentFirstLine?: number;
|
|
551
|
+
hangingIndent?: boolean;
|
|
552
|
+
spaceBefore?: number;
|
|
553
|
+
spaceAfter?: number;
|
|
554
|
+
lineSpacing?: number;
|
|
555
|
+
lineSpacingRule?: string;
|
|
556
|
+
numPr?: {
|
|
557
|
+
numId?: number;
|
|
558
|
+
ilvl?: number;
|
|
559
|
+
};
|
|
560
|
+
};
|
|
561
|
+
hasSelection: boolean;
|
|
562
|
+
isMultiParagraph: boolean;
|
|
563
|
+
/** The range belongs to a table-cell story. */
|
|
564
|
+
inTable: boolean;
|
|
565
|
+
/** The range covers exactly one non-pilcrow embed unit. */
|
|
566
|
+
isSingleEmbed: boolean;
|
|
567
|
+
/** Embed discriminator (`image`, `drawing`, …), else `null`. */
|
|
568
|
+
embedKind: string | null;
|
|
569
|
+
/** Convenience flag for a single `image` embed selection. */
|
|
570
|
+
isImage: boolean;
|
|
571
|
+
inInsertion: boolean;
|
|
572
|
+
inDeletion: boolean;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* One tracked insertion, deletion, or paragraph-mark revision read from yrs.
|
|
576
|
+
*
|
|
577
|
+
* @public
|
|
578
|
+
*/
|
|
579
|
+
interface YrsRevisionInfo {
|
|
580
|
+
revisionId: string;
|
|
581
|
+
author: string;
|
|
582
|
+
date: string;
|
|
583
|
+
kind: 'insertion' | 'deletion' | 'pPrIns' | 'pPrDel' | 'pPrChange' | 'trIns' | 'trDel' | 'tableIns' | 'tableDel';
|
|
584
|
+
story: string;
|
|
585
|
+
/** Raw affected text, capped at 80 Unicode code points. */
|
|
586
|
+
preview: string;
|
|
587
|
+
range: YrsStoryRange;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Story-local locator for one native table embed.
|
|
591
|
+
*
|
|
592
|
+
* @public
|
|
593
|
+
*/
|
|
594
|
+
interface YrsTableLoc {
|
|
595
|
+
story: string;
|
|
596
|
+
/** Zero-based table ordinal in the parent story. */
|
|
597
|
+
tableIndex: number;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* One table cell addressed in the resolved rectangular grid.
|
|
601
|
+
*
|
|
602
|
+
* @public
|
|
603
|
+
*/
|
|
604
|
+
interface YrsCellLoc extends YrsTableLoc {
|
|
605
|
+
row: number;
|
|
606
|
+
column: number;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Anchor-cell to head-cell rectangular selection, analogous to PM's
|
|
610
|
+
* `CellSelection` but independent of ProseMirror positions.
|
|
611
|
+
*
|
|
612
|
+
* @public
|
|
613
|
+
*/
|
|
614
|
+
interface YrsTableRange {
|
|
615
|
+
anchor: YrsCellLoc;
|
|
616
|
+
head: YrsCellLoc;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Receipt shared by native table-structure and cell-format operations.
|
|
620
|
+
*
|
|
621
|
+
* @public
|
|
622
|
+
*/
|
|
623
|
+
interface YrsTableReceipt {
|
|
624
|
+
table: YrsTableLoc;
|
|
625
|
+
rows: number;
|
|
626
|
+
columns: number;
|
|
627
|
+
createdStoryIds: string[];
|
|
628
|
+
deletedStoryIds: string[];
|
|
629
|
+
newParaIds: string[];
|
|
630
|
+
deletedTable: boolean;
|
|
631
|
+
revisionIds: string[];
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* OOXML/PM-shaped cell border value passed through to `tcPr.borders`.
|
|
635
|
+
*
|
|
636
|
+
* @public
|
|
637
|
+
*/
|
|
638
|
+
interface YrsCellBorder {
|
|
639
|
+
style: string;
|
|
640
|
+
size?: number;
|
|
641
|
+
color?: {
|
|
642
|
+
rgb: string;
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Complete per-side border object for {@link YrsSession.setCellBorders}.
|
|
647
|
+
*
|
|
648
|
+
* @public
|
|
649
|
+
*/
|
|
650
|
+
type YrsCellBorders = Partial<Record<'top' | 'bottom' | 'left' | 'right' | 'insideH' | 'insideV', YrsCellBorder>>;
|
|
651
|
+
/**
|
|
652
|
+
* One live replica of the yrs editing model. Thin typed wrapper over the
|
|
653
|
+
* wasm `EditSession` — no editing logic on this side of the boundary.
|
|
654
|
+
*/
|
|
655
|
+
interface YrsSession {
|
|
656
|
+
/** The yrs client id this replica writes with. */
|
|
657
|
+
readonly clientId: number;
|
|
658
|
+
/** Register raw sfnt bytes in the session's measurement/display font store. */
|
|
659
|
+
registerFont(bytes: Uint8Array): number;
|
|
660
|
+
/** Clear the session's registered measurement/display fonts. */
|
|
661
|
+
clearFonts(): void;
|
|
662
|
+
/** Measure one paragraph through the session's resident text engine. */
|
|
663
|
+
measureParagraphJson(input: string): string;
|
|
664
|
+
/** Paginate and retain the measured input and Layout in the session. */
|
|
665
|
+
layoutDocumentJson(input: string): string;
|
|
666
|
+
/** Build display primitives against the session's resident font store. */
|
|
667
|
+
buildDisplayListJson(input: string): string;
|
|
668
|
+
/** Build a binary FrameDelta v1 against the last host-applied frame. */
|
|
669
|
+
buildDisplayListFrame(input: string, expectedFrameEpoch: number): Uint8Array;
|
|
670
|
+
/** Apply a collapsed plain-text insertion and return its resident FrameDelta. */
|
|
671
|
+
applyInput(text: string, expectedFrameEpoch: number): Uint8Array;
|
|
672
|
+
/** Apply a collapsed character deletion/paragraph merge and return its resident FrameDelta. */
|
|
673
|
+
applyDelete(direction: 'backward' | 'forward', expectedFrameEpoch: number): Uint8Array;
|
|
674
|
+
/** Instrumented apply used only by opt-in browser performance traces. */
|
|
675
|
+
applyInputProfiled(text: string, expectedFrameEpoch: number): {
|
|
676
|
+
frame: Uint8Array;
|
|
677
|
+
profile: YrsEngineApplyProfile;
|
|
678
|
+
};
|
|
679
|
+
/** Instrumented deletion used only by opt-in browser performance traces. */
|
|
680
|
+
applyDeleteProfiled(direction: 'backward' | 'forward', expectedFrameEpoch: number): {
|
|
681
|
+
frame: Uint8Array;
|
|
682
|
+
profile: YrsEngineApplyProfile;
|
|
683
|
+
};
|
|
684
|
+
/** Snapshot the inputs needed to move resident layout ownership to a worker. */
|
|
685
|
+
residentWorkerSnapshot(): YrsResidentWorkerSnapshot | null;
|
|
686
|
+
/** Resident display-list hit/range queries; results are small JSON records. */
|
|
687
|
+
displayHitTestRegionsJson(pageIndex: number, x: number, y: number): string;
|
|
688
|
+
displayRangeRectsJson(from: number, to: number): string;
|
|
689
|
+
displayRangeRectsRegionJson(region: 'body' | 'header' | 'footer', rId: string, from: number, to: number): string;
|
|
690
|
+
/** Read a glyph outline from the session's resident font store. */
|
|
691
|
+
outlineGlyphJson(fontId: number, glyphId: number): string;
|
|
692
|
+
/** Hydrates from an encoded yrs v1 update (typically a peer's {@link encodeState} output). */
|
|
693
|
+
loadState(update: Uint8Array): void;
|
|
694
|
+
/**
|
|
695
|
+
* Seeds stories from parsed content (S1 scaffold; the real
|
|
696
|
+
* `load(ParsedDocument)` lands with the ops track). Returns paraIds per
|
|
697
|
+
* story in document order.
|
|
698
|
+
*/
|
|
699
|
+
loadStories(stories: readonly YrsStorySeed[]): Record<string, string[]>;
|
|
700
|
+
/** Full document state as one yrs v1 update (Yjs wire format). */
|
|
701
|
+
encodeState(): Uint8Array;
|
|
702
|
+
/** Applies a remote/incremental yrs v1 update. */
|
|
703
|
+
applyUpdate(update: Uint8Array): void;
|
|
704
|
+
/** Apply a same-user worker update under the local undo origin. @internal */
|
|
705
|
+
applyLocalUpdate(update: Uint8Array, story: string): void;
|
|
706
|
+
/**
|
|
707
|
+
* Subscribes to every committed transaction's v1 update (local AND
|
|
708
|
+
* applied-remote). Returns an unsubscribe function.
|
|
709
|
+
*/
|
|
710
|
+
onUpdate(listener: (update: Uint8Array) => void): () => void;
|
|
711
|
+
/** Store this peer's awareness selection as sticky positions. */
|
|
712
|
+
setSelection(anchor: YrsLoc, head?: YrsLoc): void;
|
|
713
|
+
/** Resolve this peer's current sticky selection, or null before initialization. */
|
|
714
|
+
selection(): YrsSelection | null;
|
|
715
|
+
/** Store this peer's rectangular table selection outside the document. */
|
|
716
|
+
setCellSelection(range: YrsTableRange): void;
|
|
717
|
+
/** Resolve the current sticky cell selection, or null before initialization. */
|
|
718
|
+
cellSelection(): YrsTableRange | null;
|
|
719
|
+
/** Lazily begin local-origin undo capture after import/seeding has completed. */
|
|
720
|
+
beginUndoCapture(story: string, includeTableStories?: boolean): void;
|
|
721
|
+
/** Coalesce the stack entries added since `startDepth` into one host undo intent. */
|
|
722
|
+
markUndoGroup(startDepth: number): void;
|
|
723
|
+
/** Undo/redo only local-origin direct operations (never remote/system transactions). */
|
|
724
|
+
undo(): boolean;
|
|
725
|
+
redo(): boolean;
|
|
726
|
+
canUndo(): boolean;
|
|
727
|
+
canRedo(): boolean;
|
|
728
|
+
/** Current local undo/redo stack sizes (zero before tracking starts). */
|
|
729
|
+
undoDepth(): number;
|
|
730
|
+
redoDepth(): number;
|
|
731
|
+
/** Adds a story with one paragraph; the receipt carries its paraId. */
|
|
732
|
+
createStory(storyId: string, initialText: string, pStyle?: string, alignment?: string): YrsParagraphReceipt;
|
|
733
|
+
/** Removes a complete story (including an unreachable table-cell story). */
|
|
734
|
+
deleteStory(storyId: string): void;
|
|
735
|
+
/** Inserts a row above or below the cell that `at` resolves into. */
|
|
736
|
+
insertRow(at: YrsCellLoc, side: 'above' | 'below', suggesting?: YrsAuthor): YrsTableReceipt;
|
|
737
|
+
/** Inserts a rectangular structural table at a paragraph-keyed location. */
|
|
738
|
+
insertTable(at: YrsLoc, rows: number, columns: number, suggesting?: YrsAuthor): YrsTableReceipt;
|
|
739
|
+
/** Inserts a column left or right of the cell that `at` resolves into. */
|
|
740
|
+
insertColumn(at: YrsCellLoc, side: 'left' | 'right'): YrsTableReceipt;
|
|
741
|
+
/** Deletes every row covered by an explicit rectangular cell range. */
|
|
742
|
+
deleteRow(range: YrsTableRange, suggesting?: YrsAuthor): YrsTableReceipt;
|
|
743
|
+
/** Deletes every column covered by an explicit rectangular cell range. */
|
|
744
|
+
deleteColumn(range: YrsTableRange): YrsTableReceipt;
|
|
745
|
+
/** Removes a complete table plus its reachable cell stories. */
|
|
746
|
+
deleteTable(table: YrsTableLoc): YrsTableReceipt;
|
|
747
|
+
/** Merges a rectangular range into its top-left cell. */
|
|
748
|
+
mergeCells(range: YrsTableRange): YrsTableReceipt;
|
|
749
|
+
/** Splits the merged cell covering `at` into one cell per grid slot. */
|
|
750
|
+
splitCell(at: YrsCellLoc, rows?: number, columns?: number): YrsTableReceipt;
|
|
751
|
+
/** Sets or clears the selected cells' background color. */
|
|
752
|
+
setCellShading(range: YrsTableRange, color: string | null): YrsTableReceipt;
|
|
753
|
+
/**
|
|
754
|
+
* Merges an OOXML/PM-shaped patch into selected cells' `tcPr`. JSON `null`
|
|
755
|
+
* clears a property; merge/split-owned span keys are rejected.
|
|
756
|
+
*/
|
|
757
|
+
setCellTextFormat(range: YrsTableRange, patch: Readonly<Record<string, unknown>>): YrsTableReceipt;
|
|
758
|
+
/** Replaces the complete selected-cell border property object. */
|
|
759
|
+
setCellBorders(range: YrsTableRange, borders: YrsCellBorders): YrsTableReceipt;
|
|
760
|
+
/** Sets one authored grid-column width in twips. */
|
|
761
|
+
setColumnWidth(at: YrsCellLoc, widthTwips: number): YrsTableReceipt;
|
|
762
|
+
/** Sets the table-wide preferred width in twips. */
|
|
763
|
+
setTableWidth(table: YrsTableLoc, widthTwips: number): YrsTableReceipt;
|
|
764
|
+
/** Inserts paragraph-break-free text. Suggesting mode mints a revision. */
|
|
765
|
+
insertText(at: YrsLoc, text: string, suggesting?: YrsAuthor): YrsRevisionReceipt;
|
|
766
|
+
/**
|
|
767
|
+
* Deletes a range (plain) or marks it as a suggested deletion (suggesting).
|
|
768
|
+
* A range spanning paragraphs also merges them (pilcrow-as-character).
|
|
769
|
+
*/
|
|
770
|
+
deleteRange(range: YrsStoryRange, suggesting?: YrsAuthor): YrsRevisionReceipt;
|
|
771
|
+
/** Replaces a range with text in one transaction (one shared revision when suggesting). */
|
|
772
|
+
replaceRange(range: YrsStoryRange, text: string, suggesting?: YrsAuthor): YrsRevisionReceipt;
|
|
773
|
+
/**
|
|
774
|
+
* Splits a paragraph by inserting one pilcrow. The FIRST half keeps the
|
|
775
|
+
* original paraId; the SECOND half is re-minted (`secondParaId`).
|
|
776
|
+
*/
|
|
777
|
+
splitParagraph(at: YrsLoc, suggesting?: YrsAuthor): YrsSplitReceipt;
|
|
778
|
+
/** Merges `paraId` with the FOLLOWING paragraph. Errors on the final paragraph. */
|
|
779
|
+
mergeParagraphs(story: string, paraId: string, suggesting?: YrsAuthor): YrsRevisionReceipt;
|
|
780
|
+
/** Toggles one run mark across a range (PM toggleMark range semantics). */
|
|
781
|
+
toggleMark(range: YrsStoryRange, mark: YrsRunMark): void;
|
|
782
|
+
/** Applies set-valued direct formatting; omitted fields are kept and `null` fields clear. */
|
|
783
|
+
formatRange(range: YrsStoryRange, delta: YrsInlineFormatDelta): void;
|
|
784
|
+
/** Sets or clears the protected hyperlink attribute over a non-empty range. */
|
|
785
|
+
setHyperlink(range: YrsStoryRange, hyperlink: YrsHyperlinkAttrs | null): void;
|
|
786
|
+
/** Clears direct formatting while retaining hyperlinks and tracked-change stamps. */
|
|
787
|
+
clearFormatting(range: YrsStoryRange): void;
|
|
788
|
+
/** Applies a paragraph style id to every paragraph intersecting the range. */
|
|
789
|
+
applyParagraphStyle(range: YrsStoryRange, styleId: string, suggesting?: YrsAuthor): void;
|
|
790
|
+
/** Applies tri-state paragraph properties to every paragraph intersecting the range. */
|
|
791
|
+
setParagraphAttrs(range: YrsStoryRange, attrs: YrsParagraphAttrs, suggesting?: YrsAuthor): void;
|
|
792
|
+
/** Inserts one inline image embed, optionally as a tracked insertion. */
|
|
793
|
+
insertImage(at: YrsLoc, image: Readonly<Record<string, unknown>>, suggesting?: YrsAuthor): YrsRevisionReceipt;
|
|
794
|
+
/** Sets the authored value on a content-control embed addressed by stable payload id. */
|
|
795
|
+
setContentControlValue(embedId: string, value: YrsContentControlValue): void;
|
|
796
|
+
/** Sets a content-control value at a paragraph-keyed embed position. */
|
|
797
|
+
setContentControlValueAt(at: YrsLoc, value: YrsContentControlValue): void;
|
|
798
|
+
/** Removes the authored value from a content-control embed. */
|
|
799
|
+
clearContentControlValue(embedId: string): void;
|
|
800
|
+
/** Commits image size/wrapping/position fields in one transaction. */
|
|
801
|
+
setImageGeometry(embedId: string, geometry: YrsImageGeometry): void;
|
|
802
|
+
/** Inserts a native page-break embed at a paragraph-keyed location. */
|
|
803
|
+
insertPageBreak(at: YrsLoc): void;
|
|
804
|
+
/** Inserts a native section-break embed at a paragraph-keyed location. */
|
|
805
|
+
insertSectionBreak(at: YrsLoc, type: 'nextPage' | 'continuous' | 'oddPage' | 'evenPage'): void;
|
|
806
|
+
/** Inserts a typed watermark embed at a paragraph-keyed location. */
|
|
807
|
+
insertWatermark(at: YrsLoc, watermark: YrsWatermark): void;
|
|
808
|
+
/**
|
|
809
|
+
* Applies a batch of raw story mirror ops in one transaction — the coexistence
|
|
810
|
+
* bridge's mirror-into-yrs path (a faithful mirror of lowered PM state, not a
|
|
811
|
+
* user-intent op). Not for direct app use.
|
|
812
|
+
*/
|
|
813
|
+
applyRawOps(story: string, ops: readonly YrsRawOp[]): void;
|
|
814
|
+
/** Sets one paragraph property (any JSON value). `paraId` is reserved. */
|
|
815
|
+
setParagraphAttr(paraId: string, key: string, value: unknown): void;
|
|
816
|
+
/** Adds a sticky-anchored comment over one or more ranges. */
|
|
817
|
+
addComment(ranges: readonly YrsStoryRange[], author: string, date: string, body: unknown): YrsCommentReceipt;
|
|
818
|
+
/**
|
|
819
|
+
* Accepts tracked changes (S4b): pending insertions become plain content,
|
|
820
|
+
* pending deletions are carried out; a `pPrIns` paragraph mark clears (the
|
|
821
|
+
* split stays), a `pPrDel` mark joins with the following paragraph (whose
|
|
822
|
+
* pPr survives — Word's surviving-`w:p` rule). Resolving never stamps a new
|
|
823
|
+
* revision. Throws on an unknown revision id.
|
|
824
|
+
*/
|
|
825
|
+
acceptChange(target: YrsChangeTarget): YrsResolveReceipt;
|
|
826
|
+
/**
|
|
827
|
+
* Rejects tracked changes — the inverse of {@link acceptChange}: pending
|
|
828
|
+
* insertions roll back, pending deletions restore their text; a `pPrIns`
|
|
829
|
+
* mark joins back with the following paragraph, a `pPrDel` mark clears.
|
|
830
|
+
*/
|
|
831
|
+
rejectChange(target: YrsChangeTarget): YrsResolveReceipt;
|
|
832
|
+
/** Aggregate toolbar/a11y state from yrs over one paragraph-addressed range. */
|
|
833
|
+
selectionContext(range: YrsStoryRange): YrsSelectionContext;
|
|
834
|
+
/** Enumerate tracked changes across every story in deterministic order. */
|
|
835
|
+
listRevisions(): YrsRevisionInfo[];
|
|
836
|
+
/** Current offsets of a comment's sticky anchors. Throws when an anchor no longer resolves. */
|
|
837
|
+
resolveComment(commentId: string): YrsResolvedCommentAnchor[];
|
|
838
|
+
/** Story ids in the document, sorted. */
|
|
839
|
+
storyIds(): string[];
|
|
840
|
+
/** Story length in UTF-16 units (every embed, pilcrows included, counts 1). */
|
|
841
|
+
storyLength(story: string): number;
|
|
842
|
+
/**
|
|
843
|
+
* The story's `canonical-stream-v1` FNV-1a checksum. The coexistence watchdog
|
|
844
|
+
* compares it against the PM projector's checksum after every mirrored edit.
|
|
845
|
+
*/
|
|
846
|
+
storyChecksum(story: string): bigint;
|
|
847
|
+
/**
|
|
848
|
+
* Lowers a story straight to the renderer's `LayoutBlock[]` — the
|
|
849
|
+
* yrs-authoritative render path (the eventual replacement for
|
|
850
|
+
* `toLayoutBlocks(pmDoc)`). Throws with an unsupported-embed message on any
|
|
851
|
+
* non-native content (opaque blobs) until that class is promoted to native.
|
|
852
|
+
* The return is the layout pipeline's `LayoutBlock[]` (kept as `unknown[]` to
|
|
853
|
+
* keep this facade decoupled from the layout types).
|
|
854
|
+
*/
|
|
855
|
+
yrsBlocksForStory(story: string, env?: YrsRenderEnv): unknown[];
|
|
856
|
+
/** Paragraph snapshots in document order. */
|
|
857
|
+
paragraphs(story: string): YrsParagraph[];
|
|
858
|
+
/** Paragraph ids and inline-unit lengths, resolved in one Rust story traversal. */
|
|
859
|
+
paragraphSpans(story: string): YrsParagraphLength[];
|
|
860
|
+
/** The raw formatted-segment view (the render bridge's input). */
|
|
861
|
+
storySegments(story: string): YrsStorySegment[];
|
|
862
|
+
/** A paragraph's story span (start unit, pilcrow index). */
|
|
863
|
+
locateParagraph(story: string, paraId: string): YrsParagraphSpan;
|
|
864
|
+
/** Drops the observer and frees the wasm-side replica. Idempotent. */
|
|
865
|
+
destroy(): void;
|
|
866
|
+
}
|
|
867
|
+
/** Options for {@link createYrsSession}. */
|
|
868
|
+
interface CreateYrsSessionOptions {
|
|
869
|
+
/**
|
|
870
|
+
* The yrs client id (non-negative safe integer). Omit to allocate a random
|
|
871
|
+
* 32-bit id, yjs-style.
|
|
872
|
+
*/
|
|
873
|
+
clientId?: number;
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Creates a yrs editing replica. The first call dynamically imports and
|
|
877
|
+
* initializes the embedded docx-edit wasm (~440KB base64) — callers must
|
|
878
|
+
* load it lazily so non-editor consumers avoid the wasm startup cost.
|
|
879
|
+
*/
|
|
880
|
+
declare function createYrsSession(options?: CreateYrsSessionOptions): Promise<YrsSession>;
|
|
881
|
+
|
|
882
|
+
export { type CreateYrsSessionOptions, type ResidentEngineOffscreenPage, type ResidentEngineWorkerApplyResult, ResidentEngineWorkerClient, type ResidentEngineWorkerFrame, type YrsAuthor, type YrsCellBorder, type YrsCellBorders, type YrsCellLoc, type YrsChangeTarget, type YrsCommentReceipt, type YrsContentControlValue, type YrsEngineApplyProfile, type YrsHyperlinkAttrs, type YrsImageGeometry, type YrsInlineFormatDelta, type YrsInputParagraphSeed, type YrsInputParagraphSpan, type YrsInputPositionMap, type YrsLoc, type YrsNumberingProperties, type YrsParaOffset, type YrsParagraph, type YrsParagraphAttrs, type YrsParagraphLength, type YrsParagraphReceipt, type YrsParagraphSeed, type YrsParagraphSpan, type YrsParagraphTabStop, type YrsRawOp, type YrsRenderEnv, type YrsResidentWorkerSnapshot, type YrsResolveReceipt, type YrsResolvedCommentAnchor, type YrsRevisionInfo, type YrsRevisionReceipt, type YrsRunMark, type YrsSelection, type YrsSelectionContext, type YrsSession, type YrsSplitReceipt, type YrsStoryRange, type YrsStorySeed, type YrsStorySegment, type YrsTableLoc, type YrsTableRange, type YrsTableReceipt, type YrsTextColor, type YrsTriState, type YrsWatermark, canUseResidentEngineWorker, compareYrsLocs, createYrsInputPositionMap, createYrsSession, displayPositionToYrsLoc, documentToYrs, yrsLocToDisplayPosition, yrsToDocument };
|