js.documents 14.4.56 → 14.4.57
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/codecs/read.cjs +2 -2
- package/dist/codecs/read.js +1 -1
- package/dist/composition-plan-CfvhXeOC.cjs +627 -0
- package/dist/composition-plan-DU9nPPN7.d.cts +102 -0
- package/dist/composition-plan-f0zaExUW.js +508 -0
- package/dist/composition-plan-l6QPO4FX.d.ts +102 -0
- package/dist/convert/composition-plan.cjs +7 -0
- package/dist/convert/composition-plan.d.cts +2 -0
- package/dist/convert/composition-plan.d.ts +2 -0
- package/dist/convert/composition-plan.js +2 -0
- package/dist/convert/composition-to-pdf.cjs +12 -12
- package/dist/convert/composition-to-pdf.d.cts +1 -1
- package/dist/convert/composition-to-pdf.d.ts +1 -1
- package/dist/convert/composition-to-pdf.js +2 -2
- package/dist/convert/composition.cjs +16 -511
- package/dist/convert/composition.d.cts +2 -85
- package/dist/convert/composition.d.ts +2 -85
- package/dist/convert/composition.js +2 -502
- package/dist/convert/convert.cjs +2 -2
- package/dist/convert/convert.js +1 -1
- package/dist/convert/from-package.cjs +3 -3
- package/dist/convert/from-package.js +2 -2
- package/dist/convert/from-pdf.cjs +18 -18
- package/dist/convert/from-pdf.js +2 -2
- package/dist/convert/local.cjs +3 -3
- package/dist/convert/local.js +1 -1
- package/dist/edit/odp/slide.cjs +4 -4
- package/dist/edit/odp/slide.d.cts +1 -1
- package/dist/edit/odp/slide.d.ts +1 -1
- package/dist/edit/odp/slide.js +1 -1
- package/dist/edit/odt/content.d.cts +1 -1
- package/dist/edit/odt/content.d.ts +1 -1
- package/dist/edit/odt/editor.cjs +4 -4
- package/dist/edit/odt/editor.d.cts +1 -1
- package/dist/edit/odt/editor.d.ts +1 -1
- package/dist/edit/odt/editor.js +1 -1
- package/dist/edit/odt/table-grid.cjs +23 -0
- package/dist/edit/odt/table-grid.d.cts +54 -0
- package/dist/edit/odt/table-grid.d.ts +54 -0
- package/dist/edit/odt/table-grid.js +2 -0
- package/dist/edit/odt/table.cjs +12 -653
- package/dist/edit/odt/table.d.cts +2 -2
- package/dist/edit/odt/table.d.ts +2 -2
- package/dist/edit/odt/table.js +2 -647
- package/dist/{evaluate-BbOsgdmN.d.cts → evaluate-BSEUxiUK.d.cts} +3 -1
- package/dist/evaluate-CEzsBx3w.cjs +564 -0
- package/dist/{evaluate-C7fmk69X.d.ts → evaluate-D8fG2ZeB.d.ts} +3 -1
- package/dist/evaluate-IK-3aMv5.js +445 -0
- package/dist/evaluate-columns-CyqKHkIW.d.cts +41 -0
- package/dist/evaluate-columns-cOo8fOfT.d.ts +41 -0
- package/dist/index.cjs +24 -24
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +8 -8
- package/dist/latex/lint.cjs +2 -2
- package/dist/latex/lint.js +1 -1
- package/dist/latex/lower-fold.cjs +6 -0
- package/dist/latex/lower-fold.d.cts +17 -0
- package/dist/latex/lower-fold.d.ts +17 -0
- package/dist/latex/lower-fold.js +2 -0
- package/dist/latex/lower.cjs +11 -617
- package/dist/latex/lower.d.cts +18 -1
- package/dist/latex/lower.d.ts +18 -1
- package/dist/latex/lower.js +2 -616
- package/dist/latex/symbols.d.cts +1 -15
- package/dist/latex/symbols.d.ts +1 -15
- package/dist/latex/temml.d.cts +1 -24
- package/dist/latex/temml.d.ts +1 -24
- package/dist/layout/engine.cjs +2 -2
- package/dist/layout/engine.js +1 -1
- package/dist/layout/reconstruct-lines.cjs +315 -0
- package/dist/layout/reconstruct-lines.d.cts +2 -0
- package/dist/layout/reconstruct-lines.d.ts +2 -0
- package/dist/layout/reconstruct-lines.js +297 -0
- package/dist/layout/reconstruct-presentations-prod.cjs +9 -0
- package/dist/layout/reconstruct-presentations-prod.d.cts +26 -0
- package/dist/layout/reconstruct-presentations-prod.d.ts +26 -0
- package/dist/layout/reconstruct-presentations-prod.js +2 -0
- package/dist/layout/reconstruct-tables.cjs +5 -0
- package/dist/layout/reconstruct-tables.d.cts +22 -0
- package/dist/layout/reconstruct-tables.d.ts +22 -0
- package/dist/layout/reconstruct-tables.js +2 -0
- package/dist/layout/reconstruct.cjs +11 -1545
- package/dist/layout/reconstruct.d.cts +2 -14
- package/dist/layout/reconstruct.d.ts +2 -14
- package/dist/layout/reconstruct.js +2 -1542
- package/dist/layout/shared.cjs +2 -2
- package/dist/layout/shared.js +1 -1
- package/dist/layout/sheets-render.cjs +19 -0
- package/dist/layout/sheets-render.d.cts +41 -0
- package/dist/layout/sheets-render.d.ts +41 -0
- package/dist/layout/sheets-render.js +2 -0
- package/dist/layout/sheets.cjs +10 -544
- package/dist/layout/sheets.d.cts +13 -2
- package/dist/layout/sheets.d.ts +13 -2
- package/dist/layout/sheets.js +2 -543
- package/dist/layout/slides.cjs +2 -2
- package/dist/layout/slides.js +1 -1
- package/dist/layout-DIJzJk4x.js +526 -0
- package/dist/layout-iuiyl_Fk.cjs +621 -0
- package/dist/layout-types-oSbHvZid.d.cts +13 -0
- package/dist/layout-types-oSbHvZid.d.ts +13 -0
- package/dist/lower-DCs3rWI7.js +618 -0
- package/dist/lower-DzOb13w4.cjs +701 -0
- package/dist/markdown/math.cjs +2 -2
- package/dist/markdown/math.js +1 -1
- package/dist/mathml/layout-stretch.cjs +16 -0
- package/dist/mathml/layout-stretch.d.cts +24 -0
- package/dist/mathml/layout-stretch.d.ts +24 -0
- package/dist/mathml/layout-stretch.js +2 -0
- package/dist/mathml/layout-types.d.cts +1 -12
- package/dist/mathml/layout-types.d.ts +1 -12
- package/dist/mathml/layout.cjs +3 -525
- package/dist/mathml/layout.d.cts +2 -2
- package/dist/mathml/layout.d.ts +2 -2
- package/dist/mathml/layout.js +1 -523
- package/dist/odb/formula/evaluate.d.cts +1 -1
- package/dist/odb/formula/evaluate.d.ts +1 -1
- package/dist/odb/report/render.d.cts +1 -1
- package/dist/odb/report/render.d.ts +1 -1
- package/dist/odb/report/source.cjs +2 -2
- package/dist/odb/report/source.d.cts +1 -1
- package/dist/odb/report/source.d.ts +1 -1
- package/dist/odb/report/source.js +1 -1
- package/dist/odb/sql/evaluate-columns.cjs +122 -0
- package/dist/odb/sql/evaluate-columns.d.cts +2 -0
- package/dist/odb/sql/evaluate-columns.d.ts +2 -0
- package/dist/odb/sql/evaluate-columns.js +114 -0
- package/dist/odb/sql/evaluate-predicates.cjs +16 -0
- package/dist/odb/sql/evaluate-predicates.d.cts +23 -0
- package/dist/odb/sql/evaluate-predicates.d.ts +23 -0
- package/dist/odb/sql/evaluate-predicates.js +2 -0
- package/dist/odb/sql/evaluate.cjs +7 -556
- package/dist/odb/sql/evaluate.d.cts +2 -2
- package/dist/odb/sql/evaluate.d.ts +2 -2
- package/dist/odb/sql/evaluate.js +2 -552
- package/dist/read-BSH--XB4.js +682 -0
- package/dist/read-CahCZMwG.cjs +759 -0
- package/dist/reconstruct-BKOCAedo.d.ts +29 -0
- package/dist/reconstruct-D4TEteZ6.d.cts +29 -0
- package/dist/reconstruct-lines-B7t66ICm.d.cts +33 -0
- package/dist/reconstruct-lines-B7t66ICm.d.ts +33 -0
- package/dist/reconstruct-presentations-prod-B5fkPiRZ.js +1256 -0
- package/dist/reconstruct-presentations-prod-X315aBmI.cjs +1375 -0
- package/dist/sheets-BQCpNXsE.cjs +700 -0
- package/dist/sheets-DWDvGN-g.js +545 -0
- package/dist/svg/read-geometry.cjs +10 -0
- package/dist/svg/read-geometry.d.cts +24 -0
- package/dist/svg/read-geometry.d.ts +24 -0
- package/dist/svg/read-geometry.js +2 -0
- package/dist/svg/read.cjs +6 -680
- package/dist/svg/read.d.cts +17 -2
- package/dist/svg/read.d.ts +17 -2
- package/dist/svg/read.js +2 -679
- package/dist/symbols-BlzXfLEe.d.cts +16 -0
- package/dist/symbols-CKm2r4D0.d.ts +16 -0
- package/dist/table-B5gSMY7w.js +649 -0
- package/dist/{table-DrE6jEWv.d.cts → table-BK_Ao-Y6.d.cts} +9 -1
- package/dist/{table-B5htMG3g.d.ts → table-CxY85YUj.d.ts} +9 -1
- package/dist/table-DqUIOSPV.cjs +840 -0
- package/dist/temml-1-I9N9DD.d.cts +25 -0
- package/dist/temml-1-I9N9DD.d.ts +25 -0
- package/package.json +1 -1
package/dist/edit/odt/table.cjs
CHANGED
|
@@ -1,654 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const TABLE_CELL_STYLE_PREFIX = "OdtCell";
|
|
15
|
-
const TABLE_ROW_STYLE_PREFIX = "OdtRow";
|
|
16
|
-
const BORDER_EDGE_ATTRS = {
|
|
17
|
-
top: "fo:border-top",
|
|
18
|
-
right: "fo:border-right",
|
|
19
|
-
bottom: "fo:border-bottom",
|
|
20
|
-
left: "fo:border-left"
|
|
21
|
-
};
|
|
22
|
-
function formatBorderShorthand(color, widthPt, style) {
|
|
23
|
-
return `${(0, odf_js.formatOdfLength)(widthPt)} ${style ?? "solid"} ${(0, odf_js.formatOdfColor)(color)}`;
|
|
24
|
-
}
|
|
25
|
-
function findCellPropertiesReadOnly(pkg, element) {
|
|
26
|
-
const styleName = (0, ooxml_js.attr)(element, "table:style-name");
|
|
27
|
-
if (styleName === void 0) return;
|
|
28
|
-
const part = pkg.parts["content.xml"];
|
|
29
|
-
const root = part?.kind === "xml" ? part.nodes.find((n) => n.type === "element") : void 0;
|
|
30
|
-
if (root === void 0) return;
|
|
31
|
-
for (const child of root.children) if (child.type === "element" && child.tag === "office:automatic-styles") {
|
|
32
|
-
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") {
|
|
33
|
-
for (const props of style.children) if (props.type === "element" && props.tag === "style:table-cell-properties") return props;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function readCellDecoration(pkg, element) {
|
|
38
|
-
const props = findCellPropertiesReadOnly(pkg, element);
|
|
39
|
-
if (props === void 0) return {};
|
|
40
|
-
let background;
|
|
41
|
-
const backgroundValue = (0, ooxml_js.attr)(props, "fo:background-color");
|
|
42
|
-
if (backgroundValue !== void 0) background = (0, odf_js.parseOdfColor)(backgroundValue);
|
|
43
|
-
const borders = {};
|
|
44
|
-
[
|
|
45
|
-
"top",
|
|
46
|
-
"right",
|
|
47
|
-
"bottom",
|
|
48
|
-
"left"
|
|
49
|
-
].forEach((edge) => {
|
|
50
|
-
const raw = (0, ooxml_js.attr)(props, BORDER_EDGE_ATTRS[edge]);
|
|
51
|
-
if (raw === void 0) return;
|
|
52
|
-
const tokens = raw.trim().split(/\s+/);
|
|
53
|
-
const widthToken = tokens[0];
|
|
54
|
-
const styleToken = tokens[1];
|
|
55
|
-
const colorToken = tokens[2];
|
|
56
|
-
if (widthToken === void 0 || styleToken === void 0 || colorToken === void 0 || styleToken === "none" || styleToken === "hidden") return;
|
|
57
|
-
const widthPt = (0, odf_js.parseOdfLength)(widthToken);
|
|
58
|
-
const color = (0, odf_js.parseOdfColor)(colorToken);
|
|
59
|
-
if (widthPt === void 0 || widthPt <= 0 || color === void 0) return;
|
|
60
|
-
const style = styleToken === "solid" || styleToken === "dashed" || styleToken === "dotted" || styleToken === "double" ? styleToken : void 0;
|
|
61
|
-
borders[edge] = style === void 0 ? {
|
|
62
|
-
color,
|
|
63
|
-
widthPt
|
|
64
|
-
} : {
|
|
65
|
-
color,
|
|
66
|
-
widthPt,
|
|
67
|
-
style
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
return {
|
|
71
|
-
background,
|
|
72
|
-
borders: Object.keys(borders).length === 0 ? void 0 : borders
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
function buildCellStyle(pkg, decoration) {
|
|
76
|
-
const automaticStyles = require_edit_odt_automatic_styles.ensureAutomaticStyles(pkg);
|
|
77
|
-
const name = require_edit_odt_automatic_styles.nextStyleName(automaticStyles, "style:style", TABLE_CELL_STYLE_PREFIX);
|
|
78
|
-
const propsAttrs = {};
|
|
79
|
-
if (decoration.background !== void 0) propsAttrs["fo:background-color"] = (0, odf_js.formatOdfColor)(decoration.background);
|
|
80
|
-
if (decoration.borders !== void 0) [
|
|
81
|
-
"top",
|
|
82
|
-
"right",
|
|
83
|
-
"bottom",
|
|
84
|
-
"left"
|
|
85
|
-
].forEach((edge) => {
|
|
86
|
-
const border = decoration.borders[edge];
|
|
87
|
-
if (border !== void 0) propsAttrs[BORDER_EDGE_ATTRS[edge]] = formatBorderShorthand(border.color, border.widthPt, border.style);
|
|
88
|
-
});
|
|
89
|
-
const properties = Object.keys(propsAttrs).length === 0 ? [] : [require_xml_fragment.el("style:table-cell-properties", propsAttrs)];
|
|
90
|
-
automaticStyles.children.push(require_xml_fragment.el("style:style", {
|
|
91
|
-
"style:name": name,
|
|
92
|
-
"style:family": "table-cell"
|
|
93
|
-
}, properties));
|
|
94
|
-
return name;
|
|
95
|
-
}
|
|
96
|
-
function internTableColumnWidth(pkg, widthPt) {
|
|
97
|
-
const automaticStyles = require_edit_odt_automatic_styles.ensureAutomaticStyles(pkg);
|
|
98
|
-
const formatted = (0, odf_js.formatOdfLength)(widthPt, "pt");
|
|
99
|
-
for (const child of automaticStyles.children) {
|
|
100
|
-
if (child.type !== "element" || child.tag !== "style:style" || (0, ooxml_js.attr)(child, "style:family") !== "table-column") continue;
|
|
101
|
-
const props = child.children.find((c) => c.type === "element" && c.tag === "style:table-column-properties");
|
|
102
|
-
if (props !== void 0 && (0, ooxml_js.attr)(props, "style:column-width") === formatted) {
|
|
103
|
-
const existingName = (0, ooxml_js.attr)(child, "style:name");
|
|
104
|
-
if (existingName !== void 0) return existingName;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const name = require_edit_odt_automatic_styles.nextStyleName(automaticStyles, "style:style", TABLE_COLUMN_STYLE_PREFIX);
|
|
108
|
-
automaticStyles.children.push(require_xml_fragment.el("style:style", {
|
|
109
|
-
"style:name": name,
|
|
110
|
-
"style:family": "table-column"
|
|
111
|
-
}, [require_xml_fragment.el("style:table-column-properties", { "style:column-width": formatted })]));
|
|
112
|
-
return name;
|
|
113
|
-
}
|
|
114
|
-
function currentRowPropertiesElement(pkg, rowElement) {
|
|
115
|
-
const styleName = (0, ooxml_js.attr)(rowElement, "table:style-name");
|
|
116
|
-
const styleElement = styleName === void 0 ? void 0 : (0, odf_js.findStyleElement)(styleName, "table-row", pkg);
|
|
117
|
-
return styleElement === void 0 ? void 0 : styleElement.children.find((c) => c.type === "element" && c.tag === "style:table-row-properties");
|
|
118
|
-
}
|
|
119
|
-
function cloneCurrentRowProperties(pkg, rowElement) {
|
|
120
|
-
const props = currentRowPropertiesElement(pkg, rowElement);
|
|
121
|
-
return props === void 0 ? require_xml_fragment.el("style:table-row-properties") : structuredClone(props);
|
|
122
|
-
}
|
|
123
|
-
function xmlNodesEqual(a, b) {
|
|
124
|
-
if (a.type === "element" && b.type === "element") return xmlElementsEqual(a, b);
|
|
125
|
-
if (a.type === "text" && b.type === "text") return a.value === b.value;
|
|
126
|
-
if (a.type === "cdata" && b.type === "cdata") return a.value === b.value;
|
|
127
|
-
if (a.type === "comment" && b.type === "comment") return a.value === b.value;
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
function xmlElementsEqual(a, b) {
|
|
131
|
-
if (a.tag !== b.tag || a.attributes.length !== b.attributes.length) return false;
|
|
132
|
-
if (!a.attributes.every((candidate) => (0, ooxml_js.attr)(b, candidate.name) === candidate.value)) return false;
|
|
133
|
-
if (a.children.length !== b.children.length) return false;
|
|
134
|
-
for (let index = 0; index < a.children.length; index++) {
|
|
135
|
-
const childA = a.children[index];
|
|
136
|
-
const childB = b.children[index];
|
|
137
|
-
if (childA === void 0 || childB === void 0) return false;
|
|
138
|
-
if (!xmlNodesEqual(childA, childB)) return false;
|
|
139
|
-
}
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
function internTableRowProperties(pkg, properties) {
|
|
143
|
-
const automaticStyles = require_edit_odt_automatic_styles.ensureAutomaticStyles(pkg);
|
|
144
|
-
for (const child of automaticStyles.children) {
|
|
145
|
-
if (child.type !== "element" || child.tag !== "style:style" || (0, ooxml_js.attr)(child, "style:family") !== "table-row") continue;
|
|
146
|
-
const props = child.children.find((c) => c.type === "element" && c.tag === "style:table-row-properties");
|
|
147
|
-
if (props !== void 0 && xmlElementsEqual(props, properties)) {
|
|
148
|
-
const existingName = (0, ooxml_js.attr)(child, "style:name");
|
|
149
|
-
if (existingName !== void 0) return existingName;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const name = require_edit_odt_automatic_styles.nextStyleName(automaticStyles, "style:style", TABLE_ROW_STYLE_PREFIX);
|
|
153
|
-
automaticStyles.children.push(require_xml_fragment.el("style:style", {
|
|
154
|
-
"style:name": name,
|
|
155
|
-
"style:family": "table-row"
|
|
156
|
-
}, [properties]));
|
|
157
|
-
return name;
|
|
158
|
-
}
|
|
159
|
-
var OdtTableCell = class {
|
|
160
|
-
node;
|
|
161
|
-
pkg;
|
|
162
|
-
constructor(node, pkg) {
|
|
163
|
-
this.node = node;
|
|
164
|
-
this.pkg = pkg;
|
|
165
|
-
}
|
|
166
|
-
paragraphs() {
|
|
167
|
-
const out = [];
|
|
168
|
-
for (const child of this.node.children) if (child.type === "element" && (child.tag === "text:p" || child.tag === "text:h")) out.push(new require_edit_odt_paragraph.OdtParagraph(this.node.children, child, this.pkg));
|
|
169
|
-
return out;
|
|
170
|
-
}
|
|
171
|
-
appendParagraph(init) {
|
|
172
|
-
const paragraphElement = require_edit_odt_paragraph.buildParagraph(this.pkg, init);
|
|
173
|
-
this.node.children.push(paragraphElement);
|
|
174
|
-
return new require_edit_odt_paragraph.OdtParagraph(this.node.children, paragraphElement, this.pkg);
|
|
175
|
-
}
|
|
176
|
-
get text() {
|
|
177
|
-
return this.paragraphs().map((p) => p.text).join("\n");
|
|
178
|
-
}
|
|
179
|
-
get colSpan() {
|
|
180
|
-
const raw = (0, ooxml_js.attr)(this.node, "table:number-columns-spanned");
|
|
181
|
-
return raw === void 0 ? void 0 : Number(raw);
|
|
182
|
-
}
|
|
183
|
-
set colSpan(value) {
|
|
184
|
-
if (value === void 0) {
|
|
185
|
-
require_xml_edit.removeAttr(this.node, "table:number-columns-spanned");
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
require_xml_edit.setAttr(this.node, "table:number-columns-spanned", String(value));
|
|
189
|
-
}
|
|
190
|
-
get rowSpan() {
|
|
191
|
-
const raw = (0, ooxml_js.attr)(this.node, "table:number-rows-spanned");
|
|
192
|
-
return raw === void 0 ? void 0 : Number(raw);
|
|
193
|
-
}
|
|
194
|
-
set rowSpan(value) {
|
|
195
|
-
if (value === void 0) {
|
|
196
|
-
require_xml_edit.removeAttr(this.node, "table:number-rows-spanned");
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
require_xml_edit.setAttr(this.node, "table:number-rows-spanned", String(value));
|
|
200
|
-
}
|
|
201
|
-
get background() {
|
|
202
|
-
return readCellDecoration(this.pkg, this.node).background;
|
|
203
|
-
}
|
|
204
|
-
set background(value) {
|
|
205
|
-
writeCellBackground(this.pkg, this.node, value);
|
|
206
|
-
}
|
|
207
|
-
get borders() {
|
|
208
|
-
return readCellDecoration(this.pkg, this.node).borders;
|
|
209
|
-
}
|
|
210
|
-
set borders(value) {
|
|
211
|
-
writeCellBorders(this.pkg, this.node, value);
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
function writeCellBackground(pkg, node, value) {
|
|
215
|
-
const name = buildCellStyle(pkg, {
|
|
216
|
-
background: value,
|
|
217
|
-
borders: readCellDecoration(pkg, node).borders
|
|
218
|
-
});
|
|
219
|
-
require_xml_edit.setAttr(node, "table:style-name", name);
|
|
220
|
-
}
|
|
221
|
-
function writeCellBorders(pkg, node, value) {
|
|
222
|
-
const name = buildCellStyle(pkg, {
|
|
223
|
-
background: readCellDecoration(pkg, node).background,
|
|
224
|
-
borders: value
|
|
225
|
-
});
|
|
226
|
-
require_xml_edit.setAttr(node, "table:style-name", name);
|
|
227
|
-
}
|
|
228
|
-
var OdtCoveredTableCell = class {
|
|
229
|
-
node;
|
|
230
|
-
pkg;
|
|
231
|
-
constructor(node, pkg) {
|
|
232
|
-
this.node = node;
|
|
233
|
-
this.pkg = pkg;
|
|
234
|
-
}
|
|
235
|
-
get background() {
|
|
236
|
-
return readCellDecoration(this.pkg, this.node).background;
|
|
237
|
-
}
|
|
238
|
-
set background(value) {
|
|
239
|
-
writeCellBackground(this.pkg, this.node, value);
|
|
240
|
-
}
|
|
241
|
-
get borders() {
|
|
242
|
-
return readCellDecoration(this.pkg, this.node).borders;
|
|
243
|
-
}
|
|
244
|
-
set borders(value) {
|
|
245
|
-
writeCellBorders(this.pkg, this.node, value);
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
const COVERED_CELL_KEPT_ATTRIBUTE = "table:style-name";
|
|
249
|
-
function retagAsCovered(element) {
|
|
250
|
-
element.tag = "table:covered-table-cell";
|
|
251
|
-
element.attributes = element.attributes.filter((attribute) => attribute.name === COVERED_CELL_KEPT_ATTRIBUTE);
|
|
252
|
-
element.children = [];
|
|
253
|
-
}
|
|
254
|
-
function gridColumnElements(row) {
|
|
255
|
-
const out = [];
|
|
256
|
-
let columnIndex = 0;
|
|
257
|
-
for (const member of require_edit_odf_repeated_runs.collectRunMembers(row.children, require_edit_odf_repeated_runs.isCellOrCoveredCell, void 0)) {
|
|
258
|
-
const repeat = require_edit_odf_repeated_runs.readRunRepeatCount(member.node, require_edit_odf_repeated_runs.COLUMN_REPEAT_ATTR);
|
|
259
|
-
for (let offset = 0; offset < repeat; offset++) out.push({
|
|
260
|
-
columnIndex: columnIndex + offset,
|
|
261
|
-
element: member.node
|
|
262
|
-
});
|
|
263
|
-
columnIndex += repeat;
|
|
264
|
-
}
|
|
265
|
-
return out;
|
|
266
|
-
}
|
|
267
|
-
function rowGridColumnCount(row) {
|
|
268
|
-
return require_edit_odf_repeated_runs.collectRunMembers(row.children, require_edit_odf_repeated_runs.isCellOrCoveredCell, void 0).reduce((sum, member) => sum + require_edit_odf_repeated_runs.readRunRepeatCount(member.node, require_edit_odf_repeated_runs.COLUMN_REPEAT_ATTR), 0);
|
|
269
|
-
}
|
|
270
|
-
function locateGridColumnElement(row, columnIndex) {
|
|
271
|
-
if (columnIndex < 0) return;
|
|
272
|
-
let cursor = 0;
|
|
273
|
-
for (const member of require_edit_odf_repeated_runs.collectRunMembers(row.children, require_edit_odf_repeated_runs.isCellOrCoveredCell, void 0)) {
|
|
274
|
-
const count = require_edit_odf_repeated_runs.readRunRepeatCount(member.node, require_edit_odf_repeated_runs.COLUMN_REPEAT_ATTR);
|
|
275
|
-
if (columnIndex < cursor + count) return member.node;
|
|
276
|
-
cursor += count;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
function individuateGridColumn(row, columnIndex) {
|
|
280
|
-
return require_edit_odf_repeated_runs.replaceRun(row.children, require_edit_odf_repeated_runs.isCellOrCoveredCell, columnIndex, require_edit_odf_repeated_runs.COLUMN_REPEAT_ATTR, () => {
|
|
281
|
-
throw new Error(`individuateGridColumn: column ${columnIndex} has no existing element to individuate in this row — callers must bounds-check against rowGridColumnCount first`);
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
function tableRowElements(table) {
|
|
285
|
-
return tableRowEntries(table).map((entry) => entry.element);
|
|
286
|
-
}
|
|
287
|
-
function placedCells(row, pkg) {
|
|
288
|
-
return gridColumnElements(row).flatMap(({ columnIndex, element }) => {
|
|
289
|
-
if (element.tag !== "table:table-cell") return [];
|
|
290
|
-
const cell = new OdtTableCell(element, pkg);
|
|
291
|
-
return [{
|
|
292
|
-
columnIndex,
|
|
293
|
-
cell,
|
|
294
|
-
colSpan: cell.colSpan,
|
|
295
|
-
rowSpan: cell.rowSpan
|
|
296
|
-
}];
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
function resolveOdtGrid(table, pkg) {
|
|
300
|
-
const placedRows = [];
|
|
301
|
-
let declaredColumns = 0;
|
|
302
|
-
for (const column of tableColumnElements(table)) declaredColumns += require_edit_odf_repeated_runs.readRunRepeatCount(column, require_edit_odf_repeated_runs.COLUMN_REPEAT_ATTR);
|
|
303
|
-
for (const row of tableRowElements(table)) placedRows.push(placedCells(row, pkg));
|
|
304
|
-
return require_edit_table_grid.resolveLiveTableGrid(placedRows, declaredColumns);
|
|
305
|
-
}
|
|
306
|
-
function regionCovers(region, rowIndex, columnIndex) {
|
|
307
|
-
return region.row <= rowIndex && rowIndex < region.row + region.rowSpan && region.column <= columnIndex && columnIndex < region.column + region.columnSpan;
|
|
308
|
-
}
|
|
309
|
-
function regionsIntersect(a, b) {
|
|
310
|
-
return a.row < b.row + b.rowSpan && b.row < a.row + a.rowSpan && a.column < b.column + b.columnSpan && b.column < a.column + a.columnSpan;
|
|
311
|
-
}
|
|
312
|
-
function regionContains(outer, inner) {
|
|
313
|
-
return outer.row <= inner.row && outer.column <= inner.column && inner.row + inner.rowSpan <= outer.row + outer.rowSpan && inner.column + inner.columnSpan <= outer.column + outer.columnSpan;
|
|
314
|
-
}
|
|
315
|
-
function anchorRegions(grid) {
|
|
316
|
-
return grid.rows.flatMap((positions, row) => positions.flatMap((position, column) => {
|
|
317
|
-
if (position?.isAnchor !== true) return [];
|
|
318
|
-
const spans = {
|
|
319
|
-
blocks: [],
|
|
320
|
-
colSpan: position.cell.colSpan,
|
|
321
|
-
rowSpan: position.cell.rowSpan
|
|
322
|
-
};
|
|
323
|
-
return [{
|
|
324
|
-
row,
|
|
325
|
-
column,
|
|
326
|
-
rowSpan: (0, document_schema_js.tableCellRowSpan)(spans),
|
|
327
|
-
columnSpan: (0, document_schema_js.tableCellColumnSpan)(spans)
|
|
328
|
-
}];
|
|
329
|
-
}));
|
|
330
|
-
}
|
|
331
|
-
function isUnchangedAnchor(region, target) {
|
|
332
|
-
return target.rowSpan === 1 && region.column === target.column && region.columnSpan === target.columnSpan;
|
|
333
|
-
}
|
|
334
|
-
function describeRegionAnchor(region) {
|
|
335
|
-
return `the merge anchored at row ${region.row}, column ${region.column}`;
|
|
336
|
-
}
|
|
337
|
-
function refuseMerge(rowIndex, reason) {
|
|
338
|
-
return { refusal: {
|
|
339
|
-
rowIndex,
|
|
340
|
-
reason
|
|
341
|
-
} };
|
|
342
|
-
}
|
|
343
|
-
function planMerge(table, pkg, target, rows) {
|
|
344
|
-
const [anchorRow, ...coveredRows] = rows;
|
|
345
|
-
const anchorElement = locateGridColumnElement(anchorRow, target.column);
|
|
346
|
-
if (anchorElement === void 0) return refuseMerge(target.row, `column ${target.column} does not exist in this row`);
|
|
347
|
-
const endColumn = target.column + target.columnSpan;
|
|
348
|
-
for (const [offset, row] of rows.entries()) {
|
|
349
|
-
const totalColumns = rowGridColumnCount(row);
|
|
350
|
-
if (endColumn > totalColumns) return refuseMerge(target.row + offset, `colSpan ${target.columnSpan} starting at column ${target.column} exceeds this row's own ${totalColumns} grid columns`);
|
|
351
|
-
}
|
|
352
|
-
const regions = anchorRegions(resolveOdtGrid(table, pkg));
|
|
353
|
-
if (anchorElement.tag === "table:covered-table-cell") {
|
|
354
|
-
const covering = regions.find((region) => regionCovers(region, target.row, target.column));
|
|
355
|
-
return refuseMerge(target.row, covering === void 0 ? `column ${target.column} is a covered position that no merge anchors` : `column ${target.column} is covered by ${describeRegionAnchor(covering)}`);
|
|
356
|
-
}
|
|
357
|
-
const cutting = regions.find((region) => regionsIntersect(region, target) && !regionContains(target, region) && !isUnchangedAnchor(region, target));
|
|
358
|
-
if (cutting !== void 0) {
|
|
359
|
-
const column = Math.max(cutting.column, target.column);
|
|
360
|
-
return refuseMerge(Math.max(cutting.row, target.row), `column ${column} belongs to ${describeRegionAnchor(cutting)}, which reaches outside the region being merged and cannot be merged over`);
|
|
361
|
-
}
|
|
362
|
-
const consumed = [];
|
|
363
|
-
for (let column = target.column + 1; column < endColumn; column++) consumed.push({
|
|
364
|
-
row: anchorRow,
|
|
365
|
-
column
|
|
366
|
-
});
|
|
367
|
-
for (const row of coveredRows) for (let column = target.column; column < endColumn; column++) consumed.push({
|
|
368
|
-
row,
|
|
369
|
-
column
|
|
370
|
-
});
|
|
371
|
-
return {
|
|
372
|
-
anchor: {
|
|
373
|
-
row: anchorRow,
|
|
374
|
-
column: target.column
|
|
375
|
-
},
|
|
376
|
-
consumed
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
function applyMerge(plan, target, pkg) {
|
|
380
|
-
for (const position of plan.consumed) retagAsCovered(individuateGridColumn(position.row, position.column));
|
|
381
|
-
const anchor = new OdtTableCell(individuateGridColumn(plan.anchor.row, plan.anchor.column), pkg);
|
|
382
|
-
anchor.colSpan = target.columnSpan;
|
|
383
|
-
if (target.rowSpan > 1) anchor.rowSpan = target.rowSpan;
|
|
384
|
-
return anchor;
|
|
385
|
-
}
|
|
386
|
-
const ROW_WRAPPER_TAGS = /* @__PURE__ */ new Set([
|
|
387
|
-
"table:table-rows",
|
|
388
|
-
"table:table-header-rows",
|
|
389
|
-
"table:table-row-group"
|
|
390
|
-
]);
|
|
391
|
-
function tableRowEntries(parent, insideHeader = false) {
|
|
392
|
-
const entries = [];
|
|
393
|
-
for (const child of parent.children) {
|
|
394
|
-
if (child.type !== "element") continue;
|
|
395
|
-
if (child.tag === "table:table-row") entries.push({
|
|
396
|
-
element: child,
|
|
397
|
-
insideHeader
|
|
398
|
-
});
|
|
399
|
-
else if (ROW_WRAPPER_TAGS.has(child.tag)) entries.push(...tableRowEntries(child, insideHeader || child.tag === "table:table-header-rows"));
|
|
400
|
-
}
|
|
401
|
-
return entries;
|
|
402
|
-
}
|
|
403
|
-
const COLUMN_WRAPPER_TAGS = /* @__PURE__ */ new Set([
|
|
404
|
-
"table:table-columns",
|
|
405
|
-
"table:table-header-columns",
|
|
406
|
-
"table:table-column-group"
|
|
407
|
-
]);
|
|
408
|
-
function tableColumnEntries(parent, insideHeader = false) {
|
|
409
|
-
const entries = [];
|
|
410
|
-
for (const child of parent.children) {
|
|
411
|
-
if (child.type !== "element") continue;
|
|
412
|
-
if (child.tag === "table:table-column") entries.push({
|
|
413
|
-
element: child,
|
|
414
|
-
insideHeader
|
|
415
|
-
});
|
|
416
|
-
else if (COLUMN_WRAPPER_TAGS.has(child.tag)) entries.push(...tableColumnEntries(child, insideHeader || child.tag === "table:table-header-columns"));
|
|
417
|
-
}
|
|
418
|
-
return entries;
|
|
419
|
-
}
|
|
420
|
-
function tableColumnElements(table) {
|
|
421
|
-
return tableColumnEntries(table).map((entry) => entry.element);
|
|
422
|
-
}
|
|
423
|
-
var OdtTableRow = class {
|
|
424
|
-
node;
|
|
425
|
-
pkg;
|
|
426
|
-
table;
|
|
427
|
-
constructor(node, pkg, table) {
|
|
428
|
-
this.node = node;
|
|
429
|
-
this.pkg = pkg;
|
|
430
|
-
this.table = table;
|
|
431
|
-
}
|
|
432
|
-
cells() {
|
|
433
|
-
const out = [];
|
|
434
|
-
for (const child of this.node.children) if (child.type === "element" && child.tag === "table:table-cell") out.push(new OdtTableCell(child, this.pkg));
|
|
435
|
-
return out;
|
|
436
|
-
}
|
|
437
|
-
get heightPt() {
|
|
438
|
-
const props = currentRowPropertiesElement(this.pkg, this.node);
|
|
439
|
-
const raw = props === void 0 ? void 0 : (0, ooxml_js.attr)(props, "style:row-height");
|
|
440
|
-
return raw === void 0 ? void 0 : (0, odf_js.parseOdfLength)(raw);
|
|
441
|
-
}
|
|
442
|
-
set heightPt(value) {
|
|
443
|
-
const props = cloneCurrentRowProperties(this.pkg, this.node);
|
|
444
|
-
if (value === void 0) require_xml_edit.removeAttr(props, "style:row-height");
|
|
445
|
-
else {
|
|
446
|
-
require_xml_edit.setAttr(props, "style:row-height", (0, odf_js.formatOdfLength)(value, "pt"));
|
|
447
|
-
if ((0, ooxml_js.attr)(props, "style:use-optimal-row-height") === "true") require_xml_edit.setAttr(props, "style:use-optimal-row-height", "false");
|
|
448
|
-
}
|
|
449
|
-
if (props.attributes.length === 0 && props.children.length === 0) {
|
|
450
|
-
require_xml_edit.removeAttr(this.node, "table:style-name");
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
require_xml_edit.setAttr(this.node, "table:style-name", internTableRowProperties(this.pkg, props));
|
|
454
|
-
}
|
|
455
|
-
appendCell() {
|
|
456
|
-
const cellElement = buildCell(this.pkg);
|
|
457
|
-
this.node.children.push(cellElement);
|
|
458
|
-
return new OdtTableCell(cellElement, this.pkg);
|
|
459
|
-
}
|
|
460
|
-
appendCoveredCell() {
|
|
461
|
-
const coveredElement = require_xml_fragment.el("table:covered-table-cell");
|
|
462
|
-
this.node.children.push(coveredElement);
|
|
463
|
-
return new OdtCoveredTableCell(coveredElement, this.pkg);
|
|
464
|
-
}
|
|
465
|
-
mergeCellsHorizontally(startColumnIndex, colSpan) {
|
|
466
|
-
if (!Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCellsHorizontally: colSpan must be a positive integer, got ${colSpan}`);
|
|
467
|
-
const target = {
|
|
468
|
-
row: tableRowElements(this.table).indexOf(this.node),
|
|
469
|
-
column: startColumnIndex,
|
|
470
|
-
rowSpan: 1,
|
|
471
|
-
columnSpan: colSpan
|
|
472
|
-
};
|
|
473
|
-
const plan = planMerge(this.table, this.pkg, target, [this.node]);
|
|
474
|
-
if (plan.refusal !== void 0) throw new Error(`mergeCellsHorizontally: ${plan.refusal.reason}`);
|
|
475
|
-
return applyMerge(plan, target, this.pkg);
|
|
476
|
-
}
|
|
477
|
-
markCellCovered(columnIndex) {
|
|
478
|
-
const totalColumns = rowGridColumnCount(this.node);
|
|
479
|
-
if (columnIndex < 0 || columnIndex >= totalColumns) throw new Error(`markCellCovered: column ${columnIndex} does not exist in this row`);
|
|
480
|
-
const rowIndex = tableRowElements(this.table).indexOf(this.node);
|
|
481
|
-
const anchored = anchorRegions(resolveOdtGrid(this.table, this.pkg)).find((region) => region.row === rowIndex && region.column === columnIndex && (region.rowSpan > 1 || region.columnSpan > 1));
|
|
482
|
-
if (anchored !== void 0) throw new Error(`markCellCovered: column ${columnIndex} anchors a merge with rowSpan ${anchored.rowSpan} and colSpan ${anchored.columnSpan}, so covering it would leave the rest of that merge without an anchor`);
|
|
483
|
-
retagAsCovered(individuateGridColumn(this.node, columnIndex));
|
|
484
|
-
}
|
|
485
|
-
};
|
|
486
|
-
function buildCell(pkg) {
|
|
487
|
-
return require_xml_fragment.el("table:table-cell", {}, [require_edit_odt_paragraph.buildParagraph(pkg)]);
|
|
488
|
-
}
|
|
489
|
-
function buildRow(pkg, columnCount) {
|
|
490
|
-
const cells = [];
|
|
491
|
-
for (let i = 0; i < columnCount; i++) cells.push(buildCell(pkg));
|
|
492
|
-
return require_xml_fragment.el("table:table-row", {}, cells);
|
|
493
|
-
}
|
|
494
|
-
var OdtTable = class {
|
|
495
|
-
container;
|
|
496
|
-
node;
|
|
497
|
-
pkg;
|
|
498
|
-
removed = false;
|
|
499
|
-
constructor(container, node, pkg) {
|
|
500
|
-
this.container = container;
|
|
501
|
-
this.node = node;
|
|
502
|
-
this.pkg = pkg;
|
|
503
|
-
}
|
|
504
|
-
live() {
|
|
505
|
-
if (this.removed) throw new Error("this OdtTable has been removed and can no longer be used");
|
|
506
|
-
return this.node;
|
|
507
|
-
}
|
|
508
|
-
rows() {
|
|
509
|
-
return tableRowElements(this.live()).map((row) => new OdtTableRow(row, this.pkg, this.node));
|
|
510
|
-
}
|
|
511
|
-
headerRows() {
|
|
512
|
-
return tableRowEntries(this.live()).map((entry) => entry.insideHeader);
|
|
513
|
-
}
|
|
514
|
-
setHeaderRows(flags) {
|
|
515
|
-
const table = this.live();
|
|
516
|
-
const rows = tableRowElements(table);
|
|
517
|
-
const regrouped = [];
|
|
518
|
-
let run = [];
|
|
519
|
-
const closeRun = () => {
|
|
520
|
-
if (run.length > 0) {
|
|
521
|
-
regrouped.push(require_xml_fragment.el("table:table-header-rows", {}, run));
|
|
522
|
-
run = [];
|
|
523
|
-
}
|
|
524
|
-
};
|
|
525
|
-
rows.forEach((row, index) => {
|
|
526
|
-
if (flags[index] === true) {
|
|
527
|
-
run.push(row);
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
closeRun();
|
|
531
|
-
regrouped.push(row);
|
|
532
|
-
});
|
|
533
|
-
closeRun();
|
|
534
|
-
const rest = [];
|
|
535
|
-
let placed = false;
|
|
536
|
-
for (const child of table.children) {
|
|
537
|
-
if (!(child.type === "element" && (child.tag === "table:table-row" || ROW_WRAPPER_TAGS.has(child.tag)))) {
|
|
538
|
-
rest.push(child);
|
|
539
|
-
continue;
|
|
540
|
-
}
|
|
541
|
-
if (!placed) {
|
|
542
|
-
rest.push(...regrouped);
|
|
543
|
-
placed = true;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
if (!placed) rest.push(...regrouped);
|
|
547
|
-
table.children = rest;
|
|
548
|
-
}
|
|
549
|
-
headerColumns() {
|
|
550
|
-
return tableColumnEntries(this.live()).map((entry) => entry.insideHeader);
|
|
551
|
-
}
|
|
552
|
-
setHeaderColumns(flags) {
|
|
553
|
-
const table = this.live();
|
|
554
|
-
const columns = tableColumnElements(table);
|
|
555
|
-
const regrouped = [];
|
|
556
|
-
let run = [];
|
|
557
|
-
const closeRun = () => {
|
|
558
|
-
if (run.length > 0) {
|
|
559
|
-
regrouped.push(require_xml_fragment.el("table:table-header-columns", {}, run));
|
|
560
|
-
run = [];
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
columns.forEach((column, index) => {
|
|
564
|
-
if (flags[index] === true) {
|
|
565
|
-
run.push(column);
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
closeRun();
|
|
569
|
-
regrouped.push(column);
|
|
570
|
-
});
|
|
571
|
-
closeRun();
|
|
572
|
-
const rest = [];
|
|
573
|
-
let placed = false;
|
|
574
|
-
for (const child of table.children) {
|
|
575
|
-
if (!(child.type === "element" && (child.tag === "table:table-column" || COLUMN_WRAPPER_TAGS.has(child.tag)))) {
|
|
576
|
-
rest.push(child);
|
|
577
|
-
continue;
|
|
578
|
-
}
|
|
579
|
-
if (!placed) {
|
|
580
|
-
rest.push(...regrouped);
|
|
581
|
-
placed = true;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
if (!placed) rest.push(...regrouped);
|
|
585
|
-
table.children = rest;
|
|
586
|
-
}
|
|
587
|
-
gridRows() {
|
|
588
|
-
return this.grid().rows;
|
|
589
|
-
}
|
|
590
|
-
gridColumnCount() {
|
|
591
|
-
return this.grid().columnCount;
|
|
592
|
-
}
|
|
593
|
-
grid() {
|
|
594
|
-
return resolveOdtGrid(this.live(), this.pkg);
|
|
595
|
-
}
|
|
596
|
-
cell(rowIndex, columnIndex) {
|
|
597
|
-
const row = this.rows()[rowIndex];
|
|
598
|
-
if (row === void 0) throw new Error(`row ${rowIndex} does not exist in this table`);
|
|
599
|
-
const cell = row.cells()[columnIndex];
|
|
600
|
-
if (cell === void 0) throw new Error(`column ${columnIndex} does not exist in row ${rowIndex}`);
|
|
601
|
-
return cell;
|
|
602
|
-
}
|
|
603
|
-
appendRow(columnCount) {
|
|
604
|
-
const node = this.live();
|
|
605
|
-
const row = buildRow(this.pkg, columnCount);
|
|
606
|
-
node.children.push(row);
|
|
607
|
-
return new OdtTableRow(row, this.pkg, node);
|
|
608
|
-
}
|
|
609
|
-
appendEmptyRow() {
|
|
610
|
-
const node = this.live();
|
|
611
|
-
const row = require_xml_fragment.el("table:table-row");
|
|
612
|
-
node.children.push(row);
|
|
613
|
-
return new OdtTableRow(row, this.pkg, node);
|
|
614
|
-
}
|
|
615
|
-
mergeCells(startRow, startColumn, rowSpan, colSpan) {
|
|
616
|
-
if (!Number.isInteger(rowSpan) || rowSpan < 1 || !Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCells: rowSpan and colSpan must be positive integers, got rowSpan=${rowSpan}, colSpan=${colSpan}`);
|
|
617
|
-
const rows = tableRowElements(this.live());
|
|
618
|
-
const anchorRow = rows[startRow];
|
|
619
|
-
if (anchorRow === void 0) throw new Error(`mergeCells: row ${startRow} does not exist in this table`);
|
|
620
|
-
if (startRow + rowSpan > rows.length) throw new Error(`mergeCells: rowSpan ${rowSpan} starting at row ${startRow} exceeds this table's own ${rows.length} rows`);
|
|
621
|
-
const target = {
|
|
622
|
-
row: startRow,
|
|
623
|
-
column: startColumn,
|
|
624
|
-
rowSpan,
|
|
625
|
-
columnSpan: colSpan
|
|
626
|
-
};
|
|
627
|
-
const plan = planMerge(this.live(), this.pkg, target, [anchorRow, ...rows.slice(startRow + 1, startRow + rowSpan)]);
|
|
628
|
-
if (plan.refusal !== void 0) throw new Error(`mergeCells: row ${plan.refusal.rowIndex}: ${plan.refusal.reason}`);
|
|
629
|
-
return applyMerge(plan, target, this.pkg);
|
|
630
|
-
}
|
|
631
|
-
remove() {
|
|
632
|
-
require_xml_edit.removeChild(this.container, this.live());
|
|
633
|
-
this.removed = true;
|
|
634
|
-
}
|
|
635
|
-
};
|
|
636
|
-
function buildTable(pkg, init) {
|
|
637
|
-
const defaultWidth = DEFAULT_TABLE_WIDTH_PT / init.columns;
|
|
638
|
-
const columns = [];
|
|
639
|
-
for (let i = 0; i < init.columns; i++) {
|
|
640
|
-
const widthPt = init.columnWidthsPt?.[i] ?? defaultWidth;
|
|
641
|
-
columns.push(require_xml_fragment.el("table:table-column", { "table:style-name": internTableColumnWidth(pkg, widthPt) }));
|
|
642
|
-
}
|
|
643
|
-
const rows = [];
|
|
644
|
-
for (let r = 0; r < init.rows; r++) rows.push(buildRow(pkg, init.columns));
|
|
645
|
-
return require_xml_fragment.el("table:table", {}, [...columns, ...rows]);
|
|
646
|
-
}
|
|
647
|
-
//#endregion
|
|
648
|
-
exports.OdtCoveredTableCell = OdtCoveredTableCell;
|
|
649
|
-
exports.OdtTable = OdtTable;
|
|
650
|
-
exports.OdtTableCell = OdtTableCell;
|
|
651
|
-
exports.OdtTableRow = OdtTableRow;
|
|
652
|
-
exports.buildCellStyle = buildCellStyle;
|
|
653
|
-
exports.buildTable = buildTable;
|
|
654
|
-
exports.readCellDecoration = readCellDecoration;
|
|
2
|
+
const require_table = require("../../table-DqUIOSPV.cjs");
|
|
3
|
+
exports.OdtCoveredTableCell = require_table.OdtCoveredTableCell;
|
|
4
|
+
exports.OdtTable = require_table.OdtTable;
|
|
5
|
+
exports.OdtTableCell = require_table.OdtTableCell;
|
|
6
|
+
exports.OdtTableRow = require_table.OdtTableRow;
|
|
7
|
+
exports.TABLE_ROW_STYLE_PREFIX = require_table.TABLE_ROW_STYLE_PREFIX;
|
|
8
|
+
exports.buildCellStyle = require_table.buildCellStyle;
|
|
9
|
+
exports.buildTable = require_table.buildTable;
|
|
10
|
+
exports.readCellDecoration = require_table.readCellDecoration;
|
|
11
|
+
exports.retagAsCovered = require_table.retagAsCovered;
|
|
12
|
+
exports.tableColumnElements = require_table.tableColumnElements;
|
|
13
|
+
exports.tableRowEntries = require_table.tableRowEntries;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as OdtTableRow, c as
|
|
2
|
-
export { CellDecoration, OdtCoveredTableCell, OdtTable, OdtTableCell, OdtTableRow, TableInit, buildCellStyle, buildTable, readCellDecoration };
|
|
1
|
+
import { a as OdtTableRow, c as buildCellStyle, d as retagAsCovered, f as tableColumnElements, i as OdtTableCell, l as buildTable, n as OdtCoveredTableCell, o as TABLE_ROW_STYLE_PREFIX, p as tableRowEntries, r as OdtTable, s as TableInit, t as CellDecoration, u as readCellDecoration } from "../../table-BK_Ao-Y6.cjs";
|
|
2
|
+
export { CellDecoration, OdtCoveredTableCell, OdtTable, OdtTableCell, OdtTableRow, TABLE_ROW_STYLE_PREFIX, TableInit, buildCellStyle, buildTable, readCellDecoration, retagAsCovered, tableColumnElements, tableRowEntries };
|
package/dist/edit/odt/table.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as OdtTableRow, c as
|
|
2
|
-
export { CellDecoration, OdtCoveredTableCell, OdtTable, OdtTableCell, OdtTableRow, TableInit, buildCellStyle, buildTable, readCellDecoration };
|
|
1
|
+
import { a as OdtTableRow, c as buildCellStyle, d as retagAsCovered, f as tableColumnElements, i as OdtTableCell, l as buildTable, n as OdtCoveredTableCell, o as TABLE_ROW_STYLE_PREFIX, p as tableRowEntries, r as OdtTable, s as TableInit, t as CellDecoration, u as readCellDecoration } from "../../table-CxY85YUj.js";
|
|
2
|
+
export { CellDecoration, OdtCoveredTableCell, OdtTable, OdtTableCell, OdtTableRow, TABLE_ROW_STYLE_PREFIX, TableInit, buildCellStyle, buildTable, readCellDecoration, retagAsCovered, tableColumnElements, tableRowEntries };
|