js.documents 1.60.3 → 1.62.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 (216) hide show
  1. package/README.md +84 -44
  2. package/dist/{blr-types-CYYC3yYU.d.cts → blr-types-DVgO1DQ9.d.cts} +1 -1
  3. package/dist/{blr-types-CYYC3yYU.d.ts → blr-types-DVgO1DQ9.d.ts} +1 -1
  4. package/dist/convert/capability.cjs +1 -0
  5. package/dist/convert/capability.d.cts +1 -1
  6. package/dist/convert/capability.d.ts +1 -1
  7. package/dist/convert/capability.js +1 -0
  8. package/dist/convert/convert.cjs +29 -27
  9. package/dist/convert/convert.d.cts +9 -3
  10. package/dist/convert/convert.d.ts +9 -3
  11. package/dist/convert/convert.js +29 -27
  12. package/dist/edit/docx/content.cjs +75 -13
  13. package/dist/edit/docx/content.d.cts +8 -2
  14. package/dist/edit/docx/content.d.ts +8 -2
  15. package/dist/edit/docx/content.js +75 -13
  16. package/dist/edit/docx/paragraph.cjs +14 -0
  17. package/dist/edit/docx/paragraph.d.cts +5 -0
  18. package/dist/edit/docx/paragraph.d.ts +5 -0
  19. package/dist/edit/docx/paragraph.js +14 -0
  20. package/dist/edit/docx/run.cjs +1 -1
  21. package/dist/edit/docx/run.js +1 -1
  22. package/dist/edit/docx/table.cjs +41 -0
  23. package/dist/edit/docx/table.d.cts +7 -1
  24. package/dist/edit/docx/table.d.ts +7 -1
  25. package/dist/edit/docx/table.js +42 -1
  26. package/dist/edit/geometry.cjs +38 -0
  27. package/dist/edit/geometry.d.cts +7 -0
  28. package/dist/edit/geometry.d.ts +7 -0
  29. package/dist/edit/geometry.js +36 -0
  30. package/dist/edit/odg/content.cjs +15 -12
  31. package/dist/edit/odg/content.js +15 -12
  32. package/dist/edit/odg/editor.d.cts +1 -1
  33. package/dist/edit/odg/editor.d.ts +1 -1
  34. package/dist/edit/odg/page.d.cts +3 -3
  35. package/dist/edit/odg/page.d.ts +3 -3
  36. package/dist/edit/odg/vector.cjs +22 -13
  37. package/dist/edit/odg/vector.d.cts +1 -1
  38. package/dist/edit/odg/vector.d.ts +1 -1
  39. package/dist/edit/odg/vector.js +23 -14
  40. package/dist/edit/odp/content.cjs +15 -0
  41. package/dist/edit/odp/content.js +16 -1
  42. package/dist/edit/odp/editor.d.cts +1 -1
  43. package/dist/edit/odp/editor.d.ts +1 -1
  44. package/dist/edit/odp/image.d.cts +1 -1
  45. package/dist/edit/odp/image.d.ts +1 -1
  46. package/dist/edit/odp/shape.cjs +11 -30
  47. package/dist/edit/odp/shape.d.cts +2 -2
  48. package/dist/edit/odp/shape.d.ts +2 -2
  49. package/dist/edit/odp/shape.js +13 -33
  50. package/dist/edit/odp/slide.cjs +11 -0
  51. package/dist/edit/odp/slide.d.cts +14 -4
  52. package/dist/edit/odp/slide.d.ts +14 -4
  53. package/dist/edit/odp/slide.js +12 -1
  54. package/dist/edit/odt/content.cjs +56 -16
  55. package/dist/edit/odt/content.d.cts +4 -2
  56. package/dist/edit/odt/content.d.ts +4 -2
  57. package/dist/edit/odt/content.js +56 -17
  58. package/dist/edit/odt/editor.d.cts +1 -1
  59. package/dist/edit/odt/editor.d.ts +1 -1
  60. package/dist/edit/odt/table.cjs +36 -0
  61. package/dist/edit/odt/table.d.cts +1 -36
  62. package/dist/edit/odt/table.d.ts +1 -36
  63. package/dist/edit/odt/table.js +37 -1
  64. package/dist/edit/pptx/content.cjs +71 -3
  65. package/dist/edit/pptx/content.js +71 -3
  66. package/dist/edit/pptx/editor.d.cts +1 -1
  67. package/dist/edit/pptx/editor.d.ts +1 -1
  68. package/dist/edit/pptx/image.d.cts +1 -1
  69. package/dist/edit/pptx/image.d.ts +1 -1
  70. package/dist/edit/pptx/shape.cjs +23 -1
  71. package/dist/edit/pptx/shape.d.cts +2 -2
  72. package/dist/edit/pptx/shape.d.ts +2 -2
  73. package/dist/edit/pptx/shape.js +23 -3
  74. package/dist/edit/pptx/slide.cjs +10 -1
  75. package/dist/edit/pptx/slide.d.cts +11 -4
  76. package/dist/edit/pptx/slide.d.ts +11 -4
  77. package/dist/edit/pptx/slide.js +10 -1
  78. package/dist/edit/pptx/table.cjs +136 -0
  79. package/dist/edit/pptx/table.d.cts +2 -0
  80. package/dist/edit/pptx/table.d.ts +2 -0
  81. package/dist/edit/pptx/table.js +131 -0
  82. package/dist/firebird/backup.d.cts +1 -1
  83. package/dist/firebird/backup.d.ts +1 -1
  84. package/dist/firebird/blr-types.cjs +2 -2
  85. package/dist/firebird/blr-types.d.cts +1 -1
  86. package/dist/firebird/blr-types.d.ts +1 -1
  87. package/dist/firebird/blr-types.js +2 -2
  88. package/dist/firebird/data.cjs +68 -14
  89. package/dist/firebird/data.d.cts +1 -1
  90. package/dist/firebird/data.d.ts +1 -1
  91. package/dist/firebird/data.js +68 -14
  92. package/dist/firebird/schema.cjs +13 -1
  93. package/dist/firebird/schema.d.cts +1 -1
  94. package/dist/firebird/schema.d.ts +1 -1
  95. package/dist/firebird/schema.js +13 -1
  96. package/dist/{geometry-DvwdrIij.d.cts → geometry-DaJr8yQW.d.cts} +2 -2
  97. package/dist/{geometry-DvwdrIij.d.ts → geometry-DaJr8yQW.d.ts} +2 -2
  98. package/dist/hsqldb/binary-script.cjs +154 -0
  99. package/dist/hsqldb/binary-script.d.cts +15 -0
  100. package/dist/hsqldb/binary-script.d.ts +15 -0
  101. package/dist/hsqldb/binary-script.js +151 -0
  102. package/dist/hsqldb/cache.cjs +18 -11
  103. package/dist/hsqldb/cache.d.cts +9 -4
  104. package/dist/hsqldb/cache.d.ts +9 -4
  105. package/dist/hsqldb/cache.js +18 -11
  106. package/dist/hsqldb/rowformat.cjs +60 -16
  107. package/dist/hsqldb/rowformat.d.cts +2 -21
  108. package/dist/hsqldb/rowformat.d.ts +2 -21
  109. package/dist/hsqldb/rowformat.js +60 -17
  110. package/dist/{image-BZDy72Jb.d.cts → image-7snmKIxn.d.cts} +1 -1
  111. package/dist/{image-B-xQWYYS.d.ts → image-Cs8xF753.d.ts} +1 -1
  112. package/dist/{image-CeqwL-Qs.d.ts → image-DHcA9kaK.d.ts} +1 -1
  113. package/dist/{image-DWX6cNOD.d.cts → image-M5SezZVI.d.cts} +1 -1
  114. package/dist/index.cjs +54 -3
  115. package/dist/index.d.cts +28 -20
  116. package/dist/index.d.ts +27 -19
  117. package/dist/index.js +13 -4
  118. package/dist/layout/cell-typing.cjs +209 -0
  119. package/dist/layout/cell-typing.d.cts +22 -0
  120. package/dist/layout/cell-typing.d.ts +22 -0
  121. package/dist/layout/cell-typing.js +208 -0
  122. package/dist/layout/drawing.cjs +193 -17
  123. package/dist/layout/drawing.js +193 -17
  124. package/dist/layout/engine.cjs +46 -29
  125. package/dist/layout/engine.d.cts +0 -2
  126. package/dist/layout/engine.d.ts +0 -2
  127. package/dist/layout/engine.js +47 -30
  128. package/dist/layout/lattice.cjs +139 -0
  129. package/dist/layout/lattice.d.cts +20 -0
  130. package/dist/layout/lattice.d.ts +20 -0
  131. package/dist/layout/lattice.js +135 -0
  132. package/dist/layout/reconstruct.cjs +176 -113
  133. package/dist/layout/reconstruct.d.cts +2 -0
  134. package/dist/layout/reconstruct.d.ts +2 -0
  135. package/dist/layout/reconstruct.js +173 -110
  136. package/dist/layout/shared.cjs +52 -0
  137. package/dist/layout/shared.d.cts +4 -2
  138. package/dist/layout/shared.d.ts +4 -2
  139. package/dist/layout/shared.js +51 -1
  140. package/dist/layout/sheets.cjs +45 -11
  141. package/dist/layout/sheets.js +46 -12
  142. package/dist/layout/slides.cjs +7 -7
  143. package/dist/layout/slides.d.cts +0 -3
  144. package/dist/layout/slides.d.ts +0 -3
  145. package/dist/layout/slides.js +7 -7
  146. package/dist/markdown/write.cjs +19 -6
  147. package/dist/markdown/write.js +19 -6
  148. package/dist/mathml/layout.cjs +43 -9
  149. package/dist/mathml/layout.d.cts +1 -1
  150. package/dist/mathml/layout.d.ts +1 -1
  151. package/dist/mathml/layout.js +43 -9
  152. package/dist/mathml/variant.cjs +48 -5
  153. package/dist/mathml/variant.js +48 -5
  154. package/dist/model/embedded-drawing.cjs +32 -0
  155. package/dist/model/embedded-drawing.d.cts +8 -0
  156. package/dist/model/embedded-drawing.d.ts +8 -0
  157. package/dist/model/embedded-drawing.js +30 -0
  158. package/dist/model/formula.cjs +31 -0
  159. package/dist/model/formula.d.cts +6 -6
  160. package/dist/model/formula.d.ts +6 -6
  161. package/dist/model/formula.js +27 -0
  162. package/dist/model/geometry.d.cts +1 -1
  163. package/dist/model/geometry.d.ts +1 -1
  164. package/dist/model/paint-order.cjs +15 -0
  165. package/dist/model/paint-order.d.cts +14 -0
  166. package/dist/model/paint-order.d.ts +14 -0
  167. package/dist/model/paint-order.js +14 -0
  168. package/dist/odb/components.cjs +12 -0
  169. package/dist/odb/components.d.cts +6 -0
  170. package/dist/odb/components.d.ts +6 -0
  171. package/dist/odb/components.js +10 -0
  172. package/dist/odb/read.cjs +11 -7
  173. package/dist/odb/read.d.cts +3 -2
  174. package/dist/odb/read.d.ts +3 -2
  175. package/dist/odb/read.js +11 -7
  176. package/dist/odf/formula/detect.cjs +86 -18
  177. package/dist/odf/formula/detect.d.cts +10 -6
  178. package/dist/odf/formula/detect.d.ts +10 -6
  179. package/dist/odf/formula/detect.js +86 -19
  180. package/dist/odf/formula/read.cjs +4 -16
  181. package/dist/odf/formula/read.d.cts +4 -8
  182. package/dist/odf/formula/read.d.ts +4 -8
  183. package/dist/odf/formula/read.js +5 -17
  184. package/dist/odf/odp/read.cjs +9 -19
  185. package/dist/odf/odp/read.d.cts +2 -7
  186. package/dist/odf/odp/read.d.ts +2 -7
  187. package/dist/odf/odp/read.js +10 -20
  188. package/dist/odf/odt/read.cjs +63 -23
  189. package/dist/odf/odt/read.d.cts +2 -7
  190. package/dist/odf/odt/read.d.ts +2 -7
  191. package/dist/odf/odt/read.js +64 -24
  192. package/dist/omml/write.cjs +258 -0
  193. package/dist/omml/write.d.cts +2 -0
  194. package/dist/omml/write.d.ts +2 -0
  195. package/dist/omml/write.js +256 -0
  196. package/dist/rowformat-Cl2exlEh.d.cts +25 -0
  197. package/dist/rowformat-Cl2exlEh.d.ts +25 -0
  198. package/dist/{schema-Acco3Ezi.d.cts → schema-BeR_KJ0X.d.cts} +3 -1
  199. package/dist/{schema-VkAA6pF5.d.ts → schema-CSKwSb_v.d.ts} +3 -1
  200. package/dist/{shape-BUfjw5eZ.d.cts → shape-BhkP6HB8.d.cts} +6 -2
  201. package/dist/{shape-CTkl6kt8.d.ts → shape-BkVcwPcf.d.ts} +6 -2
  202. package/dist/{shape-BfN3m52m.d.ts → shape-CVXedeL7.d.ts} +3 -2
  203. package/dist/{shape-CN2ycxOo.d.cts → shape-CXZ6fejV.d.cts} +3 -2
  204. package/dist/table-C3CPZ--2.d.cts +35 -0
  205. package/dist/table-DjYcNOFm.d.cts +44 -0
  206. package/dist/table-DqfqMkVq.d.ts +44 -0
  207. package/dist/table-DvS_7UQS.d.ts +35 -0
  208. package/dist/{vector-ClohqsOe.d.cts → vector-Puuqu_IT.d.cts} +4 -0
  209. package/dist/{vector-ClohqsOe.d.ts → vector-Puuqu_IT.d.ts} +4 -0
  210. package/dist/write-DuyfnbL_.d.cts +16 -0
  211. package/dist/write-Zqwx6pka.d.ts +16 -0
  212. package/package.json +4 -4
  213. package/dist/odf/formula/placeholder.cjs +0 -36
  214. package/dist/odf/formula/placeholder.d.cts +0 -14
  215. package/dist/odf/formula/placeholder.d.ts +0 -14
  216. package/dist/odf/formula/placeholder.js +0 -36
