js.documents 1.83.0 → 1.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/edit/docx/content.cjs +11 -1
- package/dist/edit/docx/content.js +11 -1
- package/dist/edit/docx/paragraph.cjs +98 -0
- package/dist/edit/docx/paragraph.d.cts +13 -1
- package/dist/edit/docx/paragraph.d.ts +13 -1
- package/dist/edit/docx/paragraph.js +99 -1
- package/dist/edit/docx/props.cjs +1 -1
- package/dist/edit/docx/props.js +1 -1
- package/dist/edit/docx/run.cjs +7 -0
- package/dist/edit/docx/run.d.cts +1 -1
- package/dist/edit/docx/run.d.ts +1 -1
- package/dist/edit/docx/run.js +7 -0
- package/dist/edit/docx/table.cjs +119 -1
- package/dist/edit/docx/table.d.cts +8 -0
- package/dist/edit/docx/table.d.ts +8 -0
- package/dist/edit/docx/table.js +119 -1
- package/dist/edit/odg/page.d.cts +1 -1
- package/dist/edit/odg/page.d.ts +1 -1
- package/dist/edit/odp/shape.d.cts +1 -1
- package/dist/edit/odp/shape.d.ts +1 -1
- package/dist/edit/odp/slide.d.cts +2 -2
- package/dist/edit/odp/slide.d.ts +2 -2
- package/dist/edit/odt/content.cjs +8 -0
- package/dist/edit/odt/content.d.cts +2 -2
- package/dist/edit/odt/content.d.ts +2 -2
- package/dist/edit/odt/content.js +8 -0
- package/dist/edit/odt/editor.d.cts +3 -3
- package/dist/edit/odt/editor.d.ts +3 -3
- package/dist/edit/odt/list.d.cts +1 -1
- package/dist/edit/odt/list.d.ts +1 -1
- package/dist/edit/odt/paragraph.cjs +30 -0
- package/dist/edit/odt/paragraph.d.cts +1 -1
- package/dist/edit/odt/paragraph.d.ts +1 -1
- package/dist/edit/odt/paragraph.js +30 -0
- package/dist/edit/odt/run.cjs +6 -0
- package/dist/edit/odt/run.d.cts +1 -1
- package/dist/edit/odt/run.d.ts +1 -1
- package/dist/edit/odt/run.js +6 -0
- package/dist/edit/odt/table.cjs +105 -0
- package/dist/edit/odt/table.d.cts +2 -2
- package/dist/edit/odt/table.d.ts +2 -2
- package/dist/edit/odt/table.js +105 -2
- package/dist/edit/pptx/content.cjs +4 -0
- package/dist/edit/pptx/content.js +4 -0
- package/dist/edit/pptx/shape.cjs +3 -1
- package/dist/edit/pptx/shape.d.cts +1 -1
- package/dist/edit/pptx/shape.d.ts +1 -1
- package/dist/edit/pptx/shape.js +3 -1
- package/dist/edit/pptx/slide.d.cts +2 -2
- package/dist/edit/pptx/slide.d.ts +2 -2
- package/dist/edit/pptx/table.cjs +1 -1
- package/dist/edit/pptx/table.d.cts +1 -1
- package/dist/edit/pptx/table.d.ts +1 -1
- package/dist/edit/pptx/table.js +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/{list-DXRaCcT1.d.cts → list-CxoEJwNO.d.cts} +1 -1
- package/dist/{list-7hZydHAV.d.ts → list-DA1hCBVI.d.ts} +1 -1
- package/dist/{paragraph-kMJVZhAi.d.ts → paragraph-DV4_ZNGr.d.ts} +11 -1
- package/dist/{paragraph-Dlly6_E9.d.cts → paragraph-DXIJfPMw.d.cts} +11 -1
- package/dist/{run-DDe7miD5.d.ts → run-BYJGK31k.d.ts} +3 -0
- package/dist/{run-P0b2pDdX.d.cts → run-DEPVf5ZJ.d.cts} +3 -0
- package/dist/{run-F8JN7Vy4.d.cts → run-DQtEGilU.d.cts} +3 -0
- package/dist/{run-wB22_F5w.d.ts → run-SLSPO-4y.d.ts} +3 -0
- package/dist/{shape-BhkP6HB8.d.cts → shape-BwBiRGha.d.cts} +2 -0
- package/dist/{shape-BjX3wlig.d.ts → shape-D5IoGzf9.d.ts} +2 -0
- package/dist/{shape-BR8GL8XC.d.cts → shape-Dch9pDCf.d.cts} +2 -2
- package/dist/{shape-DeP-P4Nh.d.ts → shape-DyviC6ZG.d.ts} +2 -2
- package/dist/{table-DSFcqJ7C.d.cts → table-BtMtRYqc.d.cts} +13 -2
- package/dist/{table-AT4t4VUy.d.ts → table-BxeHHD7r.d.ts} +13 -2
- package/dist/{table-L5SxKy8_.d.ts → table-CCdAhdcG.d.ts} +1 -1
- package/dist/{table-CfRjVOFN.d.cts → table-SczxeRF0.d.cts} +1 -1
- package/package.json +1 -1
package/dist/edit/docx/table.js
CHANGED
|
@@ -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 = [
|
|
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 = [];
|
package/dist/edit/odg/page.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as ImageInit } from "../../image-M5SezZVI.cjs";
|
|
2
|
-
import { t as OdpShape } from "../../shape-
|
|
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";
|
package/dist/edit/odg/page.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as ImageInit } from "../../image-DHcA9kaK.js";
|
|
2
|
-
import { t as OdpShape } from "../../shape-
|
|
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-
|
|
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 };
|
package/dist/edit/odp/shape.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-
|
|
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-
|
|
3
|
+
import { t as OdpShape } from "../../shape-Dch9pDCf.cjs";
|
|
4
4
|
import { s as OdgVector } from "../../vector-D03KX8Ux.cjs";
|
|
5
|
-
import {
|
|
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
|
package/dist/edit/odp/slide.d.ts
CHANGED
|
@@ -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-
|
|
3
|
+
import { t as OdpShape } from "../../shape-DyviC6ZG.js";
|
|
4
4
|
import { s as OdgVector } from "../../vector-D03KX8Ux.js";
|
|
5
|
-
import {
|
|
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();
|
|
@@ -99,6 +104,7 @@ function populateParagraph(paragraph, block) {
|
|
|
99
104
|
if (run.bold === true) odtRun.bold = true;
|
|
100
105
|
if (run.italic === true) odtRun.italic = true;
|
|
101
106
|
if (run.underline === true) odtRun.underline = true;
|
|
107
|
+
if (run.strike === true) odtRun.strike = true;
|
|
102
108
|
if (run.fontFamily !== void 0) odtRun.fontFamily = run.fontFamily;
|
|
103
109
|
if (run.sizePt !== void 0) odtRun.sizePt = run.sizePt;
|
|
104
110
|
if (run.color !== void 0) odtRun.color = run.color;
|
|
@@ -148,6 +154,8 @@ function populateOdtTable(table, block) {
|
|
|
148
154
|
tableCell.rowSpan = cell.rowSpan;
|
|
149
155
|
for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
|
|
150
156
|
}
|
|
157
|
+
if (cell.background !== void 0) tableCell.background = cell.background;
|
|
158
|
+
if (cell.borders !== void 0) tableCell.borders = cell.borders;
|
|
151
159
|
populateCellBlocks(tableCell, cell.blocks);
|
|
152
160
|
colIndex += 1;
|
|
153
161
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClockPort } from "../../ports/clock.cjs";
|
|
2
|
-
import { t as OdtParagraph } from "../../paragraph-
|
|
3
|
-
import {
|
|
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-
|
|
3
|
-
import {
|
|
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
|
package/dist/edit/odt/content.js
CHANGED
|
@@ -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();
|
|
@@ -98,6 +103,7 @@ function populateParagraph(paragraph, block) {
|
|
|
98
103
|
if (run.bold === true) odtRun.bold = true;
|
|
99
104
|
if (run.italic === true) odtRun.italic = true;
|
|
100
105
|
if (run.underline === true) odtRun.underline = true;
|
|
106
|
+
if (run.strike === true) odtRun.strike = true;
|
|
101
107
|
if (run.fontFamily !== void 0) odtRun.fontFamily = run.fontFamily;
|
|
102
108
|
if (run.sizePt !== void 0) odtRun.sizePt = run.sizePt;
|
|
103
109
|
if (run.color !== void 0) odtRun.color = run.color;
|
|
@@ -147,6 +153,8 @@ function populateOdtTable(table, block) {
|
|
|
147
153
|
tableCell.rowSpan = cell.rowSpan;
|
|
148
154
|
for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
|
|
149
155
|
}
|
|
156
|
+
if (cell.background !== void 0) tableCell.background = cell.background;
|
|
157
|
+
if (cell.borders !== void 0) tableCell.borders = cell.borders;
|
|
150
158
|
populateCellBlocks(tableCell, cell.blocks);
|
|
151
159
|
colIndex += 1;
|
|
152
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-
|
|
4
|
-
import { t as OdtList } from "../../list-
|
|
5
|
-
import {
|
|
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-
|
|
4
|
-
import { t as OdtList } from "../../list-
|
|
5
|
-
import {
|
|
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
|
package/dist/edit/odt/list.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-
|
|
1
|
+
import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-CxoEJwNO.cjs";
|
|
2
2
|
export { OdtList, OdtListItem, buildList };
|
package/dist/edit/odt/list.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-
|
|
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-
|
|
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-
|
|
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 = {
|
package/dist/edit/odt/run.cjs
CHANGED
|
@@ -42,6 +42,12 @@ var OdtRun = class {
|
|
|
42
42
|
set underline(value) {
|
|
43
43
|
require_edit_odt_props.applyStyleChange(this.pkg, this.live(), "text", { underline: value });
|
|
44
44
|
}
|
|
45
|
+
get strike() {
|
|
46
|
+
return require_edit_odt_props.readCurrentStyleProperties(this.pkg, this.live(), "text").strike ?? false;
|
|
47
|
+
}
|
|
48
|
+
set strike(value) {
|
|
49
|
+
require_edit_odt_props.applyStyleChange(this.pkg, this.live(), "text", { strike: value });
|
|
50
|
+
}
|
|
45
51
|
get fontFamily() {
|
|
46
52
|
return require_edit_odt_props.readCurrentStyleProperties(this.pkg, this.live(), "text").fontFamily;
|
|
47
53
|
}
|
package/dist/edit/odt/run.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RunInit, r as buildRun, t as OdtRun } from "../../run-
|
|
1
|
+
import { n as RunInit, r as buildRun, t as OdtRun } from "../../run-DQtEGilU.cjs";
|
|
2
2
|
export { OdtRun, RunInit, buildRun };
|
package/dist/edit/odt/run.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RunInit, r as buildRun, t as OdtRun } from "../../run-
|
|
1
|
+
import { n as RunInit, r as buildRun, t as OdtRun } from "../../run-SLSPO-4y.js";
|
|
2
2
|
export { OdtRun, RunInit, buildRun };
|
package/dist/edit/odt/run.js
CHANGED
|
@@ -41,6 +41,12 @@ var OdtRun = class {
|
|
|
41
41
|
set underline(value) {
|
|
42
42
|
applyStyleChange(this.pkg, this.live(), "text", { underline: value });
|
|
43
43
|
}
|
|
44
|
+
get strike() {
|
|
45
|
+
return readCurrentStyleProperties(this.pkg, this.live(), "text").strike ?? false;
|
|
46
|
+
}
|
|
47
|
+
set strike(value) {
|
|
48
|
+
applyStyleChange(this.pkg, this.live(), "text", { strike: value });
|
|
49
|
+
}
|
|
44
50
|
get fontFamily() {
|
|
45
51
|
return readCurrentStyleProperties(this.pkg, this.live(), "text").fontFamily;
|
|
46
52
|
}
|
package/dist/edit/odt/table.cjs
CHANGED
|
@@ -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
|
|
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 };
|
package/dist/edit/odt/table.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
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 };
|