@sametalmdr/word-editor 0.2.0-alpha → 0.3.0-alpha
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/CHANGELOG.md +108 -70
- package/LICENSE +21 -21
- package/README.md +286 -247
- package/dist/canvas/box-clipboard.js +238 -238
- package/dist/canvas/box-selection.js +80 -80
- package/dist/canvas/canvas-editor.js +502 -502
- package/dist/canvas/controller.js +717 -717
- package/dist/canvas/geometry.js +131 -131
- package/dist/canvas/gesture.d.ts +0 -1
- package/dist/canvas/gesture.js +289 -289
- package/dist/canvas/handles.js +212 -212
- package/dist/canvas/menu.js +82 -82
- package/dist/canvas/mode-controller.js +81 -81
- package/dist/canvas/nudge.js +108 -108
- package/dist/canvas/overlay.js +149 -149
- package/dist/canvas/snap.js +132 -132
- package/dist/canvas/viewport.js +112 -112
- package/dist/canvas/z-order.js +171 -171
- package/dist/commands/alignment.js +150 -150
- package/dist/commands/box.js +272 -272
- package/dist/commands/clipboard.js +93 -93
- package/dist/commands/graphemes.js +112 -112
- package/dist/commands/marks.js +153 -153
- package/dist/commands/paragraph-props.js +176 -176
- package/dist/commands/size.js +368 -368
- package/dist/commands/text.js +291 -291
- package/dist/docx.d.ts +1 -0
- package/dist/docx.js +15 -13
- package/dist/editor/editing-host.js +434 -434
- package/dist/element.js +41 -41
- package/dist/fonts/OFL-Carlito.txt +94 -0
- package/dist/fonts/calibri-metrics.d.ts +27 -0
- package/dist/fonts/calibri-metrics.js +88 -0
- package/dist/history/history.js +433 -433
- package/dist/index.js +63 -63
- package/dist/input/beforeinput.js +224 -224
- package/dist/input/clipboard.js +107 -107
- package/dist/input/composition.js +341 -341
- package/dist/input/keymap.js +54 -54
- package/dist/io/ooxml/custgeom.js +72 -72
- package/dist/io/ooxml/drawingml.js +232 -232
- package/dist/io/ooxml/edits.js +67 -67
- package/dist/io/ooxml/export-splice.js +880 -880
- package/dist/io/ooxml/export.js +365 -365
- package/dist/io/ooxml/fill.d.ts +93 -8
- package/dist/io/ooxml/fill.js +618 -562
- package/dist/io/ooxml/fit.d.ts +252 -0
- package/dist/io/ooxml/fit.js +598 -0
- package/dist/io/ooxml/import-gate.js +200 -200
- package/dist/io/ooxml/import.js +691 -691
- package/dist/io/ooxml/inflate.js +126 -126
- package/dist/io/ooxml/media.js +87 -87
- package/dist/io/ooxml/ns.d.ts +2 -0
- package/dist/io/ooxml/ns.js +26 -21
- package/dist/io/ooxml/numbering.js +290 -290
- package/dist/io/ooxml/opc-write.js +171 -171
- package/dist/io/ooxml/provenance.js +93 -93
- package/dist/io/ooxml/recipe.js +708 -708
- package/dist/io/ooxml/relationships.js +59 -59
- package/dist/io/ooxml/run-fonts.d.ts +89 -0
- package/dist/io/ooxml/run-fonts.js +378 -0
- package/dist/io/ooxml/slots.d.ts +4 -0
- package/dist/io/ooxml/slots.js +582 -581
- package/dist/io/ooxml/styles-resolve.js +257 -257
- package/dist/io/ooxml/units.js +43 -43
- package/dist/io/ooxml/value.js +120 -120
- package/dist/io/ooxml/xml-scan.js +616 -616
- package/dist/io/ooxml/zip-container.js +228 -228
- package/dist/io/ooxml/zip-reject.js +106 -106
- package/dist/measure/placement.js +83 -83
- package/dist/measure/report.js +75 -75
- package/dist/model/ids.js +70 -70
- package/dist/model/normalize.js +146 -146
- package/dist/model/position.js +283 -283
- package/dist/model/transaction.js +209 -209
- package/dist/platform/capabilities.js +25 -25
- package/dist/react/index.js +21 -21
- package/dist/selection/controller.js +315 -315
- package/dist/selection/dom-map.js +334 -334
- package/dist/state/editor-state.js +109 -109
- package/dist/styles.css +66 -66
- package/package.json +94 -93
package/dist/io/ooxml/fill.d.ts
CHANGED
|
@@ -27,18 +27,23 @@ export function expectedTagProblems(tags: TagInfo[], expectedTags: readonly stri
|
|
|
27
27
|
* @returns {Problem[]}
|
|
28
28
|
*/
|
|
29
29
|
export function multilineProblems(tags: TagInfo[], multiline: readonly string[]): Problem[];
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {object} ReadOptions
|
|
32
|
+
* @property {string[] | undefined} expectedTags
|
|
33
|
+
* @property {string[] | undefined} multiline
|
|
34
|
+
* @property {Record<string, unknown>} given the options object as passed ({} when undefined), for keys a caller adds
|
|
35
|
+
* @property {Problem[]} problems
|
|
36
|
+
*/
|
|
30
37
|
/**
|
|
31
38
|
* Validates the options object: `expectedTags` and `multiline`, each an
|
|
32
|
-
* array of strings
|
|
39
|
+
* array of strings, plus whatever other keys the caller accepts (checkFit's
|
|
40
|
+
* `capacity`, which it reads itself); any other key is UNKNOWN_OPTION.
|
|
33
41
|
* @param {string} where
|
|
34
42
|
* @param {unknown} options
|
|
35
|
-
* @
|
|
43
|
+
* @param {readonly string[]} [accepted]
|
|
44
|
+
* @returns {ReadOptions}
|
|
36
45
|
*/
|
|
37
|
-
export function readOptions(where: string, options: unknown):
|
|
38
|
-
expectedTags: string[] | undefined;
|
|
39
|
-
multiline: string[] | undefined;
|
|
40
|
-
problems: Problem[];
|
|
41
|
-
};
|
|
46
|
+
export function readOptions(where: string, options: unknown, accepted?: readonly string[]): ReadOptions;
|
|
42
47
|
/**
|
|
43
48
|
* Reads the filled output back. Throws a plain Error — a failure here is a
|
|
44
49
|
* bug in the engine, never in the template or the data. Exported for its own
|
|
@@ -69,6 +74,47 @@ export function fillDocumentXml(xmlBytes: Uint8Array, data: FillData, options?:
|
|
|
69
74
|
xml: Uint8Array;
|
|
70
75
|
report: FillReport;
|
|
71
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* @typedef {object} PreparedFill everything a fill decides before it writes a byte
|
|
79
|
+
* @property {Record<string, unknown>} record the data
|
|
80
|
+
* @property {import("./slots.js").ScanResult} scan
|
|
81
|
+
* @property {TagInfo[]} tags
|
|
82
|
+
* @property {Set<string>} multilineSet
|
|
83
|
+
* @property {Map<string, string>} valueOf tag -> value as written ("" for null)
|
|
84
|
+
* @property {string[]} empty tags with an empty value, in document order
|
|
85
|
+
* @property {string[]} order tag names in document order of their first occurrence
|
|
86
|
+
* @property {Problem[]} warnings
|
|
87
|
+
* @property {ReadOptions} options
|
|
88
|
+
*/
|
|
89
|
+
/**
|
|
90
|
+
* Every check a fill makes before writing: the data's shape, the template's
|
|
91
|
+
* problems, the options', the expected tag set's, each value's. Throws ONE
|
|
92
|
+
* TemplateError (named for `where`) with all of them. fillTemplate and
|
|
93
|
+
* checkFit both go through here, so they refuse exactly the same inputs
|
|
94
|
+
* (ADR-0042 Karar 2).
|
|
95
|
+
* @param {string} where the public function's name
|
|
96
|
+
* @param {import("./xml-scan.js").XmlElement} root
|
|
97
|
+
* @param {Uint8Array} xmlBytes
|
|
98
|
+
* @param {unknown} data
|
|
99
|
+
* @param {unknown} rawOptions
|
|
100
|
+
* @param {Problem[]} extraProblems the package layer's other-part findings
|
|
101
|
+
* @param {readonly string[]} [accepted] option keys the caller accepts (readOptions)
|
|
102
|
+
* @param {(options: ReadOptions) => Problem[]} [ownOptionProblems] the caller's check of its own keys, run
|
|
103
|
+
* right after the shared ones so its problems join the same TemplateError
|
|
104
|
+
* @returns {PreparedFill}
|
|
105
|
+
*/
|
|
106
|
+
export function prepareFill(where: string, root: import("./xml-scan.js").XmlElement, xmlBytes: Uint8Array, data: unknown, rawOptions: unknown, extraProblems: Problem[], accepted?: readonly string[], ownOptionProblems?: (options: ReadOptions) => Problem[]): PreparedFill;
|
|
107
|
+
/**
|
|
108
|
+
* Reads the package: word/document.xml parsed, and every other XML part
|
|
109
|
+
* checked for braces (ADR-0037 Karar 6 — the engine fills only the main
|
|
110
|
+
* document, so a tag anywhere else would ship unfilled). An unreadable zip
|
|
111
|
+
* or XML part is PACKAGE_UNREADABLE.
|
|
112
|
+
* @param {string} where
|
|
113
|
+
* @param {unknown} bytes
|
|
114
|
+
* @param {readonly string[]} [keep] part names whose inflated bytes the caller needs (checkFit: styles, settings, theme)
|
|
115
|
+
* @returns {Promise<TemplatePackage>}
|
|
116
|
+
*/
|
|
117
|
+
export function readTemplatePackage(where: string, bytes: unknown, keep?: readonly string[]): Promise<TemplatePackage>;
|
|
72
118
|
/**
|
|
73
119
|
* What a template holds: its tags with their boxes and pages, every problem
|
|
74
120
|
* that would stop a fill, and the warnings. Template problems are reported,
|
|
@@ -114,7 +160,7 @@ export function fillTemplate(bytes: Uint8Array, data: FillData, options?: FillOp
|
|
|
114
160
|
report: FillReport;
|
|
115
161
|
}>;
|
|
116
162
|
/** The package version this engine ships in; a test holds it equal to package.json. */
|
|
117
|
-
export const ENGINE_VERSION: "0.
|
|
163
|
+
export const ENGINE_VERSION: "0.3.0-alpha";
|
|
118
164
|
/**
|
|
119
165
|
* @typedef {import("./slots.js").TemplateProblem & {index?: number, codePoint?: number, count?: number, type?: string}} Problem
|
|
120
166
|
*/
|
|
@@ -162,6 +208,41 @@ export class TemplateError extends Error {
|
|
|
162
208
|
/** @type {Problem[]} */
|
|
163
209
|
problems: Problem[];
|
|
164
210
|
}
|
|
211
|
+
export type ReadOptions = {
|
|
212
|
+
expectedTags: string[] | undefined;
|
|
213
|
+
multiline: string[] | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* the options object as passed ({} when undefined), for keys a caller adds
|
|
216
|
+
*/
|
|
217
|
+
given: Record<string, unknown>;
|
|
218
|
+
problems: Problem[];
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* everything a fill decides before it writes a byte
|
|
222
|
+
*/
|
|
223
|
+
export type PreparedFill = {
|
|
224
|
+
/**
|
|
225
|
+
* the data
|
|
226
|
+
*/
|
|
227
|
+
record: Record<string, unknown>;
|
|
228
|
+
scan: import("./slots.js").ScanResult;
|
|
229
|
+
tags: TagInfo[];
|
|
230
|
+
multilineSet: Set<string>;
|
|
231
|
+
/**
|
|
232
|
+
* tag -> value as written ("" for null)
|
|
233
|
+
*/
|
|
234
|
+
valueOf: Map<string, string>;
|
|
235
|
+
/**
|
|
236
|
+
* tags with an empty value, in document order
|
|
237
|
+
*/
|
|
238
|
+
empty: string[];
|
|
239
|
+
/**
|
|
240
|
+
* tag names in document order of their first occurrence
|
|
241
|
+
*/
|
|
242
|
+
order: string[];
|
|
243
|
+
warnings: Problem[];
|
|
244
|
+
options: ReadOptions;
|
|
245
|
+
};
|
|
165
246
|
export type TemplatePackage = {
|
|
166
247
|
entries: import("./zip-container.js").ZipEntry[];
|
|
167
248
|
main: import("./zip-container.js").ZipEntry;
|
|
@@ -171,6 +252,10 @@ export type TemplatePackage = {
|
|
|
171
252
|
xml: Uint8Array;
|
|
172
253
|
root: import("./xml-scan.js").XmlElement;
|
|
173
254
|
otherPartProblems: Problem[];
|
|
255
|
+
/**
|
|
256
|
+
* the inflated XML parts the caller asked to keep
|
|
257
|
+
*/
|
|
258
|
+
parts: Map<string, Uint8Array>;
|
|
174
259
|
};
|
|
175
260
|
export type Problem = import("./slots.js").TemplateProblem & {
|
|
176
261
|
index?: number;
|