@@ -1,3 +1,4 @@
1
+ import { formulaOfBlock, formulaPlaceholderText } from "../../model/formula.js";
1
2
  import { createOdt } from "./editor.js";
2
3
  //#region src/edit/odt/content.ts
3
4
  function buildOdtPackage(content) {
@@ -74,27 +75,56 @@ function populateParagraph(paragraph, block) {
74
75
  if (run.color !== void 0) odtRun.color = run.color;
75
76
  }
76
77
  }
78
+ function populateCellBlocks(cell, blocks) {
79
+ const [firstBlock, ...restBlocks] = blocks;
80
+ const firstParagraph = cell.paragraphs()[0];
81
+ if (firstBlock?.kind === "paragraph" && firstParagraph !== void 0) populateParagraph(firstParagraph, firstBlock);
82
+ else if (firstBlock !== void 0) appendCellBlock(cell, firstBlock);
83
+ for (const remaining of restBlocks) appendCellBlock(cell, remaining);
84
+ }
85
+ function populateOdtTable(table, block) {
86
+ const verticalMerges = /* @__PURE__ */ new Map();
87
+ block.rows.forEach((row) => {
88
+ const tableRow = table.appendEmptyRow();
89
+ let colIndex = 0;
90
+ let horizontalCoverRemaining = 0;
91
+ row.cells.forEach((cell) => {
92
+ if (horizontalCoverRemaining > 0) {
93
+ tableRow.appendCoveredCell();
94
+ horizontalCoverRemaining -= 1;
95
+ colIndex += 1;
96
+ return;
97
+ }
98
+ const verticalRemaining = verticalMerges.get(colIndex);
99
+ if (verticalRemaining !== void 0 && verticalRemaining > 0) {
100
+ tableRow.appendCoveredCell();
101
+ verticalMerges.set(colIndex, verticalRemaining - 1);
102
+ colIndex += 1;
103
+ return;
104
+ }
105
+ const tableCell = tableRow.appendCell();
106
+ const span = cell.colSpan ?? 1;
107
+ if (span > 1) {
108
+ tableCell.colSpan = span;
109
+ horizontalCoverRemaining = span - 1;
110
+ }
111
+ if (cell.rowSpan !== void 0 && cell.rowSpan > 1) {
112
+ tableCell.rowSpan = cell.rowSpan;
113
+ for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
114
+ }
115
+ populateCellBlocks(tableCell, cell.blocks);
116
+ colIndex += 1;
117
+ });
118
+ });
119
+ }
77
120
  function appendTable(body, block) {
78
121
  const columns = block.columnWidthsPt.length;
79
122
  if (block.rows.length === 0 || columns === 0) return;
80
- const table = body.appendTable({
81
- rows: block.rows.length,
123
+ populateOdtTable(body.appendTable({
124
+ rows: 0,
82
125
  columns,
83
126
  columnWidthsPt: block.columnWidthsPt
84
- });
85
- block.rows.forEach((row, rowIndex) => {
86
- const tableRow = table.rows()[rowIndex];
87
- if (tableRow === void 0) return;
88
- row.cells.forEach((cell, cellIndex) => {
89
- const tableCell = tableRow.cells()[cellIndex];
90
- if (tableCell === void 0) return;
91
- const [firstBlock, ...restBlocks] = cell.blocks;
92
- const firstParagraph = tableCell.paragraphs()[0];
93
- if (firstBlock?.kind === "paragraph" && firstParagraph !== void 0) populateParagraph(firstParagraph, firstBlock);
94
- else if (firstBlock !== void 0) appendCellBlock(tableCell, firstBlock);
95
- for (const remaining of restBlocks) appendCellBlock(tableCell, remaining);
96
- });
97
- });
127
+ }), block);
98
128
  }
