@office-kit/pptx 0.28.0 → 0.29.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @office-kit/pptx
2
2
 
3
+ ## 0.29.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ff0c2ad: Equations (`<a14:m>`) in a paragraph now read as `math` elements of `getShapeParagraphElements` and `getTableCellParagraphs`, one per `<m:oMath>`. Each carries a typed `MathNode` tree (fractions, scripts, radicals, n-ary operators, delimiters, matrices, accents, functions and limits) plus its plain run text; other OMML elements read as `unsupported` nodes with their text. Code that switches on `kind` should handle the new `'math'` member; a `math` element's `format` is always `null`.
8
+
9
+ The preview draws these equations in place of the blank it left before, in both text layouts, with display equations (`<m:oMathPara>`) at full size. Elements outside the modeled set are drawn as plain text in a dashed box and reported by `auditTextLayout` as `unsupported-math`. The editor keeps ignoring equations when it counts text offsets, as the core text-range functions do.
10
+
11
+ - 7778e29: `setShapeParagraphs` and `setTableCellParagraphs` accept an equation as a run: `{ equation, display?, format? }`, where `equation` is a tree of `MathNodeSpec` nodes (the input counterpart of `MathNode`). It is written as a native `<a14:m>` equation inside `mc:AlternateContent`, with the equation's linear text (`σ(z)=1/(1+e^(−z))`) as the fallback run that apps without equation support show. Equations in that form now also read back through `getShapeParagraphElements`. `ParagraphSpec.runs` is now `ReadonlyArray<RunSpec | EquationSpec>`, so code that reads `run.text` from a spec needs to check for `equation` first.
12
+
13
+ ### Patch Changes
14
+
15
+ - 20583aa: `setShapeTextFormat` without a range (and so a DSL `Text`'s `size`, `color`, `bold`, …) now also formats the shape's equations and their fallback text. Equations keep their Cambria Math face; the fallback text takes the font too. The DSL README describes writing equations through `paragraphs`.
16
+
3
17
  ## 0.28.0
4
18
 
5
19
  ### Minor Changes
package/README.md CHANGED
@@ -697,6 +697,64 @@ its text-body settings and list styles. All batch ranges are read before any
697
697
  destination text changes. `getShapeParagraphElements(shape)` reads all paragraphs
698
698
  in one pass; passing an index reads one paragraph.
699
699
 
700
+ ### Equations
701
+
702
+ A paragraph run can be an equation: a tree of math nodes (fractions, scripts,
703
+ radicals, n-ary operators, delimiters, matrices, accents, functions, limits).
704
+ LaTeX conversion is left to the caller.
705
+
706
+ ```ts
707
+ import { setShapeParagraphs } from '@office-kit/pptx';
708
+
709
+ const t = (text: string) => ({ kind: 'text', text }) as const;
710
+ setShapeParagraphs(shape, [
711
+ {
712
+ runs: [
713
+ { text: 'Logistic: ' },
714
+ {
715
+ equation: [
716
+ t('σ(z)='),
717
+ {
718
+ kind: 'fraction',
719
+ numerator: [t('1')],
720
+ denominator: [t('1+'), { kind: 'superscript', base: [t('e')], sup: [t('−z')] }],
721
+ },
722
+ ],
723
+ },
724
+ ],
725
+ },
726
+ {
727
+ runs: [
728
+ {
729
+ equation: [
730
+ t('A='),
731
+ {
732
+ kind: 'delimiter',
733
+ items: [
734
+ [
735
+ {
736
+ kind: 'matrix',
737
+ rows: [
738
+ [[t('a')], [t('b')]],
739
+ [[t('c')], [t('d')]],
740
+ ],
741
+ },
742
+ ],
743
+ ],
744
+ },
745
+ ],
746
+ display: true,
747
+ },
748
+ ],
749
+ },
750
+ ]);
751
+ ```
752
+
753
+ The equation is written as a native, editable `<a14:m>` inside
754
+ `mc:AlternateContent`, with the equation's linear text (`σ(z)=1/(1+e^(−z))`) as
755
+ the fallback that apps without equation support show. `getShapeParagraphElements`
756
+ reads it back as a `math` element, and `@office-kit/pptx-preview` draws it.
757
+
700
758
  To create several destination slides, use `addSlideAt(pres, index, [{ layout },
701
759
  { layout }])`. It returns the new slides in insertion order, with existing slide
702
760
  handles preserved. Every layout must belong to the presentation.