documents.js 1.84.0 → 1.85.1

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 (61) hide show
  1. package/dist/edit/docx/content.cjs +10 -1
  2. package/dist/edit/docx/content.js +10 -1
  3. package/dist/edit/docx/paragraph.cjs +98 -0
  4. package/dist/edit/docx/paragraph.d.cts +12 -0
  5. package/dist/edit/docx/paragraph.d.ts +12 -0
  6. package/dist/edit/docx/paragraph.js +99 -1
  7. package/dist/edit/docx/props.cjs +1 -1
  8. package/dist/edit/docx/props.js +1 -1
  9. package/dist/edit/docx/table.cjs +119 -1
  10. package/dist/edit/docx/table.d.cts +8 -0
  11. package/dist/edit/docx/table.d.ts +8 -0
  12. package/dist/edit/docx/table.js +119 -1
  13. package/dist/edit/odg/page.d.cts +1 -1
  14. package/dist/edit/odg/page.d.ts +1 -1
  15. package/dist/edit/odp/shape.d.cts +1 -1
  16. package/dist/edit/odp/shape.d.ts +1 -1
  17. package/dist/edit/odp/slide.d.cts +2 -2
  18. package/dist/edit/odp/slide.d.ts +2 -2
  19. package/dist/edit/odt/content.cjs +7 -0
  20. package/dist/edit/odt/content.d.cts +2 -2
  21. package/dist/edit/odt/content.d.ts +2 -2
  22. package/dist/edit/odt/content.js +7 -0
  23. package/dist/edit/odt/editor.d.cts +3 -3
  24. package/dist/edit/odt/editor.d.ts +3 -3
  25. package/dist/edit/odt/list.d.cts +1 -1
  26. package/dist/edit/odt/list.d.ts +1 -1
  27. package/dist/edit/odt/paragraph.cjs +30 -0
  28. package/dist/edit/odt/paragraph.d.cts +1 -1
  29. package/dist/edit/odt/paragraph.d.ts +1 -1
  30. package/dist/edit/odt/paragraph.js +30 -0
  31. package/dist/edit/odt/table.cjs +105 -0
  32. package/dist/edit/odt/table.d.cts +2 -2
  33. package/dist/edit/odt/table.d.ts +2 -2
  34. package/dist/edit/odt/table.js +105 -2
  35. package/dist/edit/pptx/content.cjs +4 -0
  36. package/dist/edit/pptx/content.js +4 -0
  37. package/dist/edit/pptx/shape.cjs +3 -1
  38. package/dist/edit/pptx/shape.d.cts +1 -1
  39. package/dist/edit/pptx/shape.d.ts +1 -1
  40. package/dist/edit/pptx/shape.js +3 -1
  41. package/dist/edit/pptx/slide.d.cts +2 -2
  42. package/dist/edit/pptx/slide.d.ts +2 -2
  43. package/dist/edit/pptx/table.cjs +1 -1
  44. package/dist/edit/pptx/table.d.cts +1 -1
  45. package/dist/edit/pptx/table.d.ts +1 -1
  46. package/dist/edit/pptx/table.js +1 -1
  47. package/dist/index.d.cts +6 -6
  48. package/dist/index.d.ts +6 -6
  49. package/dist/{list-CYsXBdVG.d.cts → list-CxoEJwNO.d.cts} +1 -1
  50. package/dist/{list-DVRX7hm9.d.ts → list-DA1hCBVI.d.ts} +1 -1
  51. package/dist/{paragraph-Bg446o16.d.ts → paragraph-DV4_ZNGr.d.ts} +10 -0
  52. package/dist/{paragraph-BZIDHdnv.d.cts → paragraph-DXIJfPMw.d.cts} +10 -0
  53. package/dist/{shape-BhkP6HB8.d.cts → shape-BwBiRGha.d.cts} +2 -0
  54. package/dist/{shape-BjX3wlig.d.ts → shape-D5IoGzf9.d.ts} +2 -0
  55. package/dist/{shape-rvNMzcun.d.cts → shape-Dch9pDCf.d.cts} +2 -2
  56. package/dist/{shape-Be0LdJGE.d.ts → shape-DyviC6ZG.d.ts} +2 -2
  57. package/dist/{table-DIXStwnk.d.cts → table-BtMtRYqc.d.cts} +13 -2
  58. package/dist/{table-CLhAexfN.d.ts → table-BxeHHD7r.d.ts} +13 -2
  59. package/dist/{table-L5SxKy8_.d.ts → table-CCdAhdcG.d.ts} +1 -1
  60. package/dist/{table-CfRjVOFN.d.cts → table-SczxeRF0.d.cts} +1 -1
  61. package/package.json +2 -2
@@ -1,10 +1,36 @@
1
+ import { colorToRgbHex, rgbHexToColor } from "../../model/color.js";
1
2
  import { el } from "../../xml/fragment.js";
3
+ import { ptToTwips, twipsToPt } from "../../model/units.js";
2
4
  import { directChildElement, insertInSchemaOrder, removeChild } from "../../xml/edit.js";
