ooxml-core 1.41.0 → 1.42.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.
Files changed (126) hide show
  1. package/README.md +4 -0
  2. package/dist/PptxHandler-73QIJ6SD.cjs +14 -0
  3. package/dist/{PptxHandler-3AGIITR7.mjs → PptxHandler-A2J4PCOB.mjs} +2 -2
  4. package/dist/PptxHandler-OGLVLX2T.mjs +5 -0
  5. package/dist/{PresentationBuilder-MZBKYOYD.cjs → PresentationBuilder-6S5PJXXF.cjs} +6 -6
  6. package/dist/{PresentationBuilder-JNID4B4Z.mjs → PresentationBuilder-APJKCMVS.mjs} +2 -2
  7. package/dist/{PresentationBuilder-5DPKFUXP.mjs → PresentationBuilder-F3BWDERK.mjs} +3 -3
  8. package/dist/automation/index.cjs +75 -89
  9. package/dist/automation/index.mjs +75 -89
  10. package/dist/chart/index.cjs +5 -5
  11. package/dist/chart/index.mjs +5 -5
  12. package/dist/{chunk-LRBWCRQ3.cjs → chunk-3J6VIKLP.cjs} +3 -3
  13. package/dist/chunk-CODMW5KF.cjs +110 -0
  14. package/dist/{chunk-KKVD3R6O.mjs → chunk-CPSTCCRD.mjs} +4 -4
  15. package/dist/{chunk-P3WAKBVS.mjs → chunk-IPV3J3I5.mjs} +82 -90
  16. package/dist/{chunk-6LGRRQ3K.mjs → chunk-MXA67O7R.mjs} +1 -1
  17. package/dist/{chunk-JXR6YWBW.mjs → chunk-N6X5CJZP.mjs} +125 -126
  18. package/dist/chunk-O3YGBYGZ.mjs +104 -0
  19. package/dist/{chunk-75KBNUKS.cjs → chunk-QZPOPUI5.cjs} +82 -89
  20. package/dist/{chunk-UE23HF2N.mjs → chunk-VKFKEVHK.mjs} +1 -1
  21. package/dist/{chunk-DD7COXWR.mjs → chunk-VV724DWE.mjs} +19 -7
  22. package/dist/{chunk-HTELXT2N.mjs → chunk-XVB3CBNM.mjs} +19 -6
  23. package/dist/{chunk-3BIFRTU4.cjs → chunk-YNQRXFTC.cjs} +1283 -1270
  24. package/dist/{chunk-ZYCBJKAE.mjs → chunk-ZUEN4RQG.mjs} +1 -1
  25. package/dist/diagram/index.cjs +499 -370
  26. package/dist/diagram/index.d.ts +1 -0
  27. package/dist/diagram/index.d.ts.map +1 -1
  28. package/dist/diagram/index.mjs +495 -371
  29. package/dist/docx/embedded.cjs +67 -89
  30. package/dist/docx/embedded.mjs +67 -89
  31. package/dist/docx/index.cjs +118 -106
  32. package/dist/docx/index.mjs +118 -106
  33. package/dist/docx/layout/index.cjs +118 -106
  34. package/dist/docx/layout/index.mjs +118 -106
  35. package/dist/docx/load/index.cjs +67 -89
  36. package/dist/docx/load/index.mjs +67 -89
  37. package/dist/docx/shape-svg.d.ts.map +1 -1
  38. package/dist/docx/ui/index.cjs +72 -94
  39. package/dist/docx/ui/index.mjs +72 -94
  40. package/dist/drawingml/dash-pattern.d.ts +61 -0
  41. package/dist/drawingml/dash-pattern.d.ts.map +1 -0
  42. package/dist/drawingml/index.cjs +249 -43
  43. package/dist/drawingml/index.d.ts +3 -0
  44. package/dist/drawingml/index.d.ts.map +1 -1
  45. package/dist/drawingml/index.mjs +241 -44
  46. package/dist/drawingml/rect-path-gradient.d.ts +5 -0
  47. package/dist/drawingml/rect-path-gradient.d.ts.map +1 -1
  48. package/dist/drawingml/shape-path-gradient.d.ts +57 -0
  49. package/dist/drawingml/shape-path-gradient.d.ts.map +1 -0
  50. package/dist/geometry/index.cjs +68 -90
  51. package/dist/geometry/index.mjs +68 -90
  52. package/dist/geometry/preset-shape-definitions-exact-action-buttons.d.ts +2 -2
  53. package/dist/geometry/preset-shape-definitions-exact-action-buttons.d.ts.map +1 -1
  54. package/dist/geometry/preset-shape-definitions-exact-arrows.d.ts.map +1 -1
  55. package/dist/geometry/preset-shape-definitions-exact-scrolls.d.ts.map +1 -1
  56. package/dist/index.cjs +686 -489
  57. package/dist/index.mjs +686 -489
  58. package/dist/pptx/automation/index.cjs +355 -191
  59. package/dist/pptx/automation/index.d.ts +11 -17
  60. package/dist/pptx/automation/index.d.ts.map +1 -1
  61. package/dist/pptx/automation/index.mjs +156 -71
  62. package/dist/pptx/chunks/{elements-6BMEOo7i.d.ts → elements-PBugbKtv.d.ts} +3 -873
  63. package/dist/pptx/chunks/elements-PBugbKtv.d.ts.map +1 -0
  64. package/dist/pptx/chunks/{index-BbXLv6As.d.ts → index-BJuR8GLL.d.ts} +4 -4
  65. package/dist/pptx/chunks/{index-BbXLv6As.d.ts.map → index-BJuR8GLL.d.ts.map} +1 -1
  66. package/dist/pptx/chunks/{index-DvN0TkJJ.d.ts → index-Rbvl2WaM.d.ts} +14 -10
  67. package/dist/pptx/chunks/index-Rbvl2WaM.d.ts.map +1 -0
  68. package/dist/pptx/chunks/{index-Dija_Wth.d.ts → index-xoJGYTgQ.d.ts} +5 -3
  69. package/dist/pptx/chunks/index-xoJGYTgQ.d.ts.map +1 -0
  70. package/dist/pptx/chunks/table-C7ITXL3Y.d.ts +875 -0
  71. package/dist/pptx/chunks/table-C7ITXL3Y.d.ts.map +1 -0
  72. package/dist/pptx/chunks/{text-operations-DorONr3h.d.ts → text-operations-BNJr7aGa.d.ts} +3 -2
  73. package/dist/pptx/chunks/text-operations-BNJr7aGa.d.ts.map +1 -0
  74. package/dist/pptx/cli/index.cjs +169 -96
  75. package/dist/pptx/cli/index.d.ts +1 -1
  76. package/dist/pptx/cli/index.mjs +4 -4
  77. package/dist/pptx/converter/index.cjs +69 -91
  78. package/dist/pptx/converter/index.d.ts +1 -1
  79. package/dist/pptx/converter/index.mjs +2 -2
  80. package/dist/pptx/editor/render/custom-show-operations.cjs +2 -2
  81. package/dist/pptx/editor/render/custom-show-operations.mjs +1 -1
  82. package/dist/pptx/editor/render/find-replace.cjs +15 -15
  83. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  84. package/dist/pptx/editor/render/find-replace.mjs +2 -2
  85. package/dist/pptx/editor/render/slide-operations.cjs +9 -9
  86. package/dist/pptx/editor/render/slide-operations.mjs +3 -3
  87. package/dist/pptx/editor/render/table-data-grid-ops.cjs +5 -5
  88. package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
  89. package/dist/pptx/editor/render/table-layout.cjs +6 -6
  90. package/dist/pptx/editor/render/table-layout.d.ts +8 -37
  91. package/dist/pptx/editor/render/table-layout.d.ts.map +1 -1
  92. package/dist/pptx/editor/render/table-layout.mjs +1 -1
  93. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +1 -1
  94. package/dist/pptx/editor/render/text-style-scope.d.ts +1 -1
  95. package/dist/pptx/index.cjs +214 -129
  96. package/dist/pptx/index.d.ts +6 -5
  97. package/dist/pptx/index.mjs +5 -5
  98. package/dist/pptx/node/index.d.ts +1 -1
  99. package/dist/teams/index.cjs +136 -91
  100. package/dist/teams/index.mjs +136 -91
  101. package/dist/text/font-metrics/design-advances.generated.d.ts +3 -1
  102. package/dist/text/font-metrics/design-advances.generated.d.ts.map +1 -1
  103. package/dist/text/index.cjs +8 -0
  104. package/dist/text/index.mjs +8 -0
  105. package/dist/visio/index.cjs +8 -0
  106. package/dist/visio/index.mjs +8 -0
  107. package/dist/visio/ui/index.cjs +8 -0
  108. package/dist/visio/ui/index.mjs +8 -0
  109. package/dist/xlsx/collab/index.cjs +67 -89
  110. package/dist/xlsx/collab/index.mjs +67 -89
  111. package/dist/xlsx/index.cjs +116 -108
  112. package/dist/xlsx/index.mjs +116 -108
  113. package/dist/xlsx/layout/shape-paint.d.ts.map +1 -1
  114. package/dist/xlsx/load/index.cjs +67 -89
  115. package/dist/xlsx/load/index.mjs +67 -89
  116. package/dist/xlsx/ui/index.cjs +72 -94
  117. package/dist/xlsx/ui/index.mjs +72 -94
  118. package/package.json +1 -1
  119. package/dist/PptxHandler-EL4E4SPH.mjs +0 -5
  120. package/dist/PptxHandler-OIZ3R3DJ.cjs +0 -14
  121. package/dist/chunk-3IT6ZD7K.mjs +0 -213
  122. package/dist/chunk-FRUB573B.cjs +0 -219
  123. package/dist/pptx/chunks/elements-6BMEOo7i.d.ts.map +0 -1
  124. package/dist/pptx/chunks/index-Dija_Wth.d.ts.map +0 -1
  125. package/dist/pptx/chunks/index-DvN0TkJJ.d.ts.map +0 -1
  126. package/dist/pptx/chunks/text-operations-DorONr3h.d.ts.map +0 -1
