@folijs/docx 0.4.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 +59 -0
- package/README.md +95 -15
- 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 +7 -0
- package/dist/export/content.d.ts.map +1 -1
- package/dist/export/content.js +185 -14
- 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 +6 -1
- package/dist/export/index.d.ts.map +1 -1
- package/dist/export/index.js +277 -28
- 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 +69 -2
- package/dist/export/parts.js.map +1 -1
- package/dist/export/pictures.d.ts +54 -0
- package/dist/export/pictures.d.ts.map +1 -0
- package/dist/export/pictures.js +359 -0
- package/dist/export/pictures.js.map +1 -0
- package/dist/export/properties.d.ts +11 -1
- package/dist/export/properties.d.ts.map +1 -1
- package/dist/export/properties.js +57 -3
- package/dist/export/properties.js.map +1 -1
- package/dist/export/tables.d.ts +27 -0
- package/dist/export/tables.d.ts.map +1 -0
- package/dist/export/tables.js +344 -0
- package/dist/export/tables.js.map +1 -0
- package/dist/images.d.ts +21 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +53 -0
- package/dist/images.js.map +1 -0
- package/dist/import/content.d.ts +15 -1
- package/dist/import/content.d.ts.map +1 -1
- package/dist/import/content.js +357 -15
- 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 +76 -13
- 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.d.ts.map +1 -1
- package/dist/import/parts.js +8 -1
- package/dist/import/parts.js.map +1 -1
- package/dist/import/pictures.d.ts +34 -0
- package/dist/import/pictures.d.ts.map +1 -0
- package/dist/import/pictures.js +147 -0
- package/dist/import/pictures.js.map +1 -0
- 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/report.d.ts +6 -0
- package/dist/import/report.d.ts.map +1 -1
- package/dist/import/report.js +5 -0
- package/dist/import/report.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/import/tables.d.ts +31 -0
- package/dist/import/tables.d.ts.map +1 -0
- package/dist/import/tables.js +236 -0
- package/dist/import/tables.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- 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 +240 -15
- package/src/export/controls.ts +259 -0
- package/src/export/index.ts +357 -32
- package/src/export/parts.ts +94 -2
- package/src/export/pictures.ts +411 -0
- package/src/export/properties.ts +69 -3
- package/src/export/tables.ts +386 -0
- package/src/images.ts +60 -0
- package/src/import/content.ts +365 -17
- package/src/import/controls.ts +137 -0
- package/src/import/index.ts +87 -12
- package/src/import/ooxml.ts +4 -0
- package/src/import/parts.ts +14 -1
- package/src/import/pictures.ts +176 -0
- package/src/import/properties.ts +59 -0
- package/src/import/report.ts +11 -0
- package/src/import/stories.ts +122 -0
- package/src/import/tables.ts +267 -0
- package/src/index.ts +1 -0
- package/src/settings.ts +191 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
# @folijs/docx
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- cd343e4: Sections, headers and footers, notes, fields, content controls, find and replace, and PDF, as Word models them: imported, laid out on pages, edited there and written back to `.docx`.
|
|
8
|
+
- **Schema v5** (`@folijs/core`, ADR-0007): `stories` in the envelope (headers, footers, footnotes and endnotes, each a tree of blocks), `controls` (content controls' properties) and `settings` (even and odd headers, note options, `doNotUseHTMLParagraphAutoSpacing`); field markers (`fieldStart`, `fieldCode`, `fieldSeparator`, `fieldEnd`), content control markers (`controlStart`, `controlEnd`; a `controls` attribute on blocks, rows and cells), `noteReference` and `noteMark` nodes; sections gain `columns`, `pageNumbers`, note properties and a tracked setup change (`change`). `SCHEMA_VERSION` 5: v4 documents migrate on load (the version only: what was opaque stays so until the `.docx` is imported again).
|
|
9
|
+
- **Stories and undo** (`@folijs/core`): `editor.story(id)` gives an editor over a header, footer or note; its changes are `StoryStep`s of the body's history (one undo across the document), `EnvelopeStep` for the last section, settings and controls; accept and reject all reach every story.
|
|
10
|
+
- **Sections** (`@folijs/core`, `@folijs/view`, `@folijs/react`): columns (equal and set widths, the line between, column breaks), continuous, next-column and even and odd page sections with Word's blank page, balanced columns above a continuous break; `insertSectionBreak`, `removeSectionBreak`, `setSectionSetup`, `insertColumnBreak`, tracked as Word records them; a Section menu and Page setup dialog.
|
|
11
|
+
- **Headers and footers**: drawn in their margins on every page (first, even and default variants, linked to the previous section, a taller one pushing the text, page fields filled per page), edited in place (double click or the Header menu, Escape returns) with typing, formatting, pictures, tables, undo and tracking; `setDifferentFirstPage`, `setDifferentEvenPages`, `setStoryLinked`.
|
|
12
|
+
- **Footnotes and endnotes**: at their reference's page foot under a separator, continued on the next page, beneath the text or at the end of a section or the document; numbered in Word's formats with restarts (`noteNumbers`, never stored); `insertNote`, `setNoteProperties`, `convertNotes`; deleted with their reference, tracked, carried on the clipboard; edited in place (double click, Shift+Alt+N, the Notes menu and its options dialog).
|
|
13
|
+
- **Fields**: shown with their results, selected and deleted whole, codes hidden or shown (Alt+F9); `updateFields` (`PAGE`, `NUMPAGES`, `SECTIONPAGES`, `DATE`, `TIME`, `REF`, `PAGEREF`, `SEQ`, `TOC` from heading styles with their pages, `MERGEFIELD` from data; F9, Ctrl+A then F9, `view.updateFields`, `view.print()`) returning what it updated and what it left; `fieldsIn`, `insertField`, `insertPageNumber`, `insertDate`, `insertCrossReference`, `insertTableOfContents`; a Fields menu and cross-reference dialog.
|
|
14
|
+
- **Content controls**: plain and rich text, drop-down, combo box, date, check box, picture, repeating sections, with Word's locks, placeholders and what each kind holds; frames, titles, lists, a date picker and check boxes in the view (Alt+Down, Space); `insertControl`, `setControlValue` and `controlValues` (by id or tag), `setControlProperties`, `addRepeatingItem`; a Controls menu and properties dialog.
|
|
15
|
+
- **Navigation**: `findAll`, `replace`, `replaceAll` over the body and every story (match case, whole words, tracked while tracking, one undo step), `insertBookmark`, `renameBookmark`, `deleteBookmark`, `listBookmarks`, `goTo`, `documentOutline`; matches marked with the CSS Custom Highlight API; `FoliNavigation` (find, replace and go to panel, bookmarks dialog, outline), included in `FoliEditor`, with Word's keys (Ctrl+F, Ctrl+H, Ctrl+G, F3, Shift+F3, Ctrl+Shift+F5) and a Navigate menu.
|
|
16
|
+
- **DOCX** (`@folijs/docx`): headers, footers, footnotes and endnotes read and written as stories (unchanged ones byte for byte, new ones with their parts, relationships and content types), complex and simple fields, content controls at every level (properties patched into the kept `w:sdtPr`), sections' columns, page numbers and note properties, `word/settings.xml`'s even and odd headers and note options. Word reads Foli's sections, headers, notes, fields, controls and replacements back (`scripts/corpus/*-roundtrip.mjs`).
|
|
17
|
+
- **PDF** (`@folijs/pdf`, first released): `exportPdf(document, { page, resources, review, styles })` prints Foli's own pages with a headless Chromium page the app supplies (Playwright 1.42+; Puppeteer's page type fits): each section on its own sheet size, fields updated from the pages first, safe links and bookmark links as PDF links, headings as PDF bookmarks, a tagged PDF. The page loads nothing from the network (images and fonts as `data:` URLs only). Against Word's PDFs of the corpus it scores 0.954 over 24 pages.
|
|
18
|
+
- **Pages against Word**: all 158 paragraphs outside tables that the harness compares on Word's page; headers, footers and notes scored with the rest of the page (0.889 over 24 pages on screen).
|
|
19
|
+
|
|
20
|
+
0.5.0 cannot read documents saved by 0.6.0 (schema v5). Known limits are in [Known limitations](https://github.com/josep-audenis/foli/blob/main/docs/limitations.md) (content, finding and going places, print and PDF sections).
|
|
21
|
+
|
|
22
|
+
Changed behaviour (pre-1.0 minor):
|
|
23
|
+
- `.docx` headers, footers and notes import as `stories` (0.5.0 kept them as parts, never shown); note references, fields (`w:fldChar`, `w:instrText`, `w:fldSimple`) and content controls (`w:sdt`) that imported as `opaqueInline` or `opaqueBlock` now import as nodes. A v4 document's opaque content stays opaque until the `.docx` is imported again.
|
|
24
|
+
- Layout: between two paragraphs goes the larger of the first's space after and the second's space before, as in Word's PDFs (0.5.0 added them; they still add up with `w:doNotUseHTMLParagraphAutoSpacing`); a line is as tall as its runs and paragraph mark, not the paragraph style's font; a header or footer taller than its margin pushes the text. Pages break differently than in 0.5.0, closer to Word.
|
|
25
|
+
- `FoliEditor` includes `FoliNavigation` and takes Ctrl+F, Ctrl+H, Ctrl+G, F3, Shift+F3 and Ctrl+Shift+F5 while the focus is in the document or its panels (the browser's own find no longer opens there).
|
|
26
|
+
- `FoliToolbar` shows the Section, Header, Fields, Navigate, Notes and Controls menus.
|
|
27
|
+
- `view.print()` updates every field before printing; the print rules are shared with `exportPdf`.
|
|
28
|
+
- Backspace at a field's edge selects the field first, and a selection crossing a field's markers takes the whole field, as in Word; the caret steps over a field's code.
|
|
29
|
+
- `acceptAllChanges` and `rejectAllChanges` also settle the tracked changes in headers, footers and notes.
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [cd343e4]
|
|
34
|
+
- @folijs/core@0.6.0
|
|
35
|
+
|
|
36
|
+
## 0.5.0
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- 18f838a: Tables and pictures as Word models them: imported, edited on pages and written back to `.docx`.
|
|
41
|
+
- **Schema v4** (`@folijs/core`, ADR-0006): `table`, `tableRow` and `tableCell` nodes with Word's table, row and cell properties (grid, merges, borders, shading, widths, header rows, `cantSplit`), table styles resolved as Word does (conditional formatting for first and last rows and columns, bands), `picture` nodes (inline or floating: `float` with Word's position and wrapping) and the envelope's `resources` (the pictures' images by key: content type, size, a URL or an opted-in `data:` URL; no base64 by default). `SCHEMA_VERSION` 4: v3 documents migrate on load.
|
|
42
|
+
- **Table editing** (`@folijs/core`, `@folijs/view`): cells isolate edits; typing, Enter, Backspace and Delete in cells; Tab and Shift+Tab between cells (Tab in the last cell adds a row); arrows across rows, pages and out of the table; `CellSelection` (drag, Shift+arrows) with copy, cut, paste and delete; commands `insertTable`, `insertRow`, `deleteRows`, `insertColumn`, `deleteColumns`, `deleteTable`, `mergeCells`, `splitCell`, `toggleHeaderRow`, `setTableStyle`, `setCellShading`, `setColumnWidth`; column borders dragged in the view. Rows inserted and deleted while tracking are tracked as Word records them.
|
|
43
|
+
- **Tables on pages** (`@folijs/view`): tables drawn from the model, rows flowed across pages (split at a line, header rows repeated, `cantSplit` kept whole); 277 of the corpus's 280 cell paragraphs on Word's page.
|
|
44
|
+
- **Pictures** (`@folijs/core`, `@folijs/view`): `insertPicture` (alt text required unless decorative, or `{ requireAlt: false }`: pasted and dropped files go in so and are marked), `setPictureSize`, `setPictureAlt`, `selectedPicture`; pictures drawn at their size, selected by a click, resized by a handle with their aspect ratio kept; image files pasted or dropped go through the app's `upload` hook (`EditorViewOptions.upload`, `view.insertFiles`), images shown through `EditorViewOptions.resource`; floating pictures laid out with the text around them (square, top and bottom, behind and in front of text), where Word places them in the corpus. `measureImageFile`, `textWidthEmu` and `EMU_PER_PX` are exported.
|
|
45
|
+
- **React** (`@folijs/react`): `FoliToolbar` gets a Table menu (insert table dialog, rows, columns, merge, split, header row, delete), a table style box, a cell shading menu and a Picture… dialog (insert from a file with alt text; edit a picture's alt text and size); `FoliEditor` and `FoliCanvas` take `upload` and `resource` props, `FoliToolbar` `upload`. Keyboard-usable and axe-clean in Chromium, Firefox and WebKit.
|
|
46
|
+
- **DOCX** (`@folijs/docx`): tables read into the model and written back (unchanged ones as written, changed ones child by child; tracked row changes); inline (`wp:inline`) and floating (`wp:anchor`) pictures read as picture nodes with their images as resources, written back byte for byte when unchanged, new images as media parts from `data:` URLs or `ExportOptions.resource`; `packageImages(pkg)` gives the view URLs for a package's images; `report.picturesWithoutAlt`. Word opens the corpus's tables and pictures exported unchanged and edited.
|
|
47
|
+
|
|
48
|
+
0.4.0 cannot read documents saved by 0.5.0 (schema v4). Known limits are in [Known limitations](https://github.com/josep-audenis/foli/blob/main/docs/limitations.md) (tables and pictures sections).
|
|
49
|
+
|
|
50
|
+
Changed behaviour (pre-1.0 minor):
|
|
51
|
+
- `.docx` tables and drawings that imported as `opaqueBlock` and `opaqueInline` now import as `table` and `picture` nodes; a v3 document's opaque tables stay opaque until the `.docx` is imported again.
|
|
52
|
+
- `exportDocx` needs the bytes of a picture added since import: a `data:` URL resource or `ExportOptions.resource(key, resource)`; without them it throws a `DocxError` (never drops the picture).
|
|
53
|
+
- The editor's pages are `position: relative; isolation: isolate; display: flow-root` (pictures behind and in front of text are positioned against them; a floating picture past the page's text makes the page taller).
|
|
54
|
+
- Inserting or deleting a table while tracking is recorded as tracked rows (0.4.0 did not make the edit), and `deleteComment` and `deleteAllComments` remove comments anchored in tables (0.4.0 kept them: tables were opaque).
|
|
55
|
+
- `FoliToolbar` shows the Table menu, table style box, cell shading menu and Picture… button.
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [18f838a]
|
|
60
|
+
- @folijs/core@0.5.0
|
|
61
|
+
|
|
3
62
|
## 0.4.0
|
|
4
63
|
|
|
5
64
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @folijs/docx
|
|
2
2
|
|
|
3
3
|
DOCX for [Foli](https://github.com/josep-audenis/foli): imports a `.docx` into Foli's Word model
|
|
4
|
-
(schema
|
|
4
|
+
(schema v5 of `@folijs/core`), exports it back losslessly (`exportDocx`), and reads its package
|
|
5
5
|
(zip, parts, content types, relationships) and XML keeping every byte it does not change. No DOM:
|
|
6
6
|
runs in the browser, workers and Node 20.12+. Depends only on `@folijs/core`.
|
|
7
7
|
|
|
@@ -15,14 +15,15 @@ const {
|
|
|
15
15
|
package: pkg,
|
|
16
16
|
report,
|
|
17
17
|
} = await importDocx(new Uint8Array(await file.arrayBuffer()));
|
|
18
|
-
document.content; //
|
|
18
|
+
document.content; // paragraphs with Word's properties, runs as text with marks, tables
|
|
19
|
+
document.stories; // headers, footers, footnotes and endnotes, by id
|
|
19
20
|
document.styles; // with basedOn, run and paragraph properties
|
|
20
|
-
report.opaque; // { "w:
|
|
21
|
+
report.opaque; // { "w:annotationRef": 4 }: content kept verbatim, not editable
|
|
21
22
|
```
|
|
22
23
|
|
|
23
24
|
**Import** (`importDocx`, `importPackage`) reads the main document, styles (with the document
|
|
24
25
|
defaults), numbering, the theme's fonts and colors, comments (with replies and resolved state
|
|
25
|
-
from `commentsExtended`) and
|
|
26
|
+
from `commentsExtended`), sections, headers, footers, footnotes, endnotes and settings:
|
|
26
27
|
|
|
27
28
|
- **Paragraphs** with their properties (style, justification, indentation, spacing, keep rules,
|
|
28
29
|
outline level, numbering, tab stops, borders, shading, the paragraph mark's formatting and
|
|
@@ -30,12 +31,41 @@ from `commentsExtended`) and sections:
|
|
|
30
31
|
(`w14:paraId`…). **Runs** become text, tabs and breaks with their properties as marks; tracked
|
|
31
32
|
insertions, deletions and moves, hyperlinks (target from the relationship, or a bookmark),
|
|
32
33
|
bookmarks, comment ranges and references are modeled.
|
|
34
|
+
- **Sections** (11.6): page size and margins, how each starts, `w:cols` (equal or set widths, the
|
|
35
|
+
line between them), `w:pgNumType`, `w:footnotePr`, `w:endnotePr` and a tracked setup change
|
|
36
|
+
(`w:sectPrChange`), read and written; a section unchanged is exported byte for byte, a changed
|
|
37
|
+
one rewrites only what changed. A recorded setup is written with every value spelled out: Word
|
|
38
|
+
sees no change in what it leaves out.
|
|
39
|
+
- **Headers, footers and notes** (11.4) become `stories` holding the body's kinds of blocks
|
|
40
|
+
(tables and pictures included), a note's reference a `noteReference` node and its number in the
|
|
41
|
+
note a `noteMark`. What a story may not hold (a section break, a note reference, a comment, a
|
|
42
|
+
page or column break in a note) stays verbatim there, reported.
|
|
43
|
+
- **Fields** (11.5): complex fields (`w:fldChar`, `w:instrText`), nested and across runs and
|
|
44
|
+
paragraphs, become `fieldStart`, `fieldCode`, `fieldSeparator` and `fieldEnd` markers with their
|
|
45
|
+
result as ordinary content; `w:fldSimple` reads as the same markers and is written back as one.
|
|
46
|
+
Merge fields and form fields (`w:ffData` kept) are fields like the others.
|
|
47
|
+
- **Content controls** (11.5, 11.9) at run, block, row and cell level are modeled with their
|
|
48
|
+
properties (`controls`), `w:sdtPr` and `w:sdtEndPr` kept in `ext`: what changes is patched child
|
|
49
|
+
by child, the rest stays byte for byte, a new control gets a whole `w:sdtPr`, and the glossary
|
|
50
|
+
gives the text an emptied one shows. Data bindings are kept, not evaluated. An empty block
|
|
51
|
+
control stays verbatim.
|
|
52
|
+
- **Tables** (10.4) become `table`, `tableRow` and `tableCell` nodes: the table's, rows' and
|
|
53
|
+
cells' properties (`w:tblPr`, `w:tblGrid`, `w:tblPrEx`, `w:trPr`, `w:tcPr`) as attributes,
|
|
54
|
+
merges as Word writes them (`gridSpan`, `vMerge`), a row inserted or deleted as a tracked
|
|
55
|
+
change, the cells' paragraphs and nested tables; a table style's parts and conditional
|
|
56
|
+
formats go to its `StyleJSON`. A table the model cannot hold as it is stays opaque, reported:
|
|
57
|
+
rows or cells inside a content control or custom XML, markers between rows, elements out of
|
|
58
|
+
Word's order, a cell not ending with a paragraph, tables nested more than 64 deep, a table
|
|
59
|
+
right after a table (Word merges the two) or ending the body, and a page, column or section
|
|
60
|
+
break in a cell (the model has none there). A row's `w:tblPrEx` keeps what a row may not
|
|
61
|
+
override (a style, band sizes) in its `ext`, and a table style's `wholeTable` conditional
|
|
62
|
+
format stays in its `ext`, both reported. A table made in the model is written as Word
|
|
63
|
+
requires (properties, grid, rows); Word opens it, with or without a grid.
|
|
33
64
|
- **Lossless:** every properties element is kept verbatim (`ext` on paragraphs, sections,
|
|
34
65
|
styles, numbering levels and definitions, the document defaults; `runExt` on runs; a comment's
|
|
35
66
|
start tag), and unknown attributes of modeled elements go to attribute bags (paragraphs,
|
|
36
67
|
links, tracked changes, bookmarks and comment anchors: `w16du:dateUtc`, `w14:paraId`…). Every
|
|
37
|
-
element Foli does not model yet (
|
|
38
|
-
footnote references, equations…) becomes an opaque node holding its source, and so does an
|
|
68
|
+
element Foli does not model yet (equations, charts, shapes…) becomes an opaque node holding its source, and so does an
|
|
39
69
|
element the model rejects as a whole (a tracked change with an id past Word's range, a link in
|
|
40
70
|
a link, a run with an unknown attribute): never stripped to plain text. Export (8.5) writes all
|
|
41
71
|
of it back; keep `package` with the document, the parts Foli does not edit come from it. The
|
|
@@ -57,14 +87,17 @@ from `commentsExtended`) and sections:
|
|
|
57
87
|
between elements, and the empty paragraph given to an empty body or comment. Text is read as
|
|
58
88
|
Word reads it: without `xml:space="preserve"`, whitespace at the ends of a `w:t` is not text.
|
|
59
89
|
|
|
60
|
-
**Settings.** Of `settings.xml
|
|
61
|
-
and, when `exportDocx` is given `trackRevisions`, written:
|
|
62
|
-
|
|
63
|
-
part
|
|
90
|
+
**Settings.** Of `settings.xml`, `w:trackRevisions` is read (`DocxImport.trackRevisions`)
|
|
91
|
+
and, when `exportDocx` is given `trackRevisions`, written; `w:evenAndOddHeaders` and the note
|
|
92
|
+
properties of `w:footnotePr` and `w:endnotePr` are the document's `settings`, written when they
|
|
93
|
+
differ from the part (the separators listed in those elements stay). Each is added in its place
|
|
94
|
+
among the settings, or removed; the rest of the part is kept byte for byte, and all of it when
|
|
95
|
+
nothing differs. A new package gets a settings part only with tracking on or `settings`.
|
|
64
96
|
|
|
65
97
|
**Export** (`exportDocx(document, package?, options?)`) writes the parts the editor owns
|
|
66
98
|
(`document.xml`, `styles.xml`, `numbering.xml`, `comments.xml`, `commentsExtended.xml`,
|
|
67
|
-
relationships for new hyperlink targets, and `settings.xml` when `trackRevisions`
|
|
99
|
+
relationships for new hyperlink targets, and `settings.xml` when `trackRevisions` or `settings`
|
|
100
|
+
change it)
|
|
68
101
|
and copies every other part of the original package byte for byte (its compressed entry
|
|
69
102
|
included). Within the parts it writes:
|
|
70
103
|
|
|
@@ -94,15 +127,62 @@ included). Within the parts it writes:
|
|
|
94
127
|
into: one element of the expected kind, prefixes the part declares, no attribute the writer
|
|
95
128
|
writes itself. What does not fit is a `DocxError`, never ill-formed XML.
|
|
96
129
|
- Without a package, a new one is made (from a migrated v2 document, say), declaring Word's
|
|
97
|
-
namespaces. A document that refers to parts of its original package (headers
|
|
98
|
-
pictures, content kept verbatim with relationship ids) needs that package:
|
|
99
|
-
without one is a `DocxError`.
|
|
130
|
+
namespaces. A document that refers to parts of its original package (headers and footers it
|
|
131
|
+
has no story for, pictures, content kept verbatim with relationship ids) needs that package:
|
|
132
|
+
exporting it without one is a `DocxError`.
|
|
133
|
+
- Headers, footers, footnotes and endnotes are the document's `stories`. An unchanged one keeps
|
|
134
|
+
its part (or, for a note, its element) byte for byte; a changed one is written from the model;
|
|
135
|
+
a new one gets its part, relationship and content type. A note whose story is gone is removed
|
|
136
|
+
from its part. A document without `stories` leaves those parts as they are. Notes inserted,
|
|
137
|
+
deleted, tracked, converted or given new options in the editor are written as Word writes them,
|
|
138
|
+
and Word reads them back (`scripts/corpus/story-roundtrip.mjs`).
|
|
139
|
+
- Tables are written from the model: each properties element as paragraphs' are (verbatim
|
|
140
|
+
while unchanged, else child by child), the grid as read while its widths are, rows and cells
|
|
141
|
+
in order; Word reads every corpus table back with Foli's text, unchanged and edited
|
|
142
|
+
(`scripts/corpus/table-roundtrip.mjs`). A changed table style definition is refused
|
|
143
|
+
(`DocxError`): Foli has no command that changes one.
|
|
144
|
+
- **Pictures** (10.8, 10.9): a `w:drawing` holding one DrawingML picture (`wp:inline` or
|
|
145
|
+
`wp:anchor`, `pic:pic`, its image an embedded `image/*` part) becomes a `picture` node: `resource` (the
|
|
146
|
+
image part's name, `word/media/image1.png`, a key of the envelope's `resources`, which give
|
|
147
|
+
its content type, size and part), its size in EMU (`wp:extent`), `alt` and `title`
|
|
148
|
+
(`wp:docPr`), `decorative` (Office's `adec:decorative`), and the drawing verbatim in `ext`
|
|
149
|
+
(cropping, effects, ids; an SVG picture's SVG part stays there, its PNG fallback is the
|
|
150
|
+
resource). An empty description stays empty. A picture without alt text and not decorative is allowed and
|
|
151
|
+
counted (`report.picturesWithoutAlt`). A floating picture (`wp:anchor`) is a `picture` node
|
|
152
|
+
too, with `float`: `horizontal` and `vertical` (`relativeFrom` as `relativeTo`, and
|
|
153
|
+
`wp:posOffset` as `offset` in EMU or `wp:align` as `align`), `wrap` (`square`, `tight`,
|
|
154
|
+
`through`, `topAndBottom`; `wp:wrapNone` is `behind` or `inFront` by `behindDoc`), `side`
|
|
155
|
+
(`wrapText`), `distance` (`distT`…`distR`), `allowOverlap` and `layoutInCell`; its z-order,
|
|
156
|
+
lock and wrap polygon stay in `ext`. A position given both an `offset` and an `align` (Foli's
|
|
157
|
+
schema allows it; Word's holds one) is written with the offset. One positioned by `simplePos`, hidden, sized relative to
|
|
158
|
+
the page (`wp14:sizeRelH`/`sizeRelV`), or with no position or wrapping the model reads, stays
|
|
159
|
+
opaque, as linked images, charts, shapes and other drawings do.
|
|
160
|
+
- Pictures are written from their `ext` with only what the model changed from it written in
|
|
161
|
+
(the extent and the transform's size, alt text and title on `wp:docPr` and `pic:cNvPr`, the
|
|
162
|
+
image's relationship): an unchanged picture comes back byte for byte, values the file holds
|
|
163
|
+
twice (and differently) included. A copy of a drawing (the same id twice) gets new
|
|
164
|
+
`wp:docPr` and `pic:cNvPr` ids, its `wp14` anchor ids left to Word. One without `ext` (new) is
|
|
165
|
+
a fresh drawing, inline or `wp:anchor` (a position Word cannot read written as `column` or
|
|
166
|
+
`paragraph` at offset 0, tight and through wrapping with the picture's rectangle as the
|
|
167
|
+
polygon); so is a floating picture whose `float` differs from its `ext`'s, and one made
|
|
168
|
+
floating or inline: what only its `ext` held is then lost (cropping, effects, z-order, lock,
|
|
169
|
+
`hidden`, the wrap polygon, an SVG picture's SVG part, a click link; no command changes a
|
|
170
|
+
float yet); new ids are above every drawing id in the document's parts. Its image
|
|
171
|
+
is the package's part when the resource names one there of the size and an image type import
|
|
172
|
+
recorded (a part of that name in another package is another image); otherwise a new media
|
|
173
|
+
part (`word/media/foli-imageN.ext`, its content type declared) with the bytes of the
|
|
174
|
+
resource's `data:` URL (base64 or percent-encoded) or of `ExportOptions.resource(key,
|
|
175
|
+
resource)` (an app's upload); without bytes the export fails (`DocxError`), never drops the
|
|
176
|
+
picture. Image relationships are matched by the part they point to. A drawing read in another
|
|
177
|
+
part or package that refers to other relationships (an SVG's PNG fallback, a click link) is
|
|
178
|
+
written fresh.
|
|
100
179
|
- Not written: the theme (read-only in the model: the original part is kept; a new package has
|
|
101
180
|
none, so Word's default applies). Page margins Word requires but the document leaves out are
|
|
102
181
|
written with Word's defaults. A part read as UTF-16 is written as UTF-8, declared so.
|
|
103
182
|
|
|
104
183
|
Checked: the corpus exported without edits equals the original under the canonical comparison
|
|
105
|
-
(`src/testing/canonical.ts`), with every other part, and every unchanged element, byte for byte
|
|
184
|
+
(`src/testing/canonical.ts`), with every other part, and every unchanged element, byte for byte
|
|
185
|
+
(tables as written, but for what import drops everywhere);
|
|
106
186
|
re-imported, it is the same document; random edits leave every other paragraph identical and
|
|
107
187
|
the edited one's unknown properties in place; Word opens the exports (unchanged, edited, and new
|
|
108
188
|
packages) and finds the reference numbers in the unchanged ones
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fields and inline content controls as an edit can leave them, made writable (ADR-0007). A field
|
|
3
|
+
* part without its partner is dropped, with the code of a field that lost its end, so the code
|
|
4
|
+
* never becomes text; the result stays. An inline control a paragraph split runs over becomes one
|
|
5
|
+
* control per paragraph, as `w:sdt` cannot cross a paragraph; ends without a partner are dropped
|
|
6
|
+
* when written.
|
|
7
|
+
*/
|
|
8
|
+
import type { FoliDocument } from "@folijs/core";
|
|
9
|
+
import type { DocxPackage } from "../package.js";
|
|
10
|
+
/**
|
|
11
|
+
* `doc` (a validated copy, changed in place) with its fields and inline controls writable. Field
|
|
12
|
+
* parts are only repaired where an edit can be what broke them: not in a package holding broken
|
|
13
|
+
* fields of its own (Word reads those in its way), nor where verbatim content holds field
|
|
14
|
+
* characters, whose partners the model cannot see.
|
|
15
|
+
*/
|
|
16
|
+
export declare function balanced(doc: FoliDocument, original?: DocxPackage): FoliDocument;
|
|
17
|
+
//# sourceMappingURL=balance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../src/export/balance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAiFjD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,YAAY,CAiBhF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
function paragraphsOf(nodes, out = []) {
|
|
2
|
+
for (const node of nodes) {
|
|
3
|
+
if (node.type === "paragraph")
|
|
4
|
+
out.push(node);
|
|
5
|
+
else if (node.content)
|
|
6
|
+
paragraphsOf(node.content, out);
|
|
7
|
+
}
|
|
8
|
+
return out;
|
|
9
|
+
}
|
|
10
|
+
function balanceFields(paragraphs) {
|
|
11
|
+
const drop = new Set();
|
|
12
|
+
const open = [];
|
|
13
|
+
for (const paragraph of paragraphs) {
|
|
14
|
+
for (const node of paragraph.content ?? []) {
|
|
15
|
+
if (node.type === "fieldStart")
|
|
16
|
+
open.push([node]);
|
|
17
|
+
else if (node.type === "fieldCode" || node.type === "fieldSeparator") {
|
|
18
|
+
const field = open.at(-1);
|
|
19
|
+
if (field)
|
|
20
|
+
field.push(node);
|
|
21
|
+
else
|
|
22
|
+
drop.add(node);
|
|
23
|
+
}
|
|
24
|
+
else if (node.type === "fieldEnd" && !open.pop())
|
|
25
|
+
drop.add(node);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (const field of open)
|
|
29
|
+
for (const node of field)
|
|
30
|
+
drop.add(node);
|
|
31
|
+
if (!drop.size)
|
|
32
|
+
return;
|
|
33
|
+
for (const paragraph of paragraphs)
|
|
34
|
+
if (paragraph.content)
|
|
35
|
+
paragraph.content = paragraph.content.filter((n) => !drop.has(n));
|
|
36
|
+
}
|
|
37
|
+
function balanceControls(paragraphs) {
|
|
38
|
+
const endsLeft = new Map();
|
|
39
|
+
const ends = (paragraph) => (paragraph.content ?? []).filter((n) => n.type === "controlEnd");
|
|
40
|
+
for (const paragraph of paragraphs)
|
|
41
|
+
for (const end of ends(paragraph))
|
|
42
|
+
endsLeft.set(end.attrs?.id, (endsLeft.get(end.attrs?.id) ?? 0) + 1);
|
|
43
|
+
if (!endsLeft.size)
|
|
44
|
+
return;
|
|
45
|
+
let open = [];
|
|
46
|
+
for (const paragraph of paragraphs) {
|
|
47
|
+
const content = open.map((id) => ({ type: "controlStart", attrs: { id } }));
|
|
48
|
+
const here = [...open];
|
|
49
|
+
for (const node of paragraph.content ?? []) {
|
|
50
|
+
content.push(node);
|
|
51
|
+
const id = node.attrs?.id;
|
|
52
|
+
if (node.type === "controlStart")
|
|
53
|
+
here.push(id);
|
|
54
|
+
else if (node.type === "controlEnd") {
|
|
55
|
+
endsLeft.set(id, endsLeft.get(id) - 1);
|
|
56
|
+
const at = here.lastIndexOf(id);
|
|
57
|
+
if (at >= 0)
|
|
58
|
+
here.splice(at, 1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Innermost first; a control with no end further on has lost it, and its start is dropped.
|
|
62
|
+
open = here.filter((id) => (endsLeft.get(id) ?? 0) > 0);
|
|
63
|
+
for (const id of [...open].reverse())
|
|
64
|
+
content.push({ type: "controlEnd", attrs: { id } });
|
|
65
|
+
if (content.length)
|
|
66
|
+
paragraph.content = content;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** Whether the field characters of a part's XML open and close properly. */
|
|
70
|
+
function fieldsWhole(xml) {
|
|
71
|
+
let depth = 0;
|
|
72
|
+
for (const [, type] of xml.matchAll(/fldCharType\s*=\s*["'](begin|separate|end)["']/g)) {
|
|
73
|
+
if (type === "begin")
|
|
74
|
+
depth++;
|
|
75
|
+
else if (depth === 0)
|
|
76
|
+
return false;
|
|
77
|
+
else if (type === "end")
|
|
78
|
+
depth--;
|
|
79
|
+
}
|
|
80
|
+
return depth === 0;
|
|
81
|
+
}
|
|
82
|
+
/** Whether content kept verbatim among `nodes` holds field characters. */
|
|
83
|
+
function holdsVerbatimField(nodes) {
|
|
84
|
+
return nodes.some((node) => (typeof node.attrs?.xml === "string" && node.attrs.xml.includes("fldChar")) ||
|
|
85
|
+
holdsVerbatimField(node.content ?? []));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* `doc` (a validated copy, changed in place) with its fields and inline controls writable. Field
|
|
89
|
+
* parts are only repaired where an edit can be what broke them: not in a package holding broken
|
|
90
|
+
* fields of its own (Word reads those in its way), nor where verbatim content holds field
|
|
91
|
+
* characters, whose partners the model cannot see.
|
|
92
|
+
*/
|
|
93
|
+
export function balanced(doc, original) {
|
|
94
|
+
const packageWhole = !original ||
|
|
95
|
+
original.parts
|
|
96
|
+
.filter((part) => /^\/word\/[^/]+\.xml$/.test(part.name))
|
|
97
|
+
.every((part) => fieldsWhole(original.text(part.name)));
|
|
98
|
+
const trees = [
|
|
99
|
+
doc.content.content ?? [],
|
|
100
|
+
...doc.comments.map((c) => c.content),
|
|
101
|
+
...Object.values(doc.stories ?? {}).map((s) => s.content.content ?? []),
|
|
102
|
+
];
|
|
103
|
+
for (const tree of trees) {
|
|
104
|
+
const paragraphs = paragraphsOf(tree);
|
|
105
|
+
if (packageWhole && !holdsVerbatimField(tree))
|
|
106
|
+
balanceFields(paragraphs);
|
|
107
|
+
balanceControls(paragraphs);
|
|
108
|
+
}
|
|
109
|
+
return doc;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=balance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/export/balance.ts"],"names":[],"mappings":"AAUA,SAAS,YAAY,CAAC,KAA0B,EAAE,GAAG,GAAe,EAAE;IACpE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACzC,IAAI,IAAI,CAAC,OAAO;YAAE,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,aAAa,CAAC,UAA+B;IACpD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAY,CAAC;IACjC,MAAM,IAAI,GAAiB,EAAE,CAAC;IAC9B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,OAAO,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U,QAAQ,CAAC,GAAiB,EAAE,QAAsB;IAChE,MAAM,YAAY,GAChB,CAAC,QAAQ;QACT,QAAQ,CAAC,KAAK;aACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACxD,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG;QACZ,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE;QACzB,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QACrC,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;KACxE,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,YAAY,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;YAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QACzE,eAAe,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/export/content.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* hyperlinks and tracked changes around them, markers between them, opaque content verbatim.
|
|
4
4
|
*/
|
|
5
5
|
import type { NodeJSON } from "@folijs/core";
|
|
6
|
+
import type { ControlWriter } from "./controls.js";
|
|
6
7
|
import { type Namespaces } from "./xmlout.js";
|
|
7
8
|
export interface WriteContext {
|
|
8
9
|
readonly namespaces: Namespaces;
|
|
@@ -11,6 +12,12 @@ export interface WriteContext {
|
|
|
11
12
|
* still has it with that target, otherwise a new one.
|
|
12
13
|
*/
|
|
13
14
|
readonly hyperlink: (href: string, id: string | undefined) => string;
|
|
15
|
+
/** A picture's `w:drawing` (its image related to the part, its media part allocated). */
|
|
16
|
+
readonly picture: (attrs: Record<string, unknown>) => string;
|
|
17
|
+
/** The kind of note being written: what its `noteMark` is. */
|
|
18
|
+
readonly note?: "footnote" | "endnote";
|
|
19
|
+
/** The document's content controls. */
|
|
20
|
+
readonly controls: ControlWriter;
|
|
14
21
|
}
|
|
15
22
|
export declare function blocksXml(blocks: readonly NodeJSON[], context: WriteContext): string;
|
|
16
23
|
export declare function paragraphXml(p: NodeJSON, context: WriteContext): string;
|
|
@@ -1 +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,
|
|
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,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AASnD,OAAO,EAAqD,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAEjG,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;IACrE,yFAAyF;IACzF,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC;IAC7D,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACvC,uCAAuC;IACvC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;CAClC;AAkCD,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAOpF;AAuBD,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAMvE"}
|