@office-kit/pptx 0.28.0 → 0.30.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,27 @@
1
1
  # @office-kit/pptx
2
2
 
3
+ ## 0.30.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0f80c9e: Read shapes wrapped in `mc:AlternateContent` in a shape tree. The desktop app saves a shape holding an equation this way, and such shapes were left out of `getSlideShapes`, so the preview drew nothing for them. The reader now takes the branch an application without newer features would take: the a14 choice (the equation) or, for any other choice, the fallback. Removing, reordering, grouping, ungrouping and copying such a shape move the whole wrapper.
8
+
9
+ `getSlideShapes` can now return more shapes for decks that use this markup, which shifts the index of later shapes.
10
+
11
+ ## 0.29.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 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`.
16
+
17
+ 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.
18
+
19
+ - 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.
20
+
21
+ ### Patch Changes
22
+
23
+ - 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`.
24
+
3
25
  ## 0.28.0
4
26
 
5
27
  ### Minor Changes
package/README.md CHANGED
@@ -697,6 +697,71 @@ 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
+
758
+ The desktop app saves a shape holding an equation differently: the whole shape
759
+ sits in `mc:AlternateContent`, with a picture of it as the fallback.
760
+ `getSlideShapes` returns the shape from the equation branch, so its text and
761
+ equations read and edit as usual, and removing, reordering, grouping or copying
762
+ it moves the wrapper too. Text and format edits change only that branch, so an
763
+ app that shows the fallback keeps showing the old picture.
764
+
700
765
  To create several destination slides, use `addSlideAt(pres, index, [{ layout },
701
766
  { layout }])`. It returns the new slides in insertion order, with existing slide
702
767
  handles preserved. Every layout must belong to the presentation.