js.documents 1.72.0 → 1.74.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/table.cjs +32 -0
- package/dist/edit/docx/table.d.cts +2 -0
- package/dist/edit/docx/table.d.ts +2 -0
- package/dist/edit/docx/table.js +32 -0
- package/dist/edit/odp/slide.d.cts +1 -1
- package/dist/edit/odp/slide.d.ts +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.d.cts +1 -1
- package/dist/edit/odt/editor.d.ts +1 -1
- package/dist/edit/odt/table.cjs +47 -0
- package/dist/edit/odt/table.d.cts +1 -1
- package/dist/edit/odt/table.d.ts +1 -1
- package/dist/edit/odt/table.js +47 -0
- package/dist/edit/pdf/editor.cjs +63 -0
- package/dist/edit/pdf/editor.d.cts +26 -0
- package/dist/edit/pdf/editor.d.ts +26 -0
- package/dist/edit/pdf/editor.js +60 -0
- package/dist/edit/pdf/item.cjs +483 -0
- package/dist/edit/pdf/item.d.cts +2 -0
- package/dist/edit/pdf/item.d.ts +2 -0
- package/dist/edit/pdf/item.js +468 -0
- package/dist/edit/pdf/page.cjs +178 -0
- package/dist/edit/pdf/page.d.cts +49 -0
- package/dist/edit/pdf/page.d.ts +49 -0
- package/dist/edit/pdf/page.js +176 -0
- package/dist/edit/pdf/util.cjs +38 -0
- package/dist/edit/pdf/util.d.cts +6 -0
- package/dist/edit/pdf/util.d.ts +6 -0
- package/dist/edit/pdf/util.js +36 -0
- package/dist/index.cjs +14 -0
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +4 -1
- package/dist/item-CNEgqooo.d.ts +227 -0
- package/dist/item-DhYRoAvM.d.cts +227 -0
- package/dist/{table-kvclAXS5.d.ts → table-AT4t4VUy.d.ts} +4 -0
- package/dist/{table-sEo1Jf8c.d.cts → table-DSFcqJ7C.d.cts} +4 -0
- package/package.json +1 -1
package/dist/edit/docx/table.cjs
CHANGED
|
@@ -74,6 +74,21 @@ var DocxTableRow = class {
|
|
|
74
74
|
for (const child of this.node.children) if (child.type === "element" && child.tag === "w:tc") out.push(new DocxTableCell(child));
|
|
75
75
|
return out;
|
|
76
76
|
}
|
|
77
|
+
mergeCellsHorizontally(startColumnIndex, colSpan) {
|
|
78
|
+
if (!Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCellsHorizontally: colSpan must be a positive integer, got ${colSpan}`);
|
|
79
|
+
const cellElements = [];
|
|
80
|
+
for (const child of this.node.children) if (child.type === "element" && child.tag === "w:tc") cellElements.push(child);
|
|
81
|
+
const anchorElement = cellElements[startColumnIndex];
|
|
82
|
+
if (anchorElement === void 0) throw new Error(`mergeCellsHorizontally: column ${startColumnIndex} does not exist in this row`);
|
|
83
|
+
if (startColumnIndex + colSpan > cellElements.length) throw new Error(`mergeCellsHorizontally: colSpan ${colSpan} starting at column ${startColumnIndex} exceeds this row's own ${cellElements.length} columns`);
|
|
84
|
+
for (let i = 1; i < colSpan; i++) {
|
|
85
|
+
const consumedElement = cellElements[startColumnIndex + i];
|
|
86
|
+
if (consumedElement !== void 0) require_xml_edit.removeChild(this.node.children, consumedElement);
|
|
87
|
+
}
|
|
88
|
+
const anchor = new DocxTableCell(anchorElement);
|
|
89
|
+
anchor.colSpan = colSpan;
|
|
90
|
+
return anchor;
|
|
91
|
+
}
|
|
77
92
|
};
|
|
78
93
|
function buildCell() {
|
|
79
94
|
return require_xml_fragment.el("w:tc", {}, [require_edit_docx_paragraph.buildParagraph()]);
|
|
@@ -110,6 +125,23 @@ var DocxTable = class {
|
|
|
110
125
|
node.children.push(row);
|
|
111
126
|
return new DocxTableRow(row);
|
|
112
127
|
}
|
|
128
|
+
mergeCells(startRow, startColumn, rowSpan, colSpan) {
|
|
129
|
+
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}`);
|
|
130
|
+
const rows = this.rows();
|
|
131
|
+
const anchorRow = rows[startRow];
|
|
132
|
+
if (anchorRow === void 0) throw new Error(`mergeCells: row ${startRow} does not exist in this table`);
|
|
133
|
+
const anchor = anchorRow.mergeCellsHorizontally(startColumn, colSpan);
|
|
134
|
+
if (rowSpan > 1) {
|
|
135
|
+
anchor.verticalMerge = "restart";
|
|
136
|
+
for (let r = 1; r < rowSpan; r++) {
|
|
137
|
+
const coveredRow = rows[startRow + r];
|
|
138
|
+
if (coveredRow === void 0) throw new Error(`mergeCells: rowSpan ${rowSpan} starting at row ${startRow} exceeds this table's own ${rows.length} rows`);
|
|
139
|
+
const coveredAnchor = coveredRow.mergeCellsHorizontally(startColumn, colSpan);
|
|
140
|
+
coveredAnchor.verticalMerge = "continue";
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return anchor;
|
|
144
|
+
}
|
|
113
145
|
remove() {
|
|
114
146
|
require_xml_edit.removeChild(this.container, this.live());
|
|
115
147
|
this.removed = true;
|
|
@@ -23,6 +23,7 @@ declare class DocxTableRow {
|
|
|
23
23
|
private readonly node;
|
|
24
24
|
constructor(node: XmlElement);
|
|
25
25
|
cells(): DocxTableCell[];
|
|
26
|
+
mergeCellsHorizontally(startColumnIndex: number, colSpan: number): DocxTableCell;
|
|
26
27
|
}
|
|
27
28
|
declare class DocxTable {
|
|
28
29
|
private readonly container;
|
|
@@ -33,6 +34,7 @@ declare class DocxTable {
|
|
|
33
34
|
rows(): DocxTableRow[];
|
|
34
35
|
cell(rowIndex: number, columnIndex: number): DocxTableCell;
|
|
35
36
|
appendRow(columnCount: number): DocxTableRow;
|
|
37
|
+
mergeCells(startRow: number, startColumn: number, rowSpan: number, colSpan: number): DocxTableCell;
|
|
36
38
|
remove(): void;
|
|
37
39
|
}
|
|
38
40
|
declare function buildTable(init: TableInit): XmlElement;
|
|
@@ -23,6 +23,7 @@ declare class DocxTableRow {
|
|
|
23
23
|
private readonly node;
|
|
24
24
|
constructor(node: XmlElement);
|
|
25
25
|
cells(): DocxTableCell[];
|
|
26
|
+
mergeCellsHorizontally(startColumnIndex: number, colSpan: number): DocxTableCell;
|
|
26
27
|
}
|
|
27
28
|
declare class DocxTable {
|
|
28
29
|
private readonly container;
|
|
@@ -33,6 +34,7 @@ declare class DocxTable {
|
|
|
33
34
|
rows(): DocxTableRow[];
|
|
34
35
|
cell(rowIndex: number, columnIndex: number): DocxTableCell;
|
|
35
36
|
appendRow(columnCount: number): DocxTableRow;
|
|
37
|
+
mergeCells(startRow: number, startColumn: number, rowSpan: number, colSpan: number): DocxTableCell;
|
|
36
38
|
remove(): void;
|
|
37
39
|
}
|
|
38
40
|
declare function buildTable(init: TableInit): XmlElement;
|
package/dist/edit/docx/table.js
CHANGED
|
@@ -73,6 +73,21 @@ var DocxTableRow = class {
|
|
|
73
73
|
for (const child of this.node.children) if (child.type === "element" && child.tag === "w:tc") out.push(new DocxTableCell(child));
|
|
74
74
|
return out;
|
|
75
75
|
}
|
|
76
|
+
mergeCellsHorizontally(startColumnIndex, colSpan) {
|
|
77
|
+
if (!Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCellsHorizontally: colSpan must be a positive integer, got ${colSpan}`);
|
|
78
|
+
const cellElements = [];
|
|
79
|
+
for (const child of this.node.children) if (child.type === "element" && child.tag === "w:tc") cellElements.push(child);
|
|
80
|
+
const anchorElement = cellElements[startColumnIndex];
|
|
81
|
+
if (anchorElement === void 0) throw new Error(`mergeCellsHorizontally: column ${startColumnIndex} does not exist in this row`);
|
|
82
|
+
if (startColumnIndex + colSpan > cellElements.length) throw new Error(`mergeCellsHorizontally: colSpan ${colSpan} starting at column ${startColumnIndex} exceeds this row's own ${cellElements.length} columns`);
|
|
83
|
+
for (let i = 1; i < colSpan; i++) {
|
|
84
|
+
const consumedElement = cellElements[startColumnIndex + i];
|
|
85
|
+
if (consumedElement !== void 0) removeChild(this.node.children, consumedElement);
|
|
86
|
+
}
|
|
87
|
+
const anchor = new DocxTableCell(anchorElement);
|
|
88
|
+
anchor.colSpan = colSpan;
|
|
89
|
+
return anchor;
|
|
90
|
+
}
|
|
76
91
|
};
|
|
77
92
|
function buildCell() {
|
|
78
93
|
return el("w:tc", {}, [buildParagraph()]);
|
|
@@ -109,6 +124,23 @@ var DocxTable = class {
|
|
|
109
124
|
node.children.push(row);
|
|
110
125
|
return new DocxTableRow(row);
|
|
111
126
|
}
|
|
127
|
+
mergeCells(startRow, startColumn, rowSpan, colSpan) {
|
|
128
|
+
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}`);
|
|
129
|
+
const rows = this.rows();
|
|
130
|
+
const anchorRow = rows[startRow];
|
|
131
|
+
if (anchorRow === void 0) throw new Error(`mergeCells: row ${startRow} does not exist in this table`);
|
|
132
|
+
const anchor = anchorRow.mergeCellsHorizontally(startColumn, colSpan);
|
|
133
|
+
if (rowSpan > 1) {
|
|
134
|
+
anchor.verticalMerge = "restart";
|
|
135
|
+
for (let r = 1; r < rowSpan; r++) {
|
|
136
|
+
const coveredRow = rows[startRow + r];
|
|
137
|
+
if (coveredRow === void 0) throw new Error(`mergeCells: rowSpan ${rowSpan} starting at row ${startRow} exceeds this table's own ${rows.length} rows`);
|
|
138
|
+
const coveredAnchor = coveredRow.mergeCellsHorizontally(startColumn, colSpan);
|
|
139
|
+
coveredAnchor.verticalMerge = "continue";
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return anchor;
|
|
143
|
+
}
|
|
112
144
|
remove() {
|
|
113
145
|
removeChild(this.container, this.live());
|
|
114
146
|
this.removed = true;
|
|
@@ -2,7 +2,7 @@ import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
|
|
|
2
2
|
import { t as ImageInit } from "../../image-M5SezZVI.cjs";
|
|
3
3
|
import { t as OdpShape } from "../../shape-BR8GL8XC.cjs";
|
|
4
4
|
import { s as OdgVector } from "../../vector-D03KX8Ux.cjs";
|
|
5
|
-
import { i as TableInit, t as OdtTable } from "../../table-
|
|
5
|
+
import { i as TableInit, t as OdtTable } from "../../table-DSFcqJ7C.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
|
@@ -2,7 +2,7 @@ import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
|
|
|
2
2
|
import { t as ImageInit } from "../../image-DHcA9kaK.js";
|
|
3
3
|
import { t as OdpShape } from "../../shape-DeP-P4Nh.js";
|
|
4
4
|
import { s as OdgVector } from "../../vector-D03KX8Ux.js";
|
|
5
|
-
import { i as TableInit, t as OdtTable } from "../../table-
|
|
5
|
+
import { i as TableInit, t as OdtTable } from "../../table-AT4t4VUy.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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClockPort } from "../../ports/clock.cjs";
|
|
2
2
|
import { t as OdtParagraph } from "../../paragraph-Dlly6_E9.cjs";
|
|
3
|
-
import { t as OdtTable } from "../../table-
|
|
3
|
+
import { t as OdtTable } from "../../table-DSFcqJ7C.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
2
|
import { t as OdtParagraph } from "../../paragraph-kMJVZhAi.js";
|
|
3
|
-
import { t as OdtTable } from "../../table-
|
|
3
|
+
import { t as OdtTable } from "../../table-AT4t4VUy.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
|
|
@@ -2,7 +2,7 @@ import { ClockPort } from "../../ports/clock.cjs";
|
|
|
2
2
|
import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
|
|
3
3
|
import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-Dlly6_E9.cjs";
|
|
4
4
|
import { t as OdtList } from "../../list-DXRaCcT1.cjs";
|
|
5
|
-
import { i as TableInit, t as OdtTable } from "../../table-
|
|
5
|
+
import { i as TableInit, t as OdtTable } from "../../table-DSFcqJ7C.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
|
|
@@ -2,7 +2,7 @@ import { ClockPort } from "../../ports/clock.js";
|
|
|
2
2
|
import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
|
|
3
3
|
import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-kMJVZhAi.js";
|
|
4
4
|
import { t as OdtList } from "../../list-7hZydHAV.js";
|
|
5
|
-
import { i as TableInit, t as OdtTable } from "../../table-
|
|
5
|
+
import { i as TableInit, t as OdtTable } from "../../table-AT4t4VUy.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/table.cjs
CHANGED
|
@@ -89,6 +89,37 @@ var OdtTableRow = class {
|
|
|
89
89
|
appendCoveredCell() {
|
|
90
90
|
this.node.children.push(require_xml_fragment.el("table:covered-table-cell"));
|
|
91
91
|
}
|
|
92
|
+
gridCells() {
|
|
93
|
+
const out = [];
|
|
94
|
+
for (const child of this.node.children) if (child.type === "element" && (child.tag === "table:table-cell" || child.tag === "table:covered-table-cell")) out.push(child);
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
mergeCellsHorizontally(startColumnIndex, colSpan) {
|
|
98
|
+
if (!Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCellsHorizontally: colSpan must be a positive integer, got ${colSpan}`);
|
|
99
|
+
const gridCells = this.gridCells();
|
|
100
|
+
const anchorElement = gridCells[startColumnIndex];
|
|
101
|
+
if (anchorElement === void 0) throw new Error(`mergeCellsHorizontally: column ${startColumnIndex} does not exist in this row`);
|
|
102
|
+
if (anchorElement.tag === "table:covered-table-cell") throw new Error(`mergeCellsHorizontally: column ${startColumnIndex} is already covered by another merge -- address that merge's own anchor cell instead`);
|
|
103
|
+
if (startColumnIndex + colSpan > gridCells.length) throw new Error(`mergeCellsHorizontally: colSpan ${colSpan} starting at column ${startColumnIndex} exceeds this row's own ${gridCells.length} grid columns`);
|
|
104
|
+
for (let i = 1; i < colSpan; i++) {
|
|
105
|
+
const consumedElement = gridCells[startColumnIndex + i];
|
|
106
|
+
if (consumedElement !== void 0) {
|
|
107
|
+
consumedElement.tag = "table:covered-table-cell";
|
|
108
|
+
consumedElement.attributes = [];
|
|
109
|
+
consumedElement.children = [];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const anchor = new OdtTableCell(anchorElement, this.pkg);
|
|
113
|
+
anchor.colSpan = colSpan;
|
|
114
|
+
return anchor;
|
|
115
|
+
}
|
|
116
|
+
markCellCovered(columnIndex) {
|
|
117
|
+
const element = this.gridCells()[columnIndex];
|
|
118
|
+
if (element === void 0) throw new Error(`markCellCovered: column ${columnIndex} does not exist in this row`);
|
|
119
|
+
element.tag = "table:covered-table-cell";
|
|
120
|
+
element.attributes = [];
|
|
121
|
+
element.children = [];
|
|
122
|
+
}
|
|
92
123
|
};
|
|
93
124
|
function buildCell(pkg) {
|
|
94
125
|
return require_xml_fragment.el("table:table-cell", {}, [require_edit_odt_paragraph.buildParagraph(pkg)]);
|
|
@@ -136,6 +167,22 @@ var OdtTable = class {
|
|
|
136
167
|
node.children.push(row);
|
|
137
168
|
return new OdtTableRow(row, this.pkg);
|
|
138
169
|
}
|
|
170
|
+
mergeCells(startRow, startColumn, rowSpan, colSpan) {
|
|
171
|
+
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}`);
|
|
172
|
+
const rows = this.rows();
|
|
173
|
+
const anchorRow = rows[startRow];
|
|
174
|
+
if (anchorRow === void 0) throw new Error(`mergeCells: row ${startRow} does not exist in this table`);
|
|
175
|
+
const anchor = anchorRow.mergeCellsHorizontally(startColumn, colSpan);
|
|
176
|
+
if (rowSpan > 1) {
|
|
177
|
+
anchor.rowSpan = rowSpan;
|
|
178
|
+
for (let r = 1; r < rowSpan; r++) {
|
|
179
|
+
const coveredRow = rows[startRow + r];
|
|
180
|
+
if (coveredRow === void 0) throw new Error(`mergeCells: rowSpan ${rowSpan} starting at row ${startRow} exceeds this table's own ${rows.length} rows`);
|
|
181
|
+
for (let c = 0; c < colSpan; c++) coveredRow.markCellCovered(startColumn + c);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return anchor;
|
|
185
|
+
}
|
|
139
186
|
remove() {
|
|
140
187
|
require_xml_edit.removeChild(this.container, this.live());
|
|
141
188
|
this.removed = true;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as buildTable, i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "../../table-
|
|
1
|
+
import { a as buildTable, i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "../../table-DSFcqJ7C.cjs";
|
|
2
2
|
export { OdtTable, OdtTableCell, OdtTableRow, TableInit, buildTable };
|
package/dist/edit/odt/table.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as buildTable, i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "../../table-
|
|
1
|
+
import { a as buildTable, i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "../../table-AT4t4VUy.js";
|
|
2
2
|
export { OdtTable, OdtTableCell, OdtTableRow, TableInit, buildTable };
|
package/dist/edit/odt/table.js
CHANGED
|
@@ -88,6 +88,37 @@ var OdtTableRow = class {
|
|
|
88
88
|
appendCoveredCell() {
|
|
89
89
|
this.node.children.push(el("table:covered-table-cell"));
|
|
90
90
|
}
|
|
91
|
+
gridCells() {
|
|
92
|
+
const out = [];
|
|
93
|
+
for (const child of this.node.children) if (child.type === "element" && (child.tag === "table:table-cell" || child.tag === "table:covered-table-cell")) out.push(child);
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
mergeCellsHorizontally(startColumnIndex, colSpan) {
|
|
97
|
+
if (!Number.isInteger(colSpan) || colSpan < 1) throw new Error(`mergeCellsHorizontally: colSpan must be a positive integer, got ${colSpan}`);
|
|
98
|
+
const gridCells = this.gridCells();
|
|
99
|
+
const anchorElement = gridCells[startColumnIndex];
|
|
100
|
+
if (anchorElement === void 0) throw new Error(`mergeCellsHorizontally: column ${startColumnIndex} does not exist in this row`);
|
|
101
|
+
if (anchorElement.tag === "table:covered-table-cell") throw new Error(`mergeCellsHorizontally: column ${startColumnIndex} is already covered by another merge -- address that merge's own anchor cell instead`);
|
|
102
|
+
if (startColumnIndex + colSpan > gridCells.length) throw new Error(`mergeCellsHorizontally: colSpan ${colSpan} starting at column ${startColumnIndex} exceeds this row's own ${gridCells.length} grid columns`);
|
|
103
|
+
for (let i = 1; i < colSpan; i++) {
|
|
104
|
+
const consumedElement = gridCells[startColumnIndex + i];
|
|
105
|
+
if (consumedElement !== void 0) {
|
|
106
|
+
consumedElement.tag = "table:covered-table-cell";
|
|
107
|
+
consumedElement.attributes = [];
|
|
108
|
+
consumedElement.children = [];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const anchor = new OdtTableCell(anchorElement, this.pkg);
|
|
112
|
+
anchor.colSpan = colSpan;
|
|
113
|
+
return anchor;
|
|
114
|
+
}
|
|
115
|
+
markCellCovered(columnIndex) {
|
|
116
|
+
const element = this.gridCells()[columnIndex];
|
|
117
|
+
if (element === void 0) throw new Error(`markCellCovered: column ${columnIndex} does not exist in this row`);
|
|
118
|
+
element.tag = "table:covered-table-cell";
|
|
119
|
+
element.attributes = [];
|
|
120
|
+
element.children = [];
|
|
121
|
+
}
|
|
91
122
|
};
|
|
92
123
|
function buildCell(pkg) {
|
|
93
124
|
return el("table:table-cell", {}, [buildParagraph(pkg)]);
|
|
@@ -135,6 +166,22 @@ var OdtTable = class {
|
|
|
135
166
|
node.children.push(row);
|
|
136
167
|
return new OdtTableRow(row, this.pkg);
|
|
137
168
|
}
|
|
169
|
+
mergeCells(startRow, startColumn, rowSpan, colSpan) {
|
|
170
|
+
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}`);
|
|
171
|
+
const rows = this.rows();
|
|
172
|
+
const anchorRow = rows[startRow];
|
|
173
|
+
if (anchorRow === void 0) throw new Error(`mergeCells: row ${startRow} does not exist in this table`);
|
|
174
|
+
const anchor = anchorRow.mergeCellsHorizontally(startColumn, colSpan);
|
|
175
|
+
if (rowSpan > 1) {
|
|
176
|
+
anchor.rowSpan = rowSpan;
|
|
177
|
+
for (let r = 1; r < rowSpan; r++) {
|
|
178
|
+
const coveredRow = rows[startRow + r];
|
|
179
|
+
if (coveredRow === void 0) throw new Error(`mergeCells: rowSpan ${rowSpan} starting at row ${startRow} exceeds this table's own ${rows.length} rows`);
|
|
180
|
+
for (let c = 0; c < colSpan; c++) coveredRow.markCellCovered(startColumn + c);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return anchor;
|
|
184
|
+
}
|
|
138
185
|
remove() {
|
|
139
186
|
removeChild(this.container, this.live());
|
|
140
187
|
this.removed = true;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_metadata = require("../../model/metadata.cjs");
|
|
3
|
+
const require_ports_clock = require("../../ports/clock.cjs");
|
|
4
|
+
const require_edit_pdf_page = require("./page.cjs");
|
|
5
|
+
let document_schema_js = require("document-schema.js");
|
|
6
|
+
let pdf_codec = require("pdf-codec");
|
|
7
|
+
//#region src/edit/pdf/editor.ts
|
|
8
|
+
var PdfEditor = class {
|
|
9
|
+
doc;
|
|
10
|
+
constructor(doc) {
|
|
11
|
+
this.doc = doc;
|
|
12
|
+
}
|
|
13
|
+
get metadata() {
|
|
14
|
+
return this.doc.metadata;
|
|
15
|
+
}
|
|
16
|
+
set metadata(value) {
|
|
17
|
+
this.doc.metadata = value;
|
|
18
|
+
}
|
|
19
|
+
pages() {
|
|
20
|
+
return this.doc.pages.map((page) => new require_edit_pdf_page.PdfPage(this.doc.pages, page, this.doc.images));
|
|
21
|
+
}
|
|
22
|
+
page(index) {
|
|
23
|
+
const node = this.doc.pages[index];
|
|
24
|
+
return node === void 0 ? void 0 : new require_edit_pdf_page.PdfPage(this.doc.pages, node, this.doc.images);
|
|
25
|
+
}
|
|
26
|
+
appendPage(init) {
|
|
27
|
+
const page = require_edit_pdf_page.buildPage(init);
|
|
28
|
+
this.doc.pages.push(page);
|
|
29
|
+
return new require_edit_pdf_page.PdfPage(this.doc.pages, page, this.doc.images);
|
|
30
|
+
}
|
|
31
|
+
insertPageAt(index, init) {
|
|
32
|
+
const page = require_edit_pdf_page.buildPage(init);
|
|
33
|
+
const insertAt = Math.min(Math.max(index, 0), this.doc.pages.length);
|
|
34
|
+
this.doc.pages.splice(insertAt, 0, page);
|
|
35
|
+
return new require_edit_pdf_page.PdfPage(this.doc.pages, page, this.doc.images);
|
|
36
|
+
}
|
|
37
|
+
toLayoutDocument() {
|
|
38
|
+
return this.doc;
|
|
39
|
+
}
|
|
40
|
+
toBytes(options) {
|
|
41
|
+
return (0, pdf_codec.writePdf)(this.doc, options);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
function openPdf(bytes, options) {
|
|
45
|
+
return new PdfEditor((0, pdf_codec.readPdf)(bytes, options));
|
|
46
|
+
}
|
|
47
|
+
function createPdf(options) {
|
|
48
|
+
const clock = options?.clock ?? require_ports_clock.systemClock;
|
|
49
|
+
const metadata = require_model_metadata.resolveMetadataTimestamps({}, clock);
|
|
50
|
+
return new PdfEditor({
|
|
51
|
+
formatVersion: document_schema_js.LAYOUT_FORMAT_VERSION,
|
|
52
|
+
metadata,
|
|
53
|
+
pages: [require_edit_pdf_page.buildPage({
|
|
54
|
+
widthPt: options?.widthPt,
|
|
55
|
+
heightPt: options?.heightPt
|
|
56
|
+
})],
|
|
57
|
+
images: {}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
exports.PdfEditor = PdfEditor;
|
|
62
|
+
exports.createPdf = createPdf;
|
|
63
|
+
exports.openPdf = openPdf;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.cjs";
|
|
2
|
+
import { PageInit, PdfPage } from "./page.cjs";
|
|
3
|
+
import { LayoutDocument, LayoutMetadata } from "document-schema.js";
|
|
4
|
+
import { ReadPdfOptions, WritePdfOptions } from "pdf-codec";
|
|
5
|
+
//#region src/edit/pdf/editor.d.ts
|
|
6
|
+
declare class PdfEditor {
|
|
7
|
+
private readonly doc;
|
|
8
|
+
constructor(doc: LayoutDocument);
|
|
9
|
+
get metadata(): LayoutMetadata;
|
|
10
|
+
set metadata(value: LayoutMetadata);
|
|
11
|
+
pages(): PdfPage[];
|
|
12
|
+
page(index: number): PdfPage | undefined;
|
|
13
|
+
appendPage(init?: PageInit): PdfPage;
|
|
14
|
+
insertPageAt(index: number, init?: PageInit): PdfPage;
|
|
15
|
+
toLayoutDocument(): LayoutDocument;
|
|
16
|
+
toBytes(options?: WritePdfOptions): Uint8Array<ArrayBuffer>;
|
|
17
|
+
}
|
|
18
|
+
declare function openPdf(bytes: Uint8Array<ArrayBuffer>, options?: ReadPdfOptions): PdfEditor;
|
|
19
|
+
interface CreatePdfOptions {
|
|
20
|
+
readonly widthPt?: number;
|
|
21
|
+
readonly heightPt?: number;
|
|
22
|
+
readonly clock?: ClockPort;
|
|
23
|
+
}
|
|
24
|
+
declare function createPdf(options?: CreatePdfOptions): PdfEditor;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { CreatePdfOptions, PdfEditor, createPdf, openPdf };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ClockPort } from "../../ports/clock.js";
|
|
2
|
+
import { PageInit, PdfPage } from "./page.js";
|
|
3
|
+
import { LayoutDocument, LayoutMetadata } from "document-schema.js";
|
|
4
|
+
import { ReadPdfOptions, WritePdfOptions } from "pdf-codec";
|
|
5
|
+
//#region src/edit/pdf/editor.d.ts
|
|
6
|
+
declare class PdfEditor {
|
|
7
|
+
private readonly doc;
|
|
8
|
+
constructor(doc: LayoutDocument);
|
|
9
|
+
get metadata(): LayoutMetadata;
|
|
10
|
+
set metadata(value: LayoutMetadata);
|
|
11
|
+
pages(): PdfPage[];
|
|
12
|
+
page(index: number): PdfPage | undefined;
|
|
13
|
+
appendPage(init?: PageInit): PdfPage;
|
|
14
|
+
insertPageAt(index: number, init?: PageInit): PdfPage;
|
|
15
|
+
toLayoutDocument(): LayoutDocument;
|
|
16
|
+
toBytes(options?: WritePdfOptions): Uint8Array<ArrayBuffer>;
|
|
17
|
+
}
|
|
18
|
+
declare function openPdf(bytes: Uint8Array<ArrayBuffer>, options?: ReadPdfOptions): PdfEditor;
|
|
19
|
+
interface CreatePdfOptions {
|
|
20
|
+
readonly widthPt?: number;
|
|
21
|
+
readonly heightPt?: number;
|
|
22
|
+
readonly clock?: ClockPort;
|
|
23
|
+
}
|
|
24
|
+
declare function createPdf(options?: CreatePdfOptions): PdfEditor;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { CreatePdfOptions, PdfEditor, createPdf, openPdf };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { resolveMetadataTimestamps } from "../../model/metadata.js";
|
|
2
|
+
import { systemClock } from "../../ports/clock.js";
|
|
3
|
+
import { PdfPage, buildPage } from "./page.js";
|
|
4
|
+
import { LAYOUT_FORMAT_VERSION } from "document-schema.js";
|
|
5
|
+
import { readPdf, writePdf } from "pdf-codec";
|
|
6
|
+
//#region src/edit/pdf/editor.ts
|
|
7
|
+
var PdfEditor = class {
|
|
8
|
+
doc;
|
|
9
|
+
constructor(doc) {
|
|
10
|
+
this.doc = doc;
|
|
11
|
+
}
|
|
12
|
+
get metadata() {
|
|
13
|
+
return this.doc.metadata;
|
|
14
|
+
}
|
|
15
|
+
set metadata(value) {
|
|
16
|
+
this.doc.metadata = value;
|
|
17
|
+
}
|
|
18
|
+
pages() {
|
|
19
|
+
return this.doc.pages.map((page) => new PdfPage(this.doc.pages, page, this.doc.images));
|
|
20
|
+
}
|
|
21
|
+
page(index) {
|
|
22
|
+
const node = this.doc.pages[index];
|
|
23
|
+
return node === void 0 ? void 0 : new PdfPage(this.doc.pages, node, this.doc.images);
|
|
24
|
+
}
|
|
25
|
+
appendPage(init) {
|
|
26
|
+
const page = buildPage(init);
|
|
27
|
+
this.doc.pages.push(page);
|
|
28
|
+
return new PdfPage(this.doc.pages, page, this.doc.images);
|
|
29
|
+
}
|
|
30
|
+
insertPageAt(index, init) {
|
|
31
|
+
const page = buildPage(init);
|
|
32
|
+
const insertAt = Math.min(Math.max(index, 0), this.doc.pages.length);
|
|
33
|
+
this.doc.pages.splice(insertAt, 0, page);
|
|
34
|
+
return new PdfPage(this.doc.pages, page, this.doc.images);
|
|
35
|
+
}
|
|
36
|
+
toLayoutDocument() {
|
|
37
|
+
return this.doc;
|
|
38
|
+
}
|
|
39
|
+
toBytes(options) {
|
|
40
|
+
return writePdf(this.doc, options);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function openPdf(bytes, options) {
|
|
44
|
+
return new PdfEditor(readPdf(bytes, options));
|
|
45
|
+
}
|
|
46
|
+
function createPdf(options) {
|
|
47
|
+
const clock = options?.clock ?? systemClock;
|
|
48
|
+
const metadata = resolveMetadataTimestamps({}, clock);
|
|
49
|
+
return new PdfEditor({
|
|
50
|
+
formatVersion: LAYOUT_FORMAT_VERSION,
|
|
51
|
+
metadata,
|
|
52
|
+
pages: [buildPage({
|
|
53
|
+
widthPt: options?.widthPt,
|
|
54
|
+
heightPt: options?.heightPt
|
|
55
|
+
})],
|
|
56
|
+
images: {}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { PdfEditor, createPdf, openPdf };
|