js.documents 7.20.36 → 8.0.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/doc/table.cjs +35 -24
- package/dist/edit/doc/table.d.cts +2 -5
- package/dist/edit/doc/table.d.ts +2 -5
- package/dist/edit/doc/table.js +35 -24
- package/dist/edit/docx/content.cjs +27 -28
- package/dist/edit/docx/content.js +28 -29
- package/dist/edit/docx/table.cjs +5 -0
- package/dist/edit/docx/table.d.cts +1 -0
- package/dist/edit/docx/table.d.ts +1 -0
- package/dist/edit/docx/table.js +5 -0
- package/dist/edit/odp/content.cjs +1 -1
- package/dist/edit/odp/content.js +1 -1
- package/dist/edit/odp/slide.d.cts +1 -1
- package/dist/edit/odp/slide.d.ts +1 -1
- package/dist/edit/odt/content.cjs +16 -29
- package/dist/edit/odt/content.d.cts +1 -1
- package/dist/edit/odt/content.d.ts +1 -1
- package/dist/edit/odt/content.js +17 -30
- package/dist/edit/odt/editor.d.cts +1 -1
- package/dist/edit/odt/editor.d.ts +1 -1
- package/dist/edit/odt/table.cjs +40 -13
- package/dist/edit/odt/table.d.cts +2 -2
- package/dist/edit/odt/table.d.ts +2 -2
- package/dist/edit/odt/table.js +40 -14
- package/dist/edit/pptx/content.cjs +17 -28
- package/dist/edit/pptx/content.js +18 -29
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/layout/engine.cjs +4 -9
- package/dist/layout/engine.js +5 -10
- package/dist/layout/reconstruct.cjs +12 -13
- package/dist/layout/reconstruct.js +12 -13
- package/dist/layout/shared.cjs +23 -15
- package/dist/layout/shared.d.cts +19 -3
- package/dist/layout/shared.d.ts +19 -3
- package/dist/layout/shared.js +24 -17
- package/dist/layout/slides.cjs +4 -9
- package/dist/layout/slides.js +5 -10
- package/dist/ooxml/docx/embedded-objects.cjs +17 -7
- package/dist/ooxml/docx/embedded-objects.js +17 -7
- package/dist/{table-COmzfIOe.d.cts → table-DvKlZmG0.d.cts} +11 -2
- package/dist/{table-BmMyqRML.d.ts → table-qWkzpadC.d.ts} +11 -2
- package/package.json +13 -13
package/dist/edit/doc/table.cjs
CHANGED
|
@@ -1,51 +1,40 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_edit_doc_paragraph = require("./paragraph.cjs");
|
|
3
|
+
let document_schema_js = require("document-schema.js");
|
|
3
4
|
//#region src/edit/doc/table.ts
|
|
4
5
|
const DEFAULT_TABLE_WIDTH_PT = 468;
|
|
5
6
|
var DocTableCell = class {
|
|
6
|
-
container;
|
|
7
7
|
node;
|
|
8
|
-
|
|
9
|
-
constructor(container, node) {
|
|
10
|
-
this.container = container;
|
|
8
|
+
constructor(node) {
|
|
11
9
|
this.node = node;
|
|
12
10
|
}
|
|
13
|
-
live() {
|
|
14
|
-
if (this.removed) throw new Error("this DocTableCell has been removed from its row and can no longer be used");
|
|
15
|
-
return this.node;
|
|
16
|
-
}
|
|
17
|
-
remove() {
|
|
18
|
-
const index = this.container.indexOf(this.node);
|
|
19
|
-
if (index !== -1) this.container.splice(index, 1);
|
|
20
|
-
this.removed = true;
|
|
21
|
-
}
|
|
22
11
|
paragraphs() {
|
|
23
|
-
return this.
|
|
12
|
+
return this.node.blocks.filter((block) => block.kind === "paragraph").map((block) => new require_edit_doc_paragraph.DocParagraph(this.node.blocks, block));
|
|
24
13
|
}
|
|
25
14
|
appendParagraph(init) {
|
|
26
15
|
const paragraph = require_edit_doc_paragraph.buildParagraph(init);
|
|
27
|
-
this.
|
|
28
|
-
return new require_edit_doc_paragraph.DocParagraph(this.
|
|
16
|
+
this.node.blocks.push(paragraph);
|
|
17
|
+
return new require_edit_doc_paragraph.DocParagraph(this.node.blocks, paragraph);
|
|
29
18
|
}
|
|
30
19
|
get text() {
|
|
31
20
|
return this.paragraphs().map((p) => p.text).join("\n");
|
|
32
21
|
}
|
|
33
22
|
set text(value) {
|
|
34
|
-
this.
|
|
23
|
+
this.node.blocks = [require_edit_doc_paragraph.buildParagraph({ text: value })];
|
|
35
24
|
}
|
|
36
25
|
get colSpan() {
|
|
37
|
-
return this.
|
|
26
|
+
return this.node.colSpan;
|
|
38
27
|
}
|
|
39
28
|
set colSpan(value) {
|
|
40
|
-
if (value === void 0) delete this.
|
|
41
|
-
else this.
|
|
29
|
+
if (value === void 0) delete this.node.colSpan;
|
|
30
|
+
else this.node.colSpan = value;
|
|
42
31
|
}
|
|
43
32
|
get rowSpan() {
|
|
44
|
-
return this.
|
|
33
|
+
return this.node.rowSpan;
|
|
45
34
|
}
|
|
46
35
|
set rowSpan(value) {
|
|
47
|
-
if (value === void 0) delete this.
|
|
48
|
-
else this.
|
|
36
|
+
if (value === void 0) delete this.node.rowSpan;
|
|
37
|
+
else this.node.rowSpan = value;
|
|
49
38
|
}
|
|
50
39
|
};
|
|
51
40
|
var DocTableRow = class {
|
|
@@ -54,7 +43,7 @@ var DocTableRow = class {
|
|
|
54
43
|
this.node = node;
|
|
55
44
|
}
|
|
56
45
|
cells() {
|
|
57
|
-
return this.node.cells.map((cell) => new DocTableCell(
|
|
46
|
+
return this.node.cells.map((cell) => new DocTableCell(cell));
|
|
58
47
|
}
|
|
59
48
|
};
|
|
60
49
|
function buildCell() {
|
|
@@ -86,6 +75,28 @@ var DocTable = class {
|
|
|
86
75
|
node.rows.push(row);
|
|
87
76
|
return new DocTableRow(row);
|
|
88
77
|
}
|
|
78
|
+
mergeCells(startRow, startColumn, rowSpan, colSpan) {
|
|
79
|
+
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}`);
|
|
80
|
+
const node = this.live();
|
|
81
|
+
const grid = (0, document_schema_js.walkTableGrid)(node);
|
|
82
|
+
const anchorPosition = grid[startRow]?.[startColumn];
|
|
83
|
+
if (anchorPosition === void 0) throw new Error(`mergeCells: row ${startRow}, column ${startColumn} does not exist in this table`);
|
|
84
|
+
if (startRow + rowSpan > grid.length) throw new Error(`mergeCells: rowSpan ${rowSpan} starting at row ${startRow} exceeds this table's own ${grid.length} rows`);
|
|
85
|
+
const columnCount = (0, document_schema_js.tableGridColumnCount)(node);
|
|
86
|
+
if (startColumn + colSpan > columnCount) throw new Error(`mergeCells: colSpan ${colSpan} starting at column ${startColumn} exceeds this table's own ${columnCount} columns`);
|
|
87
|
+
const covered = [];
|
|
88
|
+
for (let rowIndex = startRow; rowIndex < startRow + rowSpan; rowIndex++) for (let columnIndex = startColumn; columnIndex < startColumn + colSpan; columnIndex++) {
|
|
89
|
+
const position = grid[rowIndex]?.[columnIndex];
|
|
90
|
+
if (position === void 0) throw new Error(`mergeCells: column ${columnIndex} does not exist in row ${rowIndex}`);
|
|
91
|
+
if (position.anchorRowIndex !== void 0 || (0, document_schema_js.tableCellColumnSpan)(position.cell) !== 1 || (0, document_schema_js.tableCellRowSpan)(position.cell) !== 1) throw new Error(`mergeCells: row ${rowIndex}, column ${columnIndex} already belongs to a merged region`);
|
|
92
|
+
if (rowIndex !== startRow || columnIndex !== startColumn) covered.push(position.cell);
|
|
93
|
+
}
|
|
94
|
+
const anchorCell = new DocTableCell(anchorPosition.cell);
|
|
95
|
+
if (colSpan > 1) anchorCell.colSpan = colSpan;
|
|
96
|
+
if (rowSpan > 1) anchorCell.rowSpan = rowSpan;
|
|
97
|
+
for (const cell of covered) cell.blocks = [];
|
|
98
|
+
return anchorCell;
|
|
99
|
+
}
|
|
89
100
|
remove() {
|
|
90
101
|
const node = this.live();
|
|
91
102
|
const index = this.container.indexOf(node);
|
|
@@ -6,12 +6,8 @@ interface TableInit {
|
|
|
6
6
|
readonly columns: number;
|
|
7
7
|
}
|
|
8
8
|
declare class DocTableCell {
|
|
9
|
-
private readonly container;
|
|
10
9
|
private readonly node;
|
|
11
|
-
|
|
12
|
-
constructor(container: ContentTableCell[], node: ContentTableCell);
|
|
13
|
-
private live;
|
|
14
|
-
remove(): void;
|
|
10
|
+
constructor(node: ContentTableCell);
|
|
15
11
|
paragraphs(): DocParagraph[];
|
|
16
12
|
appendParagraph(init?: ParagraphInit): DocParagraph;
|
|
17
13
|
get text(): string;
|
|
@@ -34,6 +30,7 @@ declare class DocTable {
|
|
|
34
30
|
private live;
|
|
35
31
|
rows(): DocTableRow[];
|
|
36
32
|
appendRow(): DocTableRow;
|
|
33
|
+
mergeCells(startRow: number, startColumn: number, rowSpan: number, colSpan: number): DocTableCell;
|
|
37
34
|
remove(): void;
|
|
38
35
|
}
|
|
39
36
|
declare function buildTable(init: TableInit): ContentTable;
|
package/dist/edit/doc/table.d.ts
CHANGED
|
@@ -6,12 +6,8 @@ interface TableInit {
|
|
|
6
6
|
readonly columns: number;
|
|
7
7
|
}
|
|
8
8
|
declare class DocTableCell {
|
|
9
|
-
private readonly container;
|
|
10
9
|
private readonly node;
|
|
11
|
-
|
|
12
|
-
constructor(container: ContentTableCell[], node: ContentTableCell);
|
|
13
|
-
private live;
|
|
14
|
-
remove(): void;
|
|
10
|
+
constructor(node: ContentTableCell);
|
|
15
11
|
paragraphs(): DocParagraph[];
|
|
16
12
|
appendParagraph(init?: ParagraphInit): DocParagraph;
|
|
17
13
|
get text(): string;
|
|
@@ -34,6 +30,7 @@ declare class DocTable {
|
|
|
34
30
|
private live;
|
|
35
31
|
rows(): DocTableRow[];
|
|
36
32
|
appendRow(): DocTableRow;
|
|
33
|
+
mergeCells(startRow: number, startColumn: number, rowSpan: number, colSpan: number): DocTableCell;
|
|
37
34
|
remove(): void;
|
|
38
35
|
}
|
|
39
36
|
declare function buildTable(init: TableInit): ContentTable;
|
package/dist/edit/doc/table.js
CHANGED
|
@@ -1,50 +1,39 @@
|
|
|
1
1
|
import { DocParagraph, buildParagraph } from "./paragraph.js";
|
|
2
|
+
import { tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid } from "document-schema.js";
|
|
2
3
|
//#region src/edit/doc/table.ts
|
|
3
4
|
const DEFAULT_TABLE_WIDTH_PT = 468;
|
|
4
5
|
var DocTableCell = class {
|
|
5
|
-
container;
|
|
6
6
|
node;
|
|
7
|
-
|
|
8
|
-
constructor(container, node) {
|
|
9
|
-
this.container = container;
|
|
7
|
+
constructor(node) {
|
|
10
8
|
this.node = node;
|
|
11
9
|
}
|
|
12
|
-
live() {
|
|
13
|
-
if (this.removed) throw new Error("this DocTableCell has been removed from its row and can no longer be used");
|
|
14
|
-
return this.node;
|
|
15
|
-
}
|
|
16
|
-
remove() {
|
|
17
|
-
const index = this.container.indexOf(this.node);
|
|
18
|
-
if (index !== -1) this.container.splice(index, 1);
|
|
19
|
-
this.removed = true;
|
|
20
|
-
}
|
|
21
10
|
paragraphs() {
|
|
22
|
-
return this.
|
|
11
|
+
return this.node.blocks.filter((block) => block.kind === "paragraph").map((block) => new DocParagraph(this.node.blocks, block));
|
|
23
12
|
}
|
|
24
13
|
appendParagraph(init) {
|
|
25
14
|
const paragraph = buildParagraph(init);
|
|
26
|
-
this.
|
|
27
|
-
return new DocParagraph(this.
|
|
15
|
+
this.node.blocks.push(paragraph);
|
|
16
|
+
return new DocParagraph(this.node.blocks, paragraph);
|
|
28
17
|
}
|
|
29
18
|
get text() {
|
|
30
19
|
return this.paragraphs().map((p) => p.text).join("\n");
|
|
31
20
|
}
|
|
32
21
|
set text(value) {
|
|
33
|
-
this.
|
|
22
|
+
this.node.blocks = [buildParagraph({ text: value })];
|
|
34
23
|
}
|
|
35
24
|
get colSpan() {
|
|
36
|
-
return this.
|
|
25
|
+
return this.node.colSpan;
|
|
37
26
|
}
|
|
38
27
|
set colSpan(value) {
|
|
39
|
-
if (value === void 0) delete this.
|
|
40
|
-
else this.
|
|
28
|
+
if (value === void 0) delete this.node.colSpan;
|
|
29
|
+
else this.node.colSpan = value;
|
|
41
30
|
}
|
|
42
31
|
get rowSpan() {
|
|
43
|
-
return this.
|
|
32
|
+
return this.node.rowSpan;
|
|
44
33
|
}
|
|
45
34
|
set rowSpan(value) {
|
|
46
|
-
if (value === void 0) delete this.
|
|
47
|
-
else this.
|
|
35
|
+
if (value === void 0) delete this.node.rowSpan;
|
|
36
|
+
else this.node.rowSpan = value;
|
|
48
37
|
}
|
|
49
38
|
};
|
|
50
39
|
var DocTableRow = class {
|
|
@@ -53,7 +42,7 @@ var DocTableRow = class {
|
|
|
53
42
|
this.node = node;
|
|
54
43
|
}
|
|
55
44
|
cells() {
|
|
56
|
-
return this.node.cells.map((cell) => new DocTableCell(
|
|
45
|
+
return this.node.cells.map((cell) => new DocTableCell(cell));
|
|
57
46
|
}
|
|
58
47
|
};
|
|
59
48
|
function buildCell() {
|
|
@@ -85,6 +74,28 @@ var DocTable = class {
|
|
|
85
74
|
node.rows.push(row);
|
|
86
75
|
return new DocTableRow(row);
|
|
87
76
|
}
|
|
77
|
+
mergeCells(startRow, startColumn, rowSpan, colSpan) {
|
|
78
|
+
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}`);
|
|
79
|
+
const node = this.live();
|
|
80
|
+
const grid = walkTableGrid(node);
|
|
81
|
+
const anchorPosition = grid[startRow]?.[startColumn];
|
|
82
|
+
if (anchorPosition === void 0) throw new Error(`mergeCells: row ${startRow}, column ${startColumn} does not exist in this table`);
|
|
83
|
+
if (startRow + rowSpan > grid.length) throw new Error(`mergeCells: rowSpan ${rowSpan} starting at row ${startRow} exceeds this table's own ${grid.length} rows`);
|
|
84
|
+
const columnCount = tableGridColumnCount(node);
|
|
85
|
+
if (startColumn + colSpan > columnCount) throw new Error(`mergeCells: colSpan ${colSpan} starting at column ${startColumn} exceeds this table's own ${columnCount} columns`);
|
|
86
|
+
const covered = [];
|
|
87
|
+
for (let rowIndex = startRow; rowIndex < startRow + rowSpan; rowIndex++) for (let columnIndex = startColumn; columnIndex < startColumn + colSpan; columnIndex++) {
|
|
88
|
+
const position = grid[rowIndex]?.[columnIndex];
|
|
89
|
+
if (position === void 0) throw new Error(`mergeCells: column ${columnIndex} does not exist in row ${rowIndex}`);
|
|
90
|
+
if (position.anchorRowIndex !== void 0 || tableCellColumnSpan(position.cell) !== 1 || tableCellRowSpan(position.cell) !== 1) throw new Error(`mergeCells: row ${rowIndex}, column ${columnIndex} already belongs to a merged region`);
|
|
91
|
+
if (rowIndex !== startRow || columnIndex !== startColumn) covered.push(position.cell);
|
|
92
|
+
}
|
|
93
|
+
const anchorCell = new DocTableCell(anchorPosition.cell);
|
|
94
|
+
if (colSpan > 1) anchorCell.colSpan = colSpan;
|
|
95
|
+
if (rowSpan > 1) anchorCell.rowSpan = rowSpan;
|
|
96
|
+
for (const cell of covered) cell.blocks = [];
|
|
97
|
+
return anchorCell;
|
|
98
|
+
}
|
|
88
99
|
remove() {
|
|
89
100
|
const node = this.live();
|
|
90
101
|
const index = this.container.indexOf(node);
|
|
@@ -189,6 +189,24 @@ function populateCellBlocks(cell, blocks) {
|
|
|
189
189
|
else if (firstBlock !== void 0) appendCellBlock(cell, firstBlock);
|
|
190
190
|
for (const remaining of restBlocks) appendCellBlock(cell, remaining);
|
|
191
191
|
}
|
|
192
|
+
function docxRowCells(positions, positionsByRow) {
|
|
193
|
+
return positions.flatMap((position) => {
|
|
194
|
+
if (position.anchorRowIndex === void 0) return [{
|
|
195
|
+
cell: position.cell,
|
|
196
|
+
colSpan: (0, document_schema_js.tableCellColumnSpan)(position.cell),
|
|
197
|
+
verticalMerge: (0, document_schema_js.tableCellRowSpan)(position.cell) > 1 ? "restart" : void 0
|
|
198
|
+
}];
|
|
199
|
+
if (position.columnIndex === position.anchorColumnIndex) {
|
|
200
|
+
const anchor = positionsByRow[position.anchorRowIndex][position.anchorColumnIndex];
|
|
201
|
+
return [{
|
|
202
|
+
cell: position.cell,
|
|
203
|
+
colSpan: (0, document_schema_js.tableCellColumnSpan)(anchor.cell),
|
|
204
|
+
verticalMerge: "continue"
|
|
205
|
+
}];
|
|
206
|
+
}
|
|
207
|
+
return [];
|
|
208
|
+
});
|
|
209
|
+
}
|
|
192
210
|
function appendTable(body, block) {
|
|
193
211
|
const columns = block.columnWidthsPt.length;
|
|
194
212
|
if (block.rows.length === 0 || columns === 0) return;
|
|
@@ -197,39 +215,20 @@ function appendTable(body, block) {
|
|
|
197
215
|
columns,
|
|
198
216
|
columnWidthsTwips: block.columnWidthsPt.map(require_model_units.ptToTwips)
|
|
199
217
|
});
|
|
200
|
-
const
|
|
201
|
-
block.rows.forEach((row) => {
|
|
202
|
-
const
|
|
203
|
-
|
|
218
|
+
const positionsByRow = (0, document_schema_js.walkTableGrid)(block);
|
|
219
|
+
block.rows.forEach((row, rowIndex) => {
|
|
220
|
+
const rowCells = docxRowCells(positionsByRow[rowIndex], positionsByRow);
|
|
221
|
+
const tableRow = table.appendRow(rowCells.length);
|
|
222
|
+
tableRow.heightPt = row.heightPt;
|
|
204
223
|
const domCells = tableRow.cells();
|
|
205
|
-
|
|
206
|
-
row.cells.forEach((cell, cellIndex) => {
|
|
224
|
+
rowCells.forEach(({ cell, colSpan, verticalMerge }, cellIndex) => {
|
|
207
225
|
const tableCell = domCells[cellIndex];
|
|
208
226
|
if (tableCell === void 0) return;
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (active.gridSpan > 1) tableCell.colSpan = active.gridSpan;
|
|
212
|
-
tableCell.verticalMerge = "continue";
|
|
213
|
-
verticalMerges.set(colIndex, {
|
|
214
|
-
rowsRemaining: active.rowsRemaining - 1,
|
|
215
|
-
gridSpan: active.gridSpan
|
|
216
|
-
});
|
|
217
|
-
colIndex += active.gridSpan;
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
const span = cell.colSpan ?? 1;
|
|
221
|
-
if (span > 1) tableCell.colSpan = span;
|
|
222
|
-
if (cell.rowSpan !== void 0 && cell.rowSpan > 1) {
|
|
223
|
-
tableCell.verticalMerge = "restart";
|
|
224
|
-
verticalMerges.set(colIndex, {
|
|
225
|
-
rowsRemaining: cell.rowSpan - 1,
|
|
226
|
-
gridSpan: span
|
|
227
|
-
});
|
|
228
|
-
}
|
|
227
|
+
if (colSpan > 1) tableCell.colSpan = colSpan;
|
|
228
|
+
tableCell.verticalMerge = verticalMerge;
|
|
229
229
|
if (cell.background !== void 0) tableCell.background = (0, document_schema_js.resolveCellFillColor)(cell.background);
|
|
230
|
-
|
|
230
|
+
tableCell.borders = cell.borders;
|
|
231
231
|
populateCellBlocks(tableCell, cell.blocks);
|
|
232
|
-
colIndex += span;
|
|
233
232
|
});
|
|
234
233
|
});
|
|
235
234
|
}
|
|
@@ -10,7 +10,7 @@ import { FLOW_CONTAINER_ORIGIN, drawingOfBlock, embeddedDrawingVectors } from ".
|
|
|
10
10
|
import { formulaOfBlock, formulaPlaceholderText } from "../../model/formula.js";
|
|
11
11
|
import { NUMBERING_CONTENT_TYPE, NUMBERING_PART_PATH, NUMBERING_REL_TYPE, buildNumberingRoot, declaration } from "./numbering.js";
|
|
12
12
|
import { base64ToBytes } from "ooxml.js";
|
|
13
|
-
import { resolveCellFillColor } from "document-schema.js";
|
|
13
|
+
import { resolveCellFillColor, tableCellColumnSpan, tableCellRowSpan, walkTableGrid } from "document-schema.js";
|
|
14
14
|
//#region src/edit/docx/content.ts
|
|
15
15
|
var ConstructMarkerState = class {
|
|
16
16
|
nextBookmarkId = 1;
|
|
@@ -188,6 +188,24 @@ function populateCellBlocks(cell, blocks) {
|
|
|
188
188
|
else if (firstBlock !== void 0) appendCellBlock(cell, firstBlock);
|
|
189
189
|
for (const remaining of restBlocks) appendCellBlock(cell, remaining);
|
|
190
190
|
}
|
|
191
|
+
function docxRowCells(positions, positionsByRow) {
|
|
192
|
+
return positions.flatMap((position) => {
|
|
193
|
+
if (position.anchorRowIndex === void 0) return [{
|
|
194
|
+
cell: position.cell,
|
|
195
|
+
colSpan: tableCellColumnSpan(position.cell),
|
|
196
|
+
verticalMerge: tableCellRowSpan(position.cell) > 1 ? "restart" : void 0
|
|
197
|
+
}];
|
|
198
|
+
if (position.columnIndex === position.anchorColumnIndex) {
|
|
199
|
+
const anchor = positionsByRow[position.anchorRowIndex][position.anchorColumnIndex];
|
|
200
|
+
return [{
|
|
201
|
+
cell: position.cell,
|
|
202
|
+
colSpan: tableCellColumnSpan(anchor.cell),
|
|
203
|
+
verticalMerge: "continue"
|
|
204
|
+
}];
|
|
205
|
+
}
|
|
206
|
+
return [];
|
|
207
|
+
});
|
|
208
|
+
}
|
|
191
209
|
function appendTable(body, block) {
|
|
192
210
|
const columns = block.columnWidthsPt.length;
|
|
193
211
|
if (block.rows.length === 0 || columns === 0) return;
|
|
@@ -196,39 +214,20 @@ function appendTable(body, block) {
|
|
|
196
214
|
columns,
|
|
197
215
|
columnWidthsTwips: block.columnWidthsPt.map(ptToTwips)
|
|
198
216
|
});
|
|
199
|
-
const
|
|
200
|
-
block.rows.forEach((row) => {
|
|
201
|
-
const
|
|
202
|
-
|
|
217
|
+
const positionsByRow = walkTableGrid(block);
|
|
218
|
+
block.rows.forEach((row, rowIndex) => {
|
|
219
|
+
const rowCells = docxRowCells(positionsByRow[rowIndex], positionsByRow);
|
|
220
|
+
const tableRow = table.appendRow(rowCells.length);
|
|
221
|
+
tableRow.heightPt = row.heightPt;
|
|
203
222
|
const domCells = tableRow.cells();
|
|
204
|
-
|
|
205
|
-
row.cells.forEach((cell, cellIndex) => {
|
|
223
|
+
rowCells.forEach(({ cell, colSpan, verticalMerge }, cellIndex) => {
|
|
206
224
|
const tableCell = domCells[cellIndex];
|
|
207
225
|
if (tableCell === void 0) return;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (active.gridSpan > 1) tableCell.colSpan = active.gridSpan;
|
|
211
|
-
tableCell.verticalMerge = "continue";
|
|
212
|
-
verticalMerges.set(colIndex, {
|
|
213
|
-
rowsRemaining: active.rowsRemaining - 1,
|
|
214
|
-
gridSpan: active.gridSpan
|
|
215
|
-
});
|
|
216
|
-
colIndex += active.gridSpan;
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
const span = cell.colSpan ?? 1;
|
|
220
|
-
if (span > 1) tableCell.colSpan = span;
|
|
221
|
-
if (cell.rowSpan !== void 0 && cell.rowSpan > 1) {
|
|
222
|
-
tableCell.verticalMerge = "restart";
|
|
223
|
-
verticalMerges.set(colIndex, {
|
|
224
|
-
rowsRemaining: cell.rowSpan - 1,
|
|
225
|
-
gridSpan: span
|
|
226
|
-
});
|
|
227
|
-
}
|
|
226
|
+
if (colSpan > 1) tableCell.colSpan = colSpan;
|
|
227
|
+
tableCell.verticalMerge = verticalMerge;
|
|
228
228
|
if (cell.background !== void 0) tableCell.background = resolveCellFillColor(cell.background);
|
|
229
|
-
|
|
229
|
+
tableCell.borders = cell.borders;
|
|
230
230
|
populateCellBlocks(tableCell, cell.blocks);
|
|
231
|
-
colIndex += span;
|
|
232
231
|
});
|
|
233
232
|
});
|
|
234
233
|
}
|
package/dist/edit/docx/table.cjs
CHANGED
|
@@ -60,6 +60,10 @@ var DocxTableCell = class {
|
|
|
60
60
|
tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:gridSpan"));
|
|
61
61
|
require_xml_edit.insertInSchemaOrder(tcPr, require_xml_fragment.el("w:gridSpan", { "w:val": String(value) }), TC_PR_CHILD_ORDER);
|
|
62
62
|
}
|
|
63
|
+
clearBlockContent() {
|
|
64
|
+
const properties = this.node.children.filter((child) => child.type === "element" && child.tag === "w:tcPr");
|
|
65
|
+
this.node.children.splice(0, this.node.children.length, ...properties, require_edit_docx_paragraph.buildParagraph());
|
|
66
|
+
}
|
|
63
67
|
get verticalMerge() {
|
|
64
68
|
const tcPr = this.tcPrElement(false);
|
|
65
69
|
const vMerge = tcPr === void 0 ? void 0 : require_xml_edit.directChildElement(tcPr, "w:vMerge");
|
|
@@ -67,6 +71,7 @@ var DocxTableCell = class {
|
|
|
67
71
|
return (0, ooxml_js.attr)(vMerge, "w:val") === "restart" ? "restart" : "continue";
|
|
68
72
|
}
|
|
69
73
|
set verticalMerge(value) {
|
|
74
|
+
if (value === "continue") this.clearBlockContent();
|
|
70
75
|
if (value === void 0) {
|
|
71
76
|
const tcPr = this.tcPrElement(false);
|
|
72
77
|
if (tcPr !== void 0) tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:vMerge"));
|
|
@@ -14,6 +14,7 @@ declare class DocxTableCell {
|
|
|
14
14
|
private tcPrElement;
|
|
15
15
|
get colSpan(): number | undefined;
|
|
16
16
|
set colSpan(value: number | undefined);
|
|
17
|
+
private clearBlockContent;
|
|
17
18
|
get verticalMerge(): DocxVerticalMerge | undefined;
|
|
18
19
|
set verticalMerge(value: DocxVerticalMerge | undefined);
|
|
19
20
|
get background(): Color | undefined;
|
|
@@ -14,6 +14,7 @@ declare class DocxTableCell {
|
|
|
14
14
|
private tcPrElement;
|
|
15
15
|
get colSpan(): number | undefined;
|
|
16
16
|
set colSpan(value: number | undefined);
|
|
17
|
+
private clearBlockContent;
|
|
17
18
|
get verticalMerge(): DocxVerticalMerge | undefined;
|
|
18
19
|
set verticalMerge(value: DocxVerticalMerge | undefined);
|
|
19
20
|
get background(): Color | undefined;
|
package/dist/edit/docx/table.js
CHANGED
|
@@ -59,6 +59,10 @@ var DocxTableCell = class {
|
|
|
59
59
|
tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:gridSpan"));
|
|
60
60
|
insertInSchemaOrder(tcPr, el("w:gridSpan", { "w:val": String(value) }), TC_PR_CHILD_ORDER);
|
|
61
61
|
}
|
|
62
|
+
clearBlockContent() {
|
|
63
|
+
const properties = this.node.children.filter((child) => child.type === "element" && child.tag === "w:tcPr");
|
|
64
|
+
this.node.children.splice(0, this.node.children.length, ...properties, buildParagraph());
|
|
65
|
+
}
|
|
62
66
|
get verticalMerge() {
|
|
63
67
|
const tcPr = this.tcPrElement(false);
|
|
64
68
|
const vMerge = tcPr === void 0 ? void 0 : directChildElement(tcPr, "w:vMerge");
|
|
@@ -66,6 +70,7 @@ var DocxTableCell = class {
|
|
|
66
70
|
return attr(vMerge, "w:val") === "restart" ? "restart" : "continue";
|
|
67
71
|
}
|
|
68
72
|
set verticalMerge(value) {
|
|
73
|
+
if (value === "continue") this.clearBlockContent();
|
|
69
74
|
if (value === void 0) {
|
|
70
75
|
const tcPr = this.tcPrElement(false);
|
|
71
76
|
if (tcPr !== void 0) tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:vMerge"));
|
|
@@ -53,7 +53,7 @@ function appendShape(slide, shape) {
|
|
|
53
53
|
const { shape: tableFrame, table } = slide.addTable({
|
|
54
54
|
frame: shape.frame,
|
|
55
55
|
table: {
|
|
56
|
-
rows:
|
|
56
|
+
rows: 0,
|
|
57
57
|
columns: onlyBlock.columnWidthsPt.length,
|
|
58
58
|
columnWidthsPt: onlyBlock.columnWidthsPt
|
|
59
59
|
}
|
package/dist/edit/odp/content.js
CHANGED
|
@@ -52,7 +52,7 @@ function appendShape(slide, shape) {
|
|
|
52
52
|
const { shape: tableFrame, table } = slide.addTable({
|
|
53
53
|
frame: shape.frame,
|
|
54
54
|
table: {
|
|
55
|
-
rows:
|
|
55
|
+
rows: 0,
|
|
56
56
|
columns: onlyBlock.columnWidthsPt.length,
|
|
57
57
|
columnWidthsPt: onlyBlock.columnWidthsPt
|
|
58
58
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as ImageInit } from "../../image-D1z0T9Za.cjs";
|
|
2
2
|
import { t as OdpShape } from "../../shape-Kmmxib5z.cjs";
|
|
3
3
|
import { s as OdgVector } from "../../vector-DDP7hgvm.cjs";
|
|
4
|
-
import {
|
|
4
|
+
import { o as TableInit, r as OdtTable } from "../../table-DvKlZmG0.cjs";
|
|
5
5
|
import { Box, ContentFormula, ContentVector } from "document-schema.js";
|
|
6
6
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
7
7
|
//#region src/edit/odp/slide.d.ts
|
package/dist/edit/odp/slide.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as ImageInit } from "../../image-D1z0T9Za.js";
|
|
2
2
|
import { t as OdpShape } from "../../shape-ZAfNsCC5.js";
|
|
3
3
|
import { s as OdgVector } from "../../vector-DDP7hgvm.js";
|
|
4
|
-
import {
|
|
4
|
+
import { o as TableInit, r as OdtTable } from "../../table-qWkzpadC.js";
|
|
5
5
|
import { Box, ContentFormula, ContentVector } from "document-schema.js";
|
|
6
6
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
7
7
|
//#region src/edit/odp/slide.d.ts
|
|
@@ -132,43 +132,30 @@ function populateCellBlocks(cell, blocks) {
|
|
|
132
132
|
for (const remaining of restBlocks) appendCellBlock(cell, remaining);
|
|
133
133
|
}
|
|
134
134
|
function populateOdtTable(table, block) {
|
|
135
|
-
const
|
|
136
|
-
block.rows.forEach((row) => {
|
|
135
|
+
const gridPositions = (0, document_schema_js.walkTableGrid)(block);
|
|
136
|
+
block.rows.forEach((row, rowIndex) => {
|
|
137
137
|
const tableRow = table.appendEmptyRow();
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
tableRow.appendCoveredCell();
|
|
144
|
-
horizontalCoverRemaining -= 1;
|
|
145
|
-
colIndex += 1;
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const verticalRemaining = verticalMerges.get(colIndex);
|
|
149
|
-
if (verticalRemaining !== void 0 && verticalRemaining > 0) {
|
|
150
|
-
tableRow.appendCoveredCell();
|
|
151
|
-
verticalMerges.set(colIndex, verticalRemaining - 1);
|
|
152
|
-
colIndex += 1;
|
|
138
|
+
tableRow.heightPt = row.heightPt;
|
|
139
|
+
gridPositions[rowIndex].forEach((position) => {
|
|
140
|
+
const { cell } = position;
|
|
141
|
+
if (position.anchorRowIndex !== void 0) {
|
|
142
|
+
applyCellDecoration(tableRow.appendCoveredCell(), cell);
|
|
153
143
|
return;
|
|
154
144
|
}
|
|
155
145
|
const tableCell = tableRow.appendCell();
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (cell.rowSpan !== void 0 && cell.rowSpan > 1) {
|
|
162
|
-
tableCell.rowSpan = cell.rowSpan;
|
|
163
|
-
for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
|
|
164
|
-
}
|
|
165
|
-
if (cell.background !== void 0) tableCell.background = (0, document_schema_js.resolveCellFillColor)(cell.background);
|
|
166
|
-
if (cell.borders !== void 0) tableCell.borders = cell.borders;
|
|
146
|
+
const colSpan = (0, document_schema_js.tableCellColumnSpan)(cell);
|
|
147
|
+
if (colSpan > 1) tableCell.colSpan = colSpan;
|
|
148
|
+
const rowSpan = (0, document_schema_js.tableCellRowSpan)(cell);
|
|
149
|
+
if (rowSpan > 1) tableCell.rowSpan = rowSpan;
|
|
150
|
+
applyCellDecoration(tableCell, cell);
|
|
167
151
|
populateCellBlocks(tableCell, cell.blocks);
|
|
168
|
-
colIndex += 1;
|
|
169
152
|
});
|
|
170
153
|
});
|
|
171
154
|
}
|
|
155
|
+
function applyCellDecoration(target, cell) {
|
|
156
|
+
if (cell.background !== void 0) target.background = (0, document_schema_js.resolveCellFillColor)(cell.background);
|
|
157
|
+
if (cell.borders !== void 0) target.borders = cell.borders;
|
|
158
|
+
}
|
|
172
159
|
function appendTable(body, block) {
|
|
173
160
|
const columns = block.columnWidthsPt.length;
|
|
174
161
|
if (block.rows.length === 0 || columns === 0) return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as ClockPort } from "../../clock-C7SUuYN0.cjs";
|
|
2
2
|
import { t as OdtParagraph } from "../../paragraph-CRaLSzWz.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { r as OdtTable } from "../../table-DvKlZmG0.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 { t as ClockPort } from "../../clock-C7SUuYN0.js";
|
|
2
2
|
import { t as OdtParagraph } from "../../paragraph-D4f705GG.js";
|
|
3
|
-
import {
|
|
3
|
+
import { r as OdtTable } from "../../table-qWkzpadC.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
|
@@ -5,7 +5,7 @@ import { formulaOfBlock, formulaPlaceholderText } from "../../model/formula.js";
|
|
|
5
5
|
import { headingStyleName } from "./paragraph.js";
|
|
6
6
|
import { createEmptyOdtPackage } from "./scaffold.js";
|
|
7
7
|
import { OdtEditor } from "./editor.js";
|
|
8
|
-
import { resolveCellFillColor } from "document-schema.js";
|
|
8
|
+
import { resolveCellFillColor, tableCellColumnSpan, tableCellRowSpan, walkTableGrid } from "document-schema.js";
|
|
9
9
|
import { base64ToBytes } from "odf.js";
|
|
10
10
|
//#region src/edit/odt/content.ts
|
|
11
11
|
function buildOdtPackage(content, options) {
|
|
@@ -131,43 +131,30 @@ function populateCellBlocks(cell, blocks) {
|
|
|
131
131
|
for (const remaining of restBlocks) appendCellBlock(cell, remaining);
|
|
132
132
|
}
|
|
133
133
|
function populateOdtTable(table, block) {
|
|
134
|
-
const
|
|
135
|
-
block.rows.forEach((row) => {
|
|
134
|
+
const gridPositions = walkTableGrid(block);
|
|
135
|
+
block.rows.forEach((row, rowIndex) => {
|
|
136
136
|
const tableRow = table.appendEmptyRow();
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
tableRow.appendCoveredCell();
|
|
143
|
-
horizontalCoverRemaining -= 1;
|
|
144
|
-
colIndex += 1;
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const verticalRemaining = verticalMerges.get(colIndex);
|
|
148
|
-
if (verticalRemaining !== void 0 && verticalRemaining > 0) {
|
|
149
|
-
tableRow.appendCoveredCell();
|
|
150
|
-
verticalMerges.set(colIndex, verticalRemaining - 1);
|
|
151
|
-
colIndex += 1;
|
|
137
|
+
tableRow.heightPt = row.heightPt;
|
|
138
|
+
gridPositions[rowIndex].forEach((position) => {
|
|
139
|
+
const { cell } = position;
|
|
140
|
+
if (position.anchorRowIndex !== void 0) {
|
|
141
|
+
applyCellDecoration(tableRow.appendCoveredCell(), cell);
|
|
152
142
|
return;
|
|
153
143
|
}
|
|
154
144
|
const tableCell = tableRow.appendCell();
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (cell.rowSpan !== void 0 && cell.rowSpan > 1) {
|
|
161
|
-
tableCell.rowSpan = cell.rowSpan;
|
|
162
|
-
for (let c = 0; c < span; c++) verticalMerges.set(colIndex + c, cell.rowSpan - 1);
|
|
163
|
-
}
|
|
164
|
-
if (cell.background !== void 0) tableCell.background = resolveCellFillColor(cell.background);
|
|
165
|
-
if (cell.borders !== void 0) tableCell.borders = cell.borders;
|
|
145
|
+
const colSpan = tableCellColumnSpan(cell);
|
|
146
|
+
if (colSpan > 1) tableCell.colSpan = colSpan;
|
|
147
|
+
const rowSpan = tableCellRowSpan(cell);
|
|
148
|
+
if (rowSpan > 1) tableCell.rowSpan = rowSpan;
|
|
149
|
+
applyCellDecoration(tableCell, cell);
|
|
166
150
|
populateCellBlocks(tableCell, cell.blocks);
|
|
167
|
-
colIndex += 1;
|
|
168
151
|
});
|
|
169
152
|
});
|
|
170
153
|
}
|
|
154
|
+
function applyCellDecoration(target, cell) {
|
|
155
|
+
if (cell.background !== void 0) target.background = resolveCellFillColor(cell.background);
|
|
156
|
+
if (cell.borders !== void 0) target.borders = cell.borders;
|
|
157
|
+
}
|
|
171
158
|
function appendTable(body, block) {
|
|
172
159
|
const columns = block.columnWidthsPt.length;
|
|
173
160
|
if (block.rows.length === 0 || columns === 0) return;
|