@folijs/docx 0.5.0 → 0.6.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.
- package/CHANGELOG.md +33 -0
- package/README.md +42 -14
- package/dist/export/balance.d.ts +17 -0
- package/dist/export/balance.d.ts.map +1 -0
- package/dist/export/balance.js +111 -0
- package/dist/export/balance.js.map +1 -0
- package/dist/export/content.d.ts +5 -0
- package/dist/export/content.d.ts.map +1 -1
- package/dist/export/content.js +155 -22
- package/dist/export/content.js.map +1 -1
- package/dist/export/controls.d.ts +18 -0
- package/dist/export/controls.d.ts.map +1 -0
- package/dist/export/controls.js +232 -0
- package/dist/export/controls.js.map +1 -0
- package/dist/export/index.d.ts.map +1 -1
- package/dist/export/index.js +214 -18
- package/dist/export/index.js.map +1 -1
- package/dist/export/parts.d.ts +9 -1
- package/dist/export/parts.d.ts.map +1 -1
- package/dist/export/parts.js +56 -2
- package/dist/export/parts.js.map +1 -1
- package/dist/export/pictures.d.ts +3 -0
- package/dist/export/pictures.d.ts.map +1 -1
- package/dist/export/pictures.js +15 -2
- package/dist/export/pictures.js.map +1 -1
- package/dist/export/properties.d.ts.map +1 -1
- package/dist/export/properties.js +56 -2
- package/dist/export/properties.js.map +1 -1
- package/dist/import/content.d.ts +11 -1
- package/dist/import/content.d.ts.map +1 -1
- package/dist/import/content.js +205 -17
- package/dist/import/content.js.map +1 -1
- package/dist/import/controls.d.ts +14 -0
- package/dist/import/controls.d.ts.map +1 -0
- package/dist/import/controls.js +123 -0
- package/dist/import/controls.js.map +1 -0
- package/dist/import/index.d.ts +10 -2
- package/dist/import/index.d.ts.map +1 -1
- package/dist/import/index.js +73 -12
- package/dist/import/index.js.map +1 -1
- package/dist/import/ooxml.d.ts +4 -0
- package/dist/import/ooxml.d.ts.map +1 -1
- package/dist/import/ooxml.js +4 -0
- package/dist/import/ooxml.js.map +1 -1
- package/dist/import/parts.js +1 -1
- package/dist/import/parts.js.map +1 -1
- package/dist/import/properties.d.ts +2 -0
- package/dist/import/properties.d.ts.map +1 -1
- package/dist/import/properties.js +55 -0
- package/dist/import/properties.js.map +1 -1
- package/dist/import/stories.d.ts +19 -0
- package/dist/import/stories.d.ts.map +1 -0
- package/dist/import/stories.js +119 -0
- package/dist/import/stories.js.map +1 -0
- package/dist/settings.d.ts +18 -4
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +173 -26
- package/dist/settings.js.map +1 -1
- package/package.json +3 -3
- package/src/export/balance.ts +113 -0
- package/src/export/content.ts +200 -19
- package/src/export/controls.ts +259 -0
- package/src/export/index.ts +254 -17
- package/src/export/parts.ts +79 -2
- package/src/export/pictures.ts +8 -2
- package/src/export/properties.ts +68 -2
- package/src/import/content.ts +220 -17
- package/src/import/controls.ts +137 -0
- package/src/import/index.ts +84 -11
- package/src/import/ooxml.ts +4 -0
- package/src/import/parts.ts +1 -1
- package/src/import/properties.ts +59 -0
- package/src/import/stories.ts +122 -0
- package/src/settings.ts +191 -27
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content controls written back (ADR-0007). A control keeps the `w:sdtPr` and `w:sdtEndPr` it was
|
|
3
|
+
* read from: what changed is patched child by child, the rest stays byte for byte. A new control
|
|
4
|
+
* gets a whole `w:sdtPr`. A control written twice (an edit split it) gets a new `w:id` the second
|
|
5
|
+
* time; a copy carries none (core drops it), and Word gives it one.
|
|
6
|
+
*/
|
|
7
|
+
import type { ControlJSON } from "@folijs/core";
|
|
8
|
+
import { type Namespaces } from "./xmlout.js";
|
|
9
|
+
export declare class ControlWriter {
|
|
10
|
+
#private;
|
|
11
|
+
readonly controls: Readonly<Record<string, ControlJSON>>;
|
|
12
|
+
constructor(controls: Readonly<Record<string, ControlJSON>>);
|
|
13
|
+
/** What goes before a control's content, in the order `w:sdt` requires. */
|
|
14
|
+
parts(id: string, ns: Namespaces): {
|
|
15
|
+
properties: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=controls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../../src/export/controls.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAOhD,OAAO,EAAiC,KAAK,UAAU,EAAO,MAAM,aAAa,CAAC;AA+LlF,qBAAa,aAAa;;IAOZ,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAApE,YAAqB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,EAKnE;IAOD,2EAA2E;IAC3E,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAexD;CAmBF"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { controlProperties } from "../import/controls.js";
|
|
2
|
+
import { child, elements, W14, W15 } from "../import/ooxml.js";
|
|
3
|
+
import { Recorder } from "../import/report.js";
|
|
4
|
+
import { DocxError } from "../package.js";
|
|
5
|
+
import { same } from "./properties.js";
|
|
6
|
+
import { el, escapeAttribute, fragment, val } from "./xmlout.js";
|
|
7
|
+
/** `w:sdtPr`'s children in the order the schema gives them; the kind's element comes after. */
|
|
8
|
+
const ORDER = [
|
|
9
|
+
"rPr",
|
|
10
|
+
"alias",
|
|
11
|
+
"tag",
|
|
12
|
+
"id",
|
|
13
|
+
"lock",
|
|
14
|
+
"placeholder",
|
|
15
|
+
"temporary",
|
|
16
|
+
"showingPlcHdr",
|
|
17
|
+
"dataBinding",
|
|
18
|
+
"label",
|
|
19
|
+
"tabIndex",
|
|
20
|
+
];
|
|
21
|
+
const ID = /(<[\w.-]+:id\b[^>]*?[\w.-]+:val=")(-?\d+)(")/;
|
|
22
|
+
const itemsXml = (items) => items
|
|
23
|
+
.map((item) => el("w:listItem", {
|
|
24
|
+
"w:displayText": item.display ?? item.value,
|
|
25
|
+
"w:value": item.value,
|
|
26
|
+
}))
|
|
27
|
+
.join("");
|
|
28
|
+
/** An extension's element, its namespace declared on it where the part does not. */
|
|
29
|
+
const extension = (prefix, uri, ns) => ns.prefixes.has(prefix) ? {} : { [`xmlns:${prefix}`]: uri };
|
|
30
|
+
/** The element of a control's kind, as Word writes it. */
|
|
31
|
+
function kindXml(control, ns) {
|
|
32
|
+
switch (control.kind) {
|
|
33
|
+
case "text":
|
|
34
|
+
return el("w:text", control.multiLine ? { "w:multiLine": "1" } : {});
|
|
35
|
+
case "dropDown":
|
|
36
|
+
return el("w:dropDownList", {}, itemsXml(control.items ?? []));
|
|
37
|
+
case "comboBox":
|
|
38
|
+
return el("w:comboBox", {}, itemsXml(control.items ?? []));
|
|
39
|
+
case "date":
|
|
40
|
+
return el("w:date", { "w:fullDate": control.date }, val("dateFormat", control.dateFormat ?? "d MMMM yyyy") +
|
|
41
|
+
val("lid", "en-US") +
|
|
42
|
+
val("storeMappedDataAs", "dateTime") +
|
|
43
|
+
val("calendar", "gregorian"));
|
|
44
|
+
case "checkbox": {
|
|
45
|
+
const glyph = (name, state, code) => el(`w14:${name}`, {
|
|
46
|
+
"w14:val": state?.value ?? code,
|
|
47
|
+
"w14:font": state?.font ?? "MS Gothic",
|
|
48
|
+
});
|
|
49
|
+
return el("w14:checkbox", extension("w14", W14, ns), el("w14:checked", { "w14:val": control.checked ? "1" : "0" }) +
|
|
50
|
+
glyph("checkedState", control.checkedState, "2612") +
|
|
51
|
+
glyph("uncheckedState", control.uncheckedState, "2610"));
|
|
52
|
+
}
|
|
53
|
+
case "picture":
|
|
54
|
+
return el("w:picture");
|
|
55
|
+
case "repeating":
|
|
56
|
+
return el("w15:repeatingSection", extension("w15", W15, ns));
|
|
57
|
+
case "repeatingItem":
|
|
58
|
+
return el("w15:repeatingSectionItem", extension("w15", W15, ns));
|
|
59
|
+
default:
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** The whole `w:sdtPr` of a control that has none yet. */
|
|
64
|
+
function newProperties(control, id, ns) {
|
|
65
|
+
const { placeholder } = control;
|
|
66
|
+
return el("w:sdtPr", {}, val("alias", control.alias) +
|
|
67
|
+
val("tag", control.tag) +
|
|
68
|
+
val("id", id) +
|
|
69
|
+
val("lock", control.lock) +
|
|
70
|
+
(placeholder?.docPart ? el("w:placeholder", {}, val("docPart", placeholder.docPart)) : "") +
|
|
71
|
+
(placeholder?.showing ? el("w:showingPlcHdr") : "") +
|
|
72
|
+
kindXml(control, ns));
|
|
73
|
+
}
|
|
74
|
+
/** The kept `w:sdtPr` with what `control` says differently written into it. */
|
|
75
|
+
function patched(source, pr, control, kept) {
|
|
76
|
+
const edits = [];
|
|
77
|
+
const children = elements(pr);
|
|
78
|
+
const prefix = pr.name.includes(":") ? `${pr.name.split(":")[0]}:` : "";
|
|
79
|
+
const named = (local) => children.find((c) => c.ns === pr.ns && c.local === local);
|
|
80
|
+
/** Where a new child goes: before the first that comes after it. */
|
|
81
|
+
const insertAt = (local) => {
|
|
82
|
+
const rank = ORDER.indexOf(local);
|
|
83
|
+
const next = children.find((c) => {
|
|
84
|
+
const at = c.ns === pr.ns ? ORDER.indexOf(c.local) : -1;
|
|
85
|
+
return at < 0 || at > rank;
|
|
86
|
+
});
|
|
87
|
+
return next ? next.start : pr.closeStart;
|
|
88
|
+
};
|
|
89
|
+
const child1 = (local, value) => {
|
|
90
|
+
const old = named(local);
|
|
91
|
+
const xml = value === undefined ? "" : el(`${prefix}${local}`, { [`${prefix}val`]: value });
|
|
92
|
+
if (old)
|
|
93
|
+
edits.push({ from: old.start, to: old.end, text: xml });
|
|
94
|
+
else if (xml) {
|
|
95
|
+
const at = insertAt(local);
|
|
96
|
+
edits.push({ from: at, to: at, text: xml });
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const isEmptyTag = (element) => element.openEnd === element.end;
|
|
100
|
+
/** `element`'s start tag with attribute `name` set, or gone. */
|
|
101
|
+
const withAttribute = (element, name, value) => {
|
|
102
|
+
const end = isEmptyTag(element) ? element.openEnd - 2 : element.openEnd - 1;
|
|
103
|
+
let tag = source.slice(element.start, end);
|
|
104
|
+
tag = tag.replace(new RegExp(`\\s${name}\\s*=\\s*("[^"]*"|'[^']*')`), "");
|
|
105
|
+
if (value !== undefined)
|
|
106
|
+
tag += ` ${name}="${escapeAttribute(value)}"`;
|
|
107
|
+
edits.push({ from: element.start, to: end, text: tag });
|
|
108
|
+
};
|
|
109
|
+
/** `element` holding `inner` in place of its children (none: `inner` goes first among them). */
|
|
110
|
+
const withChildren = (element, inner, replace = true) => {
|
|
111
|
+
if (isEmptyTag(element))
|
|
112
|
+
edits.push({
|
|
113
|
+
from: element.openEnd - 2,
|
|
114
|
+
to: element.end,
|
|
115
|
+
text: `>${inner}</${element.name}>`,
|
|
116
|
+
});
|
|
117
|
+
else
|
|
118
|
+
edits.push({
|
|
119
|
+
from: element.openEnd,
|
|
120
|
+
to: replace ? element.closeStart : element.openEnd,
|
|
121
|
+
text: inner,
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
if (control.kind !== kept.kind)
|
|
125
|
+
throw new DocxError("A content control cannot change kind");
|
|
126
|
+
if (control.alias !== kept.alias)
|
|
127
|
+
child1("alias", control.alias);
|
|
128
|
+
if (control.tag !== kept.tag)
|
|
129
|
+
child1("tag", control.tag);
|
|
130
|
+
if (control.lock !== kept.lock)
|
|
131
|
+
child1("lock", control.lock);
|
|
132
|
+
const showing = control.placeholder?.showing === true;
|
|
133
|
+
if (showing !== (kept.placeholder?.showing === true)) {
|
|
134
|
+
const old = named("showingPlcHdr");
|
|
135
|
+
if (old)
|
|
136
|
+
edits.push({ from: old.start, to: old.end, text: showing ? `<${old.name}/>` : "" });
|
|
137
|
+
else {
|
|
138
|
+
const at = insertAt("showingPlcHdr");
|
|
139
|
+
edits.push({ from: at, to: at, text: `<${prefix}showingPlcHdr/>` });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const list = named("dropDownList") ?? named("comboBox");
|
|
143
|
+
if (list && !same(control.items, kept.items))
|
|
144
|
+
withChildren(list, itemsXml(control.items ?? []));
|
|
145
|
+
const date = named("date");
|
|
146
|
+
if (date) {
|
|
147
|
+
if (control.date !== kept.date)
|
|
148
|
+
withAttribute(date, `${prefix}fullDate`, control.date);
|
|
149
|
+
if (control.dateFormat !== kept.dateFormat) {
|
|
150
|
+
const format = child(date, "dateFormat");
|
|
151
|
+
const xml = el(`${prefix}dateFormat`, { [`${prefix}val`]: control.dateFormat });
|
|
152
|
+
if (format)
|
|
153
|
+
edits.push({ from: format.start, to: format.end, text: xml });
|
|
154
|
+
else
|
|
155
|
+
withChildren(date, xml, false);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const text = named("text");
|
|
159
|
+
if (text && (control.multiLine ?? false) !== (kept.multiLine ?? false))
|
|
160
|
+
withAttribute(text, `${prefix}multiLine`, control.multiLine ? "1" : undefined);
|
|
161
|
+
const box = children.find((c) => c.ns === W14 && c.local === "checkbox");
|
|
162
|
+
if (box && (control.checked ?? false) !== (kept.checked ?? false)) {
|
|
163
|
+
const checked = elements(box).find((c) => c.ns === W14 && c.local === "checked");
|
|
164
|
+
const name = checked?.name ?? box.name.replace("checkbox", "checked");
|
|
165
|
+
const boxPrefix = name.slice(0, name.indexOf(":") + 1);
|
|
166
|
+
const xml = el(name, { [`${boxPrefix}val`]: control.checked ? "1" : "0" });
|
|
167
|
+
if (checked)
|
|
168
|
+
edits.push({ from: checked.start, to: checked.end, text: xml });
|
|
169
|
+
else
|
|
170
|
+
withChildren(box, xml, false);
|
|
171
|
+
}
|
|
172
|
+
let out = source.slice(pr.start, pr.end);
|
|
173
|
+
// From the end; of two put at one place, the first made ends up first.
|
|
174
|
+
const order = edits.map((edit, i) => ({ edit, i }));
|
|
175
|
+
order.sort((a, b) => b.edit.from - a.edit.from || b.edit.to - a.edit.to || b.i - a.i);
|
|
176
|
+
for (const { edit } of order)
|
|
177
|
+
out = out.slice(0, edit.from - pr.start) + edit.text + out.slice(edit.to - pr.start);
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
export class ControlWriter {
|
|
181
|
+
controls;
|
|
182
|
+
#written = new Set();
|
|
183
|
+
/** Every `w:id` the document's controls hold. */
|
|
184
|
+
#held = new Set();
|
|
185
|
+
/** Above any id Word gives. */
|
|
186
|
+
#nextId = 2_000_000_000;
|
|
187
|
+
constructor(controls) {
|
|
188
|
+
this.controls = controls;
|
|
189
|
+
for (const control of Object.values(controls)) {
|
|
190
|
+
const id = control.ext && ID.exec(control.ext)?.[2];
|
|
191
|
+
if (id)
|
|
192
|
+
this.#held.add(id);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
#freshId() {
|
|
196
|
+
while (this.#held.has(String(this.#nextId)))
|
|
197
|
+
this.#nextId++;
|
|
198
|
+
return this.#nextId++;
|
|
199
|
+
}
|
|
200
|
+
/** What goes before a control's content, in the order `w:sdt` requires. */
|
|
201
|
+
parts(id, ns) {
|
|
202
|
+
if (!Object.hasOwn(this.controls, id))
|
|
203
|
+
throw new DocxError(`Content control ${id.slice(0, 64)} has no properties`);
|
|
204
|
+
const control = this.controls[id];
|
|
205
|
+
let properties = control.ext
|
|
206
|
+
? this.#kept(control, ns)
|
|
207
|
+
: newProperties(control, this.#freshId(), ns);
|
|
208
|
+
// The same control written twice: an edit has separated its parts, and ids are unique.
|
|
209
|
+
if (this.#written.has(id))
|
|
210
|
+
properties = properties.replace(ID, (_, start, _id, end) => `${start}${this.#freshId()}${end}`);
|
|
211
|
+
this.#written.add(id);
|
|
212
|
+
return { properties };
|
|
213
|
+
}
|
|
214
|
+
#kept(control, ns) {
|
|
215
|
+
const { element, source } = fragment(control.ext, ns, "sdt");
|
|
216
|
+
const pr = child(element, "sdtPr");
|
|
217
|
+
const reread = controlProperties(element, { source, report: new Recorder() });
|
|
218
|
+
const end = child(element, "sdtEndPr");
|
|
219
|
+
const after = end ? source.slice(end.start, end.end) : "";
|
|
220
|
+
const whatItSays = (c) => {
|
|
221
|
+
const { ext: _ext, deleted: _deleted, placeholder, ...rest } = c ?? {};
|
|
222
|
+
const { text: _text, ...shown } = placeholder ?? {};
|
|
223
|
+
return { ...rest, placeholder: { ...shown, showing: shown.showing === true } };
|
|
224
|
+
};
|
|
225
|
+
if (reread && same(whatItSays(control), whatItSays(reread)))
|
|
226
|
+
return source.slice(element.openEnd, element.closeStart);
|
|
227
|
+
if (!pr || !reread || pr.openEnd === pr.end)
|
|
228
|
+
return newProperties(control, this.#freshId(), ns) + after;
|
|
229
|
+
return patched(source, pr, control, reread) + after;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../src/export/controls.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAmB,GAAG,EAAE,MAAM,aAAa,CAAC;AAElF,+FAA+F;AAC/F,MAAM,KAAK,GAAG;IACZ,KAAK;IACL,OAAO;IACP,KAAK;IACL,IAAI;IACJ,MAAM;IACN,aAAa;IACb,WAAW;IACX,eAAe;IACf,aAAa;IACb,OAAO;IACP,UAAU;CACX,CAAC;AACF,MAAM,EAAE,GAAG,8CAA8C,CAAC;AAQ1D,MAAM,QAAQ,GAAG,CAAC,KAAwC,EA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CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/export/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/export/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,YAAY,EAGjB,KAAK,YAAY,EAGlB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAa,KAAK,WAAW,EAAgB,MAAM,eAAe,CAAC;AAuK1E,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CACT,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,YAAY,KACnB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,GAAG,UAAU,GAAG,SAAS,CAAC;CAC/D;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,YAAY,EACtB,QAAQ,CAAC,EAAE,WAAW,EACtB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,UAAU,CAAC,CA+CrB"}
|
package/dist/export/index.js
CHANGED
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
* the relationships new hyperlinks need); every other part is copied from the original package
|
|
5
5
|
* byte for byte. Without a package, a new one is made.
|
|
6
6
|
*/
|
|
7
|
-
import { parseDocument } from "@folijs/core";
|
|
8
|
-
import {
|
|
7
|
+
import { parseDocument, } from "@folijs/core";
|
|
8
|
+
import { controlsUsed, noteIds, packageStories } from "../import/index.js";
|
|
9
|
+
import { child, isW, REL, W } from "../import/ooxml.js";
|
|
9
10
|
import { DocxError } from "../package.js";
|
|
10
|
-
import { newSettingsXml, withTrackRevisions } from "../settings.js";
|
|
11
|
+
import { newSettingsXml, withSettings, withTrackRevisions } from "../settings.js";
|
|
12
|
+
import { parseXml } from "../xml.js";
|
|
11
13
|
import { deflateEntry, writeZip } from "../zip.js";
|
|
14
|
+
import { balanced } from "./balance.js";
|
|
12
15
|
import { blocksXml } from "./content.js";
|
|
13
|
-
import { commentsExtendedXml, commentsXml, numberingXml, stylesXml, } from "./parts.js";
|
|
16
|
+
import { commentsExtendedXml, commentsXml, notesXml, numberingXml, stylesXml, wrapPart, } from "./parts.js";
|
|
14
17
|
import { drawingXml, Media, pictureBytes } from "./pictures.js";
|
|
15
|
-
import { sectionXml } from "./properties.js";
|
|
18
|
+
import { same, sectionXml } from "./properties.js";
|
|
16
19
|
import { DEFAULT_NAMESPACES, escapeAttribute, NEW_ROOT_ATTRIBUTES, namespacesOf, } from "./xmlout.js";
|
|
17
20
|
const CT = {
|
|
18
21
|
main: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",
|
|
@@ -21,6 +24,10 @@ const CT = {
|
|
|
21
24
|
comments: "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",
|
|
22
25
|
commentsExtended: "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml",
|
|
23
26
|
settings: "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml",
|
|
27
|
+
header: "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml",
|
|
28
|
+
footer: "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml",
|
|
29
|
+
footnotes: "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",
|
|
30
|
+
endnotes: "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",
|
|
24
31
|
rels: "application/vnd.openxmlformats-package.relationships+xml",
|
|
25
32
|
};
|
|
26
33
|
const encoder = new TextEncoder();
|
|
@@ -74,11 +81,14 @@ class Relationships {
|
|
|
74
81
|
return known;
|
|
75
82
|
return this.add(REL.hyperlink, href, true);
|
|
76
83
|
}
|
|
77
|
-
|
|
84
|
+
/** Adds a relationship; `wanted` is its id (a story's), refused if another has it. */
|
|
85
|
+
add(type, target, external, wanted) {
|
|
86
|
+
if (wanted !== undefined && this.#ids.has(wanted))
|
|
87
|
+
throw new DocxError(`Relationship id ${wanted} is already in use`);
|
|
78
88
|
let n = this.#ids.size + 1;
|
|
79
89
|
while (this.#ids.has(`rId${n}`))
|
|
80
90
|
n++;
|
|
81
|
-
const id = `rId${n}`;
|
|
91
|
+
const id = wanted ?? `rId${n}`;
|
|
82
92
|
this.#ids.add(id);
|
|
83
93
|
this.added.push({ id, type, target, external });
|
|
84
94
|
if (type === REL.hyperlink && external)
|
|
@@ -103,6 +113,7 @@ const REL_IMAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relatio
|
|
|
103
113
|
function contextFor(namespaces, relationships, media, source) {
|
|
104
114
|
return {
|
|
105
115
|
namespaces,
|
|
116
|
+
controls: media.controls,
|
|
106
117
|
hyperlink: (href, id) => relationships.hyperlink(href, id),
|
|
107
118
|
picture: (attrs) => drawingXml(attrs, {
|
|
108
119
|
image: (part, current) => relationships.image(part, relative(source, part), current),
|
|
@@ -125,25 +136,81 @@ function relative(from, to) {
|
|
|
125
136
|
* Foli does not edit come back byte for byte and unchanged elements verbatim.
|
|
126
137
|
*/
|
|
127
138
|
export async function exportDocx(document, original, options = {}) {
|
|
128
|
-
const doc = withThreadIds(parseDocument(document), original);
|
|
139
|
+
const doc = balanced(withThreadIds(parseDocument(document), original), original);
|
|
129
140
|
// Before the app is asked for any picture's bytes.
|
|
130
141
|
const reference = original ? undefined : packageReference(doc);
|
|
131
142
|
if (reference) {
|
|
132
143
|
throw new DocxError(`The document refers to a part of its original package (${reference}): export it with that package`);
|
|
133
144
|
}
|
|
145
|
+
const referenced = noteReferences(doc);
|
|
146
|
+
const read = original && (doc.stories || referenced.modeled.size)
|
|
147
|
+
? packageStories(original)
|
|
148
|
+
: { stories: {}, controls: new Map() };
|
|
149
|
+
const originals = read.stories;
|
|
150
|
+
// A story is unchanged if its tree is, and the controls in it say what they said.
|
|
151
|
+
const unchanged = (id) => Object.hasOwn(originals, id) &&
|
|
152
|
+
same(doc.stories?.[id], originals[id]) &&
|
|
153
|
+
[...controlsUsed(doc.stories?.[id])].every((c) => same(doc.controls?.[c], read.controls.get(c)));
|
|
154
|
+
// Notes the model does not hold (an unknown `w:type`) stay in their part: they count too.
|
|
155
|
+
const inPart = original && referenced.modeled.size ? noteIds(original) : new Set();
|
|
156
|
+
for (const key of referenced.modeled)
|
|
157
|
+
if (!Object.hasOwn(doc.stories ?? {}, key) && !inPart.has(key))
|
|
158
|
+
throw new DocxError(`A note reference has no note: ${key.slice(0, 64)}`);
|
|
134
159
|
// The parts written from the model: their drawings are the document's own.
|
|
135
160
|
const rewritten = original
|
|
136
161
|
? [
|
|
137
162
|
original.mainDocument,
|
|
138
163
|
...original
|
|
139
164
|
.relationships(original.mainDocument)
|
|
140
|
-
.filter((r) => r.
|
|
165
|
+
.filter((r) => r.partName &&
|
|
166
|
+
(r.type === REL.comments ||
|
|
167
|
+
(doc.stories && Object.hasOwn(doc.stories, r.id) && !unchanged(r.id))))
|
|
141
168
|
.map((r) => r.partName),
|
|
142
169
|
]
|
|
143
170
|
: [];
|
|
144
171
|
const bytes = await pictureBytes(doc, original, options.resource);
|
|
145
172
|
const media = new Media(doc, original, bytes, rewritten);
|
|
146
|
-
return original
|
|
173
|
+
return original
|
|
174
|
+
? intoPackage(doc, original, originals, unchanged, referenced.isReferenced, options, media)
|
|
175
|
+
: newPackage(doc, referenced.isReferenced, options, media);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The notes the document refers to, as story ids: `modeled` by `noteReference` nodes. `isReferenced`
|
|
179
|
+
* also says yes to every note of a kind that verbatim XML refers to: which one it means is not
|
|
180
|
+
* worth guessing, and removing a note still referred to makes Word refuse the file.
|
|
181
|
+
*/
|
|
182
|
+
function noteReferences(doc) {
|
|
183
|
+
const modeled = new Set();
|
|
184
|
+
const verbatim = new Set();
|
|
185
|
+
JSON.stringify([doc.content, doc.comments, doc.stories], (key, value) => {
|
|
186
|
+
if (key === "xml" && typeof value === "string")
|
|
187
|
+
for (const [, kind] of value.matchAll(/(foot|end)noteReference/g))
|
|
188
|
+
verbatim.add(`${kind}note`);
|
|
189
|
+
const node = value;
|
|
190
|
+
if (node?.type === "noteReference" && typeof node.attrs?.story === "string")
|
|
191
|
+
modeled.add(node.attrs.story);
|
|
192
|
+
return value;
|
|
193
|
+
});
|
|
194
|
+
return {
|
|
195
|
+
modeled,
|
|
196
|
+
isReferenced: (key) => modeled.has(key) || verbatim.has(key.split(":")[0]),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** `text` if it is a well-formed part whose `w:` content is WordprocessingML; DocxError if not. */
|
|
200
|
+
function checkedPart(name, text) {
|
|
201
|
+
let root;
|
|
202
|
+
try {
|
|
203
|
+
root = parseXml(text).root;
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
throw new DocxError(`${name}: its namespaces do not fit what is written: ${error}`, {
|
|
207
|
+
cause: error,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
for (const child of root.children)
|
|
211
|
+
if (child.kind === "element" && child.prefix === "w" && child.ns !== W)
|
|
212
|
+
throw new DocxError(`${name}: its w: prefix is not WordprocessingML`);
|
|
213
|
+
return text;
|
|
147
214
|
}
|
|
148
215
|
const PARA_ID = "w14:paraId";
|
|
149
216
|
/** A comment's last paragraph's `w14:paraId`: what `commentsExtended` keys its thread state by. */
|
|
@@ -200,7 +267,23 @@ function withThreadIds(doc, pkg) {
|
|
|
200
267
|
}
|
|
201
268
|
return copy;
|
|
202
269
|
}
|
|
203
|
-
|
|
270
|
+
/** A free name for a new part: `/word/header1.xml`, `/word/header2.xml`… */
|
|
271
|
+
function freePart(stem, taken) {
|
|
272
|
+
let n = 1;
|
|
273
|
+
while (taken(`/word/${stem}${n}.xml`))
|
|
274
|
+
n++;
|
|
275
|
+
return `/word/${stem}${n}.xml`;
|
|
276
|
+
}
|
|
277
|
+
const HEADER_FOOTER = {
|
|
278
|
+
header: { root: "w:hdr", rel: REL.header, contentType: CT.header },
|
|
279
|
+
footer: { root: "w:ftr", rel: REL.footer, contentType: CT.footer },
|
|
280
|
+
};
|
|
281
|
+
const NOTES = {
|
|
282
|
+
footnote: { rel: REL.footnotes, contentType: CT.footnotes, name: "/word/footnotes.xml" },
|
|
283
|
+
endnote: { rel: REL.endnotes, contentType: CT.endnotes, name: "/word/endnotes.xml" },
|
|
284
|
+
};
|
|
285
|
+
const NOTE_KINDS = ["footnote", "endnote"];
|
|
286
|
+
async function intoPackage(doc, pkg, originals, unchanged, isReferenced, options, media) {
|
|
204
287
|
const mainName = pkg.mainDocument;
|
|
205
288
|
const main = pkg.xml(mainName);
|
|
206
289
|
const body = child(main.root, "body");
|
|
@@ -261,9 +344,79 @@ async function intoPackage(doc, pkg, options, media) {
|
|
|
261
344
|
if (comments && changedThreads(doc, pkg)) {
|
|
262
345
|
part(REL.commentsExtended, "/word/commentsExtended.xml", CT.commentsExtended, (o) => commentsExtendedXml(doc, o), true);
|
|
263
346
|
}
|
|
347
|
+
// Stories: none in the document (schema v4, or none read) leaves their parts as they are.
|
|
348
|
+
const stories = doc.stories ?? {};
|
|
349
|
+
const ownRelationships = (name, existing) => new Relationships(existing ? pkg.relationships(name) : []);
|
|
350
|
+
const newNames = new Set();
|
|
351
|
+
const writtenStories = new Map();
|
|
352
|
+
for (const [id, story] of Object.entries(stories)) {
|
|
353
|
+
if (story.kind !== "header" && story.kind !== "footer")
|
|
354
|
+
continue;
|
|
355
|
+
const { root, rel, contentType } = HEADER_FOOTER[story.kind];
|
|
356
|
+
const related = pkg.relationships(mainName).find((r) => r.id === id);
|
|
357
|
+
// Only a part this story was read from: an id can name any relationship of the package.
|
|
358
|
+
if (related && (related.type !== rel || !Object.hasOwn(originals, id)))
|
|
359
|
+
throw new DocxError(`Story ${id.slice(0, 64)} has the id of another relationship`);
|
|
360
|
+
if (!related && !/^[A-Za-z_][\w.-]*$/.test(id))
|
|
361
|
+
throw new DocxError(`Not a relationship id: ${id.slice(0, 64)}`);
|
|
362
|
+
const existing = related?.partName ? pkg.part(related.partName) : undefined;
|
|
363
|
+
if (existing && unchanged(id))
|
|
364
|
+
continue;
|
|
365
|
+
const name = existing?.name ?? freePart(story.kind, (n) => !!pkg.part(n) || newNames.has(n));
|
|
366
|
+
const xml = existing ? pkg.xml(existing.name) : undefined;
|
|
367
|
+
const ns = xml ? namespacesOf(xml.root, xml.source) : namespaces;
|
|
368
|
+
const partRels = ownRelationships(name, !!existing);
|
|
369
|
+
const inner = blocksXml(story.content.content ?? [], contextFor(ns, partRels, media, name));
|
|
370
|
+
const text = checkedPart(name, wrapPart(xml && { root: xml.root, source: xml.source }, root, ns, inner));
|
|
371
|
+
// Two relationships can share a part: both stories must then say the same.
|
|
372
|
+
const earlier = writtenStories.get(name);
|
|
373
|
+
if (earlier !== undefined && earlier !== text)
|
|
374
|
+
throw new DocxError(`${name} is shared by stories that differ`);
|
|
375
|
+
writtenStories.set(name, text);
|
|
376
|
+
if (existing)
|
|
377
|
+
set(name, text);
|
|
378
|
+
else {
|
|
379
|
+
newNames.add(name);
|
|
380
|
+
add.push({ name, data: encoder.encode(text), contentType });
|
|
381
|
+
rels.add(rel, relative(mainName, name), false, id);
|
|
382
|
+
}
|
|
383
|
+
if (partRels.added.length)
|
|
384
|
+
writeRelationships(name, partRels);
|
|
385
|
+
}
|
|
386
|
+
for (const kind of NOTE_KINDS) {
|
|
387
|
+
const { rel, contentType, name: defaultName } = NOTES[kind];
|
|
388
|
+
const name = pkg.relationships(mainName).find((r) => r.type === rel)?.partName;
|
|
389
|
+
const held = Object.values(stories).some((s) => s.kind === kind);
|
|
390
|
+
if (!name && !held)
|
|
391
|
+
continue;
|
|
392
|
+
if (name && !doc.stories)
|
|
393
|
+
continue;
|
|
394
|
+
const target = name ?? defaultName;
|
|
395
|
+
if (name && !isW(pkg.xml(name).root, `${kind}s`)) {
|
|
396
|
+
if (held)
|
|
397
|
+
throw new DocxError(`${name} is not a ${kind}s part`);
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
const partRels = ownRelationships(target, !!name);
|
|
401
|
+
const write = (o, ns) => checkedPart(target, notesXml(kind, stories, originals, unchanged, isReferenced, o, {
|
|
402
|
+
...contextFor(ns, partRels, media, target),
|
|
403
|
+
note: kind,
|
|
404
|
+
}));
|
|
405
|
+
part(rel, defaultName, contentType, write, held);
|
|
406
|
+
if (partRels.added.length)
|
|
407
|
+
writeRelationships(target, partRels);
|
|
408
|
+
}
|
|
264
409
|
const { trackRevisions } = options;
|
|
265
|
-
|
|
266
|
-
|
|
410
|
+
const { settings } = doc;
|
|
411
|
+
if (trackRevisions !== undefined || settings) {
|
|
412
|
+
part(REL.settings, "/word/settings.xml", CT.settings, (o) => {
|
|
413
|
+
if (!o)
|
|
414
|
+
return newSettingsXml(!!trackRevisions, settings);
|
|
415
|
+
const source = trackRevisions === undefined
|
|
416
|
+
? o.source
|
|
417
|
+
: withTrackRevisions(o.source, o.root, trackRevisions);
|
|
418
|
+
return settings ? withSettings(source, parseXml(source).root, settings) : source;
|
|
419
|
+
}, !!trackRevisions || !!settings);
|
|
267
420
|
}
|
|
268
421
|
if (rels.added.length)
|
|
269
422
|
writeRelationships(mainName, rels);
|
|
@@ -316,7 +469,7 @@ function changedThreads(doc, pkg) {
|
|
|
316
469
|
return false;
|
|
317
470
|
}
|
|
318
471
|
/** A new package: content types, relationships, the document and the parts it needs. */
|
|
319
|
-
async function newPackage(doc, options, media) {
|
|
472
|
+
async function newPackage(doc, isReferenced, options, media) {
|
|
320
473
|
const rels = new Relationships([]);
|
|
321
474
|
const context = contextFor(DEFAULT_NAMESPACES, rels, media, "/word/document.xml");
|
|
322
475
|
const main = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n<w:document ${NEW_ROOT_ATTRIBUTES}><w:body>${blocksXml(doc.content.content ?? [], context)}${bodySection(doc, DEFAULT_NAMESPACES)}</w:body></w:document>`;
|
|
@@ -331,6 +484,45 @@ async function newPackage(doc, options, media) {
|
|
|
331
484
|
if (doc.numbering.abstracts.length + doc.numbering.instances.length) {
|
|
332
485
|
add("/word/numbering.xml", REL.numbering, CT.numbering, numberingXml(doc, undefined, DEFAULT_NAMESPACES));
|
|
333
486
|
}
|
|
487
|
+
for (const [id, story] of Object.entries(doc.stories ?? {})) {
|
|
488
|
+
if (story.kind !== "header" && story.kind !== "footer")
|
|
489
|
+
continue;
|
|
490
|
+
if (!/^[A-Za-z_][\w.-]*$/.test(id))
|
|
491
|
+
throw new DocxError(`Not a relationship id: ${id.slice(0, 64)}`);
|
|
492
|
+
const { root, rel, contentType } = HEADER_FOOTER[story.kind];
|
|
493
|
+
const name = freePart(story.kind, (n) => parts.some((p) => p.name === n));
|
|
494
|
+
const partRels = new Relationships([]);
|
|
495
|
+
const inner = blocksXml(story.content.content ?? [], contextFor(DEFAULT_NAMESPACES, partRels, media, name));
|
|
496
|
+
parts.push({
|
|
497
|
+
name,
|
|
498
|
+
text: wrapPart(undefined, root, DEFAULT_NAMESPACES, inner),
|
|
499
|
+
contentType,
|
|
500
|
+
});
|
|
501
|
+
rels.add(rel, relative("/word/document.xml", name), false, id);
|
|
502
|
+
if (partRels.added.length)
|
|
503
|
+
parts.push({
|
|
504
|
+
name: relationshipsPartName(name),
|
|
505
|
+
text: partRels.xml(undefined),
|
|
506
|
+
contentType: CT.rels,
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
for (const kind of NOTE_KINDS) {
|
|
510
|
+
const stories = doc.stories ?? {};
|
|
511
|
+
if (!Object.values(stories).some((s) => s.kind === kind))
|
|
512
|
+
continue;
|
|
513
|
+
const { rel, contentType, name } = NOTES[kind];
|
|
514
|
+
const partRels = new Relationships([]);
|
|
515
|
+
add(name, rel, contentType, notesXml(kind, stories, {}, () => false, isReferenced, undefined, {
|
|
516
|
+
...contextFor(DEFAULT_NAMESPACES, partRels, media, name),
|
|
517
|
+
note: kind,
|
|
518
|
+
}));
|
|
519
|
+
if (partRels.added.length)
|
|
520
|
+
parts.push({
|
|
521
|
+
name: relationshipsPartName(name),
|
|
522
|
+
text: partRels.xml(undefined),
|
|
523
|
+
contentType: CT.rels,
|
|
524
|
+
});
|
|
525
|
+
}
|
|
334
526
|
if (doc.comments.length) {
|
|
335
527
|
const commentRels = new Relationships([]);
|
|
336
528
|
add("/word/comments.xml", REL.comments, CT.comments, commentsXml(doc, undefined, contextFor(DEFAULT_NAMESPACES, commentRels, media, "/word/comments.xml")));
|
|
@@ -344,8 +536,8 @@ async function newPackage(doc, options, media) {
|
|
|
344
536
|
add("/word/commentsExtended.xml", REL.commentsExtended, CT.commentsExtended, commentsExtendedXml(doc, undefined));
|
|
345
537
|
}
|
|
346
538
|
}
|
|
347
|
-
if (options.trackRevisions)
|
|
348
|
-
add("/word/settings.xml", REL.settings, CT.settings, newSettingsXml());
|
|
539
|
+
if (options.trackRevisions || doc.settings)
|
|
540
|
+
add("/word/settings.xml", REL.settings, CT.settings, newSettingsXml(!!options.trackRevisions, doc.settings));
|
|
349
541
|
parts.push({
|
|
350
542
|
name: "/word/_rels/document.xml.rels",
|
|
351
543
|
text: rels.xml(undefined),
|
|
@@ -387,11 +579,15 @@ function packageReference(doc) {
|
|
|
387
579
|
const sections = [doc.section, ...(doc.content.content ?? []).map((b) => b.attrs?.section)];
|
|
388
580
|
for (const s of sections) {
|
|
389
581
|
const section = s;
|
|
390
|
-
|
|
582
|
+
const ids = [
|
|
583
|
+
...Object.values(section?.headers ?? {}),
|
|
584
|
+
...Object.values(section?.footers ?? {}),
|
|
585
|
+
];
|
|
586
|
+
if (ids.some((id) => !doc.stories || !Object.hasOwn(doc.stories, id)))
|
|
391
587
|
return "a header or footer";
|
|
392
588
|
}
|
|
393
589
|
let found;
|
|
394
|
-
JSON.stringify([doc.content, doc.comments], (key, value) => {
|
|
590
|
+
JSON.stringify([doc.content, doc.comments, doc.stories], (key, value) => {
|
|
395
591
|
if (!found && key === "xml" && typeof value === "string" && /\sr:[A-Za-z]+="/.test(value))
|
|
396
592
|
found = "content kept verbatim";
|
|
397
593
|
const link = value;
|