99
129
  function appendCellBlock(cell, block) {
100
130
  if (block.kind === "paragraph") populateParagraph(cell.appendParagraph(), block);
@@ -103,6 +133,15 @@ function appendBlock(body, block) {
103
133
  if (block.kind === "paragraph") populateParagraph(body.appendParagraph(), block);
104
134
  else if (block.kind === "pageBreak") body.appendPageBreak();
105
135
  else if (block.kind === "table") appendTable(body, block);
136
+ else if (block.kind === "embeddedObject") appendEmbeddedObject(body, block);
137
+ }
138
+ function appendEmbeddedObject(body, block) {
139
+ const formula = formulaOfBlock(block);
140
+ if (formula === void 0) return;
141
+ populateParagraph(body.appendParagraph(), {
142
+ kind: "paragraph",
143
+ runs: [{ text: formulaPlaceholderText(formula) }]
144
+ });
106
145
  }
107
146
  //#endregion
108
- export { buildOdtPackage, populateParagraph };
147
+ export { buildOdtPackage, populateOdtTable, populateParagraph };
@@ -1,6 +1,6 @@
1
1
  import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-BXbXKPy3.cjs";
2
2
  import { t as OdtList } from "../../list-BuBM9rwQ.cjs";
3
- import { OdtTable, TableInit } from "./table.cjs";
3
+ import { i as TableInit, t as OdtTable } from "../../table-DjYcNOFm.cjs";
4
4
  import { Package } from "odf.js";
5
5
  //#region src/edit/odt/editor.d.ts
6
6
  interface OdtBody {
@@ -1,6 +1,6 @@
1
1
  import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-CoUi_88j.js";
2
2
  import { t as OdtList } from "../../list-CvKxhy3y.js";
3
- import { OdtTable, TableInit } from "./table.js";
3
+ import { i as TableInit, t as OdtTable } from "../../table-DqfqMkVq.js";
4
4
  import { Package } from "odf.js";
5
5
  //#region src/edit/odt/editor.d.ts
6
6
  interface OdtBody {
@@ -46,6 +46,28 @@ var OdtTableCell = class {
46
46
  get text() {
47
47
  return this.paragraphs().map((p) => p.text).join("\n");
48
48
  }
49
+ get colSpan() {
50
+ const raw = (0, ooxml_js.attr)(this.node, "table:number-columns-spanned");
51
+ return raw === void 0 ? void 0 : Number(raw);
52
+ }
53
+ set colSpan(value) {
54
+ if (value === void 0) {
55
+ require_xml_edit.removeAttr(this.node, "table:number-columns-spanned");
56
+ return;
57
+ }
58
+ require_xml_edit.setAttr(this.node, "table:number-columns-spanned", String(value));
59
+ }
60
+ get rowSpan() {
61
+ const raw = (0, ooxml_js.attr)(this.node, "table:number-rows-spanned");
62
+ return raw === void 0 ? void 0 : Number(raw);
63
+ }
64
+ set rowSpan(value) {
65
+ if (value === void 0) {
66
+ require_xml_edit.removeAttr(this.node, "table:number-rows-spanned");
67
+ return;
68
+ }
69
+ require_xml_edit.setAttr(this.node, "table:number-rows-spanned", String(value));
70
+ }
49
71
  };
50
72
  var OdtTableRow = class {
51
73
  node;
@@ -59,6 +81,14 @@ var OdtTableRow = class {
59
81
  for (const child of this.node.children) if (child.type === "element" && child.tag === "table:table-cell") out.push(new OdtTableCell(child, this.pkg));
60
82
  return out;
61
83
  }
84
+ appendCell() {
85
+ const cellElement = buildCell(this.pkg);
86
+ this.node.children.push(cellElement);
87
+ return new OdtTableCell(cellElement, this.pkg);
88
+ }
89
+ appendCoveredCell() {
90
+ this.node.children.push(require_xml_fragment.el("table:covered-table-cell"));
91
+ }
62
92
  };
63
93
  function buildCell(pkg) {
64
94
  return require_xml_fragment.el("table:table-cell", {}, [require_edit_odt_paragraph.buildParagraph(pkg)]);
@@ -100,6 +130,12 @@ var OdtTable = class {
100
130
  node.children.push(row);
101
131
  return new OdtTableRow(row, this.pkg);
102
132
  }
133
+ appendEmptyRow() {
134
+ const node = this.live();
135
+ const row = require_xml_fragment.el("table:table-row");
136
+ node.children.push(row);
137
+ return new OdtTableRow(row, this.pkg);
138
+ }
103
139
  remove() {
104
140
  require_xml_edit.removeChild(this.container, this.live());
105
141
  this.removed = true;
@@ -1,37 +1,2 @@
1
- import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-BXbXKPy3.cjs";
2
- import { Package, XmlElement, XmlNode } from "odf.js";
3
- //#region src/edit/odt/table.d.ts
4
- interface TableInit {
5
- readonly rows: number;
6
- readonly columns: number;
7
- readonly columnWidthsPt?: readonly number[];
8
- }
9
- declare class OdtTableCell {
10
- private readonly node;
11
- private readonly pkg;
12
- constructor(node: XmlElement, pkg: Package);
13
- paragraphs(): OdtParagraph[];
14
- appendParagraph(init?: ParagraphInit): OdtParagraph;
15
- get text(): string;
16
- }
17
- declare class OdtTableRow {
18
- private readonly node;
19
- private readonly pkg;
20
- constructor(node: XmlElement, pkg: Package);
21
- cells(): OdtTableCell[];
22
- }
23
- declare class OdtTable {
24
- private readonly container;
25
- private readonly node;
26
- private readonly pkg;
27
- private removed;
28
- constructor(container: XmlNode[], node: XmlElement, pkg: Package);
29
- private live;
30
- rows(): OdtTableRow[];
31
- cell(rowIndex: number, columnIndex: number): OdtTableCell;
32
- appendRow(columnCount: number): OdtTableRow;
33
- remove(): void;
34
- }
35
- declare function buildTable(pkg: Package, init: TableInit): XmlElement;
36
- //#endregion
1
+ import { a as buildTable, i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "../../table-DjYcNOFm.cjs";
37
2
  export { OdtTable, OdtTableCell, OdtTableRow, TableInit, buildTable };
@@ -1,37 +1,2 @@
1
- import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-CoUi_88j.js";
2
- import { Package, XmlElement, XmlNode } from "odf.js";
3
- //#region src/edit/odt/table.d.ts
4
- interface TableInit {
5
- readonly rows: number;
6
- readonly columns: number;
7
- readonly columnWidthsPt?: readonly number[];
8
- }
9
- declare class OdtTableCell {
10
- private readonly node;
11
- private readonly pkg;
12
- constructor(node: XmlElement, pkg: Package);
13
- paragraphs(): OdtParagraph[];
14
- appendParagraph(init?: ParagraphInit): OdtParagraph;
15
- get text(): string;
16
- }
17
- declare class OdtTableRow {
18
- private readonly node;
19
- private readonly pkg;
20
- constructor(node: XmlElement, pkg: Package);
21
- cells(): OdtTableCell[];
22
- }
23
- declare class OdtTable {
24
- private readonly container;
25
- private readonly node;
26
- private readonly pkg;
27
- private removed;
28
- constructor(container: XmlNode[], node: XmlElement, pkg: Package);
29
- private live;
30
- rows(): OdtTableRow[];
31
- cell(rowIndex: number, columnIndex: number): OdtTableCell;
32
- appendRow(columnCount: number): OdtTableRow;
33
- remove(): void;
34
- }
35
- declare function buildTable(pkg: Package, init: TableInit): XmlElement;
36
- //#endregion
1
+ import { a as buildTable, i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "../../table-DqfqMkVq.js";
37
2
  export { OdtTable, OdtTableCell, OdtTableRow, TableInit, buildTable };
@@ -1,5 +1,5 @@
1
1
  import { el } from "../../xml/fragment.js";
2
- import { removeChild } from "../../xml/edit.js";
2
+ import { removeAttr, removeChild, setAttr } from "../../xml/edit.js";
3
3
  import { ensureAutomaticStyles, nextStyleName } from "./automatic-styles.js";
4
4
  import { OdtParagraph, buildParagraph } from "./paragraph.js";
5
5
  import { attr } from "ooxml.js";
@@ -45,6 +45,28 @@ var OdtTableCell = class {
45
45
  get text() {
46
46
  return this.paragraphs().map((p) => p.text).join("\n");
47
47
  }
48
+ get colSpan() {
49
+ const raw = attr(this.node, "table:number-columns-spanned");
50
+ return raw === void 0 ? void 0 : Number(raw);
51
+ }
52
+ set colSpan(value) {
53
+ if (value === void 0) {
54
+ removeAttr(this.node, "table:number-columns-spanned");
55
+ return;
56
+ }
57
+ setAttr(this.node, "table:number-columns-spanned", String(value));
58
+ }
59
+ get rowSpan() {
60
+ const raw = attr(this.node, "table:number-rows-spanned");
61
+ return raw === void 0 ? void 0 : Number(raw);
62
+ }
63
+ set rowSpan(value) {
64
+ if (value === void 0) {
65
+ removeAttr(this.node, "table:number-rows-spanned");
66
+ return;
67
+ }
68
+ setAttr(this.node, "table:number-rows-spanned", String(value));
69
+ }
48
70
  };
49
71
  var OdtTableRow = class {
50
72
  node;
@@ -58,6 +80,14 @@ var OdtTableRow = class {
58
80
  for (const child of this.node.children) if (child.type === "element" && child.tag === "table:table-cell") out.push(new OdtTableCell(child, this.pkg));
59
81
  return out;
60
82
  }
83
+ appendCell() {
84
+ const cellElement = buildCell(this.pkg);
85
+ this.node.children.push(cellElement);
86
+ return new OdtTableCell(cellElement, this.pkg);
87
+ }
88
+ appendCoveredCell() {
89
+ this.node.children.push(el("table:covered-table-cell"));
90
+ }
61
91
  };
62
92
  function buildCell(pkg) {
63
93
  return el("table:table-cell", {}, [buildParagraph(pkg)]);
@@ -99,6 +129,12 @@ var OdtTable = class {
99
129
  node.children.push(row);
100
130
  return new OdtTableRow(row, this.pkg);
101
131
  }
132
+ appendEmptyRow() {
133
+ const node = this.live();
134
+ const row = el("table:table-row");
135
+ node.children.push(row);
136
+ return new OdtTableRow(row, this.pkg);
137
+ }
102
138
  remove() {
103
139
  removeChild(this.container, this.live());
104
140
  this.removed = true;
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_edit_pptx_editor = require("./editor.cjs");
3
+ const require_model_embedded_drawing = require("../../model/embedded-drawing.cjs");
3
4
  let ooxml_js = require("ooxml.js");
4
5
  //#region src/edit/pptx/content.ts
5
6
  function buildPptxPackage(content) {
@@ -16,13 +17,27 @@ function buildPptxPackage(content) {
16
17
  }
17
18
  function appendShape(slide, shape) {
18
19
  const [onlyBlock] = shape.blocks;
20
+ if (shape.blocks.length === 1 && onlyBlock?.kind === "embeddedObject" && require_model_embedded_drawing.drawingOfBlock(onlyBlock) !== void 0) return;
19
21
  if (shape.blocks.length === 1 && onlyBlock?.kind === "image") {
20
- slide.addImage({
22
+ const imageShape = slide.addImage({
21
23
  frame: shape.frame,
22
24
  format: onlyBlock.format,
23
25
  bytes: (0, ooxml_js.base64ToBytes)(onlyBlock.base64),
24
26
  altText: onlyBlock.altText
25
27
  });
28
+ if (shape.rotationDeg !== void 0) imageShape.rotationDeg = shape.rotationDeg;
29
+ return;
30
+ }
31
+ if (shape.blocks.length === 1 && onlyBlock?.kind === "table") {
32
+ populatePptxTable(slide.addTable({
33
+ frame: shape.frame,
34
+ rotationDeg: shape.rotationDeg,
35
+ table: {
36
+ rows: onlyBlock.rows.length,
37
+ columns: onlyBlock.columnWidthsPt.length,
38
+ columnWidthsPt: onlyBlock.columnWidthsPt
39
+ }
40
+ }), onlyBlock);
26
41
  return;
27
42
  }
28
43
  const paragraphs = [];
@@ -40,10 +55,63 @@ function appendShape(slide, shape) {
40
55
  }))
41
56
  });
42
57
  }
43
- slide.addTextBox({
58
+ const textBox = slide.addTextBox({
44
59
  frame: shape.frame,
45
60
  text: ""
46
- }).setParagraphs(paragraphs);
61
+ });
62
+ if (shape.rotationDeg !== void 0) textBox.rotationDeg = shape.rotationDeg;
63
+ textBox.setParagraphs(paragraphs);
64
+ }
65
+ function populateCellParagraphs(cell, blocks) {
66
+ const paragraphs = [];
67
+ for (const block of blocks) {
68
+ if (block.kind !== "paragraph") continue;
69
+ paragraphs.push({
70
+ alignment: block.alignment,
71
+ runs: block.runs.map((run) => ({
72
+ text: run.text,
73
+ bold: run.bold,
74
+ italic: run.italic,
75
+ fontFamily: run.fontFamily,
76
+ sizePt: run.sizePt,
77
+ color: run.color
78
+ }))
79
+ });
80
+ }
81
+ cell.setParagraphs(paragraphs);
82
+ }
83
+ function populatePptxTable(table, block) {
84
+ const verticalMerges = /* @__PURE__ */ new Map();
85
+ block.rows.forEach((row, rowIndex) => {
86
+ let horizontalCoverRemaining = 0;
87
+ row.cells.forEach((cell, colIndex) => {
88
+ const tableCell = table.cell(rowIndex, colIndex);
89
+ const verticalRemaining = verticalMerges.get(colIndex);
90
+ const isVerticallyCovered = verticalRemaining !== void 0 && verticalRemaining > 0;
91
+ const isHorizontallyCovered = horizontalCoverRemaining > 0;
92
+ if (isVerticallyCovered || isHorizontallyCovered) {
93
+ if (isHorizontallyCovered) {
94
+ tableCell.horizontalMerge = true;
95
+ horizontalCoverRemaining -= 1;
96
+ }
97
+ if (isVerticallyCovered && verticalRemaining !== void 0) {
98
+ tableCell.verticalMerge = true;
99
+ verticalMerges.set(colIndex, verticalRemaining - 1);
100
+ }
101
+ return;
102
+ }
103
+ const span = cell.colSpan ?? 1;
104
+ if (span > 1) {
105
+ tableCell.colSpan = span;
106
+ horizontalCoverRemaining = span - 1;
107
+ }
108
+ if (cell.rowSpan !== void 0 && cell.rowSpan > 1) {
109
+ tableCell.rowSpan = cell.rowSpan;
110
+ for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
111
+ }
112
+ populateCellParagraphs(tableCell, cell.blocks);
113
+ });
114
+ });
47
115
  }
48
116
  //#endregion
49
117
  exports.buildPptxPackage = buildPptxPackage;
@@ -1,4 +1,5 @@
1
1
  import { createPptx } from "./editor.js";
2
+ import { drawingOfBlock } from "../../model/embedded-drawing.js";
2
3
  import { base64ToBytes } from "ooxml.js";
3
4
  //#region src/edit/pptx/content.ts
4
5
  function buildPptxPackage(content) {
@@ -15,13 +16,27 @@ function buildPptxPackage(content) {
15
16
  }
16
17
  function appendShape(slide, shape) {
17
18
  const [onlyBlock] = shape.blocks;
19
+ if (shape.blocks.length === 1 && onlyBlock?.kind === "embeddedObject" && drawingOfBlock(onlyBlock) !== void 0) return;
18
20
  if (shape.blocks.length === 1 && onlyBlock?.kind === "image") {
19
- slide.addImage({
21
+ const imageShape = slide.addImage({
20
22
  frame: shape.frame,
21
23
  format: onlyBlock.format,
22
24
  bytes: base64ToBytes(onlyBlock.base64),
23
25
  altText: onlyBlock.altText
24
26
  });
27
+ if (shape.rotationDeg !== void 0) imageShape.rotationDeg = shape.rotationDeg;
28
+ return;
29
+ }
30
+ if (shape.blocks.length === 1 && onlyBlock?.kind === "table") {
31
+ populatePptxTable(slide.addTable({
32
+ frame: shape.frame,
33
+ rotationDeg: shape.rotationDeg,
34
+ table: {
35
+ rows: onlyBlock.rows.length,
36
+ columns: onlyBlock.columnWidthsPt.length,
37
+ columnWidthsPt: onlyBlock.columnWidthsPt
38
+ }
39
+ }), onlyBlock);
25
40
  return;
26
41
  }
27
42
  const paragraphs = [];
@@ -39,10 +54,63 @@ function appendShape(slide, shape) {
39
54
  }))
40
55
  });
41
56
  }
42
- slide.addTextBox({
57
+ const textBox = slide.addTextBox({
43
58
  frame: shape.frame,
44
59
  text: ""
45
- }).setParagraphs(paragraphs);
60
+ });
61
+ if (shape.rotationDeg !== void 0) textBox.rotationDeg = shape.rotationDeg;
62
+ textBox.setParagraphs(paragraphs);
63
+ }
64
+ function populateCellParagraphs(cell, blocks) {
65
+ const paragraphs = [];
66
+ for (const block of blocks) {
67
+ if (block.kind !== "paragraph") continue;
68
+ paragraphs.push({
69
+ alignment: block.alignment,
70
+ runs: block.runs.map((run) => ({
71
+ text: run.text,
72
+ bold: run.bold,
73
+ italic: run.italic,
74
+ fontFamily: run.fontFamily,
75
+ sizePt: run.sizePt,
76
+ color: run.color
77
+ }))
78
+ });
79
+ }
80
+ cell.setParagraphs(paragraphs);
81
+ }
82
+ function populatePptxTable(table, block) {
83
+ const verticalMerges = /* @__PURE__ */ new Map();
84
+ block.rows.forEach((row, rowIndex) => {
85
+ let horizontalCoverRemaining = 0;
86
+ row.cells.forEach((cell, colIndex) => {
87
+ const tableCell = table.cell(rowIndex, colIndex);
88
+ const verticalRemaining = verticalMerges.get(colIndex);
89
+ const isVerticallyCovered = verticalRemaining !== void 0 && verticalRemaining > 0;
90
+ const isHorizontallyCovered = horizontalCoverRemaining > 0;
91
+ if (isVerticallyCovered || isHorizontallyCovered) {
92
+ if (isHorizontallyCovered) {
93
+ tableCell.horizontalMerge = true;
94
+ horizontalCoverRemaining -= 1;
95
+ }
96
+ if (isVerticallyCovered && verticalRemaining !== void 0) {
97
+ tableCell.verticalMerge = true;
98
+ verticalMerges.set(colIndex, verticalRemaining - 1);
99
+ }
100
+ return;
101
+ }
102
+ const span = cell.colSpan ?? 1;
103
+ if (span > 1) {
104
+ tableCell.colSpan = span;
105
+ horizontalCoverRemaining = span - 1;
106
+ }
107
+ if (cell.rowSpan !== void 0 && cell.rowSpan > 1) {
108
+ tableCell.rowSpan = cell.rowSpan;
109
+ for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
110
+ }
111
+ populateCellParagraphs(tableCell, cell.blocks);
112
+ });
113
+ });
46
114
  }
47
115
  //#endregion
48
116
  export { buildPptxPackage };
@@ -1,4 +1,4 @@
1
- import { s as PageSize } from "../../geometry-DvwdrIij.cjs";
1
+ import { s as PageSize } from "../../geometry-DaJr8yQW.cjs";
2
2
  import { PptxSlide } from "./slide.cjs";
3
3
  import { Package } from "ooxml.js";
4
4
  //#region src/edit/pptx/editor.d.ts
@@ -1,4 +1,4 @@
1
- import { s as PageSize } from "../../geometry-DvwdrIij.js";
1
+ import { s as PageSize } from "../../geometry-DaJr8yQW.js";
2
2
  import { PptxSlide } from "./slide.js";
3
3
  import { Package } from "ooxml.js";
4
4
  //#region src/edit/pptx/editor.d.ts
@@ -1,2 +1,2 @@
1
- import { n as MediaContext, r as insertPictureShapeMedia, t as ImageInit } from "../../image-BZDy72Jb.cjs";
1
+ import { n as MediaContext, r as insertPictureShapeMedia, t as ImageInit } from "../../image-7snmKIxn.cjs";
2
2
  export { ImageInit, MediaContext, insertPictureShapeMedia };
@@ -1,2 +1,2 @@
1
- import { n as MediaContext, r as insertPictureShapeMedia, t as ImageInit } from "../../image-B-xQWYYS.js";
1
+ import { n as MediaContext, r as insertPictureShapeMedia, t as ImageInit } from "../../image-Cs8xF753.js";
2
2
  export { ImageInit, MediaContext, insertPictureShapeMedia };
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_xml_fragment = require("../../xml/fragment.cjs");
3
+ const require_xml_entities = require("../../xml/entities.cjs");
3
4
  const require_xml_edit = require("../../xml/edit.cjs");
4
5
  const require_model_units = require("../../model/units.cjs");
5
- const require_xml_entities = require("../../xml/entities.cjs");
6
6
  let ooxml_js = require("ooxml.js");
7
7
  //#region src/edit/pptx/shape.ts
8
8
  function directChild(parent, tag) {
@@ -12,6 +12,7 @@ function parseEmuAttr(element, name) {
12
12
  const value = (0, ooxml_js.attr)(element, name);
13
13
  return value === void 0 ? void 0 : Number.parseInt(value, 10);
14
14
  }
15
+ const ROTATION_UNITS_PER_DEGREE = 6e4;
15
16
  var PptxShape = class {
16
17
  container;
17
18
  node;
@@ -66,6 +67,25 @@ var PptxShape = class {
66
67
  cy: String(require_model_units.ptToEmu(value.heightPt))
67
68
  })];
68
69
  }
70
+ get rotationDeg() {
71
+ const spPr = this.spPrElement(false);
72
+ const xfrm = spPr === void 0 ? void 0 : directChild(spPr, "a:xfrm");
73
+ const rot = xfrm === void 0 ? void 0 : (0, ooxml_js.attr)(xfrm, "rot");
74
+ return rot === void 0 ? void 0 : Number(rot) / ROTATION_UNITS_PER_DEGREE;
75
+ }
76
+ set rotationDeg(value) {
77
+ const spPr = this.spPrElement(true);
78
+ let xfrm = directChild(spPr, "a:xfrm");
79
+ if (xfrm === void 0) {
80
+ xfrm = require_xml_fragment.el("a:xfrm");
81
+ spPr.children.unshift(xfrm);
82
+ }
83
+ if (value === void 0 || value === 0) {
84
+ require_xml_edit.removeAttr(xfrm, "rot");
85
+ return;
86
+ }
87
+ require_xml_edit.setAttr(xfrm, "rot", String(Math.round(value * ROTATION_UNITS_PER_DEGREE)));
88
+ }
69
89
  get text() {
70
90
  const txBody = directChild(this.live(), "p:txBody");
71
91
  return txBody === void 0 ? "" : (0, ooxml_js.textContent)(txBody);
@@ -178,5 +198,7 @@ function buildPictureShape(frame, relationshipId, shapeId) {
178
198
  }
179
199
  //#endregion
180
200
  exports.PptxShape = PptxShape;
201
+ exports.ROTATION_UNITS_PER_DEGREE = ROTATION_UNITS_PER_DEGREE;
202
+ exports.buildDrawingParagraph = buildDrawingParagraph;
181
203
  exports.buildPictureShape = buildPictureShape;
182
204
  exports.buildTextBoxShape = buildTextBoxShape;
@@ -1,2 +1,2 @@
1
- import { a as buildTextBoxShape, i as buildPictureShape, n as DrawingRunInit, r as PptxShape, t as DrawingParagraphInit } from "../../shape-BUfjw5eZ.cjs";
2
- export { DrawingParagraphInit, DrawingRunInit, PptxShape, buildPictureShape, buildTextBoxShape };
1
+ import { a as buildDrawingParagraph, i as ROTATION_UNITS_PER_DEGREE, n as DrawingRunInit, o as buildPictureShape, r as PptxShape, s as buildTextBoxShape, t as DrawingParagraphInit } from "../../shape-BhkP6HB8.cjs";
2
+ export { DrawingParagraphInit, DrawingRunInit, PptxShape, ROTATION_UNITS_PER_DEGREE, buildDrawingParagraph, buildPictureShape, buildTextBoxShape };
@@ -1,2 +1,2 @@
1
- import { a as buildTextBoxShape, i as buildPictureShape, n as DrawingRunInit, r as PptxShape, t as DrawingParagraphInit } from "../../shape-CTkl6kt8.js";
2
- export { DrawingParagraphInit, DrawingRunInit, PptxShape, buildPictureShape, buildTextBoxShape };
1
+ import { a as buildDrawingParagraph, i as ROTATION_UNITS_PER_DEGREE, n as DrawingRunInit, o as buildPictureShape, r as PptxShape, s as buildTextBoxShape, t as DrawingParagraphInit } from "../../shape-BkVcwPcf.js";
2
+ export { DrawingParagraphInit, DrawingRunInit, PptxShape, ROTATION_UNITS_PER_DEGREE, buildDrawingParagraph, buildPictureShape, buildTextBoxShape };
@@ -1,7 +1,7 @@
1
1
  import { el, txt } from "../../xml/fragment.js";
2
- import { removeChild } from "../../xml/edit.js";
3
- import { emuToPt, ptToEmu } from "../../model/units.js";
4
2
  import { encodeXmlText, needsSpacePreserve } from "../../xml/entities.js";
3
+ import { removeAttr, removeChild, setAttr } from "../../xml/edit.js";
4
+ import { emuToPt, ptToEmu } from "../../model/units.js";
5
5
  import { attr, textContent } from "ooxml.js";
6
6
  //#region src/edit/pptx/shape.ts
7
7
  function directChild(parent, tag) {
@@ -11,6 +11,7 @@ function parseEmuAttr(element, name) {
11
11
  const value = attr(element, name);
12
12
  return value === void 0 ? void 0 : Number.parseInt(value, 10);
13
13
  }
14
+ const ROTATION_UNITS_PER_DEGREE = 6e4;
14
15
  var PptxShape = class {
15
16
  container;
16
17
  node;
@@ -65,6 +66,25 @@ var PptxShape = class {
65
66
  cy: String(ptToEmu(value.heightPt))
66
67
  })];
67
68
  }
69
+ get rotationDeg() {
70
+ const spPr = this.spPrElement(false);
71
+ const xfrm = spPr === void 0 ? void 0 : directChild(spPr, "a:xfrm");
72
+ const rot = xfrm === void 0 ? void 0 : attr(xfrm, "rot");
73
+ return rot === void 0 ? void 0 : Number(rot) / ROTATION_UNITS_PER_DEGREE;
74
+ }
75
+ set rotationDeg(value) {
76
+ const spPr = this.spPrElement(true);
77
+ let xfrm = directChild(spPr, "a:xfrm");
78
+ if (xfrm === void 0) {
79
+ xfrm = el("a:xfrm");
80
+ spPr.children.unshift(xfrm);
81
+ }
82
+ if (value === void 0 || value === 0) {
83
+ removeAttr(xfrm, "rot");
84
+ return;
85
+ }
86
+ setAttr(xfrm, "rot", String(Math.round(value * ROTATION_UNITS_PER_DEGREE)));
87
+ }
68
88
  get text() {
69
89
  const txBody = directChild(this.live(), "p:txBody");
70
90
  return txBody === void 0 ? "" : textContent(txBody);
@@ -176,4 +196,4 @@ function buildPictureShape(frame, relationshipId, shapeId) {
176
196
  ]);
177
197
  }
178
198
  //#endregion
179
- export { PptxShape, buildPictureShape, buildTextBoxShape };
199
+ export { PptxShape, ROTATION_UNITS_PER_DEGREE, buildDrawingParagraph, buildPictureShape, buildTextBoxShape };