@silurus/ooxml 0.48.1 → 0.49.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/README.md +26 -3
- package/dist/{docx-ge6W7nx6.js → docx-B3mL-FY1.js} +205 -203
- package/dist/docx.mjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{mathjax-BnoS-ncC.js → math.mjs} +22 -1420
- package/dist/mathjax-DWYWI9GF.js +21 -0
- package/dist/mathml-B58AKtQj.js +1388 -0
- package/dist/{pptx-CUkjUjWS.js → pptx-DefKBJxp.js} +248 -243
- package/dist/pptx.mjs +1 -1
- package/dist/types/docx.d.ts +41 -3
- package/dist/types/index.d.ts +54 -3
- package/dist/types/math.d.ts +38 -0
- package/dist/types/pptx.d.ts +43 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ pnpm add @silurus/ooxml
|
|
|
30
30
|
|
|
31
31
|
> **Bundler note**: this package embeds `.wasm` files. With Vite add [`vite-plugin-wasm`](https://github.com/Menci/vite-plugin-wasm); with webpack use [`experiments.asyncWebAssembly`](https://webpack.js.org/configuration/experiments/).
|
|
32
32
|
|
|
33
|
-
> **Bundle size note**: the package is ESM-only (`.mjs`). npm's *Unpacked Size* sums all
|
|
33
|
+
> **Bundle size note**: the package is ESM-only (`.mjs`). npm's *Unpacked Size* sums all four entry bundles, including the **opt-in** math engine (MathJax + STIX Two Math, ~3 MB). What actually lands in your app is much smaller — import only the format you need (e.g. `@silurus/ooxml/pptx`). The math engine is a **separate entry** (`@silurus/ooxml/math`): it is bundled **only if you import it and pass it to a viewer** (see [Rendering equations](#rendering-equations)). Viewers that never receive a `math` engine — and all xlsx usage — tree-shake the ~3 MB away entirely.
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
@@ -59,6 +59,29 @@ await pptx.load('/deck.pptx');
|
|
|
59
59
|
pptx.nextSlide();
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
+
### Rendering equations
|
|
63
|
+
|
|
64
|
+
OMML equations (`m:oMath` / `m:oMathPara`) in `.docx` / `.pptx` are rendered with
|
|
65
|
+
[MathJax](https://www.mathjax.org/) + [STIX Two Math](https://github.com/stipub/stixfonts).
|
|
66
|
+
That engine is ~3 MB, so it is **opt-in**: import the `math` engine from the separate
|
|
67
|
+
`@silurus/ooxml/math` entry and pass it to the viewer. Pass it and equations render;
|
|
68
|
+
omit it and the engine is referenced nowhere, so a bundler **tree-shakes the ~3 MB
|
|
69
|
+
away entirely** (equations are simply skipped). It is fully self-contained: no
|
|
70
|
+
network, no cross-origin requests.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { DocxViewer } from '@silurus/ooxml/docx';
|
|
74
|
+
import { math } from '@silurus/ooxml/math';
|
|
75
|
+
|
|
76
|
+
const canvas = document.getElementById('docx-canvas') as HTMLCanvasElement;
|
|
77
|
+
const docx = new DocxViewer(canvas, { math }); // ← equations now render
|
|
78
|
+
await docx.load('/paper-with-equations.docx');
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The same `math` engine works for `PptxViewer` and the headless `DocxDocument` /
|
|
82
|
+
`PptxPresentation` APIs (which take `math` in their options). xlsx has no equation
|
|
83
|
+
support and never references the engine.
|
|
84
|
+
|
|
62
85
|
---
|
|
63
86
|
|
|
64
87
|
<details>
|
|
@@ -385,7 +408,7 @@ export const PptxViewerComponent = component$<{ src: string }>(({ src }) => {
|
|
|
385
408
|
| | Table of contents (TOC field) — dot leaders, right-aligned page numbers | ✅ |
|
|
386
409
|
| | keepNext / keepLines / widowControl | ✅ |
|
|
387
410
|
| **Elements** | Tables (with borders, fills, merges, banding, alignment) | ✅ |
|
|
388
|
-
| | Math equations (OMML `m:oMath` / `m:oMathPara`, rendered via MathJax) | ✅ |
|
|
411
|
+
| | Math equations (OMML `m:oMath` / `m:oMathPara`, rendered via MathJax — opt-in `@silurus/ooxml/math`) | ✅ |
|
|
389
412
|
| | Images (inline and anchored, with text wrap) | ✅ |
|
|
390
413
|
| | Text boxes / drawing shapes | ✅ |
|
|
391
414
|
| | WMF / EMF metafile images (legacy vector) | ❌ Not planned |
|
|
@@ -496,7 +519,7 @@ export const PptxViewerComponent = component$<{ src: string }>(({ src }) => {
|
|
|
496
519
|
| | Hyperlinks (`hlinkClick` — theme `hlink` colour + auto underline) | ✅ |
|
|
497
520
|
| | Text shadow (`rPr > effectLst > outerShdw`) | ✅ |
|
|
498
521
|
| | Text outline (`rPr > a:ln`) | ✅ |
|
|
499
|
-
| | Math equations (OMML `m:oMath` / `m:oMathPara`, incl. `a14:m` / `mc:AlternateContent`; STIX Two Math via MathJax) | ✅ |
|
|
522
|
+
| | Math equations (OMML `m:oMath` / `m:oMathPara`, incl. `a14:m` / `mc:AlternateContent`; STIX Two Math via MathJax — opt-in `@silurus/ooxml/math`) | ✅ |
|
|
500
523
|
| **Text — paragraphs** | Horizontal alignment (left / center / right / justify) | ✅ |
|
|
501
524
|
| | Vertical anchor (top / center / bottom) | ✅ |
|
|
502
525
|
| | Line spacing (`spcPct`, `spcPts`) | ✅ |
|