@@ -25703,84 +25703,22 @@ var triangle = (g3, dir) => g3.poly([
25703
25703
  [D * dir, 0],
25704
25704
  [-D * dir, D]
25705
25705
  ]);
25706
- var QUESTION = [
25707
- [-4.8, -33.7],
25708
- [-6.3, -31.5],
25709
- [-7.8, -31.5],
25710
- [-12.3, -28.5],
25711
- [-14.5, -28.5],
25712
- [-15.3, -27.7],
25713
- [-15.3, -25.5],
25714
- [-18.3, -21],
25715
- [-19, -17.2],
25716
- [-20.5, -16.5],
25717
- [-20.5, -12.7],
25718
- [-19, -12.7],
25719
- [-18.3, -14.2],
25720
- [-10.8, -14.2],
25721
- [-10, -13.5],
25722
- [-8.5, -13.5],
25723
- [-9.3, -17.2],
25724
- [-7.8, -19.5],
25725
- [-4, -22.5],
25726
- [-3.3, -21.7],
25727
- [-1.8, -21.7],
25728
- [-1, -23.2],
25729
- [0.5, -23.2],
25730
- [1.2, -21.7],
25731
- [2.7, -21.7],
25732
- [3.5, -22.5],
25733
- [8, -18.7],
25734
- [8.7, -17.2],
25735
- [8, -16.5],
25736
- [8, -15],
25737
- [9.5, -14.2],
25738
- [9.5, -13.5],
25739
- [8, -12.7],
25740
- [8.7, -9.7],
25741
- [5, -6],
25742
- [2, -6],
25743
- [-2.5, -2.2],
25744
- [-3.3, 0.8],
25745
- [-5.5, 2.3],
25746
- [-4.8, 6.8],
25747
- [-6.3, 7.5],
25748
- [-6.3, 18],
25749
- [-4.8, 18],
25750
- [-4, 17.3],
25751
- [4.2, 17.3],
25752
- [4.2, 6.8],
25753
- [6.5, 5.3],
25754
- [6.5, 3.8],
25755
- [8, 3],
25756
- [8, 1.5],
25757
- [8.7, 0.8],
25758
- [13.2, 0],
25759
- [17, -4.5],
25760
- [18.5, -4.5],
25761
- [18.5, -6],
25762
- [17.7, -6.7],
25763
- [18.5, -8.2],
25764
- [18.5, -15],
25765
- [20, -15.7],
25766
- [20, -18],
25767
- [17.7, -19.5],
25768
- [17.7, -21],
25769
- [15.5, -24.7],
25770
- [15.5, -27],
25771
- [14, -27],
25772
- [13.2, -27.7],
25773
- [13.2, -29.2],
25774
- [9.5, -30],
25775
- [8.7, -30.7],
25776
- [8.7, -32.2],
25777
- [5.7, -31.5],
25778
- [4.2, -33.7],
25779
- [2.7, -33.7],
25780
- [2, -32.2],
25781
- [-2.5, -32.2],
25782
- [-3.3, -33.7]
25783
- ];
25706
+ var U = 90;
25707
+ var question = (g3) => {
25708
+ const x = (v) => g3.x(v * U);
25709
+ const y = (v) => g3.y(v * U);
25710
+ const r = (v) => g3.len(v * U);
25711
+ return [
25712
+ `M ${x(-0.214)} ${y(-0.162)} A ${r(0.214)} ${r(0.2125)} 10800000 10800000`,
25713
+ `A ${r(0.108)} ${r(0.162)} 0 5400000`,
25714
+ `A ${r(0.053)} ${r(0.085)} 16200000 -5400000`,
25715
+ `L ${x(0.053)} ${y(0.187)} L ${x(-0.053)} ${y(0.187)} L ${x(-0.053)} ${y(0.08)}`,
25716
+ `A ${r(0.108)} ${r(0.16)} 10800000 5400000`,
25717
+ `A ${r(0.052)} ${r(0.082)} 5400000 -5400000`,
25718
+ `A ${r(0.107)} ${r(0.1065)} 0 -10800000`,
25719
+ `L ${x(-0.214)} ${y(-0.162)} Z`
25720
+ ].join(" ");
25721
+ };
25784
25722
  var MOVIE = [
25785
25723
  [-33.75, -16.5],
25786
25724
  [-33.75, -3],
@@ -25887,8 +25825,8 @@ var buttons = {
25887
25825
  )
25888
25826
  ]),