3
5
  import { DocxParagraph, buildParagraph } from "./paragraph.js";
4
6
  import { attr } from "ooxml.js";
5
7
  //#region src/edit/docx/table.ts
6
8
  const DEFAULT_TABLE_WIDTH_TWIPS = 9360;
7
- const TC_PR_CHILD_ORDER = ["w:gridSpan", "w:vMerge"];
9
+ const TC_PR_CHILD_ORDER = [
10
+ "w:gridSpan",
11
+ "w:vMerge",
12
+ "w:tcBorders",
13
+ "w:shd"
14
+ ];
15
+ const TC_BORDERS_CHILD_ORDER = [
16
+ "w:top",
17
+ "w:left",
18
+ "w:bottom",
19
+ "w:right"
20
+ ];
21
+ const EIGHTH_POINTS_PER_POINT = 8;
22
+ const DOCX_BORDER_STYLE_TO_VAL = {
23
+ solid: "single",
24
+ dashed: "dashed",
25
+ dotted: "dotted",
26
+ double: "double"
27
+ };
28
+ function valToBorderStyle(val) {
29
+ if (val === "dashed") return "dashed";
30
+ if (val === "dotted") return "dotted";
31
+ if (val === "double") return "double";
32
+ return "solid";
33
+ }
8
34
  var DocxTableCell = class {
9
35
  node;
10
36
  constructor(node) {
@@ -49,6 +75,75 @@ var DocxTableCell = class {
49
75
  tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:vMerge"));
50
76
  insertInSchemaOrder(tcPr, value === "restart" ? el("w:vMerge", { "w:val": "restart" }) : el("w:vMerge"), TC_PR_CHILD_ORDER);
51
77
  }
78
+ get background() {
79
+ const tcPr = this.tcPrElement(false);
80
+ const shd = tcPr === void 0 ? void 0 : directChildElement(tcPr, "w:shd");
81
+ const fill = shd === void 0 ? void 0 : attr(shd, "w:fill");
82
+ if (fill === void 0 || fill === "auto" || fill === "none") return;
83
+ return rgbHexToColor(fill);
84
+ }
85
+ set background(value) {
86
+ if (value === void 0) {
87
+ const tcPr = this.tcPrElement(false);
88
+ if (tcPr !== void 0) tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:shd"));
89
+ return;
90
+ }
91
+ const tcPr = this.tcPrElement(true);
92
+ tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:shd"));
93
+ insertInSchemaOrder(tcPr, el("w:shd", {
94
+ "w:val": "clear",
95
+ "w:color": "auto",
96
+ "w:fill": colorToRgbHex(value)
97
+ }), TC_PR_CHILD_ORDER);
98
+ }
99
+ get borders() {
100
+ const tcPr = this.tcPrElement(false);
101
+ const tcBorders = tcPr === void 0 ? void 0 : directChildElement(tcPr, "w:tcBorders");
102
+ if (tcBorders === void 0) return;
103
+ const borders = {};
104
+ for (const edge of [
105
+ "top",
106
+ "left",
107
+ "bottom",
108
+ "right"
109
+ ]) {
110
+ const element = directChildElement(tcBorders, `w:${edge}`);
111
+ const val = element === void 0 ? void 0 : attr(element, "w:val");
112
+ if (element === void 0 || val === void 0 || val === "nil" || val === "none") continue;
113
+ const sz = attr(element, "w:sz");
114
+ const colorVal = attr(element, "w:color");
115
+ borders[edge] = {
116
+ color: colorVal === void 0 || colorVal === "auto" ? {
117
+ r: 0,
118
+ g: 0,
119
+ b: 0
120
+ } : rgbHexToColor(colorVal),
121
+ widthPt: Number(sz ?? String(EIGHTH_POINTS_PER_POINT)) / EIGHTH_POINTS_PER_POINT,
122
+ style: valToBorderStyle(val)
123
+ };
124
+ }
125
+ return Object.keys(borders).length === 0 ? void 0 : borders;
126
+ }
127
+ set borders(value) {
128
+ if (value === void 0) {
129
+ const tcPr = this.tcPrElement(false);
130
+ if (tcPr !== void 0) tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:tcBorders"));
131
+ return;
132
+ }
133
+ const tcPr = this.tcPrElement(true);
134
+ tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:tcBorders"));
135
+ const tcBorders = el("w:tcBorders");
136
+ for (const edge of TC_BORDERS_CHILD_ORDER) {
137
+ const border = value[edge === "w:top" ? "top" : edge === "w:left" ? "left" : edge === "w:bottom" ? "bottom" : "right"];
138
+ if (border === void 0) continue;
139
+ tcBorders.children.push(el(edge, {
140
+ "w:val": DOCX_BORDER_STYLE_TO_VAL[border.style ?? "solid"],
141
+ "w:sz": String(Math.round(border.widthPt * EIGHTH_POINTS_PER_POINT)),
142
+ "w:color": colorToRgbHex(border.color)
143
+ }));
144
+ }
145
+ insertInSchemaOrder(tcPr, tcBorders, TC_PR_CHILD_ORDER);
146
+ }
52
147
  paragraphs() {
53
148
  const out = [];
54
149
  for (const child of this.node.children) if (child.type === "element" && child.tag === "w:p") out.push(new DocxParagraph(this.node.children, child));
@@ -68,11 +163,34 @@ var DocxTableRow = class {
68
163
  constructor(node) {
69
164
  this.node = node;
70
165
  }
166
+ trPrElement(create) {
167
+ const existing = directChildElement(this.node, "w:trPr");
168
+ if (existing !== void 0 || !create) return existing;
169
+ const created = el("w:trPr");
170
+ this.node.children.unshift(created);
171
+ return created;
172
+ }
71
173
  cells() {
72
174
  const out = [];
73
175
  for (const child of this.node.children) if (child.type === "element" && child.tag === "w:tc") out.push(new DocxTableCell(child));
74
176
  return out;
75
177
  }
178
+ get heightPt() {
179
+ const trPr = this.trPrElement(false);
180
+ const trHeight = trPr === void 0 ? void 0 : directChildElement(trPr, "w:trHeight");
181
+ const val = trHeight === void 0 ? void 0 : attr(trHeight, "w:val");
182
+ return val === void 0 ? void 0 : twipsToPt(Number(val));
183
+ }
184
+ set heightPt(value) {
185
+ const trPr = this.trPrElement(value !== void 0);
186
+ if (trPr === void 0) return;
187
+ trPr.children = trPr.children.filter((c) => !(c.type === "element" && c.tag === "w:trHeight"));
188
+ if (value === void 0) return;
189
+ trPr.children.push(el("w:trHeight", {
190
+ "w:val": String(ptToTwips(value)),
191
+ "w:hRule": "atLeast"
192
+ }));
193
+ }
76
194
  mergeCellsHorizontally(startColumnIndex, colSpan) {
77
195
  if (!Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCellsHorizontally: colSpan must be a positive integer, got ${colSpan}`);
78
196
  const cellElements = [];
@@ -1,5 +1,5 @@
1
1
  import { t as ImageInit } from "../../image-M5SezZVI.cjs";
2
- import { t as OdpShape } from "../../shape-rvNMzcun.cjs";
2
+ import { t as OdpShape } from "../../shape-Dch9pDCf.cjs";
3
3
  import { a as OdgLineVector, l as PathVectorInit, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as OdgVector, t as BoxVectorInit } from "../../vector-D03KX8Ux.cjs";
4
4
  import { Box, ContentVector } from "document-schema.js";
5
5
  import { Package, XmlElement, XmlNode } from "odf.js";
@@ -1,5 +1,5 @@
1
1
  import { t as ImageInit } from "../../image-DHcA9kaK.js";
2
- import { t as OdpShape } from "../../shape-Be0LdJGE.js";
2
+ import { t as OdpShape } from "../../shape-DyviC6ZG.js";
3
3
  import { a as OdgLineVector, l as PathVectorInit, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as OdgVector, t as BoxVectorInit } from "../../vector-D03KX8Ux.js";
4
4
  import { Box, ContentVector } from "document-schema.js";
5
5
  import { Package, XmlElement, XmlNode } from "odf.js";
@@ -1,2 +1,2 @@
1
- import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-rvNMzcun.cjs";
1
+ import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-Dch9pDCf.cjs";
2
2
  export { OdpShape, buildImageFrame, buildTableFrame, buildTextBoxFrame };
@@ -1,2 +1,2 @@
1
- import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-Be0LdJGE.js";
1
+ import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-DyviC6ZG.js";
2
2
  export { OdpShape, buildImageFrame, buildTableFrame, buildTextBoxFrame };
@@ -1,8 +1,8 @@
1
1
  import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
2
2
  import { t as ImageInit } from "../../image-M5SezZVI.cjs";
3
- import { t as OdpShape } from "../../shape-rvNMzcun.cjs";
3
+ import { t as OdpShape } from "../../shape-Dch9pDCf.cjs";
4
4
  import { s as OdgVector } from "../../vector-D03KX8Ux.cjs";
5
- import { i as TableInit, t as OdtTable } from "../../table-DIXStwnk.cjs";
5
+ import { a as TableInit, n as OdtTable } from "../../table-BtMtRYqc.cjs";
6
6
  import { ContentVector } from "document-schema.js";
7
7
  import { Package, XmlElement, XmlNode } from "odf.js";
8
8
  //#region src/edit/odp/slide.d.ts
@@ -1,8 +1,8 @@
1
1
  import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
2
2
  import { t as ImageInit } from "../../image-DHcA9kaK.js";
3
- import { t as OdpShape } from "../../shape-Be0LdJGE.js";
3
+ import { t as OdpShape } from "../../shape-DyviC6ZG.js";
4
4
  import { s as OdgVector } from "../../vector-D03KX8Ux.js";
5
- import { i as TableInit, t as OdtTable } from "../../table-CLhAexfN.js";
5
+ import { a as TableInit, n as OdtTable } from "../../table-BxeHHD7r.js";
6
6
  import { ContentVector } from "document-schema.js";
7
7
  import { Package, XmlElement, XmlNode } from "odf.js";
8
8
  //#region src/edit/odp/slide.d.ts
@@ -90,6 +90,11 @@ function appendListRun(body, paragraphs) {
90
90
  function populateParagraph(paragraph, block) {
91
91
  if (block.styleId !== void 0) paragraph.styleId = block.styleId;
92
92
  if (block.alignment !== void 0) paragraph.alignment = block.alignment;
93
+ if (block.spacingBeforePt !== void 0) paragraph.spacingBeforePt = block.spacingBeforePt;
94
+ if (block.spacingAfterPt !== void 0) paragraph.spacingAfterPt = block.spacingAfterPt;
95
+ if (block.lineSpacing !== void 0) paragraph.lineSpacing = block.lineSpacing;
96
+ if (block.indentLeftPt !== void 0) paragraph.indentLeftPt = block.indentLeftPt;
97
+ if (block.indentFirstLinePt !== void 0) paragraph.indentFirstLinePt = block.indentFirstLinePt;
93
98
  for (const run of block.runs) {
94
99
  if (run.text === " ") {
95
100
  paragraph.appendTab();
@@ -149,6 +154,8 @@ function populateOdtTable(table, block) {
149
154
  tableCell.rowSpan = cell.rowSpan;
150
155
  for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
151
156
  }
157
+ if (cell.background !== void 0) tableCell.background = cell.background;
158
+ if (cell.borders !== void 0) tableCell.borders = cell.borders;
152
159
  populateCellBlocks(tableCell, cell.blocks);
153
160
  colIndex += 1;
154
161
  });
@@ -1,6 +1,6 @@
1
1
  import { ClockPort } from "../../ports/clock.cjs";
2
- import { t as OdtParagraph } from "../../paragraph-BZIDHdnv.cjs";
3
- import { t as OdtTable } from "../../table-DIXStwnk.cjs";
2
+ import { t as OdtParagraph } from "../../paragraph-DXIJfPMw.cjs";
3
+ import { n as OdtTable } from "../../table-BtMtRYqc.cjs";
4
4
  import { ContentDocument, ContentParagraph, ContentTable } from "document-schema.js";
5
5
  import { Package } from "odf.js";
6
6
  //#region src/edit/odt/content.d.ts
@@ -1,6 +1,6 @@
1
1
  import { ClockPort } from "../../ports/clock.js";
2
- import { t as OdtParagraph } from "../../paragraph-Bg446o16.js";
3
- import { t as OdtTable } from "../../table-CLhAexfN.js";
2
+ import { t as OdtParagraph } from "../../paragraph-DV4_ZNGr.js";
3
+ import { n as OdtTable } from "../../table-BxeHHD7r.js";
4
4
  import { ContentDocument, ContentParagraph, ContentTable } from "document-schema.js";
5
5
  import { Package } from "odf.js";
6
6
  //#region src/edit/odt/content.d.ts
@@ -89,6 +89,11 @@ function appendListRun(body, paragraphs) {
89
89
  function populateParagraph(paragraph, block) {
90
90
  if (block.styleId !== void 0) paragraph.styleId = block.styleId;
91
91
  if (block.alignment !== void 0) paragraph.alignment = block.alignment;
92
+ if (block.spacingBeforePt !== void 0) paragraph.spacingBeforePt = block.spacingBeforePt;
93
+ if (block.spacingAfterPt !== void 0) paragraph.spacingAfterPt = block.spacingAfterPt;
94
+ if (block.lineSpacing !== void 0) paragraph.lineSpacing = block.lineSpacing;
95
+ if (block.indentLeftPt !== void 0) paragraph.indentLeftPt = block.indentLeftPt;
96
+ if (block.indentFirstLinePt !== void 0) paragraph.indentFirstLinePt = block.indentFirstLinePt;
92
97
  for (const run of block.runs) {
93
98
  if (run.text === " ") {
94
99
  paragraph.appendTab();
@@ -148,6 +153,8 @@ function populateOdtTable(table, block) {
148
153
  tableCell.rowSpan = cell.rowSpan;
149
154
  for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
150
155
  }
156
+ if (cell.background !== void 0) tableCell.background = cell.background;
157
+ if (cell.borders !== void 0) tableCell.borders = cell.borders;
151
158
  populateCellBlocks(tableCell, cell.blocks);
152
159
  colIndex += 1;
153
160
  });
@@ -1,8 +1,8 @@
1
1
  import { ClockPort } from "../../ports/clock.cjs";
2
2
  import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
3
- import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-BZIDHdnv.cjs";
4
- import { t as OdtList } from "../../list-CYsXBdVG.cjs";
5
- import { i as TableInit, t as OdtTable } from "../../table-DIXStwnk.cjs";
3
+ import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-DXIJfPMw.cjs";
4
+ import { t as OdtList } from "../../list-CxoEJwNO.cjs";
5
+ import { a as TableInit, n as OdtTable } from "../../table-BtMtRYqc.cjs";
6
6
  import { ContentFormula, ContentVector } from "document-schema.js";
7
7
  import { Package } from "odf.js";
8
8
  //#region src/edit/odt/editor.d.ts
@@ -1,8 +1,8 @@
1
1
  import { ClockPort } from "../../ports/clock.js";
2
2
  import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
3
- import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-Bg446o16.js";
4
- import { t as OdtList } from "../../list-DVRX7hm9.js";
5
- import { i as TableInit, t as OdtTable } from "../../table-CLhAexfN.js";
3
+ import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-DV4_ZNGr.js";
4
+ import { t as OdtList } from "../../list-DA1hCBVI.js";
5
+ import { a as TableInit, n as OdtTable } from "../../table-BxeHHD7r.js";
6
6
  import { ContentFormula, ContentVector } from "document-schema.js";
7
7
  import { Package } from "odf.js";
8
8
  //#region src/edit/odt/editor.d.ts
@@ -1,2 +1,2 @@
1
- import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-CYsXBdVG.cjs";
1
+ import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-CxoEJwNO.cjs";
2
2
  export { OdtList, OdtListItem, buildList };
@@ -1,2 +1,2 @@
1
- import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-DVRX7hm9.js";
1
+ import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-DA1hCBVI.js";
2
2
  export { OdtList, OdtListItem, buildList };
@@ -67,6 +67,36 @@ var OdtParagraph = class {
67
67
  set alignment(value) {
68
68
  require_edit_odt_props.applyStyleChange(this.pkg, this.live(), "paragraph", { alignment: value });
69
69
  }
70
+ get spacingBeforePt() {
71
+ return require_edit_odt_props.readCurrentStyleProperties(this.pkg, this.live(), "paragraph").spacingBeforePt;
72
+ }
73
+ set spacingBeforePt(value) {
74
+ require_edit_odt_props.applyStyleChange(this.pkg, this.live(), "paragraph", { spacingBeforePt: value });
75
+ }
76
+ get spacingAfterPt() {
77
+ return require_edit_odt_props.readCurrentStyleProperties(this.pkg, this.live(), "paragraph").spacingAfterPt;
78
+ }
79
+ set spacingAfterPt(value) {
80
+ require_edit_odt_props.applyStyleChange(this.pkg, this.live(), "paragraph", { spacingAfterPt: value });
81
+ }
82
+ get lineSpacing() {
83
+ return require_edit_odt_props.readCurrentStyleProperties(this.pkg, this.live(), "paragraph").lineSpacing;
84
+ }
85
+ set lineSpacing(value) {
86
+ require_edit_odt_props.applyStyleChange(this.pkg, this.live(), "paragraph", { lineSpacing: value });
87
+ }
88
+ get indentLeftPt() {
89
+ return require_edit_odt_props.readCurrentStyleProperties(this.pkg, this.live(), "paragraph").indentLeftPt;
90
+ }
91
+ set indentLeftPt(value) {
92
+ require_edit_odt_props.applyStyleChange(this.pkg, this.live(), "paragraph", { indentLeftPt: value });
93
+ }
94
+ get indentFirstLinePt() {
95
+ return require_edit_odt_props.readCurrentStyleProperties(this.pkg, this.live(), "paragraph").indentFirstLinePt;
96
+ }
97
+ set indentFirstLinePt(value) {
98
+ require_edit_odt_props.applyStyleChange(this.pkg, this.live(), "paragraph", { indentFirstLinePt: value });
99
+ }
70
100
  insertImageAfter(image) {
71
101
  const node = this.live();
72
102
  const frame = {
@@ -1,2 +1,2 @@
1
- import { n as ParagraphInit, r as buildParagraph, t as OdtParagraph } from "../../paragraph-BZIDHdnv.cjs";
1
+ import { n as ParagraphInit, r as buildParagraph, t as OdtParagraph } from "../../paragraph-DXIJfPMw.cjs";
2
2
  export { OdtParagraph, ParagraphInit, buildParagraph };
@@ -1,2 +1,2 @@
1
- import { n as ParagraphInit, r as buildParagraph, t as OdtParagraph } from "../../paragraph-Bg446o16.js";
1
+ import { n as ParagraphInit, r as buildParagraph, t as OdtParagraph } from "../../paragraph-DV4_ZNGr.js";
2
2
  export { OdtParagraph, ParagraphInit, buildParagraph };
@@ -66,6 +66,36 @@ var OdtParagraph = class {
66
66
  set alignment(value) {
67
67
  applyStyleChange(this.pkg, this.live(), "paragraph", { alignment: value });
68
68
  }
69
+ get spacingBeforePt() {
70
+ return readCurrentStyleProperties(this.pkg, this.live(), "paragraph").spacingBeforePt;
71
+ }
72
+ set spacingBeforePt(value) {
73
+ applyStyleChange(this.pkg, this.live(), "paragraph", { spacingBeforePt: value });
74
+ }
75
+ get spacingAfterPt() {
76
+ return readCurrentStyleProperties(this.pkg, this.live(), "paragraph").spacingAfterPt;
77
+ }
78
+ set spacingAfterPt(value) {
79
+ applyStyleChange(this.pkg, this.live(), "paragraph", { spacingAfterPt: value });
80
+ }
81
+ get lineSpacing() {
82
+ return readCurrentStyleProperties(this.pkg, this.live(), "paragraph").lineSpacing;
83
+ }
84
+ set lineSpacing(value) {
85
+ applyStyleChange(this.pkg, this.live(), "paragraph", { lineSpacing: value });
86
+ }
87
+ get indentLeftPt() {
88
+ return readCurrentStyleProperties(this.pkg, this.live(), "paragraph").indentLeftPt;
89
+ }
90
+ set indentLeftPt(value) {
91
+ applyStyleChange(this.pkg, this.live(), "paragraph", { indentLeftPt: value });
92
+ }
93
+ get indentFirstLinePt() {
94
+ return readCurrentStyleProperties(this.pkg, this.live(), "paragraph").indentFirstLinePt;
95
+ }
96
+ set indentFirstLinePt(value) {
97
+ applyStyleChange(this.pkg, this.live(), "paragraph", { indentFirstLinePt: value });
98
+ }
69
99
  insertImageAfter(image) {
70
100
  const node = this.live();
71
101
  const frame = {
@@ -8,6 +8,87 @@ let odf_js = require("odf.js");
8
8
  //#region src/edit/odt/table.ts
9
9
  const DEFAULT_TABLE_WIDTH_PT = 468;
10
10
  const TABLE_COLUMN_STYLE_PREFIX = "OdtCol";
11
+ const TABLE_CELL_STYLE_PREFIX = "OdtCell";
12
+ const BORDER_EDGE_ATTRS = {
13
+ top: "fo:border-top",
14
+ right: "fo:border-right",
15
+ bottom: "fo:border-bottom",
16
+ left: "fo:border-left"
17
+ };
18
+ function formatBorderShorthand(color, widthPt, style) {
19
+ return `${(0, odf_js.formatOdfLength)(widthPt)} ${style ?? "solid"} ${(0, odf_js.formatOdfColor)(color)}`;
20
+ }
21
+ function findCellPropertiesReadOnly(pkg, element) {
22
+ const styleName = (0, ooxml_js.attr)(element, "table:style-name");
23
+ if (styleName === void 0) return;
24
+ const part = pkg.parts["content.xml"];
25
+ const root = part?.kind === "xml" ? part.nodes.find((n) => n.type === "element") : void 0;
26
+ if (root === void 0) return;
27
+ for (const child of root.children) if (child.type === "element" && child.tag === "office:automatic-styles") {
28
+ for (const style of child.children) if (style.type === "element" && style.tag === "style:style" && (0, ooxml_js.attr)(style, "style:name") === styleName && (0, ooxml_js.attr)(style, "style:family") === "table-cell") {
29
+ for (const props of style.children) if (props.type === "element" && props.tag === "style:table-cell-properties") return props;
30
+ }
31
+ }
32
+ }
33
+ function readCellDecoration(pkg, element) {
34
+ const props = findCellPropertiesReadOnly(pkg, element);
35
+ if (props === void 0) return {};
36
+ let background;
37
+ const backgroundValue = (0, ooxml_js.attr)(props, "fo:background-color");
38
+ if (backgroundValue !== void 0) background = (0, odf_js.parseOdfColor)(backgroundValue);
39
+ const borders = {};
40
+ [
41
+ "top",
42
+ "right",
43
+ "bottom",
44
+ "left"
45
+ ].forEach((edge) => {
46
+ const raw = (0, ooxml_js.attr)(props, BORDER_EDGE_ATTRS[edge]);
47
+ if (raw === void 0) return;
48
+ const tokens = raw.trim().split(/\s+/);
49
+ const widthToken = tokens[0];
50
+ const styleToken = tokens[1];
51
+ const colorToken = tokens[2];
52
+ if (widthToken === void 0 || styleToken === void 0 || colorToken === void 0 || styleToken === "none" || styleToken === "hidden") return;
53
+ const widthPt = (0, odf_js.parseOdfLength)(widthToken);
54
+ const color = (0, odf_js.parseOdfColor)(colorToken);
55
+ if (widthPt === void 0 || widthPt <= 0 || color === void 0) return;
56
+ const style = styleToken === "solid" || styleToken === "dashed" || styleToken === "dotted" || styleToken === "double" ? styleToken : void 0;
57
+ borders[edge] = style === void 0 ? {
58
+ color,
59
+ widthPt
60
+ } : {
61
+ color,
62
+ widthPt,
63
+ style
64
+ };
65
+ });
66
+ return {
67
+ background,
68
+ borders: Object.keys(borders).length === 0 ? void 0 : borders
69
+ };
70
+ }
71
+ function buildCellStyle(pkg, decoration) {
72
+ const automaticStyles = require_edit_odt_automatic_styles.ensureAutomaticStyles(pkg);
73
+ const name = require_edit_odt_automatic_styles.nextStyleName(automaticStyles, "style:style", TABLE_CELL_STYLE_PREFIX);
74
+ const propsAttrs = {};
75
+ if (decoration.background !== void 0) propsAttrs["fo:background-color"] = (0, odf_js.formatOdfColor)(decoration.background);
76
+ if (decoration.borders !== void 0) [
77
+ "top",
78
+ "right",
79
+ "bottom",
80
+ "left"
81
+ ].forEach((edge) => {
82
+ const border = decoration.borders[edge];
83
+ if (border !== void 0) propsAttrs[BORDER_EDGE_ATTRS[edge]] = formatBorderShorthand(border.color, border.widthPt, border.style);
84
+ });
85
+ const properties = Object.keys(propsAttrs).length === 0 ? [] : [require_xml_fragment.el("style:table-cell-properties", propsAttrs)];
86
+ automaticStyles.children.push(require_xml_fragment.el("style:style", {
87
+ "style:name": name,
88
+ "style:family": "table-cell"
89
+ }, properties));
90
+ return name;
91
+ }
11
92
  function internTableColumnWidth(pkg, widthPt) {
12
93
  const automaticStyles = require_edit_odt_automatic_styles.ensureAutomaticStyles(pkg);
13
94
  const formatted = (0, odf_js.formatOdfLength)(widthPt, "pt");
@@ -68,6 +149,28 @@ var OdtTableCell = class {
68
149
  }
69
150
  require_xml_edit.setAttr(this.node, "table:number-rows-spanned", String(value));
70
151
  }
152
+ get background() {
153
+ return readCellDecoration(this.pkg, this.node).background;
154
+ }
155
+ set background(value) {
156
+ const current = readCellDecoration(this.pkg, this.node);
157
+ const name = buildCellStyle(this.pkg, {
158
+ background: value,
159
+ borders: current.borders
160
+ });
161
+ require_xml_edit.setAttr(this.node, "table:style-name", name);
162
+ }
163
+ get borders() {
164
+ return readCellDecoration(this.pkg, this.node).borders;
165
+ }
166
+ set borders(value) {
167
+ const current = readCellDecoration(this.pkg, this.node);
168
+ const name = buildCellStyle(this.pkg, {
169
+ background: current.background,
170
+ borders: value
171
+ });
172
+ require_xml_edit.setAttr(this.node, "table:style-name", name);
173
+ }
71
174
  };
72
175
  var OdtTableRow = class {
73
176
  node;
@@ -203,4 +306,6 @@ function buildTable(pkg, init) {
203
306
  exports.OdtTable = OdtTable;
204
307
  exports.OdtTableCell = OdtTableCell;
205
308
  exports.OdtTableRow = OdtTableRow;
309
+ exports.buildCellStyle = buildCellStyle;
206
310
  exports.buildTable = buildTable;
311
+ exports.readCellDecoration = readCellDecoration;
@@ -1,2 +1,2 @@
1
- import { a as buildTable, i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "../../table-DIXStwnk.cjs";
2
- export { OdtTable, OdtTableCell, OdtTableRow, TableInit, buildTable };
1
+ import { a as TableInit, c as readCellDecoration, i as OdtTableRow, n as OdtTable, o as buildCellStyle, r as OdtTableCell, s as buildTable, t as CellDecoration } from "../../table-BtMtRYqc.cjs";
2
+ export { CellDecoration, OdtTable, OdtTableCell, OdtTableRow, TableInit, buildCellStyle, buildTable, readCellDecoration };
@@ -1,2 +1,2 @@
1
- import { a as buildTable, i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "../../table-CLhAexfN.js";
2
- export { OdtTable, OdtTableCell, OdtTableRow, TableInit, buildTable };
1
+ import { a as TableInit, c as readCellDecoration, i as OdtTableRow, n as OdtTable, o as buildCellStyle, r as OdtTableCell, s as buildTable, t as CellDecoration } from "../../table-BxeHHD7r.js";
2
+ export { CellDecoration, OdtTable, OdtTableCell, OdtTableRow, TableInit, buildCellStyle, buildTable, readCellDecoration };
@@ -3,10 +3,91 @@ 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";
6
- import { formatOdfLength } from "odf.js";
6
+ import { formatOdfColor, formatOdfLength, parseOdfColor, parseOdfLength } from "odf.js";
7
7
  //#region src/edit/odt/table.ts
8
8
  const DEFAULT_TABLE_WIDTH_PT = 468;
9
9
  const TABLE_COLUMN_STYLE_PREFIX = "OdtCol";
10
+ const TABLE_CELL_STYLE_PREFIX = "OdtCell";
11
+ const BORDER_EDGE_ATTRS = {
12
+ top: "fo:border-top",
13
+ right: "fo:border-right",
14
+ bottom: "fo:border-bottom",
15
+ left: "fo:border-left"
16
+ };
17
+ function formatBorderShorthand(color, widthPt, style) {
18
+ return `${formatOdfLength(widthPt)} ${style ?? "solid"} ${formatOdfColor(color)}`;
19
+ }
20
+ function findCellPropertiesReadOnly(pkg, element) {
21
+ const styleName = attr(element, "table:style-name");
22
+ if (styleName === void 0) return;
23
+ const part = pkg.parts["content.xml"];
24
+ const root = part?.kind === "xml" ? part.nodes.find((n) => n.type === "element") : void 0;
25
+ if (root === void 0) return;
26
+ for (const child of root.children) if (child.type === "element" && child.tag === "office:automatic-styles") {
27
+ for (const style of child.children) if (style.type === "element" && style.tag === "style:style" && attr(style, "style:name") === styleName && attr(style, "style:family") === "table-cell") {
28
+ for (const props of style.children) if (props.type === "element" && props.tag === "style:table-cell-properties") return props;
29
+ }
30
+ }
31
+ }
32
+ function readCellDecoration(pkg, element) {
33
+ const props = findCellPropertiesReadOnly(pkg, element);
34
+ if (props === void 0) return {};
35
+ let background;
36
+ const backgroundValue = attr(props, "fo:background-color");
37
+ if (backgroundValue !== void 0) background = parseOdfColor(backgroundValue);
38
+ const borders = {};
39
+ [
40
+ "top",
41
+ "right",
42
+ "bottom",
43
+ "left"
44
+ ].forEach((edge) => {
45
+ const raw = attr(props, BORDER_EDGE_ATTRS[edge]);
46
+ if (raw === void 0) return;
47
+ const tokens = raw.trim().split(/\s+/);
48
+ const widthToken = tokens[0];
49
+ const styleToken = tokens[1];
50
+ const colorToken = tokens[2];
51
+ if (widthToken === void 0 || styleToken === void 0 || colorToken === void 0 || styleToken === "none" || styleToken === "hidden") return;
52
+ const widthPt = parseOdfLength(widthToken);
53
+ const color = parseOdfColor(colorToken);
54
+ if (widthPt === void 0 || widthPt <= 0 || color === void 0) return;
55
+ const style = styleToken === "solid" || styleToken === "dashed" || styleToken === "dotted" || styleToken === "double" ? styleToken : void 0;
56
+ borders[edge] = style === void 0 ? {
57
+ color,
58
+ widthPt
59
+ } : {
60
+ color,
61
+ widthPt,
62
+ style
63
+ };
64
+ });
65
+ return {
66
+ background,
67
+ borders: Object.keys(borders).length === 0 ? void 0 : borders
68
+ };
69
+ }
70
+ function buildCellStyle(pkg, decoration) {
71
+ const automaticStyles = ensureAutomaticStyles(pkg);
72
+ const name = nextStyleName(automaticStyles, "style:style", TABLE_CELL_STYLE_PREFIX);
73
+ const propsAttrs = {};
74
+ if (decoration.background !== void 0) propsAttrs["fo:background-color"] = formatOdfColor(decoration.background);
75
+ if (decoration.borders !== void 0) [
76
+ "top",
77
+ "right",
78
+ "bottom",
79
+ "left"
80
+ ].forEach((edge) => {
81
+ const border = decoration.borders[edge];
82
+ if (border !== void 0) propsAttrs[BORDER_EDGE_ATTRS[edge]] = formatBorderShorthand(border.color, border.widthPt, border.style);
83
+ });
84
+ const properties = Object.keys(propsAttrs).length === 0 ? [] : [el("style:table-cell-properties", propsAttrs)];
85
+ automaticStyles.children.push(el("style:style", {
86
+ "style:name": name,
87
+ "style:family": "table-cell"
88
+ }, properties));
89
+ return name;
90
+ }
10
91
  function internTableColumnWidth(pkg, widthPt) {
11
92
  const automaticStyles = ensureAutomaticStyles(pkg);
12
93
  const formatted = formatOdfLength(widthPt, "pt");
@@ -67,6 +148,28 @@ var OdtTableCell = class {
67
148
  }
68
149
  setAttr(this.node, "table:number-rows-spanned", String(value));
69
150
  }
151
+ get background() {
152
+ return readCellDecoration(this.pkg, this.node).background;
153
+ }
154
+ set background(value) {
155
+ const current = readCellDecoration(this.pkg, this.node);
156
+ const name = buildCellStyle(this.pkg, {
157
+ background: value,
158
+ borders: current.borders
159
+ });
160
+ setAttr(this.node, "table:style-name", name);
161
+ }
162
+ get borders() {
163
+ return readCellDecoration(this.pkg, this.node).borders;
164
+ }
165
+ set borders(value) {
166
+ const current = readCellDecoration(this.pkg, this.node);
167
+ const name = buildCellStyle(this.pkg, {
168
+ background: current.background,
169
+ borders: value
170
+ });
171
+ setAttr(this.node, "table:style-name", name);
172
+ }
70
173
  };
71
174
  var OdtTableRow = class {
72
175
  node;
@@ -199,4 +302,4 @@ function buildTable(pkg, init) {
199
302
  return el("table:table", {}, [...columns, ...rows]);
200
303
  }
201
304
  //#endregion
202
- export { OdtTable, OdtTableCell, OdtTableRow, buildTable };
305
+ export { OdtTable, OdtTableCell, OdtTableRow, buildCellStyle, buildTable, readCellDecoration };