@folijs/docx 0.0.0-stage → 0.3.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.
Files changed (79) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +21 -0
  3. package/README.md +141 -2
  4. package/dist/export/content.d.ts +17 -0
  5. package/dist/export/content.d.ts.map +1 -0
  6. package/dist/export/content.js +165 -0
  7. package/dist/export/content.js.map +1 -0
  8. package/dist/export/index.d.ts +14 -0
  9. package/dist/export/index.d.ts.map +1 -0
  10. package/dist/export/index.js +352 -0
  11. package/dist/export/index.js.map +1 -0
  12. package/dist/export/parts.d.ts +24 -0
  13. package/dist/export/parts.d.ts.map +1 -0
  14. package/dist/export/parts.js +413 -0
  15. package/dist/export/parts.js.map +1 -0
  16. package/dist/export/properties.d.ts +39 -0
  17. package/dist/export/properties.d.ts.map +1 -0
  18. package/dist/export/properties.js +506 -0
  19. package/dist/export/properties.js.map +1 -0
  20. package/dist/export/xmlout.d.ts +63 -0
  21. package/dist/export/xmlout.d.ts.map +1 -0
  22. package/dist/export/xmlout.js +194 -0
  23. package/dist/export/xmlout.js.map +1 -0
  24. package/dist/import/content.d.ts +35 -0
  25. package/dist/import/content.d.ts.map +1 -0
  26. package/dist/import/content.js +370 -0
  27. package/dist/import/content.js.map +1 -0
  28. package/dist/import/index.d.ts +26 -0
  29. package/dist/import/index.d.ts.map +1 -0
  30. package/dist/import/index.js +96 -0
  31. package/dist/import/index.js.map +1 -0
  32. package/dist/import/ooxml.d.ts +38 -0
  33. package/dist/import/ooxml.d.ts.map +1 -0
  34. package/dist/import/ooxml.js +70 -0
  35. package/dist/import/ooxml.js.map +1 -0
  36. package/dist/import/parts.d.ts +35 -0
  37. package/dist/import/parts.d.ts.map +1 -0
  38. package/dist/import/parts.js +365 -0
  39. package/dist/import/parts.js.map +1 -0
  40. package/dist/import/properties.d.ts +50 -0
  41. package/dist/import/properties.d.ts.map +1 -0
  42. package/dist/import/properties.js +403 -0
  43. package/dist/import/properties.js.map +1 -0
  44. package/dist/import/report.d.ts +28 -0
  45. package/dist/import/report.d.ts.map +1 -0
  46. package/dist/import/report.js +42 -0
  47. package/dist/import/report.js.map +1 -0
  48. package/dist/index.d.ts +6 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +6 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/package.d.ts +70 -0
  53. package/dist/package.d.ts.map +1 -0
  54. package/dist/package.js +259 -0
  55. package/dist/package.js.map +1 -0
  56. package/dist/xml.d.ts +79 -0
  57. package/dist/xml.d.ts.map +1 -0
  58. package/dist/xml.js +384 -0
  59. package/dist/xml.js.map +1 -0
  60. package/dist/zip.d.ts +66 -0
  61. package/dist/zip.d.ts.map +1 -0
  62. package/dist/zip.js +356 -0
  63. package/dist/zip.js.map +1 -0
  64. package/package.json +36 -3
  65. package/src/export/content.ts +229 -0
  66. package/src/export/index.ts +445 -0
  67. package/src/export/parts.ts +545 -0
  68. package/src/export/properties.ts +608 -0
  69. package/src/export/xmlout.ts +225 -0
  70. package/src/import/content.ts +413 -0
  71. package/src/import/index.ts +126 -0
  72. package/src/import/ooxml.ts +77 -0
  73. package/src/import/parts.ts +423 -0
  74. package/src/import/properties.ts +504 -0
  75. package/src/import/report.ts +64 -0
  76. package/src/index.ts +24 -0
  77. package/src/package.ts +328 -0
  78. package/src/xml.ts +443 -0
  79. package/src/zip.ts +401 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # @folijs/docx