25889
25827
  actionButtonHelp: build("actionButtonHelp", (g3) => [
25890
- darken(g3.poly(QUESTION)),
25891
- darken(g3.circle(-0.2, 27.4, 7))
25828
+ darken(question(g3)),
25829
+ darken(g3.circle(0, 0.295 * U, 0.08 * U))
25892
25830
  ]),
25893
25831
  actionButtonInformation: build("actionButtonInformation", (g3) => [
25894
25832
  darken(g3.circle(0, 0.4, 34)),
@@ -29211,12 +29149,46 @@ var leftRightUpArrow2 = exactDef(
29211
29149
  )
29212
29150
  ]
29213
29151
  );
29152
+ var swooshArrow3 = exactDef(
29153
+ "swooshArrow",
29154
+ { adj1: 25e3, adj2: 16667 },
29155
+ [
29156
+ "a1 pin 1 adj1 75000",
29157
+ "maxAdj2 */ 70000 w ss",
29158
+ "a2 pin 0 adj2 maxAdj2",
29159
+ "ad1 */ h a1 100000",
29160
+ "ad2 */ ss a2 100000",
29161
+ "xB +- r 0 ad2",
29162
+ "yB +- t ssd8 0",
29163
+ "alfa */ cd4 1 14",
29164
+ "dx0 tan ssd8 alfa",
29165
+ "xC +- xB 0 dx0",
29166
+ "dx1 tan ad1 alfa",
29167
+ "yF +- yB ad1 0",
29168
+ "xF +- xB dx1 0",
29169
+ "xE +- xF dx0 0",
29170
+ "yE +- yF ssd8 0",
29171
+ "dy2 +- yE 0 t",
29172
+ "dy22 */ dy2 1 2",
29173
+ "dy3 */ h 1 20",
29174
+ "yD +- dy22 0 dy3",
29175
+ "dy4 */ hd6 1 1",
29176
+ "yP1 +- hd6 dy4 0",
29177
+ "xP1 val wd6",
29178
+ "dy5 */ hd6 1 2",
29179
+ "yP2 +- yF dy5 0",
29180
+ "xP2 val wd4"
29181
+ ],
29182
+ "l t r b",
29183
+ [p("M l b Q xP1 yP1 xB yB L xC t L r yD L xE yE L xF yF Q xP2 yP2 l b Z")]
29184
+ );
29214
29185
  var EXACT_ARROW_PRESET_DEFINITIONS = {
29215
29186
  leftRightArrow: leftRightArrow2,
29216
29187
  upDownArrow: upDownArrow2,
29217
29188
  quadArrow: quadArrow2,
29218
29189
  leftUpArrow: leftUpArrow2,
29219
- leftRightUpArrow: leftRightUpArrow2
29190
+ leftRightUpArrow: leftRightUpArrow2,
29191
+ swooshArrow: swooshArrow3
29220
29192
  };
