@yudaocode/univer-docs 1.6.211 → 1.6.213
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/WORD_TEMPLATE_PROTOCOL.md +33 -0
- package/lib/cjs/index.js +2073 -432
- package/lib/cjs/index.js.map +1 -1
- package/lib/es/index.js +2492 -840
- package/lib/es/index.js.map +1 -1
- package/lib/types/index.d.ts +39 -5
- package/package.json +1 -1
|
@@ -174,3 +174,36 @@ When exporting an **unfilled template** `IDocumentData` to `.docx` via `exportDo
|
|
|
174
174
|
|
|
175
175
|
- `docProps/yudao-meta.json` persists `tableOrder` (`body.tables.map(t => t.tableId)`), `tableRowLoops`, and `tableRepeatHeaders` alongside `<w:sdt>` OOXML tags (`<w:alias>`, `<w:tag>`, `<w:lock>`, `<w:dataBinding w:xpath="..."/>`) and `<w:tblHeader/>`.
|
|
176
176
|
- On `parseDocxBytesWithReport(docxBytes)`, `oldTableOrder[idx]` is mapped to the newly parsed `docData.body.tables[idx].tableId` (`oldToNewTblId`), remapping `"${oldTblId}:${rowIndex}"` -> `"${newTblId}:${rowIndex}"` in `tableRowLoops` and `"${oldTblId}"` -> `"${newTblId}"` in `tableRepeatHeaders` inside `YUDAO_DOCS_TEMPLATE_RESOURCE`.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 5. OOXML Pagination, Typography, Drawings & Dynamic Field Fidelity
|
|
181
|
+
|
|
182
|
+
### 5.1 Table Width, Row Height, Keep-Together & Repeated Headers
|
|
183
|
+
|
|
184
|
+
| OOXML Element | `IDocumentData` Snapshot Representation | Import / Export Contract |
|
|
185
|
+
| :--- | :--- | :--- |
|
|
186
|
+
| `<w:tblW w:w="..." w:type="dxa\|pct\|auto\|nil"/>` + `<w:tblLayout w:type="fixed\|autofit"/>` | `tableSource[tableId].size`, `layout` (`TableLayoutType.FIXED` / `AUTO_FIT`), `yudaoTblWidthType`, `yudaoTblWidthDxa`, `yudaoTblWidthPct`, `tableColumns[i].size` | Fixed-width tables preserve exact `dxa` table width, `fixed` layout, `<w:gridCol>`, and per-cell `<w:tcW>` (including `vMerge` continuation cells) without degrading to `auto` |
|
|
187
|
+
| `<w:trHeight w:val="..." w:hRule="atLeast\|exact\|auto"/>` | `tableRows[r].trHeight` (`val: { v: pt, u: POINT }`, `hRule: TableRowHeightRule`) + `yudaoTrHRule` | Omitted `w:hRule` defaults to `atLeast` per ECMA-376 §17.4.80; rows without `<w:trHeight>` use `AUTO` without synthetic height inflation; exported `.docx` writes explicit `w:hRule` |
|
|
188
|
+
| `<w:cantSplit/>` | `tableRows[r].cantSplit` (`BooleanNumber.TRUE` / `FALSE`) | Preserved on import, cloned onto expanded `tableRowLoops` detail rows, and emitted on export (`<w:cantSplit/>` / `<w:cantSplit w:val="0"/>`) |
|
|
189
|
+
| `<w:tblHeader/>` | `tableRows[r].repeatHeaderRow` (`BooleanNumber.TRUE` / `FALSE`) | Preserved across multi-row headers and synchronized with `tableRowLoops.repeatHeaderRow` |
|
|
190
|
+
|
|
191
|
+
### 5.2 Separate Latin & East Asian Typography, Line Spacing & Margins
|
|
192
|
+
|
|
193
|
+
- **Latin vs East Asian Fonts (`<w:rFonts>`)**:
|
|
194
|
+
- `ITextStyle.ff` stores the primary Latin font (`w:ascii` / `w:hAnsi`), while `eastAsiaFontFamily` (and `yudaoRFonts`) stores the explicit East Asian font (`w:eastAsia`, resolved through run `<w:rPr>` -> paragraph style `w:basedOn` chain -> `docDefaults` -> `word/theme/theme1.xml`).
|
|
195
|
+
- On `.docx` export, `w:ascii`/`w:hAnsi` and `w:eastAsia` are emitted independently so Latin fonts never overwrite explicit CJK fonts (such as `宋体` / `仿宋` / `黑体`).
|
|
196
|
+
- **Paragraph Line Spacing & Grid (`<w:spacing>`, `<w:docGrid>`)**:
|
|
197
|
+
- `SpacingRule.AUTO` maps `1.0` <-> `w:line="240" w:lineRule="auto"` (`1.25x` <-> `w:line="300" w:lineRule="auto"`); `EXACT` and `AT_LEAST` map point heights <-> twentieths of a point (`dxa`), alongside independent `spaceAbove` (`w:before`), `spaceBelow` (`w:after`), `contextualSpacing`, `snapToGrid`, and section `charSpace`/`linePitch` (`<w:docGrid>`).
|
|
198
|
+
- **Page & Header/Footer Distances (`<w:pgMar>`)**:
|
|
199
|
+
- `documentStyle.marginTop`, `marginBottom`, `marginLeft`, `marginRight`, `marginHeader` (`w:header`), and `marginFooter` (`w:footer`) are parsed order-independently in points (`dxa / 20`) and mirrored onto `body.sectionBreaks[]`.
|
|
200
|
+
|
|
201
|
+
### 5.3 Body & Header/Footer Drawings (`normalizeDocDrawingsAndPluginResource`)
|
|
202
|
+
|
|
203
|
+
- `normalizeDocDrawingsAndPluginResource(snapshot)` reconciles `snapshot.drawings` with the `DOC_DRAWING_PLUGIN` entry in `snapshot.resources`, aligns `unitId`/`subUnitId` to `snapshot.id`, normalizes `PositionedObjectLayoutType.INLINE = 0`, marks drawings referenced in `headers`/`footers` with `isMultiTransform = 1` + `transforms`, and syncs header/footer `tableSource` entries.
|
|
204
|
+
- Both browser-decoded snapshots (`io.decodeDocx`) and host/server-provided `IDocumentData` snapshots paint inline body images and header/footer logos (including logos inside borderless header `<w:tbl>` or `<w:sdt>`) across designer (`edit` / `workbench`) and read-only (`view`) modes.
|
|
205
|
+
|
|
206
|
+
### 5.4 Dynamic Document Fields (`PAGE` / `NUMPAGES`)
|
|
207
|
+
|
|
208
|
+
- Complex `<w:fldChar w:fldCharType="begin\|separate\|end"/>` + `<w:instrText>` and `<w:fldSimple>` fields in body, table cells, headers, and footers are parsed into `yudaoBlockKind: "docField"` custom ranges (`fieldInstr`, `fieldSimple`), preserving cached display runs for Univer canvas preview and re-emitting live OOXML fields plus `<w:updateFields w:val="true"/>` in `word/settings.xml` on `.docx` export.
|
|
209
|
+
- Browser `decodeDocx` / `parseDocxBytesWithReport` emits an explicit compatibility warning (`code: "UNSUPPORTED_FIELD"`) whenever dynamic `PAGE` / `NUMPAGES` fields are detected so hosts and users know canvas preview displays cached static text rather than live page numbers.
|