documents.js 1.60.3 → 1.62.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/README.md +84 -44
- package/dist/{blr-types-CYYC3yYU.d.cts → blr-types-DVgO1DQ9.d.cts} +1 -1
- package/dist/{blr-types-CYYC3yYU.d.ts → blr-types-DVgO1DQ9.d.ts} +1 -1
- package/dist/convert/capability.cjs +1 -0
- package/dist/convert/capability.d.cts +1 -1
- package/dist/convert/capability.d.ts +1 -1
- package/dist/convert/capability.js +1 -0
- package/dist/convert/convert.cjs +29 -27
- package/dist/convert/convert.d.cts +9 -3
- package/dist/convert/convert.d.ts +9 -3
- package/dist/convert/convert.js +29 -27
- package/dist/edit/docx/content.cjs +75 -13
- package/dist/edit/docx/content.d.cts +8 -2
- package/dist/edit/docx/content.d.ts +8 -2
- package/dist/edit/docx/content.js +75 -13
- package/dist/edit/docx/paragraph.cjs +14 -0
- package/dist/edit/docx/paragraph.d.cts +5 -0
- package/dist/edit/docx/paragraph.d.ts +5 -0
- package/dist/edit/docx/paragraph.js +14 -0
- package/dist/edit/docx/run.cjs +1 -1
- package/dist/edit/docx/run.js +1 -1
- package/dist/edit/docx/table.cjs +41 -0
- package/dist/edit/docx/table.d.cts +7 -1
- package/dist/edit/docx/table.d.ts +7 -1
- package/dist/edit/docx/table.js +42 -1
- package/dist/edit/geometry.cjs +38 -0
- package/dist/edit/geometry.d.cts +7 -0
- package/dist/edit/geometry.d.ts +7 -0
- package/dist/edit/geometry.js +36 -0
- package/dist/edit/odg/content.cjs +15 -12
- package/dist/edit/odg/content.js +15 -12
- package/dist/edit/odg/editor.d.cts +1 -1
- package/dist/edit/odg/editor.d.ts +1 -1
- package/dist/edit/odg/page.d.cts +3 -3
- package/dist/edit/odg/page.d.ts +3 -3
- package/dist/edit/odg/vector.cjs +22 -13
- package/dist/edit/odg/vector.d.cts +1 -1
- package/dist/edit/odg/vector.d.ts +1 -1
- package/dist/edit/odg/vector.js +23 -14
- package/dist/edit/odp/content.cjs +15 -0
- package/dist/edit/odp/content.js +16 -1
- package/dist/edit/odp/editor.d.cts +1 -1
- package/dist/edit/odp/editor.d.ts +1 -1
- package/dist/edit/odp/image.d.cts +1 -1
- package/dist/edit/odp/image.d.ts +1 -1
- package/dist/edit/odp/shape.cjs +11 -30
- package/dist/edit/odp/shape.d.cts +2 -2
- package/dist/edit/odp/shape.d.ts +2 -2
- package/dist/edit/odp/shape.js +13 -33
- package/dist/edit/odp/slide.cjs +11 -0
- package/dist/edit/odp/slide.d.cts +14 -4
- package/dist/edit/odp/slide.d.ts +14 -4
- package/dist/edit/odp/slide.js +12 -1
- package/dist/edit/odt/content.cjs +56 -16
- package/dist/edit/odt/content.d.cts +4 -2
- package/dist/edit/odt/content.d.ts +4 -2
- package/dist/edit/odt/content.js +56 -17
- package/dist/edit/odt/editor.d.cts +1 -1
- package/dist/edit/odt/editor.d.ts +1 -1
- package/dist/edit/odt/table.cjs +36 -0
- package/dist/edit/odt/table.d.cts +1 -36
- package/dist/edit/odt/table.d.ts +1 -36
- package/dist/edit/odt/table.js +37 -1
- package/dist/edit/pptx/content.cjs +71 -3
- package/dist/edit/pptx/content.js +71 -3
- package/dist/edit/pptx/editor.d.cts +1 -1
- package/dist/edit/pptx/editor.d.ts +1 -1
- package/dist/edit/pptx/image.d.cts +1 -1
- package/dist/edit/pptx/image.d.ts +1 -1
- package/dist/edit/pptx/shape.cjs +23 -1
- package/dist/edit/pptx/shape.d.cts +2 -2
- package/dist/edit/pptx/shape.d.ts +2 -2
- package/dist/edit/pptx/shape.js +23 -3
- package/dist/edit/pptx/slide.cjs +10 -1
- package/dist/edit/pptx/slide.d.cts +11 -4
- package/dist/edit/pptx/slide.d.ts +11 -4
- package/dist/edit/pptx/slide.js +10 -1
- package/dist/edit/pptx/table.cjs +136 -0
- package/dist/edit/pptx/table.d.cts +2 -0
- package/dist/edit/pptx/table.d.ts +2 -0
- package/dist/edit/pptx/table.js +131 -0
- package/dist/firebird/backup.d.cts +1 -1
- package/dist/firebird/backup.d.ts +1 -1
- package/dist/firebird/blr-types.cjs +2 -2
- package/dist/firebird/blr-types.d.cts +1 -1
- package/dist/firebird/blr-types.d.ts +1 -1
- package/dist/firebird/blr-types.js +2 -2
- package/dist/firebird/data.cjs +68 -14
- package/dist/firebird/data.d.cts +1 -1
- package/dist/firebird/data.d.ts +1 -1
- package/dist/firebird/data.js +68 -14
- package/dist/firebird/schema.cjs +13 -1
- package/dist/firebird/schema.d.cts +1 -1
- package/dist/firebird/schema.d.ts +1 -1
- package/dist/firebird/schema.js +13 -1
- package/dist/{geometry-DvwdrIij.d.cts → geometry-DaJr8yQW.d.cts} +2 -2
- package/dist/{geometry-DvwdrIij.d.ts → geometry-DaJr8yQW.d.ts} +2 -2
- package/dist/hsqldb/binary-script.cjs +154 -0
- package/dist/hsqldb/binary-script.d.cts +15 -0
- package/dist/hsqldb/binary-script.d.ts +15 -0
- package/dist/hsqldb/binary-script.js +151 -0
- package/dist/hsqldb/cache.cjs +18 -11
- package/dist/hsqldb/cache.d.cts +9 -4
- package/dist/hsqldb/cache.d.ts +9 -4
- package/dist/hsqldb/cache.js +18 -11
- package/dist/hsqldb/rowformat.cjs +60 -16
- package/dist/hsqldb/rowformat.d.cts +2 -21
- package/dist/hsqldb/rowformat.d.ts +2 -21
- package/dist/hsqldb/rowformat.js +60 -17
- package/dist/{image-BZDy72Jb.d.cts → image-7snmKIxn.d.cts} +1 -1
- package/dist/{image-B-xQWYYS.d.ts → image-Cs8xF753.d.ts} +1 -1
- package/dist/{image-CeqwL-Qs.d.ts → image-DHcA9kaK.d.ts} +1 -1
- package/dist/{image-DWX6cNOD.d.cts → image-M5SezZVI.d.cts} +1 -1
- package/dist/index.cjs +54 -3
- package/dist/index.d.cts +28 -20
- package/dist/index.d.ts +27 -19
- package/dist/index.js +13 -4
- package/dist/layout/cell-typing.cjs +209 -0
- package/dist/layout/cell-typing.d.cts +22 -0
- package/dist/layout/cell-typing.d.ts +22 -0
- package/dist/layout/cell-typing.js +208 -0
- package/dist/layout/drawing.cjs +193 -17
- package/dist/layout/drawing.js +193 -17
- package/dist/layout/engine.cjs +46 -29
- package/dist/layout/engine.d.cts +0 -2
- package/dist/layout/engine.d.ts +0 -2
- package/dist/layout/engine.js +47 -30
- package/dist/layout/lattice.cjs +139 -0
- package/dist/layout/lattice.d.cts +20 -0
- package/dist/layout/lattice.d.ts +20 -0
- package/dist/layout/lattice.js +135 -0
- package/dist/layout/reconstruct.cjs +176 -113
- package/dist/layout/reconstruct.d.cts +2 -0
- package/dist/layout/reconstruct.d.ts +2 -0
- package/dist/layout/reconstruct.js +173 -110
- package/dist/layout/shared.cjs +52 -0
- package/dist/layout/shared.d.cts +4 -2
- package/dist/layout/shared.d.ts +4 -2
- package/dist/layout/shared.js +51 -1
- package/dist/layout/sheets.cjs +45 -11
- package/dist/layout/sheets.js +46 -12
- package/dist/layout/slides.cjs +7 -7
- package/dist/layout/slides.d.cts +0 -3
- package/dist/layout/slides.d.ts +0 -3
- package/dist/layout/slides.js +7 -7
- package/dist/markdown/write.cjs +19 -6
- package/dist/markdown/write.js +19 -6
- package/dist/mathml/layout.cjs +43 -9
- package/dist/mathml/layout.d.cts +1 -1
- package/dist/mathml/layout.d.ts +1 -1
- package/dist/mathml/layout.js +43 -9
- package/dist/mathml/variant.cjs +48 -5
- package/dist/mathml/variant.js +48 -5
- package/dist/model/embedded-drawing.cjs +32 -0
- package/dist/model/embedded-drawing.d.cts +8 -0
- package/dist/model/embedded-drawing.d.ts +8 -0
- package/dist/model/embedded-drawing.js +30 -0
- package/dist/model/formula.cjs +31 -0
- package/dist/model/formula.d.cts +6 -6
- package/dist/model/formula.d.ts +6 -6
- package/dist/model/formula.js +27 -0
- package/dist/model/geometry.d.cts +1 -1
- package/dist/model/geometry.d.ts +1 -1
- package/dist/model/paint-order.cjs +15 -0
- package/dist/model/paint-order.d.cts +14 -0
- package/dist/model/paint-order.d.ts +14 -0
- package/dist/model/paint-order.js +14 -0
- package/dist/odb/components.cjs +12 -0
- package/dist/odb/components.d.cts +6 -0
- package/dist/odb/components.d.ts +6 -0
- package/dist/odb/components.js +10 -0
- package/dist/odb/read.cjs +11 -7
- package/dist/odb/read.d.cts +3 -2
- package/dist/odb/read.d.ts +3 -2
- package/dist/odb/read.js +11 -7
- package/dist/odf/formula/detect.cjs +86 -18
- package/dist/odf/formula/detect.d.cts +10 -6
- package/dist/odf/formula/detect.d.ts +10 -6
- package/dist/odf/formula/detect.js +86 -19
- package/dist/odf/formula/read.cjs +4 -16
- package/dist/odf/formula/read.d.cts +4 -8
- package/dist/odf/formula/read.d.ts +4 -8
- package/dist/odf/formula/read.js +5 -17
- package/dist/odf/odp/read.cjs +9 -19
- package/dist/odf/odp/read.d.cts +2 -7
- package/dist/odf/odp/read.d.ts +2 -7
- package/dist/odf/odp/read.js +10 -20
- package/dist/odf/odt/read.cjs +63 -23
- package/dist/odf/odt/read.d.cts +2 -7
- package/dist/odf/odt/read.d.ts +2 -7
- package/dist/odf/odt/read.js +64 -24
- package/dist/omml/write.cjs +258 -0
- package/dist/omml/write.d.cts +2 -0
- package/dist/omml/write.d.ts +2 -0
- package/dist/omml/write.js +256 -0
- package/dist/rowformat-Cl2exlEh.d.cts +25 -0
- package/dist/rowformat-Cl2exlEh.d.ts +25 -0
- package/dist/{schema-Acco3Ezi.d.cts → schema-BeR_KJ0X.d.cts} +3 -1
- package/dist/{schema-VkAA6pF5.d.ts → schema-CSKwSb_v.d.ts} +3 -1
- package/dist/{shape-BUfjw5eZ.d.cts → shape-BhkP6HB8.d.cts} +6 -2
- package/dist/{shape-CTkl6kt8.d.ts → shape-BkVcwPcf.d.ts} +6 -2
- package/dist/{shape-BfN3m52m.d.ts → shape-CVXedeL7.d.ts} +3 -2
- package/dist/{shape-CN2ycxOo.d.cts → shape-CXZ6fejV.d.cts} +3 -2
- package/dist/table-C3CPZ--2.d.cts +35 -0
- package/dist/table-DjYcNOFm.d.cts +44 -0
- package/dist/table-DqfqMkVq.d.ts +44 -0
- package/dist/table-DvS_7UQS.d.ts +35 -0
- package/dist/{vector-ClohqsOe.d.cts → vector-Puuqu_IT.d.cts} +4 -0
- package/dist/{vector-ClohqsOe.d.ts → vector-Puuqu_IT.d.ts} +4 -0
- package/dist/write-DuyfnbL_.d.cts +16 -0
- package/dist/write-Zqwx6pka.d.ts +16 -0
- package/package.json +4 -4
- package/dist/odf/formula/placeholder.cjs +0 -36
- package/dist/odf/formula/placeholder.d.cts +0 -14
- package/dist/odf/formula/placeholder.d.ts +0 -14
- package/dist/odf/formula/placeholder.js +0 -36
|
@@ -1,16 +1,44 @@
|
|
|
1
1
|
import { ptToTwips } from "../../model/units.js";
|
|
2
2
|
import { createDocx } from "./editor.js";
|
|
3
|
+
import { formulaOfBlock, formulaPlaceholderText } from "../../model/formula.js";
|
|
3
4
|
import { base64ToBytes } from "ooxml.js";
|
|
4
5
|
//#region src/edit/docx/content.ts
|
|
5
|
-
function buildDocxPackage(content) {
|
|
6
|
+
function buildDocxPackage(content, options) {
|
|
6
7
|
if (content.kind !== "wordprocessing") throw new Error("buildDocxPackage requires a wordprocessing ContentDocument");
|
|
7
8
|
const editor = createDocx();
|
|
8
9
|
content.sections.forEach((section, sectionIndex) => {
|
|
9
10
|
if (sectionIndex > 0) editor.body.appendPageBreak();
|
|
10
|
-
|
|
11
|
+
appendBlocks(editor.body, section.blocks, options);
|
|
11
12
|
});
|
|
12
13
|
return editor.toPackage();
|
|
13
14
|
}
|
|
15
|
+
function isMergeableImageParagraph(block) {
|
|
16
|
+
return block.kind === "paragraph" && block.runs.every((run) => run.text === "");
|
|
17
|
+
}
|
|
18
|
+
function appendBlocks(body, blocks, options) {
|
|
19
|
+
let index = 0;
|
|
20
|
+
while (index < blocks.length) {
|
|
21
|
+
const block = blocks[index];
|
|
22
|
+
const next = blocks[index + 1];
|
|
23
|
+
if (block !== void 0 && isMergeableImageParagraph(block) && next?.kind === "image") {
|
|
24
|
+
const paragraph = body.appendParagraph();
|
|
25
|
+
paragraph.styleId = block.styleId;
|
|
26
|
+
paragraph.alignment = block.alignment;
|
|
27
|
+
paragraph.list = block.list;
|
|
28
|
+
paragraph.insertImageAfter({
|
|
29
|
+
format: next.format,
|
|
30
|
+
bytes: base64ToBytes(next.base64),
|
|
31
|
+
widthPt: next.widthPt,
|
|
32
|
+
heightPt: next.heightPt,
|
|
33
|
+
altText: next.altText
|
|
34
|
+
});
|
|
35
|
+
index += 2;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (block !== void 0) appendBlock(body, block, options);
|
|
39
|
+
index += 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
14
42
|
function populateParagraph(paragraph, block) {
|
|
15
43
|
paragraph.styleId = block.styleId;
|
|
16
44
|
paragraph.alignment = block.alignment;
|
|
@@ -29,32 +57,57 @@ function populateParagraph(paragraph, block) {
|
|
|
29
57
|
if (run.color !== void 0) docxRun.color = run.color;
|
|
30
58
|
}
|
|
31
59
|
}
|
|
60
|
+
function populateCellBlocks(cell, blocks) {
|
|
61
|
+
const [firstBlock, ...restBlocks] = blocks;
|
|
62
|
+
const firstParagraph = cell.paragraphs()[0];
|
|
63
|
+
if (firstBlock?.kind === "paragraph" && firstParagraph !== void 0) populateParagraph(firstParagraph, firstBlock);
|
|
64
|
+
else if (firstBlock !== void 0) appendCellBlock(cell, firstBlock);
|
|
65
|
+
for (const remaining of restBlocks) appendCellBlock(cell, remaining);
|
|
66
|
+
}
|
|
32
67
|
function appendTable(body, block) {
|
|
33
68
|
const columns = block.columnWidthsPt.length;
|
|
34
69
|
if (block.rows.length === 0 || columns === 0) return;
|
|
35
70
|
const table = body.appendTable({
|
|
36
|
-
rows:
|
|
71
|
+
rows: 0,
|
|
37
72
|
columns,
|
|
38
73
|
columnWidthsTwips: block.columnWidthsPt.map(ptToTwips)
|
|
39
74
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
75
|
+
const verticalMerges = /* @__PURE__ */ new Map();
|
|
76
|
+
block.rows.forEach((row) => {
|
|
77
|
+
const domCells = table.appendRow(row.cells.length).cells();
|
|
78
|
+
let colIndex = 0;
|
|
43
79
|
row.cells.forEach((cell, cellIndex) => {
|
|
44
|
-
const tableCell =
|
|
80
|
+
const tableCell = domCells[cellIndex];
|
|
45
81
|
if (tableCell === void 0) return;
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
82
|
+
const active = verticalMerges.get(colIndex);
|
|
83
|
+
if (active !== void 0 && active.rowsRemaining > 0) {
|
|
84
|
+
if (active.gridSpan > 1) tableCell.colSpan = active.gridSpan;
|
|
85
|
+
tableCell.verticalMerge = "continue";
|
|
86
|
+
verticalMerges.set(colIndex, {
|
|
87
|
+
rowsRemaining: active.rowsRemaining - 1,
|
|
88
|
+
gridSpan: active.gridSpan
|
|
89
|
+
});
|
|
90
|
+
colIndex += active.gridSpan;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const span = cell.colSpan ?? 1;
|
|
94
|
+
if (span > 1) tableCell.colSpan = span;
|
|
95
|
+
if (cell.rowSpan !== void 0 && cell.rowSpan > 1) {
|
|
96
|
+
tableCell.verticalMerge = "restart";
|
|
97
|
+
verticalMerges.set(colIndex, {
|
|
98
|
+
rowsRemaining: cell.rowSpan - 1,
|
|
99
|
+
gridSpan: span
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
populateCellBlocks(tableCell, cell.blocks);
|
|
103
|
+
colIndex += span;
|
|
51
104
|
});
|
|
52
105
|
});
|
|
53
106
|
}
|
|
54
107
|
function appendCellBlock(cell, block) {
|
|
55
108
|
if (block.kind === "paragraph") populateParagraph(cell.appendParagraph(), block);
|
|
56
109
|
}
|
|
57
|
-
function appendBlock(body, block) {
|
|
110
|
+
function appendBlock(body, block, options) {
|
|
58
111
|
if (block.kind === "paragraph") populateParagraph(body.appendParagraph(), block);
|
|
59
112
|
else if (block.kind === "image") body.appendParagraph().insertImageAfter({
|
|
60
113
|
format: block.format,
|
|
@@ -65,6 +118,15 @@ function appendBlock(body, block) {
|
|
|
65
118
|
});
|
|
66
119
|
else if (block.kind === "pageBreak") body.appendPageBreak();
|
|
67
120
|
else if (block.kind === "table") appendTable(body, block);
|
|
121
|
+
else if (block.kind === "embeddedObject") appendEmbeddedObject(body, block, options);
|
|
122
|
+
}
|
|
123
|
+
function appendEmbeddedObject(body, block, options) {
|
|
124
|
+
const formula = formulaOfBlock(block);
|
|
125
|
+
if (formula === void 0) return;
|
|
126
|
+
const paragraph = body.appendParagraph();
|
|
127
|
+
const { written, diagnostics } = paragraph.appendOfficeMath(formula.mathml);
|
|
128
|
+
for (const diagnostic of diagnostics) options?.onMathDiagnostic?.(diagnostic, { sourcePath: block.sourcePath });
|
|
129
|
+
if (!written) paragraph.appendRun({ text: formulaPlaceholderText(formula) });
|
|
68
130
|
}
|
|
69
131
|
//#endregion
|
|
70
132
|
export { buildDocxPackage };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
|
+
const require_omml_write = require("../../omml/write.cjs");
|
|
3
4
|
const require_xml_edit = require("../../xml/edit.cjs");
|
|
4
5
|
const require_edit_docx_image = require("./image.cjs");
|
|
5
6
|
const require_edit_docx_props = require("./props.cjs");
|
|
@@ -104,6 +105,19 @@ var DocxParagraph = class {
|
|
|
104
105
|
const numPr = require_xml_edit.getOrCreateChildElement(pPr, "w:numPr", require_edit_docx_props.PPR_ORDER, () => require_xml_fragment.el("w:numPr"));
|
|
105
106
|
numPr.children = [require_xml_fragment.el("w:ilvl", { "w:val": String(value.level) }), require_xml_fragment.el("w:numId", { "w:val": value.numId })];
|
|
106
107
|
}
|
|
108
|
+
appendOfficeMath(mathml) {
|
|
109
|
+
const node = this.live();
|
|
110
|
+
const result = require_omml_write.buildOfficeMathParagraph(mathml);
|
|
111
|
+
if (result.element === void 0) return {
|
|
112
|
+
...result,
|
|
113
|
+
written: false
|
|
114
|
+
};
|
|
115
|
+
node.children.push(result.element);
|
|
116
|
+
return {
|
|
117
|
+
...result,
|
|
118
|
+
written: true
|
|
119
|
+
};
|
|
120
|
+
}
|
|
107
121
|
insertImageAfter(image) {
|
|
108
122
|
const node = this.live();
|
|
109
123
|
if (this.imageContext === void 0) throw new Error("insertImageAfter requires a paragraph opened through a DocxEditor");
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { r as MathMlNode } from "../../nodes-pArN9ilm.cjs";
|
|
2
|
+
import { r as OmmlWriteResult } from "../../write-DuyfnbL_.cjs";
|
|
1
3
|
import { n as MediaContext, t as ImageInit } from "../../image-BfRLAD9B.cjs";
|
|
2
4
|
import { n as RunInit, t as DocxRun } from "../../run-B3GNScJH.cjs";
|
|
3
5
|
import { ContentListMembership } from "document-schema.js";
|
|
@@ -32,6 +34,9 @@ declare class DocxParagraph {
|
|
|
32
34
|
set alignment(value: 'left' | 'center' | 'right' | 'justify' | undefined);
|
|
33
35
|
get list(): ContentListMembership | undefined;
|
|
34
36
|
set list(value: ContentListMembership | undefined);
|
|
37
|
+
appendOfficeMath(mathml: readonly MathMlNode[]): OmmlWriteResult & {
|
|
38
|
+
readonly written: boolean;
|
|
39
|
+
};
|
|
35
40
|
insertImageAfter(image: ImageInit): void;
|
|
36
41
|
remove(): void;
|
|
37
42
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { r as MathMlNode } from "../../nodes-pArN9ilm.js";
|
|
2
|
+
import { r as OmmlWriteResult } from "../../write-Zqwx6pka.js";
|
|
1
3
|
import { n as MediaContext, t as ImageInit } from "../../image-BfRLAD9B.js";
|
|
2
4
|
import { n as RunInit, t as DocxRun } from "../../run-D2rTWHbt.js";
|
|
3
5
|
import { Package, XmlElement, XmlNode } from "ooxml.js";
|
|
@@ -32,6 +34,9 @@ declare class DocxParagraph {
|
|
|
32
34
|
set alignment(value: 'left' | 'center' | 'right' | 'justify' | undefined);
|
|
33
35
|
get list(): ContentListMembership | undefined;
|
|
34
36
|
set list(value: ContentListMembership | undefined);
|
|
37
|
+
appendOfficeMath(mathml: readonly MathMlNode[]): OmmlWriteResult & {
|
|
38
|
+
readonly written: boolean;
|
|
39
|
+
};
|
|
35
40
|
insertImageAfter(image: ImageInit): void;
|
|
36
41
|
remove(): void;
|
|
37
42
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { el } from "../../xml/fragment.js";
|
|
2
|
+
import { buildOfficeMathParagraph } from "../../omml/write.js";
|
|
2
3
|
import { getOrCreateChildElement, removeChild } from "../../xml/edit.js";
|
|
3
4
|
import { insertImageMedia } from "./image.js";
|
|
4
5
|
import { PPR_ORDER, ensureFirstChild, getAlignment, getStyleId, setAlignment, setStyleId } from "./props.js";
|
|
@@ -103,6 +104,19 @@ var DocxParagraph = class {
|
|
|
103
104
|
const numPr = getOrCreateChildElement(pPr, "w:numPr", PPR_ORDER, () => el("w:numPr"));
|
|
104
105
|
numPr.children = [el("w:ilvl", { "w:val": String(value.level) }), el("w:numId", { "w:val": value.numId })];
|
|
105
106
|
}
|
|
107
|
+
appendOfficeMath(mathml) {
|
|
108
|
+
const node = this.live();
|
|
109
|
+
const result = buildOfficeMathParagraph(mathml);
|
|
110
|
+
if (result.element === void 0) return {
|
|
111
|
+
...result,
|
|
112
|
+
written: false
|
|
113
|
+
};
|
|
114
|
+
node.children.push(result.element);
|
|
115
|
+
return {
|
|
116
|
+
...result,
|
|
117
|
+
written: true
|
|
118
|
+
};
|
|
119
|
+
}
|
|
106
120
|
insertImageAfter(image) {
|
|
107
121
|
const node = this.live();
|
|
108
122
|
if (this.imageContext === void 0) throw new Error("insertImageAfter requires a paragraph opened through a DocxEditor");
|
package/dist/edit/docx/run.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
|
+
const require_xml_entities = require("../../xml/entities.cjs");
|
|
3
4
|
const require_xml_edit = require("../../xml/edit.cjs");
|
|
4
5
|
const require_edit_docx_props = require("./props.cjs");
|
|
5
|
-
const require_xml_entities = require("../../xml/entities.cjs");
|
|
6
6
|
let ooxml_js = require("ooxml.js");
|
|
7
7
|
let document_schema_js = require("document-schema.js");
|
|
8
8
|
//#region src/edit/docx/run.ts
|
package/dist/edit/docx/run.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { colorToRgbHex } from "../../model/color.js";
|
|
2
2
|
import { el, txt } from "../../xml/fragment.js";
|
|
3
|
+
import { encodeXmlText, needsSpacePreserve } from "../../xml/entities.js";
|
|
3
4
|
import { removeChild, setAttr } from "../../xml/edit.js";
|
|
4
5
|
import { RPR_ORDER, ensureFirstChild, getColor, getFontFamily, getSizePt, getToggle, setColor, setFontFamily, setSizePt, setToggle } from "./props.js";
|
|
5
|
-
import { encodeXmlText, needsSpacePreserve } from "../../xml/entities.js";
|
|
6
6
|
import { textContent } from "ooxml.js";
|
|
7
7
|
//#region src/edit/docx/run.ts
|
|
8
8
|
function directChild(parent, tag) {
|
package/dist/edit/docx/table.cjs
CHANGED
|
@@ -2,13 +2,54 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
3
|
const require_xml_edit = require("../../xml/edit.cjs");
|
|
4
4
|
const require_edit_docx_paragraph = require("./paragraph.cjs");
|
|
5
|
+
let ooxml_js = require("ooxml.js");
|
|
5
6
|
//#region src/edit/docx/table.ts
|
|
6
7
|
const DEFAULT_TABLE_WIDTH_TWIPS = 9360;
|
|
8
|
+
const TC_PR_CHILD_ORDER = ["w:gridSpan", "w:vMerge"];
|
|
7
9
|
var DocxTableCell = class {
|
|
8
10
|
node;
|
|
9
11
|
constructor(node) {
|
|
10
12
|
this.node = node;
|
|
11
13
|
}
|
|
14
|
+
tcPrElement(create) {
|
|
15
|
+
const existing = require_xml_edit.directChildElement(this.node, "w:tcPr");
|
|
16
|
+
if (existing !== void 0 || !create) return existing;
|
|
17
|
+
const created = require_xml_fragment.el("w:tcPr");
|
|
18
|
+
this.node.children.unshift(created);
|
|
19
|
+
return created;
|
|
20
|
+
}
|
|
21
|
+
get colSpan() {
|
|
22
|
+
const tcPr = this.tcPrElement(false);
|
|
23
|
+
const gridSpan = tcPr === void 0 ? void 0 : require_xml_edit.directChildElement(tcPr, "w:gridSpan");
|
|
24
|
+
const val = gridSpan === void 0 ? void 0 : (0, ooxml_js.attr)(gridSpan, "w:val");
|
|
25
|
+
return val === void 0 ? void 0 : Number(val);
|
|
26
|
+
}
|
|
27
|
+
set colSpan(value) {
|
|
28
|
+
if (value === void 0) {
|
|
29
|
+
const tcPr = this.tcPrElement(false);
|
|
30
|
+
if (tcPr !== void 0) tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:gridSpan"));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const tcPr = this.tcPrElement(true);
|
|
34
|
+
tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:gridSpan"));
|
|
35
|
+
require_xml_edit.insertInSchemaOrder(tcPr, require_xml_fragment.el("w:gridSpan", { "w:val": String(value) }), TC_PR_CHILD_ORDER);
|
|
36
|
+
}
|
|
37
|
+
get verticalMerge() {
|
|
38
|
+
const tcPr = this.tcPrElement(false);
|
|
39
|
+
const vMerge = tcPr === void 0 ? void 0 : require_xml_edit.directChildElement(tcPr, "w:vMerge");
|
|
40
|
+
if (vMerge === void 0) return;
|
|
41
|
+
return (0, ooxml_js.attr)(vMerge, "w:val") === "restart" ? "restart" : "continue";
|
|
42
|
+
}
|
|
43
|
+
set verticalMerge(value) {
|
|
44
|
+
if (value === void 0) {
|
|
45
|
+
const tcPr = this.tcPrElement(false);
|
|
46
|
+
if (tcPr !== void 0) tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:vMerge"));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const tcPr = this.tcPrElement(true);
|
|
50
|
+
tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:vMerge"));
|
|
51
|
+
require_xml_edit.insertInSchemaOrder(tcPr, value === "restart" ? require_xml_fragment.el("w:vMerge", { "w:val": "restart" }) : require_xml_fragment.el("w:vMerge"), TC_PR_CHILD_ORDER);
|
|
52
|
+
}
|
|
12
53
|
paragraphs() {
|
|
13
54
|
const out = [];
|
|
14
55
|
for (const child of this.node.children) if (child.type === "element" && child.tag === "w:p") out.push(new require_edit_docx_paragraph.DocxParagraph(this.node.children, child));
|
|
@@ -6,9 +6,15 @@ interface TableInit {
|
|
|
6
6
|
readonly columns: number;
|
|
7
7
|
readonly columnWidthsTwips?: readonly number[];
|
|
8
8
|
}
|
|
9
|
+
type DocxVerticalMerge = 'restart' | 'continue';
|
|
9
10
|
declare class DocxTableCell {
|
|
10
11
|
private readonly node;
|
|
11
12
|
constructor(node: XmlElement);
|
|
13
|
+
private tcPrElement;
|
|
14
|
+
get colSpan(): number | undefined;
|
|
15
|
+
set colSpan(value: number | undefined);
|
|
16
|
+
get verticalMerge(): DocxVerticalMerge | undefined;
|
|
17
|
+
set verticalMerge(value: DocxVerticalMerge | undefined);
|
|
12
18
|
paragraphs(): DocxParagraph[];
|
|
13
19
|
appendParagraph(init?: ParagraphInit): DocxParagraph;
|
|
14
20
|
get text(): string;
|
|
@@ -31,4 +37,4 @@ declare class DocxTable {
|
|
|
31
37
|
}
|
|
32
38
|
declare function buildTable(init: TableInit): XmlElement;
|
|
33
39
|
//#endregion
|
|
34
|
-
export { DocxTable, DocxTableCell, DocxTableRow, TableInit, buildTable };
|
|
40
|
+
export { DocxTable, DocxTableCell, DocxTableRow, DocxVerticalMerge, TableInit, buildTable };
|
|
@@ -6,9 +6,15 @@ interface TableInit {
|
|
|
6
6
|
readonly columns: number;
|
|
7
7
|
readonly columnWidthsTwips?: readonly number[];
|
|
8
8
|
}
|
|
9
|
+
type DocxVerticalMerge = 'restart' | 'continue';
|
|
9
10
|
declare class DocxTableCell {
|
|
10
11
|
private readonly node;
|
|
11
12
|
constructor(node: XmlElement);
|
|
13
|
+
private tcPrElement;
|
|
14
|
+
get colSpan(): number | undefined;
|
|
15
|
+
set colSpan(value: number | undefined);
|
|
16
|
+
get verticalMerge(): DocxVerticalMerge | undefined;
|
|
17
|
+
set verticalMerge(value: DocxVerticalMerge | undefined);
|
|
12
18
|
paragraphs(): DocxParagraph[];
|
|
13
19
|
appendParagraph(init?: ParagraphInit): DocxParagraph;
|
|
14
20
|
get text(): string;
|
|
@@ -31,4 +37,4 @@ declare class DocxTable {
|
|
|
31
37
|
}
|
|
32
38
|
declare function buildTable(init: TableInit): XmlElement;
|
|
33
39
|
//#endregion
|
|
34
|
-
export { DocxTable, DocxTableCell, DocxTableRow, TableInit, buildTable };
|
|
40
|
+
export { DocxTable, DocxTableCell, DocxTableRow, DocxVerticalMerge, TableInit, buildTable };
|
package/dist/edit/docx/table.js
CHANGED
|
@@ -1,13 +1,54 @@
|
|
|
1
1
|
import { el } from "../../xml/fragment.js";
|
|
2
|
-
import { removeChild } from "../../xml/edit.js";
|
|
2
|
+
import { directChildElement, insertInSchemaOrder, removeChild } from "../../xml/edit.js";
|
|
3
3
|
import { DocxParagraph, buildParagraph } from "./paragraph.js";
|
|
4
|
+
import { attr } from "ooxml.js";
|
|
4
5
|
//#region src/edit/docx/table.ts
|
|
5
6
|
const DEFAULT_TABLE_WIDTH_TWIPS = 9360;
|
|
7
|
+
const TC_PR_CHILD_ORDER = ["w:gridSpan", "w:vMerge"];
|
|
6
8
|
var DocxTableCell = class {
|
|
7
9
|
node;
|
|
8
10
|
constructor(node) {
|
|
9
11
|
this.node = node;
|
|
10
12
|
}
|
|
13
|
+
tcPrElement(create) {
|
|
14
|
+
const existing = directChildElement(this.node, "w:tcPr");
|
|
15
|
+
if (existing !== void 0 || !create) return existing;
|
|
16
|
+
const created = el("w:tcPr");
|
|
17
|
+
this.node.children.unshift(created);
|
|
18
|
+
return created;
|
|
19
|
+
}
|
|
20
|
+
get colSpan() {
|
|
21
|
+
const tcPr = this.tcPrElement(false);
|
|
22
|
+
const gridSpan = tcPr === void 0 ? void 0 : directChildElement(tcPr, "w:gridSpan");
|
|
23
|
+
const val = gridSpan === void 0 ? void 0 : attr(gridSpan, "w:val");
|
|
24
|
+
return val === void 0 ? void 0 : Number(val);
|
|
25
|
+
}
|
|
26
|
+
set colSpan(value) {
|
|
27
|
+
if (value === void 0) {
|
|
28
|
+
const tcPr = this.tcPrElement(false);
|
|
29
|
+
if (tcPr !== void 0) tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:gridSpan"));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const tcPr = this.tcPrElement(true);
|
|
33
|
+
tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:gridSpan"));
|
|
34
|
+
insertInSchemaOrder(tcPr, el("w:gridSpan", { "w:val": String(value) }), TC_PR_CHILD_ORDER);
|
|
35
|
+
}
|
|
36
|
+
get verticalMerge() {
|
|
37
|
+
const tcPr = this.tcPrElement(false);
|
|
38
|
+
const vMerge = tcPr === void 0 ? void 0 : directChildElement(tcPr, "w:vMerge");
|
|
39
|
+
if (vMerge === void 0) return;
|
|
40
|
+
return attr(vMerge, "w:val") === "restart" ? "restart" : "continue";
|
|
41
|
+
}
|
|
42
|
+
set verticalMerge(value) {
|
|
43
|
+
if (value === void 0) {
|
|
44
|
+
const tcPr = this.tcPrElement(false);
|
|
45
|
+
if (tcPr !== void 0) tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:vMerge"));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const tcPr = this.tcPrElement(true);
|
|
49
|
+
tcPr.children = tcPr.children.filter((c) => !(c.type === "element" && c.tag === "w:vMerge"));
|
|
50
|
+
insertInSchemaOrder(tcPr, value === "restart" ? el("w:vMerge", { "w:val": "restart" }) : el("w:vMerge"), TC_PR_CHILD_ORDER);
|
|
51
|
+
}
|
|
11
52
|
paragraphs() {
|
|
12
53
|
const out = [];
|
|
13
54
|
for (const child of this.node.children) if (child.type === "element" && child.tag === "w:p") out.push(new DocxParagraph(this.node.children, child));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_edit = require("../xml/edit.cjs");
|
|
3
|
+
let odf_js = require("odf.js");
|
|
4
|
+
//#region src/edit/geometry.ts
|
|
5
|
+
function buildTransformAttr(frame, rotationDeg) {
|
|
6
|
+
const angleRad = -rotationDeg * Math.PI / 180;
|
|
7
|
+
const localCenter = {
|
|
8
|
+
xPt: frame.widthPt / 2,
|
|
9
|
+
yPt: frame.heightPt / 2
|
|
10
|
+
};
|
|
11
|
+
const rotatedCenter = (0, odf_js.applyOdfTransform)([{
|
|
12
|
+
kind: "rotate",
|
|
13
|
+
angleRad
|
|
14
|
+
}], localCenter);
|
|
15
|
+
const desiredCenter = {
|
|
16
|
+
xPt: frame.xPt + frame.widthPt / 2,
|
|
17
|
+
yPt: frame.yPt + frame.heightPt / 2
|
|
18
|
+
};
|
|
19
|
+
const txPt = desiredCenter.xPt - rotatedCenter.xPt;
|
|
20
|
+
const tyPt = desiredCenter.yPt - rotatedCenter.yPt;
|
|
21
|
+
return `rotate(${angleRad}) translate(${(0, odf_js.formatOdfLength)(txPt)} ${(0, odf_js.formatOdfLength)(tyPt)})`;
|
|
22
|
+
}
|
|
23
|
+
function applyOdfGeometry(node, frame, rotationDeg) {
|
|
24
|
+
require_xml_edit.setAttr(node, "svg:width", (0, odf_js.formatOdfLength)(frame.widthPt));
|
|
25
|
+
require_xml_edit.setAttr(node, "svg:height", (0, odf_js.formatOdfLength)(frame.heightPt));
|
|
26
|
+
if (rotationDeg === void 0 || rotationDeg === 0) {
|
|
27
|
+
require_xml_edit.removeAttr(node, "draw:transform");
|
|
28
|
+
require_xml_edit.setAttr(node, "svg:x", (0, odf_js.formatOdfLength)(frame.xPt));
|
|
29
|
+
require_xml_edit.setAttr(node, "svg:y", (0, odf_js.formatOdfLength)(frame.yPt));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
require_xml_edit.removeAttr(node, "svg:x");
|
|
33
|
+
require_xml_edit.removeAttr(node, "svg:y");
|
|
34
|
+
require_xml_edit.setAttr(node, "draw:transform", buildTransformAttr(frame, rotationDeg));
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.applyOdfGeometry = applyOdfGeometry;
|
|
38
|
+
exports.buildTransformAttr = buildTransformAttr;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { t as Box } from "../geometry-DaJr8yQW.cjs";
|
|
2
|
+
import { XmlElement } from "odf.js";
|
|
3
|
+
//#region src/edit/geometry.d.ts
|
|
4
|
+
declare function buildTransformAttr(frame: Box, rotationDeg: number): string;
|
|
5
|
+
declare function applyOdfGeometry(node: XmlElement, frame: Box, rotationDeg: number | undefined): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { applyOdfGeometry, buildTransformAttr };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { t as Box } from "../geometry-DaJr8yQW.js";
|
|
2
|
+
import { XmlElement } from "odf.js";
|
|
3
|
+
//#region src/edit/geometry.d.ts
|
|
4
|
+
declare function buildTransformAttr(frame: Box, rotationDeg: number): string;
|
|
5
|
+
declare function applyOdfGeometry(node: XmlElement, frame: Box, rotationDeg: number | undefined): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { applyOdfGeometry, buildTransformAttr };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { removeAttr, setAttr } from "../xml/edit.js";
|
|
2
|
+
import { applyOdfTransform, formatOdfLength } from "odf.js";
|
|
3
|
+
//#region src/edit/geometry.ts
|
|
4
|
+
function buildTransformAttr(frame, rotationDeg) {
|
|
5
|
+
const angleRad = -rotationDeg * Math.PI / 180;
|
|
6
|
+
const localCenter = {
|
|
7
|
+
xPt: frame.widthPt / 2,
|
|
8
|
+
yPt: frame.heightPt / 2
|
|
9
|
+
};
|
|
10
|
+
const rotatedCenter = applyOdfTransform([{
|
|
11
|
+
kind: "rotate",
|
|
12
|
+
angleRad
|
|
13
|
+
}], localCenter);
|
|
14
|
+
const desiredCenter = {
|
|
15
|
+
xPt: frame.xPt + frame.widthPt / 2,
|
|
16
|
+
yPt: frame.yPt + frame.heightPt / 2
|
|
17
|
+
};
|
|
18
|
+
const txPt = desiredCenter.xPt - rotatedCenter.xPt;
|
|
19
|
+
const tyPt = desiredCenter.yPt - rotatedCenter.yPt;
|
|
20
|
+
return `rotate(${angleRad}) translate(${formatOdfLength(txPt)} ${formatOdfLength(tyPt)})`;
|
|
21
|
+
}
|
|
22
|
+
function applyOdfGeometry(node, frame, rotationDeg) {
|
|
23
|
+
setAttr(node, "svg:width", formatOdfLength(frame.widthPt));
|
|
24
|
+
setAttr(node, "svg:height", formatOdfLength(frame.heightPt));
|
|
25
|
+
if (rotationDeg === void 0 || rotationDeg === 0) {
|
|
26
|
+
removeAttr(node, "draw:transform");
|
|
27
|
+
setAttr(node, "svg:x", formatOdfLength(frame.xPt));
|
|
28
|
+
setAttr(node, "svg:y", formatOdfLength(frame.yPt));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
removeAttr(node, "svg:x");
|
|
32
|
+
removeAttr(node, "svg:y");
|
|
33
|
+
setAttr(node, "draw:transform", buildTransformAttr(frame, rotationDeg));
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { applyOdfGeometry, buildTransformAttr };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_edit_odt_content = require("../odt/content.cjs");
|
|
3
3
|
const require_edit_odg_editor = require("./editor.cjs");
|
|
4
|
+
const require_model_paint_order = require("../../model/paint-order.cjs");
|
|
4
5
|
let odf_js = require("odf.js");
|
|
5
6
|
//#region src/edit/odg/content.ts
|
|
6
7
|
function buildOdgPackage(content) {
|
|
@@ -10,33 +11,35 @@ function buildOdgPackage(content) {
|
|
|
10
11
|
if (firstPage !== void 0) editor.pageSize = firstPage.size;
|
|
11
12
|
for (const page of content.pages) {
|
|
12
13
|
const odgPage = editor.addPage();
|
|
13
|
-
for (const
|
|
14
|
-
|
|
14
|
+
for (const entry of require_model_paint_order.mergeByPaintOrder(page.vectors, page.shapes)) if (entry.kind === "vector") appendVector(odgPage, entry.value);
|
|
15
|
+
else appendShape(odgPage, entry.value);
|
|
15
16
|
}
|
|
16
17
|
return editor.toPackage();
|
|
17
18
|
}
|
|
18
19
|
function appendVector(page, vector) {
|
|
19
|
-
if (vector.kind === "
|
|
20
|
+
if (vector.kind === "line") {
|
|
21
|
+
page.addLine({
|
|
22
|
+
from: vector.from,
|
|
23
|
+
to: vector.to,
|
|
24
|
+
stroke: vector.stroke
|
|
25
|
+
});
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const built = vector.kind === "rect" ? page.addRect({
|
|
20
29
|
frame: vector.frame,
|
|
21
30
|
fill: vector.fill,
|
|
22
31
|
stroke: vector.stroke
|
|
23
|
-
})
|
|
24
|
-
else if (vector.kind === "ellipse") page.addEllipse({
|
|
32
|
+
}) : vector.kind === "ellipse" ? page.addEllipse({
|
|
25
33
|
frame: vector.frame,
|
|
26
34
|
fill: vector.fill,
|
|
27
35
|
stroke: vector.stroke
|
|
28
|
-
})
|
|
29
|
-
else if (vector.kind === "line") page.addLine({
|
|
30
|
-
from: vector.from,
|
|
31
|
-
to: vector.to,
|
|
32
|
-
stroke: vector.stroke
|
|
33
|
-
});
|
|
34
|
-
else page.addPath({
|
|
36
|
+
}) : page.addPath({
|
|
35
37
|
frame: vector.frame,
|
|
36
38
|
subpaths: vector.subpaths,
|
|
37
39
|
fill: vector.fill,
|
|
38
40
|
stroke: vector.stroke
|
|
39
41
|
});
|
|
42
|
+
if (vector.rotationDeg !== void 0) built.rotationDeg = vector.rotationDeg;
|
|
40
43
|
}
|
|
41
44
|
function appendShape(page, shape) {
|
|
42
45
|
const [onlyBlock] = shape.blocks;
|
package/dist/edit/odg/content.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { populateParagraph } from "../odt/content.js";
|
|
2
2
|
import { createOdg } from "./editor.js";
|
|
3
|
+
import { mergeByPaintOrder } from "../../model/paint-order.js";
|
|
3
4
|
import { base64ToBytes } from "odf.js";
|
|
4
5
|
//#region src/edit/odg/content.ts
|
|
5
6
|
function buildOdgPackage(content) {
|
|
@@ -9,33 +10,35 @@ function buildOdgPackage(content) {
|
|
|
9
10
|
if (firstPage !== void 0) editor.pageSize = firstPage.size;
|
|
10
11
|
for (const page of content.pages) {
|
|
11
12
|
const odgPage = editor.addPage();
|
|
12
|
-
for (const
|
|
13
|
-
|
|
13
|
+
for (const entry of mergeByPaintOrder(page.vectors, page.shapes)) if (entry.kind === "vector") appendVector(odgPage, entry.value);
|
|
14
|
+
else appendShape(odgPage, entry.value);
|
|
14
15
|
}
|
|
15
16
|
return editor.toPackage();
|
|
16
17
|
}
|
|
17
18
|
function appendVector(page, vector) {
|
|
18
|
-
if (vector.kind === "
|
|
19
|
+
if (vector.kind === "line") {
|
|
20
|
+
page.addLine({
|
|
21
|
+
from: vector.from,
|
|
22
|
+
to: vector.to,
|
|
23
|
+
stroke: vector.stroke
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const built = vector.kind === "rect" ? page.addRect({
|
|
19
28
|
frame: vector.frame,
|
|
20
29
|
fill: vector.fill,
|
|
21
30
|
stroke: vector.stroke
|
|
22
|
-
})
|
|
23
|
-
else if (vector.kind === "ellipse") page.addEllipse({
|
|
31
|
+
}) : vector.kind === "ellipse" ? page.addEllipse({
|
|
24
32
|
frame: vector.frame,
|
|
25
33
|
fill: vector.fill,
|
|
26
34
|
stroke: vector.stroke
|
|
27
|
-
})
|
|
28
|
-
else if (vector.kind === "line") page.addLine({
|
|
29
|
-
from: vector.from,
|
|
30
|
-
to: vector.to,
|
|
31
|
-
stroke: vector.stroke
|
|
32
|
-
});
|
|
33
|
-
else page.addPath({
|
|
35
|
+
}) : page.addPath({
|
|
34
36
|
frame: vector.frame,
|
|
35
37
|
subpaths: vector.subpaths,
|
|
36
38
|
fill: vector.fill,
|
|
37
39
|
stroke: vector.stroke
|
|
38
40
|
});
|
|
41
|
+
if (vector.rotationDeg !== void 0) built.rotationDeg = vector.rotationDeg;
|
|
39
42
|
}
|
|
40
43
|
function appendShape(page, shape) {
|
|
41
44
|
const [onlyBlock] = shape.blocks;
|
package/dist/edit/odg/page.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as ImageInit } from "../../image-
|
|
2
|
-
import { t as OdpShape } from "../../shape-
|
|
3
|
-
import { a as OdgLineVector, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as PathVectorInit, t as BoxVectorInit } from "../../vector-
|
|
1
|
+
import { t as ImageInit } from "../../image-M5SezZVI.cjs";
|
|
2
|
+
import { t as OdpShape } from "../../shape-CXZ6fejV.cjs";
|
|
3
|
+
import { a as OdgLineVector, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as PathVectorInit, t as BoxVectorInit } from "../../vector-Puuqu_IT.cjs";
|
|
4
4
|
import { Box } from "document-schema.js";
|
|
5
5
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
6
6
|
//#region src/edit/odg/page.d.ts
|
package/dist/edit/odg/page.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as ImageInit } from "../../image-
|
|
2
|
-
import { t as OdpShape } from "../../shape-
|
|
3
|
-
import { a as OdgLineVector, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as PathVectorInit, t as BoxVectorInit } from "../../vector-
|
|
1
|
+
import { t as ImageInit } from "../../image-DHcA9kaK.js";
|
|
2
|
+
import { t as OdpShape } from "../../shape-CVXedeL7.js";
|
|
3
|
+
import { a as OdgLineVector, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as PathVectorInit, t as BoxVectorInit } from "../../vector-Puuqu_IT.js";
|
|
4
4
|
import { Box } from "document-schema.js";
|
|
5
5
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
6
6
|
//#region src/edit/odg/page.d.ts
|