2
+
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8da5b98: Word documents (schema v3): Foli opens a `.docx`, shows it with the file's own styles on real pages, edits it, and saves it back without losing what it does not edit.
8
+ - **Model** (`@folijs/core`, schema v3, Word-shaped): paragraph properties as attributes (style, justification, indentation, spacing, keep and widow rules, page break before, outline level, numbering, tab stops, borders, shading); run properties as marks (character style, bold, italic, underline styles, strike, font, size, color, highlight, shading, vertical alignment, caps); headings as Word's heading styles; lists as Word's numbering (formats, starts, restarts, levels, legal numbering); sections with their own page size, orientation and margins; styles with `basedOn`, document defaults and the theme in the envelope; tracked insertions and deletions and comment anchors, with the comments; content the model does not hold kept as opaque nodes. Effective formatting and list numbers resolved as Word resolves them. Documents saved by 0.1.0 and 0.2.0 load through a migration without content loss.
9
+ - **DOCX** (`@folijs/docx`, new; browser, worker and Node, no third-party dependencies): `importDocx` to schema v3 with a report of what stayed opaque; `exportDocx` rewriting only the parts the editor owns, so a document saved without edits is the original under a canonical comparison, and parts the editor does not own are written back byte for byte. Checked with Word: every corpus document, exported unchanged and edited, opens without a repair prompt.
10
+ - **View** (`@folijs/view`): `renderDocument` lays a document out read-only on Word-like pages (tracked changes as markup or final); `EditorView` edits on the same pages, each section on pages of its own size and margins, and prints one sheet per page with each section's size. A font the machine lacks falls back to a metric-compatible substitute when one is installed (Carlito, Caladea, Liberation…).
11
+ - **React** (`@folijs/react`): `FoliEditor` and `useFoliEditor` take a document of any version and edit and report it as v3; the toolbar has a style box (the document's paragraph styles, headings included), font, size, line spacing and a page break, with Word-numbered bulleted and numbered lists.
12
+ - **Fidelity with Word** (corpus of five Word-written documents; `corpus/README.md`): 106 of 106 paragraphs start on Word's page and 103 on Word's line; pages scored against Word's PDF at 0.544.
13
+
14
+ Known risks, besides those of 0.2.0 (manual IME, screen-reader and real-paste checks not run): headers, footers, footnotes and floating pictures are kept and exported but not shown; tables are shown from their XML but are not editable or split across pages; page setups and section breaks cannot be edited yet; tracked changes are shown but not recorded, accepted or rejected (Phase 9). See [Known limitations](https://github.com/josep-audenis/foli/blob/main/docs/limitations.md).
15
+
16
+ Breaking (pre-1.0 minor): upgrade every app that reads your documents before saving with 0.3.0, since 0.2.0 cannot read version 3.
17
+ - Documents persist as v3: `FoliChange.document`, `getDocument()` and `useFoliEditor` give v3; `createEditor`, `setDocument` and `FoliEditor`'s `initialContent` take a document of any version (`EditorDocument`) and migrate it.
18
+ - Names: schema v3 takes the plain ones (`FoliDocument`, `parseDocument`, `parseContent`, `schema`, `SCHEMA_VERSION` 3). `createDocument(content?, section?)` makes a v3 document: its content is v3 and its second argument a section in twips (0.2.0's took v2 content and settings in millimetres; both still type-check, so a 0.2.0 call such as `createDocument(htmlToDoc(html))` fails in `createEditor` or gives a wrong page size). v2's are `FoliDocumentV2` and `parseContentV2`, and `htmlToDoc` still returns v2 content; v2's `schema`, `parseDocument` and `SCHEMA_VERSION` are no longer exported (`parseDocument` reads v1 and v2 documents and migrates them). `MARK_TYPES`, `HEADING_LEVELS` and the JSON types such as `DocJSON` still describe v2.
19
+ - Marks follow Word: text color is the `color` mark (`value`), and `highlight` takes a Word color name (the palette is Word's); there is no `textColor` mark. Use `setTextColor`, `setHighlight` and `colorAt(state, "textColor" | "highlight")` rather than `toggleMark` or `isMarkActive` with these marks.
20
+ - Links: `parseDocument` keeps any link target a file has (a `.docx` may hold `file:` links, say), where 0.2.0 rejected unsafe ones. Foli's view only makes a link of a safe target (`isSafeHref`); check it too wherever you turn a document's links into HTML yourself. Commands still refuse an unsafe href.
21
+ - Keyboard: Tab types a tab outside lists, as in Word (in 0.2.0 it moved the focus); Escape, then Tab, moves the focus out of the editor.
22
+ - Lists: `toggleList(kind)` and `wrapInList(kind)` take no attributes; `splitListItem`, `sinkListItem`, `liftListItem` and `liftListItemAtStart` are commands, not factories.
23
+ - On a state without a v3 envelope, `setBlockType` and the list and format commands do not apply.
24
+ - Removed: `insertHorizontalRule` (and `commands.insertHorizontalRule`), `listTypeAt`, the ¶, H1–H3 and rule toolbar buttons (the style box replaces them), and the CSS variables `--foli-font-family`, `--foli-font-size`, `--foli-line-height`, `--foli-link-color`, `--foli-marker-color`, `--foli-rule-color` and `--foli-rule-thickness` (the document's styles set them now).
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [8da5b98]
29
+ - @folijs/core@0.3.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Josep Audenis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,142 @@
1
- # Temporary Holding Version
1
+ # @folijs/docx
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ DOCX for [Foli](https://github.com/josep-audenis/foli): imports a `.docx` into Foli's Word model
4
+ (schema v3 of `@folijs/core`), exports it back losslessly (`exportDocx`), and reads its package
5
+ (zip, parts, content types, relationships) and XML keeping every byte it does not change. No DOM:
6
+ runs in the browser, workers and Node 20.12+. Depends only on `@folijs/core`.
7
+
8
+ > Early release: the API may change in any 0.x minor version (changes in `CHANGELOG.md`).
9
+
10
+ ```ts
11
+ import { importDocx } from "@folijs/docx";
12
+
13
+ const {
14
+ document,
15
+ package: pkg,
16
+ report,
17
+ } = await importDocx(new Uint8Array(await file.arrayBuffer()));
18
+ document.content; // schema v3: paragraphs with Word's properties, runs as text with marks
19
+ document.styles; // with basedOn, run and paragraph properties
20
+ report.opaque; // { "w:tbl": 1, "w:drawing": 1 }: kept verbatim, not editable yet
21
+ ```
22
+
23
+ **Import** (`importDocx`, `importPackage`) reads the main document, styles (with the document
24
+ defaults), numbering, the theme's fonts and colors, comments (with replies and resolved state
25
+ from `commentsExtended`) and sections:
26
+
27
+ - **Paragraphs** with their properties (style, justification, indentation, spacing, keep rules,
28
+ outline level, numbering, tab stops, borders, shading, the paragraph mark's formatting and
29
+ tracked insertion or deletion, formatting changes, section breaks) and their own attributes
30
+ (`w14:paraId`…). **Runs** become text, tabs and breaks with their properties as marks; tracked
31
+ insertions, deletions and moves, hyperlinks (target from the relationship, or a bookmark),
32
+ bookmarks, comment ranges and references are modeled.
33
+ - **Lossless:** every properties element is kept verbatim (`ext` on paragraphs, sections,
34
+ styles, numbering levels and definitions, the document defaults; `runExt` on runs; a comment's
35
+ start tag), and unknown attributes of modeled elements go to attribute bags (paragraphs,
36
+ links, tracked changes, bookmarks and comment anchors: `w16du:dateUtc`, `w14:paraId`…). Every
37
+ element Foli does not model yet (tables, content controls, pictures, fields' structure,
38
+ footnote references, equations…) becomes an opaque node holding its source, and so does an
39
+ element the model rejects as a whole (a tracked change with an id past Word's range, a link in
40
+ a link, a run with an unknown attribute): never stripped to plain text. Export (8.5) writes all
41
+ of it back; keep `package` with the document, the parts Foli does not edit come from it. The
42
+ tests check every attribute of the corpus's document and comments parts is kept.
43
+ - **What Word opens, imports:** each value is checked on its own; one the model cannot hold (out
44
+ of range, a unit such as `1.5cm`, a date without a time) is left out of the model, kept in the
45
+ verbatim element and listed in `report.unmodeled`. A style cycle is broken where it closes, a
46
+ reply that would close a cycle of replies is not kept. Not imported, because Word recomputes
47
+ them or they show nothing: spelling marks (`w:proofErr`), rendered page breaks
48
+ (`w:lastRenderedPageBreak`), editing session ids on runs (`w:rsid*`) and runs with no content:
49
+ counted in `report.dropped`. Import time is linear in the file (crafted files included).
50
+ - **Failures** are `DocxError` (or `ZipError` from the package): a file that is not a
51
+ WordprocessingML document, Strict Open XML (refused until a real file needs it), or an element
52
+ past the model's absolute limits (over 16 MiB kept verbatim).
53
+ - **Not kept exactly**, to be equal under export's canonical comparison: run boundaries
54
+ (adjacent runs with the same properties become one text), `w:cr` (read as a line break),
55
+ `w:noBreakHyphen` and `w:softHyphen` (read as U+2011 and U+00AD), an explicit
56
+ `w:type="textWrapping"` on a break, XML comments, processing instructions and whitespace
57
+ between elements, and the empty paragraph given to an empty body or comment. Text is read as
58
+ Word reads it: without `xml:space="preserve"`, whitespace at the ends of a `w:t` is not text.
59
+
60
+ **Export** (`exportDocx(document, package?)`) writes the parts the editor owns (`document.xml`,
61
+ `styles.xml`, `numbering.xml`, `comments.xml`, `commentsExtended.xml`, and relationships for new
62
+ hyperlink targets) and copies every other part of the original package byte for byte (its
63
+ compressed entry included). Within the parts it writes:
64
+
65
+ - An element read from the file comes back verbatim while its values are what import read from
66
+ it (a paragraph's `w:pPr`, a run's `w:rPr`, a section, a style, a numbering level or
67
+ definition, a comment's start tag). Changed, it is rewritten child by child: unchanged
68
+ properties keep their original element (unknown attributes included), changed ones are
69
+ written from the model, and children Foli does not model stay in the order Word requires.
70
+ Recorded formatting changes inside a style's, a level's, the defaults' or a paragraph mark's
71
+ properties are not modeled: they stay as written.
72
+ - Opaque content, unknown attributes in bags, latent styles, picture bullets and anything else
73
+ the parts hold outside the model come back as they were; styles, definitions and comments the
74
+ editor removed are left out; new ones are added where Word expects them; a part the document
75
+ now needs (numbering, comments, comment threads) is added with its content type and
76
+ relationship. Comments made in the editor that are in a thread get a `w14:paraId`, so their
77
+ replies and resolved state are written.
78
+ - Runs are regrouped from the model: hyperlinks outermost, then insertions (or move
79
+ destinations), deletions (or move sources) with `w:delText`, then runs of equal properties.
80
+ Line ends and vertical tabs in text become breaks, a tab character `w:tab` (read back as a
81
+ `tab` node); a character XML cannot hold (other control characters, lone surrogates) is
82
+ refused with a `DocxError`, never written.
83
+ - Verbatim content (opaque nodes, `ext`, attribute bags) is checked against the part it goes
84
+ into: one element of the expected kind, prefixes the part declares, no attribute the writer
85
+ writes itself. What does not fit is a `DocxError`, never ill-formed XML.
86
+ - Without a package, a new one is made (from a migrated v2 document, say), declaring Word's
87
+ namespaces. A document that refers to parts of its original package (headers, footers,
88
+ pictures, content kept verbatim with relationship ids) needs that package: exporting it
89
+ without one is a `DocxError`.
90
+ - Not written: the theme (read-only in the model: the original part is kept; a new package has
91
+ none, so Word's default applies). Page margins Word requires but the document leaves out are
92
+ written with Word's defaults. A part read as UTF-16 is written as UTF-8, declared so.
93
+
94
+ Checked: the corpus exported without edits equals the original under the canonical comparison
95
+ (`src/testing/canonical.ts`), with every other part, and every unchanged element, byte for byte;
96
+ re-imported, it is the same document; random edits leave every other paragraph identical and
97
+ the edited one's unknown properties in place; Word opens the exports (unchanged, edited, and new
98
+ packages) and finds the reference numbers in the unchanged ones
99
+ (`scripts/corpus/rewrite-corpus.mjs`).
100
+
101
+ The package layer underneath:
102
+
103
+ ```ts
104
+ import { readPackage } from "@folijs/docx";
105
+
106
+ const pkg = await readPackage(new Uint8Array(await file.arrayBuffer()));
107
+ pkg.mainDocument; // "/word/document.xml"
108
+ pkg.relationships(pkg.mainDocument); // [{ id: "rId1", type: ".../styles", partName: "/word/styles.xml", ... }]
109
+ const doc = pkg.xml(pkg.mainDocument); // elements with their offsets in doc.source
110
+ const body = doc.root.children.find((n) => n.kind === "element" && n.local === "body");
111
+
112
+ // Unchanged parts are copied from the original file as stored: written back with no
113
+ // replacements, the package is the identical file.
114
+ const bytes = await pkg.write(new Map([["/word/document.xml", new TextEncoder().encode(edited)]]));
115
+ ```
116
+
117
+ - **Zip:** central directory reader and writer on the platform's `DecompressionStream` and
118
+ `CompressionStream` (`deflate-raw`). Entries keep their headers and compressed data; only
119
+ replaced parts are compressed again (keeping their name bytes). Data descriptors supported;
120
+ encrypted entries, ZIP64 and methods other than stored and deflate are refused. Untrusted
121
+ files are expected: every local header must match its directory record, entries may not
122
+ overlap, an end record counts only with its directory right before it, declared sizes must be
123
+ ones deflate can produce, and every entry's size and CRC-32 is checked while inflating, one
124
+ entry at a time. Limits on entry count and uncompressed size (`maxEntries`, default 10 000;
125
+ `maxSize`, default 512 MiB).
126
+ - **XML:** `parseXml` keeps the source string and every node's offsets (`start`, `end`, and for
127
+ elements `openEnd` and `closeStart`), so content the importer does not understand is written
128
+ back as the exact characters it was read from (attributes also give `valueStart` and
129
+ `valueEnd`). Namespaces resolved (`ns`, reserved prefixes enforced), references decoded, line
130
+ ends and attribute whitespace normalized as XML defines; characters XML forbids, `--` in
131
+ comments and `]]>` in text refused. No DTD: a document type declaration is refused (OOXML
132
+ forbids one), so no entity expansion. Nesting limited (`maxDepth`, default 1000) so code
133
+ walking the tree recursively is safe; linear time in the input.
134
+ - **Package:** part names compare case-insensitively and percent-decoded (never decoding a
135
+ `/`), content types by override then default extension, relationship targets resolved
136
+ against their source part (a target that is a full URI is not a part). The main part must be
137
+ WordprocessingML (document, template, or their macro-enabled kinds). Text parts decode as
138
+ UTF-8 or UTF-16 by byte order mark; invalid bytes throw. Each XML part is parsed once.
139
+
140
+ Errors: `ZipError` (the container), `XmlError` (with the `offset`), `DocxError` (the package,
141
+ naming the part; an XML error is its `cause`). `readPackage` takes the zip limits and
142
+ `maxDepth`.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Schema v3 content back to WordprocessingML: paragraphs, runs grouped by their properties,
3
+ * hyperlinks and tracked changes around them, markers between them, opaque content verbatim.
4
+ */
5
+ import type { NodeJSON } from "@folijs/core";
6
+ import { type Namespaces } from "./xmlout.js";
7
+ export interface WriteContext {
8
+ readonly namespaces: Namespaces;
9
+ /**
10
+ * The relationship id for an external hyperlink target: the link's own when the package
11
+ * still has it with that target, otherwise a new one.
12
+ */
13
+ readonly hyperlink: (href: string, id: string | undefined) => string;
14
+ }
15
+ export declare function blocksXml(blocks: readonly NodeJSON[], context: WriteContext): string;
16
+ export declare function paragraphXml(p: NodeJSON, context: WriteContext): string;
17
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/export/content.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAoC,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,CAAC;CACtE;AAWD,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAOpF;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAIvE"}
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Schema v3 content back to WordprocessingML: paragraphs, runs grouped by their properties,
3
+ * hyperlinks and tracked changes around them, markers between them, opaque content verbatim.
4
+ */
5
+ import { paragraphPropertiesXml, runPropertiesXml, same } from "./properties.js";
6
+ import { bagXml, el, escapeText, fragment } from "./xmlout.js";
7
+ /** Opaque XML as kept, once checked to be one element that fits the part (DocxError otherwise). */
8
+ function verbatim(xml, context) {
9
+ const text = typeof xml === "string" ? xml : "";
10
+ fragment(text, context.namespaces);
11
+ return text;
12
+ }
13
+ export function blocksXml(blocks, context) {
14
+ let out = "";
15
+ for (const block of blocks) {
16
+ if (block.type === "paragraph")
17
+ out += paragraphXml(block, context);
18
+ else if (block.type === "opaqueBlock")
19
+ out += verbatim(block.attrs?.xml, context);
20
+ }
21
+ return out;
22
+ }
23
+ export function paragraphXml(p, context) {
24
+ const attrs = (p.attrs ?? {});
25
+ const own = bagXml(attrs.attributes, context.namespaces);
26
+ return `<w:p${own}>${paragraphPropertiesXml(attrs, context.namespaces)}${inlinesXml(p.content ?? [], context)}</w:p>`;
27
+ }
28
+ const markOf = (node, type) => node.marks?.find((m) => m.type === type);
29
+ /** Consecutive nodes with the same `key`, each run of them given to `write`. */
30
+ function grouped(nodes, key, write) {
31
+ let out = "";
32
+ for (let i = 0; i < nodes.length;) {
33
+ const k = key(nodes[i]);
34
+ let j = i + 1;
35
+ while (j < nodes.length && same(key(nodes[j]), k))
36
+ j++;
37
+ out += write(nodes.slice(i, j), k);
38
+ i = j;
39
+ }
40
+ return out;
41
+ }
42
+ /** Hyperlinks outermost, then insertions (or move destinations), then deletions (or move sources). */
43
+ function inlinesXml(nodes, context) {
44
+ return grouped(nodes, (n) => markOf(n, "link"), (group, link) => {
45
+ const inner = grouped(group, (n) => markOf(n, "insertion"), (g, ins) => wrapChange(ins, "ins", "moveTo", grouped(g, (n) => markOf(n, "deletion"), (g2, del) => wrapChange(del, "del", "moveFrom", runsXml(g2, !!del, context), context)), context));
46
+ return link ? hyperlinkXml(link, inner, context) : inner;
47
+ });
48
+ }
49
+ const CHANGE_ATTRIBUTES = ["w:id", "w:author", "w:date"];
50
+ function wrapChange(mark, local, moveLocal, inner, context) {
51
+ if (!mark)
52
+ return inner;
53
+ const a = (mark.attrs ?? {});
54
+ const name = a.move ? `w:${moveLocal}` : `w:${local}`;
55
+ const open = el(name, {
56
+ "w:id": String(a.id),
57
+ "w:author": String(a.author ?? ""),
58
+ "w:date": a.date,
59
+ }).slice(0, -2);
60
+ return `${open}${bagXml(a.attributes, context.namespaces, CHANGE_ATTRIBUTES)}>${inner}</${name}>`;
61
+ }
62
+ function hyperlinkXml(link, inner, context) {
63
+ const a = (link.attrs ?? {});
64
+ const attributes = { ...(a.attributes ?? {}) };
65
+ const original = attributes["r:id"];
66
+ delete attributes["r:id"];
67
+ // A target: its relationship. None (a relationship the package does not have, read as no
68
+ // target): the original reference as it was.
69
+ const id = typeof a.href === "string" ? context.hyperlink(a.href, original) : original;
70
+ const open = el("w:hyperlink", {
71
+ "r:id": id,
72
+ "w:anchor": a.anchor,
73
+ "w:tooltip": a.tooltip,
74
+ }).slice(0, -2);
75
+ return `${open}${bagXml(attributes, context.namespaces, ["r:id", "w:anchor", "w:tooltip"])}>${inner}</w:hyperlink>`;
76
+ }
77
+ /** Inline nodes that are a run's content (the rest stands between runs). */
78
+ function inRun(node) {
79
+ if (node.type === "opaqueInline")
80
+ return node.attrs?.run === true;
81
+ return ["text", "tab", "hardBreak", "pageBreak", "columnBreak", "commentReference"].includes(node.type);
82
+ }
83
+ const STRUCTURE = new Set(["link", "insertion", "deletion"]);
84
+ /** A run's own properties: its marks without the hyperlink and tracked changes around it. */
85
+ function runMarks(node) {
86
+ return (node.marks ?? []).filter((m) => !STRUCTURE.has(m.type));
87
+ }
88
+ function runsXml(nodes, deleted, context) {
89
+ return grouped(nodes, (n) => (inRun(n) ? runMarks(n) : n), (group) => {
90
+ const first = group[0];
91
+ if (!inRun(first))
92
+ return group.map((n) => markerXml(n, context)).join("");
93
+ const marks = runMarks(first);
94
+ const ext = marks.find((m) => m.type === "runExt")?.attrs?.xml;
95
+ const rPr = runPropertiesXml(marks.filter((m) => m.type !== "runExt"), ext, context.namespaces);
96
+ return `<w:r>${rPr}${group.map((n) => runContentXml(n, deleted, context)).join("")}</w:r>`;
97
+ });
98
+ }
99
+ function markerXml(node, context) {
100
+ const a = (node.attrs ?? {});
101
+ const tag = (name, attrs) => `${el(name, attrs).slice(0, -2)}${bagXml(a.attributes, context.namespaces, Object.keys(attrs))}/>`;
102
+ switch (node.type) {
103
+ case "bookmarkStart":
104
+ return tag("w:bookmarkStart", { "w:id": String(a.id), "w:name": String(a.name ?? "") });
105
+ case "bookmarkEnd":
106
+ return tag("w:bookmarkEnd", { "w:id": String(a.id) });
107
+ case "commentStart":
108
+ return tag("w:commentRangeStart", { "w:id": String(a.id) });
109
+ case "commentEnd":
110
+ return tag("w:commentRangeEnd", { "w:id": String(a.id) });
111
+ case "opaqueInline":
112
+ return verbatim(a.xml, context);
113
+ default:
114
+ return "";
115
+ }
116
+ }
117
+ /**
118
+ * Text as `w:t` (or `w:delText`), with tabs and Word's special hyphens as their elements, and
119
+ * line ends and vertical tabs (Office's line break in pasted text) as breaks.
120
+ */
121
+ function textXml(text, deleted) {
122
+ const name = deleted ? "w:delText" : "w:t";
123
+ let out = "";
124
+ // A vertical tab (U+000B) is a line break, as Office pastes it.
125
+ const lines = text.split(String.fromCharCode(11)).join("\n");
126
+ for (const piece of lines.split(/(\r\n|[\t‑­\n\r])/)) {
127
+ if (piece === "")
128
+ continue;
129
+ if (piece === "\t")
130
+ out += "<w:tab/>";
131
+ else if (piece === "‑")
132
+ out += "<w:noBreakHyphen/>";
133
+ else if (piece === "­")
134
+ out += "<w:softHyphen/>";
135
+ else if (piece === "\n" || piece === "\r" || piece === "\r\n")
136
+ out += "<w:br/>";
137
+ else {
138
+ const preserve = /^\s|\s$/.test(piece) ? ' xml:space="preserve"' : "";
139
+ out += `<${name}${preserve}>${escapeText(piece)}</${name}>`;
140
+ }
141
+ }
142
+ return out;
143
+ }
144
+ function runContentXml(node, deleted, context) {
145
+ const a = (node.attrs ?? {});
146
+ switch (node.type) {
147
+ case "text":
148
+ return textXml(node.text ?? "", deleted);
149
+ case "tab":
150
+ return "<w:tab/>";
151
+ case "hardBreak":
152
+ return el("w:br", { "w:clear": a.clear });
153
+ case "pageBreak":
154
+ return el("w:br", { "w:type": "page" });
155
+ case "columnBreak":
156
+ return el("w:br", { "w:type": "column" });
157
+ case "commentReference":
158
+ return `${el("w:commentReference", { "w:id": String(a.id) }).slice(0, -2)}${bagXml(a.attributes, context.namespaces, ["w:id"])}/>`;
159
+ case "opaqueInline":
160
+ return verbatim(a.xml, context);
161
+ default:
162
+ return "";
163
+ }
164
+ }
165
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/export/content.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE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AAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QAC3C,KAAK,KAAK;YACR,OAAO,UAAU,CAAC;QACpB,KAAK,WAAW;YACd,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,KAA2B,EAAE,CAAC,CAAC;QAClE,KAAK,WAAW;YACd,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAC1C,KAAK,aAAa;YAChB,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5C,KAAK,kBAAkB;YACrB,OAAO,GAAG,EAAE,CAAC,oBAAoB,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;QACrI,KAAK,cAAc;YACjB,OAAO,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Schema v3 to `.docx` (ADR-0005): the parts the editor owns are written from the document
3
+ * (`document.xml`, `styles.xml`, `numbering.xml`, `comments.xml`, `commentsExtended.xml` and
4
+ * the relationships new hyperlinks need); every other part is copied from the original package
5
+ * byte for byte. Without a package, a new one is made.
6
+ */
7
+ import { type FoliDocument } from "@folijs/core";
8
+ import { type DocxPackage } from "../package.js";
9
+ /**
10
+ * The document as a `.docx`. With `original` (the package it was imported from), the parts
11
+ * Foli does not edit come back byte for byte and unchanged elements verbatim.
12
+ */
13
+ export declare function exportDocx(document: FoliDocument, original?: DocxPackage): Promise<Uint8Array>;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/export/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAiB,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAa,KAAK,WAAW,EAAgB,MAAM,eAAe,CAAC;AAkG1E;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,YAAY,EACtB,QAAQ,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,UAAU,CAAC,CAGrB"}