29221
29193
 
29222
29194
  // geometry/preset-shape-definitions-exact-circular.ts
@@ -30022,10 +29994,13 @@ var verticalScroll = exactDef(
30022
29994
  p(
30023
29995
  "M ch ch2 A ch2 ch2 10800000 5400000 L x6 t A ch2 ch2 16200000 10800000 L x4 ch L x4 y4 A ch2 ch2 0 5400000 L ch2 b A ch2 ch2 5400000 10800000 L ch y3 Z"
30024
29996
  ),
30025
- p("M l y4 A ch2 ch2 10800000 21600000 Z M xsw cy3 A ch4 ch4 0 21600000 Z", {
30026
- fill: "darkenLess",
30027
- stroke: false
30028
- }),
29997
+ p(
29998
+ "M ch y4 A ch2 ch2 0 5400000 A ch2 ch2 5400000 10800000 A ch4 ch4 16200000 10800000 Z M x3b ch2 A ch2 ch2 0 5400000 A ch4 ch4 5400000 10800000 Z",
29999
+ {
30000
+ fill: "darkenLess",
30001
+ stroke: false
30002
+ }
30003
+ ),
30029
30004
  p(
30030
30005
  "M x3 t A ch2 ch2 16200000 10800000 L x4 ch M ch2 y4 L ch y4 M x3b ch2 L x3 ch2 A ch4 ch4 16200000 -10800000",
30031
30006
  { fill: "none" }
@@ -30041,10 +30016,13 @@ var horizontalScroll = exactDef(
30041
30016
  p(
30042
30017
  "M ch2 ch A ch2 ch2 16200000 -5400000 L l x6 A ch2 ch2 10800000 -10800000 L ch x4 L y4 x4 A ch2 ch2 5400000 -5400000 L r ch2 A ch2 ch2 0 -10800000 L y3 ch Z"
30043
30018
  ),
30044
- p("M y4 t A ch2 ch2 16200000 21600000 Z M ch cyw A ch4 ch4 0 21600000 Z", {
30045
- fill: "darkenLess",
30046
- stroke: false
30047
- }),
30019
+ p(
30020
+ "M y4 ch A ch2 ch2 5400000 -5400000 A ch2 ch2 0 -10800000 A ch4 ch4 10800000 -10800000 Z M ch2 x3b A ch2 ch2 5400000 -5400000 A ch4 ch4 0 -10800000 Z",
30021
+ {
30022
+ fill: "darkenLess",
30023
+ stroke: false
30024
+ }
30025
+ ),
30048
30026
  p(
30049
30027
  "M l x3 A ch2 ch2 10800000 -10800000 L ch x4 M y4 ch2 L y4 ch M ch2 x3b L ch2 x3 A ch4 ch4 10800000 10800000",
30050
30028
  { fill: "none" }
@@ -45870,7 +45848,7 @@ function lerpStops(a2, b, t) {
45870
45848
  opacity: oa + (ob - oa) * t
45871
45849
  };
45872
45850
  }
45873
- function colorAt(stops, position) {
45851
+ function gradientColorAt(stops, position) {
45874
45852
  const first2 = stops[0];
45875
45853
  const last = stops[stops.length - 1];
45876
45854
  if (position <= first2.position) {
@@ -45925,7 +45903,7 @@ function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options7) {
45925
45903
  if (!Number.isInteger(bands) || bands < 1) throw new RangeError("Invalid gradient band count");
45926
45904
  for (let i2 = bands; i2 >= 0; i2 -= 1) {
45927
45905
  const t = i2 / bands;
45928
- const { color: color2, opacity } = colorAt(sorted2, t * 100);
45906
+ const { color: color2, opacity } = gradientColorAt(sorted2, t * 100);
45929
45907
  const left2 = lerpEdge(inner2.left, 0, t);
45930
45908
  const top = lerpEdge(inner2.top, 0, t);
45931
45909
  const right2 = lerpEdge(inner2.right, 100, t);
@@ -71650,7 +71628,7 @@ function radarSvg(model2, area) {
71650
71628
  }
71651
71629
 
71652
71630
  // chart/render/chart-svg-hierarchy.ts
71653
- var colorAt2 = (model2, index3) => {
71631
+ var colorAt = (model2, index3) => {
71654
71632
  const first2 = model2.series[0];
71655
71633
  const colors = first2?.pointColors;
71656
71634
  return (colors && colors.length > 0 ? colors[index3 % colors.length] : void 0) ?? first2?.color ?? "#4472C4";
@@ -71679,7 +71657,7 @@ function treemapSvg(model2, area) {
71679
71657
  }
71680
71658
  out.push(`<g data-chart-series="${cell.seriesIndex}" data-chart-point="${cell.pointIndex}">`);
71681
71659
  out.push(
71682
- rect2(cell.x, cell.y, cell.w, cell.h, colorAt2(model2, cell.colorIndex)).replace(
71660
+ rect2(cell.x, cell.y, cell.w, cell.h, colorAt(model2, cell.colorIndex)).replace(
71683
71661
  "/>",
71684
71662
  ' rx="2"/>'
71685
71663
  )
@@ -71718,7 +71696,7 @@ function sunburstSvg(model2, area) {
71718
71696
  );
71719
71697
  for (const arc3 of arcs)
71720
71698
  out.push(
71721
- `<path d="${arc3.d}" fill="${colorAt2(model2, arc3.colorIndex)}" stroke="#FFFFFF" stroke-width="1.5"${arc3.pointIndex === void 0 ? "" : ` data-chart-series="0" data-chart-point="${arc3.pointIndex}"`}/>`
71699
+ `<path d="${arc3.d}" fill="${colorAt(model2, arc3.colorIndex)}" stroke="#FFFFFF" stroke-width="1.5"${arc3.pointIndex === void 0 ? "" : ` data-chart-series="0" data-chart-point="${arc3.pointIndex}"`}/>`
71722
71700
  );
71723
71701
  const flatLabels = levels.length > 1 || model2.series.length !== 1 ? void 0 : model2.categories;
71724
71702
  for (const arc3 of model2.hierarchy?.labels === false ? [] : arcs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ooxml-core",
3
- "version": "1.41.0",
3
+ "version": "1.42.0",
4
4
  "description": "Shared OOXML logic for the Word, PowerPoint and Excel viewers: everything except the UI",
5
5
  "keywords": [
6
6
  "charts",
@@ -1,5 +0,0 @@
1
- export { PptxHandler } from './chunk-HTELXT2N.mjs';
2
- import './chunk-UE23HF2N.mjs';
3
- import './chunk-P3WAKBVS.mjs';
4
- import './chunk-GXHKNSZX.mjs';
5
- import './chunk-CA7KCNL3.mjs';
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk3BIFRTU4_cjs = require('./chunk-3BIFRTU4.cjs');
4
- require('./chunk-LRBWCRQ3.cjs');
5
- require('./chunk-75KBNUKS.cjs');
6
- require('./chunk-XZPZHXV4.cjs');
7
- require('./chunk-5W2QL4SB.cjs');
8
-
9
-
10
-
11
- Object.defineProperty(exports, "PptxHandler", {
12
- enumerable: true,
13
- get: function () { return chunk3BIFRTU4_cjs.PptxHandler; }
14
- });
@@ -1,213 +0,0 @@
1
- // pptx/editor/render/table-layout.ts
2
- function createDefaultCell() {
3
- return { text: "", style: {} };
4
- }
5
- var DEFAULT_INSERTED_ROW_HEIGHT = 40;
6
- function insertTableRow(tableData, rowIdx, position) {
7
- const insertIdx = position === "above" ? rowIdx : rowIdx + 1;
8
- const colCount = tableData.columnWidths.length;
9
- const newCells = [];
10
- for (let c = 0; c < colCount; c++) {
11
- let insideMerge = false;
12
- for (let r = 0; r < insertIdx; r++) {
13
- const cell = tableData.rows[r]?.cells[c];
14
- if (!cell) {
15
- continue;
16
- }
17
- const rs = Math.max(1, cell.rowSpan ?? 1);
18
- if (rs > 1 && r + rs > insertIdx && !cell.vMerge && !cell.hMerge) {
19
- insideMerge = true;
20
- break;
21
- }
22
- }
23
- if (insideMerge) {
24
- newCells.push({ text: "", vMerge: true });
25
- } else {
26
- newCells.push(createDefaultCell());
27
- }
28
- }
29
- const adjustedRows = tableData.rows.map((row, ri) => {
30
- if (ri >= insertIdx) {
31
- return row;
32
- }
33
- let needsUpdate = false;
34
- const updatedCells = row.cells.map((cell) => {
35
- const rs = Math.max(1, cell.rowSpan ?? 1);
36
- if (rs > 1 && ri + rs > insertIdx && !cell.vMerge && !cell.hMerge) {
37
- needsUpdate = true;
38
- return { ...cell, rowSpan: rs + 1 };
39
- }
40
- return cell;
41
- });
42
- return needsUpdate ? { ...row, cells: updatedCells } : row;
43
- });
44
- const newRows = [...adjustedRows];
45
- newRows.splice(insertIdx, 0, { cells: newCells, height: DEFAULT_INSERTED_ROW_HEIGHT });
46
- return { ...tableData, rows: newRows };
47
- }
48
- function deleteTableRow(tableData, rowIdx) {
49
- if (tableData.rows.length <= 1) {
50
- return tableData;
51
- }
52
- if (rowIdx < 0 || rowIdx >= tableData.rows.length) {
53
- return tableData;
54
- }
55
- const removedRow = tableData.rows[rowIdx];
56
- const adjustedRows = [...tableData.rows];
57
- const updateCellRowSpan = (cells, colIdx, newRowSpan) => cells.map((cc, ci) => ci === colIdx ? { ...cc, rowSpan: newRowSpan } : cc);
58
- for (let c = 0; c < removedRow.cells.length; c++) {
59
- const cell = removedRow.cells[c];
60
- if (cell.vMerge) {
61
- for (let r = rowIdx - 1; r >= 0; r--) {
62
- const aboveCell = adjustedRows[r]?.cells[c];
63
- if (!aboveCell) {
64
- break;
65
- }
66
- if (!aboveCell.vMerge) {
67
- const rs = Math.max(1, aboveCell.rowSpan ?? 1);
68
- if (rs > 1) {
69
- adjustedRows[r] = {
70
- ...adjustedRows[r],
71
- cells: updateCellRowSpan(adjustedRows[r].cells, c, rs - 1 > 1 ? rs - 1 : void 0)
72
- };
73
- }
74
- break;
75
- }
76
- }
77
- } else {
78
- const rs = Math.max(1, cell.rowSpan ?? 1);
79
- if (rs > 1) {
80
- const nextRowIdx = rowIdx + 1;
81
- if (nextRowIdx < adjustedRows.length) {
82
- adjustedRows[nextRowIdx] = {
83
- ...adjustedRows[nextRowIdx],
84
- cells: adjustedRows[nextRowIdx].cells.map((cc, ci) => {
85
- if (ci !== c) {
86
- return cc;
87
- }
88
- const newRs = rs - 1;
89
- return {
90
- ...cc,
91
- text: cell.text || cc.text,
92
- textRuns: cell.text ? cell.textRuns : cc.textRuns,
93
- paragraphs: cell.text ? cell.paragraphs : cc.paragraphs,
94
- style: cc.style || cell.style,
95
- rowSpan: newRs > 1 ? newRs : void 0,
96
- vMerge: void 0,
97
- gridSpan: cell.gridSpan
98
- };
99
- })
100
- };
101
- }
102
- }
103
- }
104
- }
105
- const newRows = adjustedRows.filter((_, i) => i !== rowIdx);
106
- return { ...tableData, rows: newRows };
107
- }
108
- function normalizeWidths(widths) {
109
- const sum = widths.reduce((a, b) => a + b, 0);
110
- return sum > 0 ? widths.map((w) => w / sum) : widths;
111
- }
112
- function insertTableColumn(tableData, colIdx, position) {
113
- const insertIdx = position === "left" ? colIdx : colIdx + 1;
114
- const newWidths = [...tableData.columnWidths];
115
- const splitSourceIdx = insertIdx < newWidths.length ? insertIdx : newWidths.length - 1;
116
- const originalWidth = newWidths[splitSourceIdx] ?? 1 / newWidths.length;
117
- const halfWidth = originalWidth / 2;
118
- newWidths[splitSourceIdx] = halfWidth;
119
- newWidths.splice(insertIdx, 0, halfWidth);
120
- const normalizedWidths = normalizeWidths(newWidths);
121
- const newRows = tableData.rows.map((row) => {
122
- let insideMerge = false;
123
- for (let c = 0; c < insertIdx && c < row.cells.length; c++) {
124
- const cell = row.cells[c];
125
- if (!cell) {
126
- continue;
127
- }
128
- const gs = Math.max(1, cell.gridSpan ?? 1);
129
- if (gs > 1 && c + gs > insertIdx && !cell.hMerge) {
130
- insideMerge = true;
131
- break;
132
- }
133
- }
134
- const newCells = [...row.cells];
135
- const newCell = insideMerge ? { text: "", hMerge: true } : createDefaultCell();
136
- newCells.splice(insertIdx, 0, newCell);
137
- return { ...row, cells: newCells };
138
- });
139
- const finalRows = newRows.map((row) => {
140
- let needsUpdate = false;
141
- const updatedCells = row.cells.map((cell, ci) => {
142
- if (ci >= insertIdx) {
143
- return cell;
144
- }
145
- const gs = Math.max(1, cell.gridSpan ?? 1);
146
- if (gs > 1 && ci + gs > insertIdx && !cell.hMerge && !cell.vMerge) {
147
- needsUpdate = true;
148
- return { ...cell, gridSpan: gs + 1 };
149
- }
150
- return cell;
151
- });
152
- return needsUpdate ? { ...row, cells: updatedCells } : row;
153
- });
154
- return { ...tableData, rows: finalRows, columnWidths: normalizedWidths };
155
- }
156
- function deleteTableColumn(tableData, colIdx) {
157
- if (tableData.columnWidths.length <= 1) {
158
- return tableData;
159
- }
160
- if (colIdx < 0 || colIdx >= tableData.columnWidths.length) {
161
- return tableData;
162
- }
163
- const newRows = tableData.rows.map((row) => {
164
- const adjustedCells = [...row.cells];
165
- const cell = adjustedCells[colIdx];
166
- if (cell) {
167
- if (cell.hMerge) {
168
- for (let c = colIdx - 1; c >= 0; c--) {
169
- const leftCell = adjustedCells[c];
170
- if (!leftCell) {
171
- break;
172
- }
173
- if (!leftCell.hMerge) {
174
- const gs = Math.max(1, leftCell.gridSpan ?? 1);
175
- if (gs > 1) {
176
- adjustedCells[c] = {
177
- ...leftCell,
178
- gridSpan: gs - 1 > 1 ? gs - 1 : void 0
179
- };
180
- }
181
- break;
182
- }
183
- }
184
- } else {
185
- const gs = Math.max(1, cell.gridSpan ?? 1);
186
- if (gs > 1) {
187
- const nextColIdx = colIdx + 1;
188
- if (nextColIdx < adjustedCells.length) {
189
- const nextCell = adjustedCells[nextColIdx];
190
- adjustedCells[nextColIdx] = {
191
- ...nextCell,
192
- text: cell.text || nextCell.text,
193
- textRuns: cell.text ? cell.textRuns : nextCell.textRuns,
194
- paragraphs: cell.text ? cell.paragraphs : nextCell.paragraphs,
195
- style: nextCell.style || cell.style,
196
- gridSpan: gs - 1 > 1 ? gs - 1 : void 0,
197
- hMerge: void 0,
198
- rowSpan: cell.rowSpan
199
- };
200
- }
201
- }
202
- }
203
- }
204
- return {
205
- ...row,
206
- cells: adjustedCells.filter((_, i) => i !== colIdx)
207
- };
208
- });
209
- const newWidths = normalizeWidths(tableData.columnWidths.filter((_, i) => i !== colIdx));
210
- return { ...tableData, rows: newRows, columnWidths: newWidths };
211
- }
212
-
213
- export { DEFAULT_INSERTED_ROW_HEIGHT, deleteTableColumn, deleteTableRow, insertTableColumn, insertTableRow };
@@ -1,219 +0,0 @@
1
- 'use strict';
2
-
3
- // pptx/editor/render/table-layout.ts
4
- function createDefaultCell() {
5
- return { text: "", style: {} };
6
- }
7
- var DEFAULT_INSERTED_ROW_HEIGHT = 40;
8
- function insertTableRow(tableData, rowIdx, position) {
9
- const insertIdx = position === "above" ? rowIdx : rowIdx + 1;
10
- const colCount = tableData.columnWidths.length;
11
- const newCells = [];
12
- for (let c = 0; c < colCount; c++) {
13
- let insideMerge = false;
14
- for (let r = 0; r < insertIdx; r++) {
15
- const cell = tableData.rows[r]?.cells[c];
16
- if (!cell) {
17
- continue;
18
- }
19
- const rs = Math.max(1, cell.rowSpan ?? 1);
20
- if (rs > 1 && r + rs > insertIdx && !cell.vMerge && !cell.hMerge) {
21
- insideMerge = true;
22
- break;
23
- }
24
- }
25
- if (insideMerge) {
26
- newCells.push({ text: "", vMerge: true });
27
- } else {
28
- newCells.push(createDefaultCell());
29
- }
30
- }
31
- const adjustedRows = tableData.rows.map((row, ri) => {
32
- if (ri >= insertIdx) {
33
- return row;
34
- }
35
- let needsUpdate = false;
36
- const updatedCells = row.cells.map((cell) => {
37
- const rs = Math.max(1, cell.rowSpan ?? 1);
38
- if (rs > 1 && ri + rs > insertIdx && !cell.vMerge && !cell.hMerge) {
39
- needsUpdate = true;
40
- return { ...cell, rowSpan: rs + 1 };
41
- }
42
- return cell;
43
- });
44
- return needsUpdate ? { ...row, cells: updatedCells } : row;
45
- });
46
- const newRows = [...adjustedRows];
47
- newRows.splice(insertIdx, 0, { cells: newCells, height: DEFAULT_INSERTED_ROW_HEIGHT });
48
- return { ...tableData, rows: newRows };
49
- }
50
- function deleteTableRow(tableData, rowIdx) {
51
- if (tableData.rows.length <= 1) {
52
- return tableData;
53
- }
54
- if (rowIdx < 0 || rowIdx >= tableData.rows.length) {
55
- return tableData;
56
- }
57
- const removedRow = tableData.rows[rowIdx];
58
- const adjustedRows = [...tableData.rows];
59
- const updateCellRowSpan = (cells, colIdx, newRowSpan) => cells.map((cc, ci) => ci === colIdx ? { ...cc, rowSpan: newRowSpan } : cc);
60
- for (let c = 0; c < removedRow.cells.length; c++) {
61
- const cell = removedRow.cells[c];
62
- if (cell.vMerge) {
63
- for (let r = rowIdx - 1; r >= 0; r--) {
64
- const aboveCell = adjustedRows[r]?.cells[c];
65
- if (!aboveCell) {
66
- break;
67
- }
68
- if (!aboveCell.vMerge) {
69
- const rs = Math.max(1, aboveCell.rowSpan ?? 1);
70
- if (rs > 1) {
71
- adjustedRows[r] = {
72
- ...adjustedRows[r],
73
- cells: updateCellRowSpan(adjustedRows[r].cells, c, rs - 1 > 1 ? rs - 1 : void 0)
74
- };
75
- }
76
- break;
77
- }
78
- }
79
- } else {
80
- const rs = Math.max(1, cell.rowSpan ?? 1);
81
- if (rs > 1) {
82
- const nextRowIdx = rowIdx + 1;
83
- if (nextRowIdx < adjustedRows.length) {
84
- adjustedRows[nextRowIdx] = {
85
- ...adjustedRows[nextRowIdx],
86
- cells: adjustedRows[nextRowIdx].cells.map((cc, ci) => {
87
- if (ci !== c) {
88
- return cc;
89
- }
90
- const newRs = rs - 1;
91
- return {
92
- ...cc,
93
- text: cell.text || cc.text,
94
- textRuns: cell.text ? cell.textRuns : cc.textRuns,
95
- paragraphs: cell.text ? cell.paragraphs : cc.paragraphs,
96
- style: cc.style || cell.style,
97
- rowSpan: newRs > 1 ? newRs : void 0,
98
- vMerge: void 0,
99
- gridSpan: cell.gridSpan
100
- };
101
- })
102
- };
103
- }
104
- }
105
- }
106
- }
107
- const newRows = adjustedRows.filter((_, i) => i !== rowIdx);
108
- return { ...tableData, rows: newRows };
109
- }
110
- function normalizeWidths(widths) {
111
- const sum = widths.reduce((a, b) => a + b, 0);
112
- return sum > 0 ? widths.map((w) => w / sum) : widths;
113
- }
114
- function insertTableColumn(tableData, colIdx, position) {
115
- const insertIdx = position === "left" ? colIdx : colIdx + 1;
116
- const newWidths = [...tableData.columnWidths];
117
- const splitSourceIdx = insertIdx < newWidths.length ? insertIdx : newWidths.length - 1;
118
- const originalWidth = newWidths[splitSourceIdx] ?? 1 / newWidths.length;
119
- const halfWidth = originalWidth / 2;
120
- newWidths[splitSourceIdx] = halfWidth;
121
- newWidths.splice(insertIdx, 0, halfWidth);
122
- const normalizedWidths = normalizeWidths(newWidths);
123
- const newRows = tableData.rows.map((row) => {
124
- let insideMerge = false;
125
- for (let c = 0; c < insertIdx && c < row.cells.length; c++) {
126
- const cell = row.cells[c];
127
- if (!cell) {
128
- continue;
129
- }
130
- const gs = Math.max(1, cell.gridSpan ?? 1);
131
- if (gs > 1 && c + gs > insertIdx && !cell.hMerge) {
132
- insideMerge = true;
133
- break;
134
- }
135
- }
136
- const newCells = [...row.cells];
137
- const newCell = insideMerge ? { text: "", hMerge: true } : createDefaultCell();
138
- newCells.splice(insertIdx, 0, newCell);
139
- return { ...row, cells: newCells };
140
- });
141
- const finalRows = newRows.map((row) => {
142
- let needsUpdate = false;
143
- const updatedCells = row.cells.map((cell, ci) => {
144
- if (ci >= insertIdx) {
145
- return cell;
146
- }
147
- const gs = Math.max(1, cell.gridSpan ?? 1);
148
- if (gs > 1 && ci + gs > insertIdx && !cell.hMerge && !cell.vMerge) {
149
- needsUpdate = true;
150
- return { ...cell, gridSpan: gs + 1 };
151
- }
152
- return cell;
153
- });
154
- return needsUpdate ? { ...row, cells: updatedCells } : row;
155
- });
156
- return { ...tableData, rows: finalRows, columnWidths: normalizedWidths };
157
- }
158
- function deleteTableColumn(tableData, colIdx) {
159
- if (tableData.columnWidths.length <= 1) {
160
- return tableData;
161
- }
162
- if (colIdx < 0 || colIdx >= tableData.columnWidths.length) {
163
- return tableData;
164
- }
165
- const newRows = tableData.rows.map((row) => {
166
- const adjustedCells = [...row.cells];
167
- const cell = adjustedCells[colIdx];
168
- if (cell) {
169
- if (cell.hMerge) {
170
- for (let c = colIdx - 1; c >= 0; c--) {
171
- const leftCell = adjustedCells[c];
172
- if (!leftCell) {
173
- break;
174
- }
175
- if (!leftCell.hMerge) {
176
- const gs = Math.max(1, leftCell.gridSpan ?? 1);
177
- if (gs > 1) {
178
- adjustedCells[c] = {
179
- ...leftCell,
180
- gridSpan: gs - 1 > 1 ? gs - 1 : void 0
181
- };
182
- }
183
- break;
184
- }
185
- }
186
- } else {
187
- const gs = Math.max(1, cell.gridSpan ?? 1);
188
- if (gs > 1) {
189
- const nextColIdx = colIdx + 1;
190
- if (nextColIdx < adjustedCells.length) {
191
- const nextCell = adjustedCells[nextColIdx];
192
- adjustedCells[nextColIdx] = {
193
- ...nextCell,
194
- text: cell.text || nextCell.text,
195
- textRuns: cell.text ? cell.textRuns : nextCell.textRuns,
196
- paragraphs: cell.text ? cell.paragraphs : nextCell.paragraphs,
197
- style: nextCell.style || cell.style,
198
- gridSpan: gs - 1 > 1 ? gs - 1 : void 0,
199
- hMerge: void 0,
200
- rowSpan: cell.rowSpan
201
- };
202
- }
203
- }
204
- }
205
- }
206
- return {
207
- ...row,
208
- cells: adjustedCells.filter((_, i) => i !== colIdx)
209
- };
210
- });
211
- const newWidths = normalizeWidths(tableData.columnWidths.filter((_, i) => i !== colIdx));
212
- return { ...tableData, rows: newRows, columnWidths: newWidths };
213
- }
214
-
215
- exports.DEFAULT_INSERTED_ROW_HEIGHT = DEFAULT_INSERTED_ROW_HEIGHT;
216
- exports.deleteTableColumn = deleteTableColumn;
217
- exports.deleteTableRow = deleteTableRow;
218
- exports.insertTableColumn = insertTableColumn;
219
- exports.insertTableRow = insertTableRow;