js.documents 1.70.0 → 1.71.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/odg/page.d.cts +1 -1
- package/dist/edit/odg/page.d.ts +1 -1
- package/dist/edit/odp/shape.d.cts +1 -1
- package/dist/edit/odp/shape.d.ts +1 -1
- package/dist/edit/odp/slide.d.cts +2 -2
- package/dist/edit/odp/slide.d.ts +2 -2
- package/dist/edit/odt/content.cjs +43 -0
- package/dist/edit/odt/content.d.cts +2 -2
- package/dist/edit/odt/content.d.ts +2 -2
- package/dist/edit/odt/content.js +43 -0
- package/dist/edit/odt/editor.d.cts +3 -3
- package/dist/edit/odt/editor.d.ts +3 -3
- package/dist/edit/odt/image.cjs +23 -0
- package/dist/edit/odt/image.d.cts +2 -0
- package/dist/edit/odt/image.d.ts +2 -0
- package/dist/edit/odt/image.js +21 -0
- package/dist/edit/odt/list.d.cts +1 -1
- package/dist/edit/odt/list.d.ts +1 -1
- package/dist/edit/odt/paragraph.cjs +11 -0
- package/dist/edit/odt/paragraph.d.cts +1 -1
- package/dist/edit/odt/paragraph.d.ts +1 -1
- package/dist/edit/odt/paragraph.js +11 -0
- package/dist/edit/odt/table.d.cts +1 -1
- package/dist/edit/odt/table.d.ts +1 -1
- package/dist/image-DwrOnL_Z.d.ts +14 -0
- package/dist/image-m_rfpuY8.d.cts +14 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/{list-BJVehfU8.d.ts → list-7hZydHAV.d.ts} +1 -1
- package/dist/{list-BzcN-LTJ.d.cts → list-DXRaCcT1.d.cts} +1 -1
- package/dist/odf/formula/detect.cjs +2 -15
- package/dist/odf/formula/detect.js +2 -15
- package/dist/odf/image/detect.cjs +48 -0
- package/dist/odf/image/detect.d.cts +10 -0
- package/dist/odf/image/detect.d.ts +10 -0
- package/dist/odf/image/detect.js +47 -0
- package/dist/odf/odt/read.cjs +65 -11
- package/dist/odf/odt/read.js +65 -11
- package/dist/odf/shared/flow-anchor.cjs +19 -0
- package/dist/odf/shared/flow-anchor.d.cts +6 -0
- package/dist/odf/shared/flow-anchor.d.ts +6 -0
- package/dist/odf/shared/flow-anchor.js +18 -0
- package/dist/{paragraph-BXbXKPy3.d.cts → paragraph-Dlly6_E9.d.cts} +2 -0
- package/dist/{paragraph-CjtZP77X.d.ts → paragraph-kMJVZhAi.d.ts} +2 -0
- package/dist/{shape-C8qDhn0l.d.cts → shape-BR8GL8XC.d.cts} +2 -2
- package/dist/{shape-GV8i37zL.d.ts → shape-DeP-P4Nh.d.ts} +2 -2
- package/dist/{table-Vf6nCixr.d.ts → table-kvclAXS5.d.ts} +1 -1
- package/dist/{table-DjYcNOFm.d.cts → table-sEo1Jf8c.d.cts} +1 -1
- package/package.json +2 -2
package/dist/edit/odg/page.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as ImageInit } from "../../image-M5SezZVI.cjs";
|
|
2
|
-
import { t as OdpShape } from "../../shape-
|
|
2
|
+
import { t as OdpShape } from "../../shape-BR8GL8XC.cjs";
|
|
3
3
|
import { a as OdgLineVector, l as PathVectorInit, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as OdgVector, t as BoxVectorInit } from "../../vector-D03KX8Ux.cjs";
|
|
4
4
|
import { Box, ContentVector } from "document-schema.js";
|
|
5
5
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
package/dist/edit/odg/page.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as ImageInit } from "../../image-DHcA9kaK.js";
|
|
2
|
-
import { t as OdpShape } from "../../shape-
|
|
2
|
+
import { t as OdpShape } from "../../shape-DeP-P4Nh.js";
|
|
3
3
|
import { a as OdgLineVector, l as PathVectorInit, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as OdgVector, t as BoxVectorInit } from "../../vector-D03KX8Ux.js";
|
|
4
4
|
import { Box, ContentVector } from "document-schema.js";
|
|
5
5
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-
|
|
1
|
+
import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-BR8GL8XC.cjs";
|
|
2
2
|
export { OdpShape, buildImageFrame, buildTableFrame, buildTextBoxFrame };
|
package/dist/edit/odp/shape.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-
|
|
1
|
+
import { i as buildTextBoxFrame, n as buildImageFrame, r as buildTableFrame, t as OdpShape } from "../../shape-DeP-P4Nh.js";
|
|
2
2
|
export { OdpShape, buildImageFrame, buildTableFrame, buildTextBoxFrame };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
|
|
2
2
|
import { t as ImageInit } from "../../image-M5SezZVI.cjs";
|
|
3
|
-
import { t as OdpShape } from "../../shape-
|
|
3
|
+
import { t as OdpShape } from "../../shape-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-sEo1Jf8c.cjs";
|
|
6
6
|
import { ContentVector } from "document-schema.js";
|
|
7
7
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
8
8
|
//#region src/edit/odp/slide.d.ts
|
package/dist/edit/odp/slide.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
|
|
2
2
|
import { t as ImageInit } from "../../image-DHcA9kaK.js";
|
|
3
|
-
import { t as OdpShape } from "../../shape-
|
|
3
|
+
import { t as OdpShape } from "../../shape-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-kvclAXS5.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
|
|
@@ -5,6 +5,7 @@ const require_model_embedded_drawing = require("../../model/embedded-drawing.cjs
|
|
|
5
5
|
const require_model_formula = require("../../model/formula.cjs");
|
|
6
6
|
const require_edit_odt_scaffold = require("./scaffold.cjs");
|
|
7
7
|
const require_edit_odt_editor = require("./editor.cjs");
|
|
8
|
+
let odf_js = require("odf.js");
|
|
8
9
|
//#region src/edit/odt/content.ts
|
|
9
10
|
function buildOdtPackage(content, options) {
|
|
10
11
|
if (content.kind !== "wordprocessing") throw new Error("buildOdtPackage requires a wordprocessing ContentDocument");
|
|
@@ -17,6 +18,21 @@ function buildOdtPackage(content, options) {
|
|
|
17
18
|
});
|
|
18
19
|
return editor.toPackage();
|
|
19
20
|
}
|
|
21
|
+
function isMergeableImageParagraph(block) {
|
|
22
|
+
return block.kind === "paragraph" && block.list === void 0 && block.runs.every((run) => run.text === "");
|
|
23
|
+
}
|
|
24
|
+
function appendMergedImageParagraph(body, paragraphBlock, imageBlock) {
|
|
25
|
+
const paragraph = body.appendParagraph();
|
|
26
|
+
if (paragraphBlock.styleId !== void 0) paragraph.styleId = paragraphBlock.styleId;
|
|
27
|
+
if (paragraphBlock.alignment !== void 0) paragraph.alignment = paragraphBlock.alignment;
|
|
28
|
+
paragraph.insertImageAfter({
|
|
29
|
+
format: imageBlock.format,
|
|
30
|
+
bytes: (0, odf_js.base64ToBytes)(imageBlock.base64),
|
|
31
|
+
widthPt: imageBlock.widthPt,
|
|
32
|
+
heightPt: imageBlock.heightPt,
|
|
33
|
+
altText: imageBlock.altText
|
|
34
|
+
});
|
|
35
|
+
}
|
|
20
36
|
function appendBlocks(body, blocks) {
|
|
21
37
|
let i = 0;
|
|
22
38
|
while (i < blocks.length) {
|
|
@@ -25,6 +41,12 @@ function appendBlocks(body, blocks) {
|
|
|
25
41
|
i++;
|
|
26
42
|
continue;
|
|
27
43
|
}
|
|
44
|
+
const next = blocks[i + 1];
|
|
45
|
+
if (isMergeableImageParagraph(block) && next?.kind === "image") {
|
|
46
|
+
appendMergedImageParagraph(body, block, next);
|
|
47
|
+
i += 2;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
28
50
|
if (block.kind === "paragraph" && block.list !== void 0) {
|
|
29
51
|
const run = [];
|
|
30
52
|
while (i < blocks.length) {
|
|
@@ -86,6 +108,13 @@ function populateCellBlocks(cell, blocks) {
|
|
|
86
108
|
const [firstBlock, ...restBlocks] = blocks;
|
|
87
109
|
const firstParagraph = cell.paragraphs()[0];
|
|
88
110
|
if (firstBlock?.kind === "paragraph" && firstParagraph !== void 0) populateParagraph(firstParagraph, firstBlock);
|
|
111
|
+
else if (firstBlock?.kind === "image" && firstParagraph !== void 0) firstParagraph.insertImageAfter({
|
|
112
|
+
format: firstBlock.format,
|
|
113
|
+
bytes: (0, odf_js.base64ToBytes)(firstBlock.base64),
|
|
114
|
+
widthPt: firstBlock.widthPt,
|
|
115
|
+
heightPt: firstBlock.heightPt,
|
|
116
|
+
altText: firstBlock.altText
|
|
117
|
+
});
|
|
89
118
|
else if (firstBlock !== void 0) appendCellBlock(cell, firstBlock);
|
|
90
119
|
for (const remaining of restBlocks) appendCellBlock(cell, remaining);
|
|
91
120
|
}
|
|
@@ -135,9 +164,23 @@ function appendTable(body, block) {
|
|
|
135
164
|
}
|
|
136
165
|
function appendCellBlock(cell, block) {
|
|
137
166
|
if (block.kind === "paragraph") populateParagraph(cell.appendParagraph(), block);
|
|
167
|
+
else if (block.kind === "image") cell.appendParagraph().insertImageAfter({
|
|
168
|
+
format: block.format,
|
|
169
|
+
bytes: (0, odf_js.base64ToBytes)(block.base64),
|
|
170
|
+
widthPt: block.widthPt,
|
|
171
|
+
heightPt: block.heightPt,
|
|
172
|
+
altText: block.altText
|
|
173
|
+
});
|
|
138
174
|
}
|
|
139
175
|
function appendBlock(body, block) {
|
|
140
176
|
if (block.kind === "paragraph") populateParagraph(body.appendParagraph(), block);
|
|
177
|
+
else if (block.kind === "image") body.appendParagraph().insertImageAfter({
|
|
178
|
+
format: block.format,
|
|
179
|
+
bytes: (0, odf_js.base64ToBytes)(block.base64),
|
|
180
|
+
widthPt: block.widthPt,
|
|
181
|
+
heightPt: block.heightPt,
|
|
182
|
+
altText: block.altText
|
|
183
|
+
});
|
|
141
184
|
else if (block.kind === "pageBreak") body.appendPageBreak();
|
|
142
185
|
else if (block.kind === "table") appendTable(body, block);
|
|
143
186
|
else if (block.kind === "embeddedObject") appendEmbeddedObject(body, block);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClockPort } from "../../ports/clock.cjs";
|
|
2
|
-
import { t as OdtParagraph } from "../../paragraph-
|
|
3
|
-
import { t as OdtTable } from "../../table-
|
|
2
|
+
import { t as OdtParagraph } from "../../paragraph-Dlly6_E9.cjs";
|
|
3
|
+
import { t as OdtTable } from "../../table-sEo1Jf8c.cjs";
|
|
4
4
|
import { ContentDocument, ContentParagraph, ContentTable } from "document-schema.js";
|
|
5
5
|
import { Package } from "odf.js";
|
|
6
6
|
//#region src/edit/odt/content.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClockPort } from "../../ports/clock.js";
|
|
2
|
-
import { t as OdtParagraph } from "../../paragraph-
|
|
3
|
-
import { t as OdtTable } from "../../table-
|
|
2
|
+
import { t as OdtParagraph } from "../../paragraph-kMJVZhAi.js";
|
|
3
|
+
import { t as OdtTable } from "../../table-kvclAXS5.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
|
@@ -4,6 +4,7 @@ import { FLOW_CONTAINER_ORIGIN, drawingOfBlock, embeddedDrawingVectors } from ".
|
|
|
4
4
|
import { formulaOfBlock, formulaPlaceholderText } from "../../model/formula.js";
|
|
5
5
|
import { createEmptyOdtPackage } from "./scaffold.js";
|
|
6
6
|
import { OdtEditor } from "./editor.js";
|
|
7
|
+
import { base64ToBytes } from "odf.js";
|
|
7
8
|
//#region src/edit/odt/content.ts
|
|
8
9
|
function buildOdtPackage(content, options) {
|
|
9
10
|
if (content.kind !== "wordprocessing") throw new Error("buildOdtPackage requires a wordprocessing ContentDocument");
|
|
@@ -16,6 +17,21 @@ function buildOdtPackage(content, options) {
|
|
|
16
17
|
});
|
|
17
18
|
return editor.toPackage();
|
|
18
19
|
}
|
|
20
|
+
function isMergeableImageParagraph(block) {
|
|
21
|
+
return block.kind === "paragraph" && block.list === void 0 && block.runs.every((run) => run.text === "");
|
|
22
|
+
}
|
|
23
|
+
function appendMergedImageParagraph(body, paragraphBlock, imageBlock) {
|
|
24
|
+
const paragraph = body.appendParagraph();
|
|
25
|
+
if (paragraphBlock.styleId !== void 0) paragraph.styleId = paragraphBlock.styleId;
|
|
26
|
+
if (paragraphBlock.alignment !== void 0) paragraph.alignment = paragraphBlock.alignment;
|
|
27
|
+
paragraph.insertImageAfter({
|
|
28
|
+
format: imageBlock.format,
|
|
29
|
+
bytes: base64ToBytes(imageBlock.base64),
|
|
30
|
+
widthPt: imageBlock.widthPt,
|
|
31
|
+
heightPt: imageBlock.heightPt,
|
|
32
|
+
altText: imageBlock.altText
|
|
33
|
+
});
|
|
34
|
+
}
|
|
19
35
|
function appendBlocks(body, blocks) {
|
|
20
36
|
let i = 0;
|
|
21
37
|
while (i < blocks.length) {
|
|
@@ -24,6 +40,12 @@ function appendBlocks(body, blocks) {
|
|
|
24
40
|
i++;
|
|
25
41
|
continue;
|
|
26
42
|
}
|
|
43
|
+
const next = blocks[i + 1];
|
|
44
|
+
if (isMergeableImageParagraph(block) && next?.kind === "image") {
|
|
45
|
+
appendMergedImageParagraph(body, block, next);
|
|
46
|
+
i += 2;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
27
49
|
if (block.kind === "paragraph" && block.list !== void 0) {
|
|
28
50
|
const run = [];
|
|
29
51
|
while (i < blocks.length) {
|
|
@@ -85,6 +107,13 @@ function populateCellBlocks(cell, blocks) {
|
|
|
85
107
|
const [firstBlock, ...restBlocks] = blocks;
|
|
86
108
|
const firstParagraph = cell.paragraphs()[0];
|
|
87
109
|
if (firstBlock?.kind === "paragraph" && firstParagraph !== void 0) populateParagraph(firstParagraph, firstBlock);
|
|
110
|
+
else if (firstBlock?.kind === "image" && firstParagraph !== void 0) firstParagraph.insertImageAfter({
|
|
111
|
+
format: firstBlock.format,
|
|
112
|
+
bytes: base64ToBytes(firstBlock.base64),
|
|
113
|
+
widthPt: firstBlock.widthPt,
|
|
114
|
+
heightPt: firstBlock.heightPt,
|
|
115
|
+
altText: firstBlock.altText
|
|
116
|
+
});
|
|
88
117
|
else if (firstBlock !== void 0) appendCellBlock(cell, firstBlock);
|
|
89
118
|
for (const remaining of restBlocks) appendCellBlock(cell, remaining);
|
|
90
119
|
}
|
|
@@ -134,9 +163,23 @@ function appendTable(body, block) {
|
|
|
134
163
|
}
|
|
135
164
|
function appendCellBlock(cell, block) {
|
|
136
165
|
if (block.kind === "paragraph") populateParagraph(cell.appendParagraph(), block);
|
|
166
|
+
else if (block.kind === "image") cell.appendParagraph().insertImageAfter({
|
|
167
|
+
format: block.format,
|
|
168
|
+
bytes: base64ToBytes(block.base64),
|
|
169
|
+
widthPt: block.widthPt,
|
|
170
|
+
heightPt: block.heightPt,
|
|
171
|
+
altText: block.altText
|
|
172
|
+
});
|
|
137
173
|
}
|
|
138
174
|
function appendBlock(body, block) {
|
|
139
175
|
if (block.kind === "paragraph") populateParagraph(body.appendParagraph(), block);
|
|
176
|
+
else if (block.kind === "image") body.appendParagraph().insertImageAfter({
|
|
177
|
+
format: block.format,
|
|
178
|
+
bytes: base64ToBytes(block.base64),
|
|
179
|
+
widthPt: block.widthPt,
|
|
180
|
+
heightPt: block.heightPt,
|
|
181
|
+
altText: block.altText
|
|
182
|
+
});
|
|
140
183
|
else if (block.kind === "pageBreak") body.appendPageBreak();
|
|
141
184
|
else if (block.kind === "table") appendTable(body, block);
|
|
142
185
|
else if (block.kind === "embeddedObject") appendEmbeddedObject(body, block);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClockPort } from "../../ports/clock.cjs";
|
|
2
2
|
import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
|
|
3
|
-
import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-
|
|
4
|
-
import { t as OdtList } from "../../list-
|
|
5
|
-
import { i as TableInit, t as OdtTable } from "../../table-
|
|
3
|
+
import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-Dlly6_E9.cjs";
|
|
4
|
+
import { t as OdtList } from "../../list-DXRaCcT1.cjs";
|
|
5
|
+
import { i as TableInit, t as OdtTable } from "../../table-sEo1Jf8c.cjs";
|
|
6
6
|
import { ContentFormula, ContentVector } from "document-schema.js";
|
|
7
7
|
import { Package } from "odf.js";
|
|
8
8
|
//#region src/edit/odt/editor.d.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClockPort } from "../../ports/clock.js";
|
|
2
2
|
import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
|
|
3
|
-
import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-
|
|
4
|
-
import { t as OdtList } from "../../list-
|
|
5
|
-
import { i as TableInit, t as OdtTable } from "../../table-
|
|
3
|
+
import { n as ParagraphInit, t as OdtParagraph } from "../../paragraph-kMJVZhAi.js";
|
|
4
|
+
import { t as OdtList } from "../../list-7hZydHAV.js";
|
|
5
|
+
import { i as TableInit, t as OdtTable } from "../../table-kvclAXS5.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
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
|
+
const require_xml_odf_text = require("../../xml/odf-text.cjs");
|
|
4
|
+
const require_odf_package_media = require("../../odf-package/media.cjs");
|
|
5
|
+
let odf_js = require("odf.js");
|
|
6
|
+
//#region src/edit/odt/image.ts
|
|
7
|
+
function buildImageFrame(href, frame, altText) {
|
|
8
|
+
const children = [];
|
|
9
|
+
if (altText !== void 0) children.push(require_xml_fragment.el("svg:title", {}, require_xml_odf_text.encodeOdfText(altText)));
|
|
10
|
+
children.push(require_xml_fragment.el("draw:image", { "xlink:href": href }));
|
|
11
|
+
return require_xml_fragment.el("draw:frame", {
|
|
12
|
+
"text:anchor-type": "as-char",
|
|
13
|
+
"svg:width": (0, odf_js.formatOdfLength)(frame.widthPt),
|
|
14
|
+
"svg:height": (0, odf_js.formatOdfLength)(frame.heightPt)
|
|
15
|
+
}, children);
|
|
16
|
+
}
|
|
17
|
+
function insertImageFrameMedia(pkg, frame, image) {
|
|
18
|
+
const { partPath } = require_odf_package_media.addImageMedia(pkg, image.bytes, image.format);
|
|
19
|
+
return buildImageFrame(partPath, frame, image.altText);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.buildImageFrame = buildImageFrame;
|
|
23
|
+
exports.insertImageFrameMedia = insertImageFrameMedia;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { el } from "../../xml/fragment.js";
|
|
2
|
+
import { encodeOdfText } from "../../xml/odf-text.js";
|
|
3
|
+
import { addImageMedia } from "../../odf-package/media.js";
|
|
4
|
+
import { formatOdfLength } from "odf.js";
|
|
5
|
+
//#region src/edit/odt/image.ts
|
|
6
|
+
function buildImageFrame(href, frame, altText) {
|
|
7
|
+
const children = [];
|
|
8
|
+
if (altText !== void 0) children.push(el("svg:title", {}, encodeOdfText(altText)));
|
|
9
|
+
children.push(el("draw:image", { "xlink:href": href }));
|
|
10
|
+
return el("draw:frame", {
|
|
11
|
+
"text:anchor-type": "as-char",
|
|
12
|
+
"svg:width": formatOdfLength(frame.widthPt),
|
|
13
|
+
"svg:height": formatOdfLength(frame.heightPt)
|
|
14
|
+
}, children);
|
|
15
|
+
}
|
|
16
|
+
function insertImageFrameMedia(pkg, frame, image) {
|
|
17
|
+
const { partPath } = addImageMedia(pkg, image.bytes, image.format);
|
|
18
|
+
return buildImageFrame(partPath, frame, image.altText);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { buildImageFrame, insertImageFrameMedia };
|
package/dist/edit/odt/list.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-
|
|
1
|
+
import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-DXRaCcT1.cjs";
|
|
2
2
|
export { OdtList, OdtListItem, buildList };
|
package/dist/edit/odt/list.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-
|
|
1
|
+
import { n as OdtListItem, r as buildList, t as OdtList } from "../../list-7hZydHAV.js";
|
|
2
2
|
export { OdtList, OdtListItem, buildList };
|
|
@@ -2,6 +2,7 @@ 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_xml_odf_text = require("../../xml/odf-text.cjs");
|
|
5
|
+
const require_edit_odt_image = require("./image.cjs");
|
|
5
6
|
const require_edit_odt_props = require("./props.cjs");
|
|
6
7
|
const require_edit_odt_run = require("./run.cjs");
|
|
7
8
|
let ooxml_js = require("ooxml.js");
|
|
@@ -66,6 +67,16 @@ var OdtParagraph = class {
|
|
|
66
67
|
set alignment(value) {
|
|
67
68
|
require_edit_odt_props.applyStyleChange(this.pkg, this.live(), "paragraph", { alignment: value });
|
|
68
69
|
}
|
|
70
|
+
insertImageAfter(image) {
|
|
71
|
+
const node = this.live();
|
|
72
|
+
const frame = {
|
|
73
|
+
xPt: 0,
|
|
74
|
+
yPt: 0,
|
|
75
|
+
widthPt: image.widthPt,
|
|
76
|
+
heightPt: image.heightPt
|
|
77
|
+
};
|
|
78
|
+
node.children.push(require_edit_odt_image.insertImageFrameMedia(this.pkg, frame, image));
|
|
79
|
+
}
|
|
69
80
|
remove() {
|
|
70
81
|
require_xml_edit.removeChild(this.container, this.live());
|
|
71
82
|
this.removed = true;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as ParagraphInit, r as buildParagraph, t as OdtParagraph } from "../../paragraph-
|
|
1
|
+
import { n as ParagraphInit, r as buildParagraph, t as OdtParagraph } from "../../paragraph-Dlly6_E9.cjs";
|
|
2
2
|
export { OdtParagraph, ParagraphInit, buildParagraph };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as ParagraphInit, r as buildParagraph, t as OdtParagraph } from "../../paragraph-
|
|
1
|
+
import { n as ParagraphInit, r as buildParagraph, t as OdtParagraph } from "../../paragraph-kMJVZhAi.js";
|
|
2
2
|
export { OdtParagraph, ParagraphInit, buildParagraph };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { el } from "../../xml/fragment.js";
|
|
2
2
|
import { removeAttr, removeChild, setAttr } from "../../xml/edit.js";
|
|
3
3
|
import { decodeOdfText } from "../../xml/odf-text.js";
|
|
4
|
+
import { insertImageFrameMedia } from "./image.js";
|
|
4
5
|
import { applyStyleChange, readCurrentStyleProperties } from "./props.js";
|
|
5
6
|
import { OdtRun, buildRun } from "./run.js";
|
|
6
7
|
import { attr } from "ooxml.js";
|
|
@@ -65,6 +66,16 @@ var OdtParagraph = class {
|
|
|
65
66
|
set alignment(value) {
|
|
66
67
|
applyStyleChange(this.pkg, this.live(), "paragraph", { alignment: value });
|
|
67
68
|
}
|
|
69
|
+
insertImageAfter(image) {
|
|
70
|
+
const node = this.live();
|
|
71
|
+
const frame = {
|
|
72
|
+
xPt: 0,
|
|
73
|
+
yPt: 0,
|
|
74
|
+
widthPt: image.widthPt,
|
|
75
|
+
heightPt: image.heightPt
|
|
76
|
+
};
|
|
77
|
+
node.children.push(insertImageFrameMedia(this.pkg, frame, image));
|
|
78
|
+
}
|
|
68
79
|
remove() {
|
|
69
80
|
removeChild(this.container, this.live());
|
|
70
81
|
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-sEo1Jf8c.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-kvclAXS5.js";
|
|
2
2
|
export { OdtTable, OdtTableCell, OdtTableRow, TableInit, buildTable };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { t as Box } from "./geometry-DaJr8yQW.js";
|
|
2
|
+
import { Package, XmlElement } from "odf.js";
|
|
3
|
+
//#region src/edit/odt/image.d.ts
|
|
4
|
+
interface ImageInit {
|
|
5
|
+
readonly format: 'png' | 'jpeg';
|
|
6
|
+
readonly bytes: Uint8Array<ArrayBuffer>;
|
|
7
|
+
readonly widthPt: number;
|
|
8
|
+
readonly heightPt: number;
|
|
9
|
+
readonly altText?: string;
|
|
10
|
+
}
|
|
11
|
+
declare function buildImageFrame(href: string, frame: Box, altText?: string): XmlElement;
|
|
12
|
+
declare function insertImageFrameMedia(pkg: Package, frame: Box, image: ImageInit): XmlElement;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { buildImageFrame as n, insertImageFrameMedia as r, ImageInit as t };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { t as Box } from "./geometry-DaJr8yQW.cjs";
|
|
2
|
+
import { Package, XmlElement } from "odf.js";
|
|
3
|
+
//#region src/edit/odt/image.d.ts
|
|
4
|
+
interface ImageInit {
|
|
5
|
+
readonly format: 'png' | 'jpeg';
|
|
6
|
+
readonly bytes: Uint8Array<ArrayBuffer>;
|
|
7
|
+
readonly widthPt: number;
|
|
8
|
+
readonly heightPt: number;
|
|
9
|
+
readonly altText?: string;
|
|
10
|
+
}
|
|
11
|
+
declare function buildImageFrame(href: string, frame: Box, altText?: string): XmlElement;
|
|
12
|
+
declare function insertImageFrameMedia(pkg: Package, frame: Box, image: ImageInit): XmlElement;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { buildImageFrame as n, insertImageFrameMedia as r, ImageInit as t };
|
package/dist/index.d.cts
CHANGED
|
@@ -20,15 +20,15 @@ import { a as PAGE_SIZE_A4, d as flipY, l as SLIDE_SIZE_STANDARD, o as PAGE_SIZE
|
|
|
20
20
|
import { BuildOdgPackageOptions, buildOdgPackage } from "./edit/odg/content.cjs";
|
|
21
21
|
import { i as LayoutFont, r as DEFAULT_LAYOUT_FONT, t as Alignment } from "./style-DkamR3aY.cjs";
|
|
22
22
|
import { n as RunInit, t as OdtRun } from "./run-F8JN7Vy4.cjs";
|
|
23
|
-
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-
|
|
24
|
-
import { n as OdtListItem, t as OdtList } from "./list-
|
|
25
|
-
import { t as OdpShape } from "./shape-
|
|
23
|
+
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-Dlly6_E9.cjs";
|
|
24
|
+
import { n as OdtListItem, t as OdtList } from "./list-DXRaCcT1.cjs";
|
|
25
|
+
import { t as OdpShape } from "./shape-BR8GL8XC.cjs";
|
|
26
26
|
import { a as OdgLineVector, c as OdgVectorKind, l as PathVectorInit, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as OdgVector, t as BoxVectorInit } from "./vector-D03KX8Ux.cjs";
|
|
27
27
|
import { OdgPage, PageImageInit, TextBoxInit } from "./edit/odg/page.cjs";
|
|
28
28
|
import { CreateOdgOptions, OdgEditor, createOdg, openOdg } from "./edit/odg/editor.cjs";
|
|
29
29
|
import { CreateEmptyOdgPackageOptions } from "./edit/odg/scaffold.cjs";
|
|
30
30
|
import { BuildOdpPackageOptions, buildOdpPackage } from "./edit/odp/content.cjs";
|
|
31
|
-
import { i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "./table-
|
|
31
|
+
import { i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "./table-sEo1Jf8c.cjs";
|
|
32
32
|
import { OdpSlide, SlideImageInit, SlideTableInit, TextBoxInit as TextBoxInit$1 } from "./edit/odp/slide.cjs";
|
|
33
33
|
import { CreateOdpOptions, OdpEditor, createOdp, openOdp } from "./edit/odp/editor.cjs";
|
|
34
34
|
import { CreateEmptyOdpPackageOptions } from "./edit/odp/scaffold.cjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -20,15 +20,15 @@ import { a as PAGE_SIZE_A4, d as flipY, l as SLIDE_SIZE_STANDARD, o as PAGE_SIZE
|
|
|
20
20
|
import { BuildOdgPackageOptions, buildOdgPackage } from "./edit/odg/content.js";
|
|
21
21
|
import { i as LayoutFont, r as DEFAULT_LAYOUT_FONT, t as Alignment } from "./style-DkamR3aY.js";
|
|
22
22
|
import { n as RunInit, t as OdtRun } from "./run-wB22_F5w.js";
|
|
23
|
-
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-
|
|
24
|
-
import { n as OdtListItem, t as OdtList } from "./list-
|
|
25
|
-
import { t as OdpShape } from "./shape-
|
|
23
|
+
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-kMJVZhAi.js";
|
|
24
|
+
import { n as OdtListItem, t as OdtList } from "./list-7hZydHAV.js";
|
|
25
|
+
import { t as OdpShape } from "./shape-DeP-P4Nh.js";
|
|
26
26
|
import { a as OdgLineVector, c as OdgVectorKind, l as PathVectorInit, n as LineVectorInit, o as OdgPathVector, r as OdgBoxVector, s as OdgVector, t as BoxVectorInit } from "./vector-D03KX8Ux.js";
|
|
27
27
|
import { OdgPage, PageImageInit, TextBoxInit } from "./edit/odg/page.js";
|
|
28
28
|
import { CreateOdgOptions, OdgEditor, createOdg, openOdg } from "./edit/odg/editor.js";
|
|
29
29
|
import { CreateEmptyOdgPackageOptions } from "./edit/odg/scaffold.js";
|
|
30
30
|
import { BuildOdpPackageOptions, buildOdpPackage } from "./edit/odp/content.js";
|
|
31
|
-
import { i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "./table-
|
|
31
|
+
import { i as TableInit, n as OdtTableCell, r as OdtTableRow, t as OdtTable } from "./table-kvclAXS5.js";
|
|
32
32
|
import { OdpSlide, SlideImageInit, SlideTableInit, TextBoxInit as TextBoxInit$1 } from "./edit/odp/slide.js";
|
|
33
33
|
import { CreateOdpOptions, OdpEditor, createOdp, openOdp } from "./edit/odp/editor.js";
|
|
34
34
|
import { CreateEmptyOdpPackageOptions } from "./edit/odp/scaffold.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-
|
|
1
|
+
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-kMJVZhAi.js";
|
|
2
2
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
3
3
|
//#region src/edit/odt/list.d.ts
|
|
4
4
|
declare class OdtListItem {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-
|
|
1
|
+
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-Dlly6_E9.cjs";
|
|
2
2
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
3
3
|
//#region src/edit/odt/list.d.ts
|
|
4
4
|
declare class OdtListItem {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_odf_shared_flow_anchor = require("../shared/flow-anchor.cjs");
|
|
2
3
|
const require_odf_formula_read = require("./read.cjs");
|
|
3
4
|
let odf_js = require("odf.js");
|
|
4
5
|
//#region src/odf/formula/detect.ts
|
|
@@ -12,20 +13,6 @@ function formulaOfFrame(frame, pkg) {
|
|
|
12
13
|
if (href === void 0) return;
|
|
13
14
|
return require_odf_formula_read.readOdfEmbeddedFormula(pkg, subPackagePathFromHref(href));
|
|
14
15
|
}
|
|
15
|
-
function flowAnchoredFrameBox(frame) {
|
|
16
|
-
const widthValue = (0, odf_js.attrValue)(frame, "svg:width");
|
|
17
|
-
const heightValue = (0, odf_js.attrValue)(frame, "svg:height");
|
|
18
|
-
if (widthValue === void 0 || heightValue === void 0) return;
|
|
19
|
-
const widthPt = (0, odf_js.parseOdfLength)(widthValue);
|
|
20
|
-
const heightPt = (0, odf_js.parseOdfLength)(heightValue);
|
|
21
|
-
if (widthPt === void 0 || heightPt === void 0) return;
|
|
22
|
-
return {
|
|
23
|
-
xPt: 0,
|
|
24
|
-
yPt: 0,
|
|
25
|
-
widthPt,
|
|
26
|
-
heightPt
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
16
|
function nestedGroupFunctions(group, groupFunctions) {
|
|
30
17
|
const value = (0, odf_js.attrValue)(group, "draw:transform");
|
|
31
18
|
const own = value === void 0 ? [] : (0, odf_js.parseOdfTransform)(value);
|
|
@@ -34,7 +21,7 @@ function nestedGroupFunctions(group, groupFunctions) {
|
|
|
34
21
|
function readFormulaFrame(frame, groupFunctions, pkg, allowFlowAnchored) {
|
|
35
22
|
const formula = formulaOfFrame(frame, pkg);
|
|
36
23
|
if (formula === void 0) return;
|
|
37
|
-
const box = (0, odf_js.readDrawFrame)(frame, groupFunctions, pkg)?.frame ?? (allowFlowAnchored ? flowAnchoredFrameBox(frame) : void 0);
|
|
24
|
+
const box = (0, odf_js.readDrawFrame)(frame, groupFunctions, pkg)?.frame ?? (allowFlowAnchored ? require_odf_shared_flow_anchor.flowAnchoredFrameBox(frame) : void 0);
|
|
38
25
|
if (box === void 0) return;
|
|
39
26
|
return {
|
|
40
27
|
frameElement: frame,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { flowAnchoredFrameBox } from "../shared/flow-anchor.js";
|
|
1
2
|
import { readOdfEmbeddedFormula } from "./read.js";
|
|
2
|
-
import { attrValue, childrenWithTag,
|
|
3
|
+
import { attrValue, childrenWithTag, parseOdfTransform, readDrawFrame } from "odf.js";
|
|
3
4
|
//#region src/odf/formula/detect.ts
|
|
4
5
|
function subPackagePathFromHref(href) {
|
|
5
6
|
return href.replace(/^#?\.\//, "");
|
|
@@ -11,20 +12,6 @@ function formulaOfFrame(frame, pkg) {
|
|
|
11
12
|
if (href === void 0) return;
|
|
12
13
|
return readOdfEmbeddedFormula(pkg, subPackagePathFromHref(href));
|
|
13
14
|
}
|
|
14
|
-
function flowAnchoredFrameBox(frame) {
|
|
15
|
-
const widthValue = attrValue(frame, "svg:width");
|
|
16
|
-
const heightValue = attrValue(frame, "svg:height");
|
|
17
|
-
if (widthValue === void 0 || heightValue === void 0) return;
|
|
18
|
-
const widthPt = parseOdfLength(widthValue);
|
|
19
|
-
const heightPt = parseOdfLength(heightValue);
|
|
20
|
-
if (widthPt === void 0 || heightPt === void 0) return;
|
|
21
|
-
return {
|
|
22
|
-
xPt: 0,
|
|
23
|
-
yPt: 0,
|
|
24
|
-
widthPt,
|
|
25
|
-
heightPt
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
15
|
function nestedGroupFunctions(group, groupFunctions) {
|
|
29
16
|
const value = attrValue(group, "draw:transform");
|
|
30
17
|
const own = value === void 0 ? [] : parseOdfTransform(value);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_odf_shared_flow_anchor = require("../shared/flow-anchor.cjs");
|
|
3
|
+
let odf_js = require("odf.js");
|
|
4
|
+
//#region src/odf/image/detect.ts
|
|
5
|
+
function nestedGroupFunctions(group, groupFunctions) {
|
|
6
|
+
const value = (0, odf_js.attrValue)(group, "draw:transform");
|
|
7
|
+
const own = value === void 0 ? [] : (0, odf_js.parseOdfTransform)(value);
|
|
8
|
+
return own.length === 0 ? groupFunctions : [...own, ...groupFunctions];
|
|
9
|
+
}
|
|
10
|
+
function readImageFrame(frame, groupFunctions, pkg, allowFlowAnchored) {
|
|
11
|
+
if ((0, odf_js.childrenWithTag)(frame, "draw:object")[0] !== void 0) return;
|
|
12
|
+
const imageElement = (0, odf_js.childrenWithTag)(frame, "draw:image")[0];
|
|
13
|
+
if (imageElement === void 0) return;
|
|
14
|
+
const box = (0, odf_js.readDrawFrame)(frame, groupFunctions, pkg)?.frame ?? (allowFlowAnchored ? require_odf_shared_flow_anchor.flowAnchoredFrameBox(frame) : void 0);
|
|
15
|
+
if (box === void 0) return;
|
|
16
|
+
const image = (0, odf_js.readDrawImageBlock)(imageElement, frame, box, pkg);
|
|
17
|
+
if (image === void 0) return;
|
|
18
|
+
return {
|
|
19
|
+
frameElement: frame,
|
|
20
|
+
image
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function walkForImageFrames(nodes, groupFunctions, pkg, out) {
|
|
24
|
+
for (const node of nodes) {
|
|
25
|
+
if (node.type !== "element") continue;
|
|
26
|
+
if (node.tag === "draw:frame") {
|
|
27
|
+
const detected = readImageFrame(node, groupFunctions, pkg, true);
|
|
28
|
+
if (detected !== void 0) {
|
|
29
|
+
out.push(detected);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
walkForImageFrames(node.children, groupFunctions, pkg, out);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (node.tag === "draw:g") {
|
|
36
|
+
walkForImageFrames(node.children, nestedGroupFunctions(node, groupFunctions), pkg, out);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
walkForImageFrames(node.children, groupFunctions, pkg, out);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function collectImageFrames(nodes, pkg) {
|
|
43
|
+
const out = [];
|
|
44
|
+
walkForImageFrames(nodes, [], pkg, out);
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
exports.collectImageFrames = collectImageFrames;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ContentImageBlock } from "document-schema.js";
|
|
2
|
+
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
3
|
+
//#region src/odf/image/detect.d.ts
|
|
4
|
+
interface DetectedImageFrame {
|
|
5
|
+
readonly frameElement: XmlElement;
|
|
6
|
+
readonly image: ContentImageBlock;
|
|
7
|
+
}
|
|
8
|
+
declare function collectImageFrames(nodes: readonly XmlNode[], pkg: Package): readonly DetectedImageFrame[];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { DetectedImageFrame, collectImageFrames };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ContentImageBlock } from "document-schema.js";
|
|
2
|
+
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
3
|
+
//#region src/odf/image/detect.d.ts
|
|
4
|
+
interface DetectedImageFrame {
|
|
5
|
+
readonly frameElement: XmlElement;
|
|
6
|
+
readonly image: ContentImageBlock;
|
|
7
|
+
}
|
|
8
|
+
declare function collectImageFrames(nodes: readonly XmlNode[], pkg: Package): readonly DetectedImageFrame[];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { DetectedImageFrame, collectImageFrames };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { flowAnchoredFrameBox } from "../shared/flow-anchor.js";
|
|
2
|
+
import { attrValue, childrenWithTag, parseOdfTransform, readDrawFrame, readDrawImageBlock } from "odf.js";
|
|
3
|
+
//#region src/odf/image/detect.ts
|
|
4
|
+
function nestedGroupFunctions(group, groupFunctions) {
|
|
5
|
+
const value = attrValue(group, "draw:transform");
|
|
6
|
+
const own = value === void 0 ? [] : parseOdfTransform(value);
|
|
7
|
+
return own.length === 0 ? groupFunctions : [...own, ...groupFunctions];
|
|
8
|
+
}
|
|
9
|
+
function readImageFrame(frame, groupFunctions, pkg, allowFlowAnchored) {
|
|
10
|
+
if (childrenWithTag(frame, "draw:object")[0] !== void 0) return;
|
|
11
|
+
const imageElement = childrenWithTag(frame, "draw:image")[0];
|
|
12
|
+
if (imageElement === void 0) return;
|
|
13
|
+
const box = readDrawFrame(frame, groupFunctions, pkg)?.frame ?? (allowFlowAnchored ? flowAnchoredFrameBox(frame) : void 0);
|
|
14
|
+
if (box === void 0) return;
|
|
15
|
+
const image = readDrawImageBlock(imageElement, frame, box, pkg);
|
|
16
|
+
if (image === void 0) return;
|
|
17
|
+
return {
|
|
18
|
+
frameElement: frame,
|
|
19
|
+
image
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function walkForImageFrames(nodes, groupFunctions, pkg, out) {
|
|
23
|
+
for (const node of nodes) {
|
|
24
|
+
if (node.type !== "element") continue;
|
|
25
|
+
if (node.tag === "draw:frame") {
|
|
26
|
+
const detected = readImageFrame(node, groupFunctions, pkg, true);
|
|
27
|
+
if (detected !== void 0) {
|
|
28
|
+
out.push(detected);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
walkForImageFrames(node.children, groupFunctions, pkg, out);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (node.tag === "draw:g") {
|
|
35
|
+
walkForImageFrames(node.children, nestedGroupFunctions(node, groupFunctions), pkg, out);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
walkForImageFrames(node.children, groupFunctions, pkg, out);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function collectImageFrames(nodes, pkg) {
|
|
42
|
+
const out = [];
|
|
43
|
+
walkForImageFrames(nodes, [], pkg, out);
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { collectImageFrames };
|
package/dist/odf/odt/read.cjs
CHANGED
|
@@ -3,6 +3,7 @@ const require_model_embedded_drawing = require("../../model/embedded-drawing.cjs
|
|
|
3
3
|
const require_model_formula = require("../../model/formula.cjs");
|
|
4
4
|
const require_model_block_splice = require("../../model/block-splice.cjs");
|
|
5
5
|
const require_odf_formula_detect = require("../formula/detect.cjs");
|
|
6
|
+
const require_odf_image_detect = require("../image/detect.cjs");
|
|
6
7
|
const require_odf_vector_detect = require("../vector/detect.cjs");
|
|
7
8
|
let document_schema_js = require("document-schema.js");
|
|
8
9
|
let odf_js = require("odf.js");
|
|
@@ -18,17 +19,28 @@ function readOdtContent(pkg) {
|
|
|
18
19
|
const section = odtDoc.sections[0];
|
|
19
20
|
const { placements: formulaPlacements, consumedBlockIndices: formulaConsumed } = collectFormulaPlacements(text.children, pkg);
|
|
20
21
|
const { placements: vectorPlacements, consumedBlockIndices: vectorConsumed } = collectVectorPlacements(text.children, pkg);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
const { placements: imagePlacements } = collectImagePlacements(text.children, pkg);
|
|
23
|
+
if (formulaPlacements.length > 0 || vectorPlacements.length > 0 || imagePlacements.length > 0) {
|
|
24
|
+
const combined = [
|
|
25
|
+
...formulaPlacements.map((placement) => ({
|
|
26
|
+
index: placement.index,
|
|
27
|
+
build: (sourcePath) => require_model_formula.buildFormulaBlock(placement.detected.formula, placement.detected.frame, sourcePath)
|
|
28
|
+
})),
|
|
29
|
+
...vectorPlacements.map((placement) => ({
|
|
30
|
+
index: placement.index,
|
|
31
|
+
build: (sourcePath) => ({
|
|
32
|
+
...require_model_embedded_drawing.buildDrawingBlock(section.pageSize, placement.vectors),
|
|
33
|
+
sourcePath
|
|
34
|
+
})
|
|
35
|
+
})),
|
|
36
|
+
...imagePlacements.map((placement) => ({
|
|
37
|
+
index: placement.index,
|
|
38
|
+
build: (sourcePath) => ({
|
|
39
|
+
...placement.detected.image,
|
|
40
|
+
sourcePath
|
|
41
|
+
})
|
|
42
|
+
}))
|
|
43
|
+
].sort((a, b) => a.index - b.index);
|
|
32
44
|
const consumedBlockIndices = /* @__PURE__ */ new Set([...formulaConsumed, ...vectorConsumed]);
|
|
33
45
|
odtDoc.sections[0] = {
|
|
34
46
|
...section,
|
|
@@ -166,5 +178,47 @@ function walkListForVectorPlacements(itemNodes, pkg, state) {
|
|
|
166
178
|
}
|
|
167
179
|
}
|
|
168
180
|
}
|
|
181
|
+
function pushImagePlacements(out, index, detected) {
|
|
182
|
+
for (const frame of detected) out.push({
|
|
183
|
+
index,
|
|
184
|
+
detected: frame
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function pushImageParagraphPlacement(node, pkg, state) {
|
|
188
|
+
const detected = require_odf_image_detect.collectImageFrames(node.children, pkg);
|
|
189
|
+
state.blockCount += 1;
|
|
190
|
+
pushImagePlacements(state.placements, state.blockCount, detected);
|
|
191
|
+
}
|
|
192
|
+
function collectImagePlacements(nodes, pkg) {
|
|
193
|
+
const state = {
|
|
194
|
+
blockCount: 0,
|
|
195
|
+
placements: []
|
|
196
|
+
};
|
|
197
|
+
walkForImagePlacements(nodes, pkg, state);
|
|
198
|
+
return { placements: state.placements };
|
|
199
|
+
}
|
|
200
|
+
function walkForImagePlacements(nodes, pkg, state) {
|
|
201
|
+
for (const node of nodes) {
|
|
202
|
+
if (node.type !== "element") continue;
|
|
203
|
+
if (node.tag === "text:p" || node.tag === "text:h") pushImageParagraphPlacement(node, pkg, state);
|
|
204
|
+
else if (node.tag === "text:list") walkListForImagePlacements(node.children, pkg, state);
|
|
205
|
+
else if (node.tag === "table:table") {
|
|
206
|
+
state.blockCount += 1;
|
|
207
|
+
pushImagePlacements(state.placements, state.blockCount, require_odf_image_detect.collectImageFrames(node.children, pkg));
|
|
208
|
+
} else if (node.tag === "text:section") walkForImagePlacements(node.children, pkg, state);
|
|
209
|
+
else pushImagePlacements(state.placements, state.blockCount, require_odf_image_detect.collectImageFrames([node], pkg));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function walkListForImagePlacements(itemNodes, pkg, state) {
|
|
213
|
+
for (const item of itemNodes) {
|
|
214
|
+
if (item.type !== "element" || item.tag !== "text:list-item") continue;
|
|
215
|
+
for (const itemChild of item.children) {
|
|
216
|
+
if (itemChild.type !== "element") continue;
|
|
217
|
+
if (itemChild.tag === "text:p" || itemChild.tag === "text:h") pushImageParagraphPlacement(itemChild, pkg, state);
|
|
218
|
+
else if (itemChild.tag === "text:list") walkListForImagePlacements(itemChild.children, pkg, state);
|
|
219
|
+
else pushImagePlacements(state.placements, state.blockCount, require_odf_image_detect.collectImageFrames([itemChild], pkg));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
169
223
|
//#endregion
|
|
170
224
|
exports.readOdtContent = readOdtContent;
|
package/dist/odf/odt/read.js
CHANGED
|
@@ -2,6 +2,7 @@ import { buildDrawingBlock } from "../../model/embedded-drawing.js";
|
|
|
2
2
|
import { buildFormulaBlock } from "../../model/formula.js";
|
|
3
3
|
import { spliceBlocks } from "../../model/block-splice.js";
|
|
4
4
|
import { collectFormulaFrames } from "../formula/detect.js";
|
|
5
|
+
import { collectImageFrames } from "../image/detect.js";
|
|
5
6
|
import { collectContainerVectors, isVectorElementTag } from "../vector/detect.js";
|
|
6
7
|
import { CONTENT_FORMAT_VERSION } from "document-schema.js";
|
|
7
8
|
import { findChildElement, readOdt, rootElement } from "odf.js";
|
|
@@ -17,17 +18,28 @@ function readOdtContent(pkg) {
|
|
|
17
18
|
const section = odtDoc.sections[0];
|
|
18
19
|
const { placements: formulaPlacements, consumedBlockIndices: formulaConsumed } = collectFormulaPlacements(text.children, pkg);
|
|
19
20
|
const { placements: vectorPlacements, consumedBlockIndices: vectorConsumed } = collectVectorPlacements(text.children, pkg);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
const { placements: imagePlacements } = collectImagePlacements(text.children, pkg);
|
|
22
|
+
if (formulaPlacements.length > 0 || vectorPlacements.length > 0 || imagePlacements.length > 0) {
|
|
23
|
+
const combined = [
|
|
24
|
+
...formulaPlacements.map((placement) => ({
|
|
25
|
+
index: placement.index,
|
|
26
|
+
build: (sourcePath) => buildFormulaBlock(placement.detected.formula, placement.detected.frame, sourcePath)
|
|
27
|
+
})),
|
|
28
|
+
...vectorPlacements.map((placement) => ({
|
|
29
|
+
index: placement.index,
|
|
30
|
+
build: (sourcePath) => ({
|
|
31
|
+
...buildDrawingBlock(section.pageSize, placement.vectors),
|
|
32
|
+
sourcePath
|
|
33
|
+
})
|
|
34
|
+
})),
|
|
35
|
+
...imagePlacements.map((placement) => ({
|
|
36
|
+
index: placement.index,
|
|
37
|
+
build: (sourcePath) => ({
|
|
38
|
+
...placement.detected.image,
|
|
39
|
+
sourcePath
|
|
40
|
+
})
|
|
41
|
+
}))
|
|
42
|
+
].sort((a, b) => a.index - b.index);
|
|
31
43
|
const consumedBlockIndices = /* @__PURE__ */ new Set([...formulaConsumed, ...vectorConsumed]);
|
|
32
44
|
odtDoc.sections[0] = {
|
|
33
45
|
...section,
|
|
@@ -165,5 +177,47 @@ function walkListForVectorPlacements(itemNodes, pkg, state) {
|
|
|
165
177
|
}
|
|
166
178
|
}
|
|
167
179
|
}
|
|
180
|
+
function pushImagePlacements(out, index, detected) {
|
|
181
|
+
for (const frame of detected) out.push({
|
|
182
|
+
index,
|
|
183
|
+
detected: frame
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function pushImageParagraphPlacement(node, pkg, state) {
|
|
187
|
+
const detected = collectImageFrames(node.children, pkg);
|
|
188
|
+
state.blockCount += 1;
|
|
189
|
+
pushImagePlacements(state.placements, state.blockCount, detected);
|
|
190
|
+
}
|
|
191
|
+
function collectImagePlacements(nodes, pkg) {
|
|
192
|
+
const state = {
|
|
193
|
+
blockCount: 0,
|
|
194
|
+
placements: []
|
|
195
|
+
};
|
|
196
|
+
walkForImagePlacements(nodes, pkg, state);
|
|
197
|
+
return { placements: state.placements };
|
|
198
|
+
}
|
|
199
|
+
function walkForImagePlacements(nodes, pkg, state) {
|
|
200
|
+
for (const node of nodes) {
|
|
201
|
+
if (node.type !== "element") continue;
|
|
202
|
+
if (node.tag === "text:p" || node.tag === "text:h") pushImageParagraphPlacement(node, pkg, state);
|
|
203
|
+
else if (node.tag === "text:list") walkListForImagePlacements(node.children, pkg, state);
|
|
204
|
+
else if (node.tag === "table:table") {
|
|
205
|
+
state.blockCount += 1;
|
|
206
|
+
pushImagePlacements(state.placements, state.blockCount, collectImageFrames(node.children, pkg));
|
|
207
|
+
} else if (node.tag === "text:section") walkForImagePlacements(node.children, pkg, state);
|
|
208
|
+
else pushImagePlacements(state.placements, state.blockCount, collectImageFrames([node], pkg));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function walkListForImagePlacements(itemNodes, pkg, state) {
|
|
212
|
+
for (const item of itemNodes) {
|
|
213
|
+
if (item.type !== "element" || item.tag !== "text:list-item") continue;
|
|
214
|
+
for (const itemChild of item.children) {
|
|
215
|
+
if (itemChild.type !== "element") continue;
|
|
216
|
+
if (itemChild.tag === "text:p" || itemChild.tag === "text:h") pushImageParagraphPlacement(itemChild, pkg, state);
|
|
217
|
+
else if (itemChild.tag === "text:list") walkListForImagePlacements(itemChild.children, pkg, state);
|
|
218
|
+
else pushImagePlacements(state.placements, state.blockCount, collectImageFrames([itemChild], pkg));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
168
222
|
//#endregion
|
|
169
223
|
export { readOdtContent };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let odf_js = require("odf.js");
|
|
3
|
+
//#region src/odf/shared/flow-anchor.ts
|
|
4
|
+
function flowAnchoredFrameBox(frame) {
|
|
5
|
+
const widthValue = (0, odf_js.attrValue)(frame, "svg:width");
|
|
6
|
+
const heightValue = (0, odf_js.attrValue)(frame, "svg:height");
|
|
7
|
+
if (widthValue === void 0 || heightValue === void 0) return;
|
|
8
|
+
const widthPt = (0, odf_js.parseOdfLength)(widthValue);
|
|
9
|
+
const heightPt = (0, odf_js.parseOdfLength)(heightValue);
|
|
10
|
+
if (widthPt === void 0 || heightPt === void 0) return;
|
|
11
|
+
return {
|
|
12
|
+
xPt: 0,
|
|
13
|
+
yPt: 0,
|
|
14
|
+
widthPt,
|
|
15
|
+
heightPt
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.flowAnchoredFrameBox = flowAnchoredFrameBox;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { attrValue, parseOdfLength } from "odf.js";
|
|
2
|
+
//#region src/odf/shared/flow-anchor.ts
|
|
3
|
+
function flowAnchoredFrameBox(frame) {
|
|
4
|
+
const widthValue = attrValue(frame, "svg:width");
|
|
5
|
+
const heightValue = attrValue(frame, "svg:height");
|
|
6
|
+
if (widthValue === void 0 || heightValue === void 0) return;
|
|
7
|
+
const widthPt = parseOdfLength(widthValue);
|
|
8
|
+
const heightPt = parseOdfLength(heightValue);
|
|
9
|
+
if (widthPt === void 0 || heightPt === void 0) return;
|
|
10
|
+
return {
|
|
11
|
+
xPt: 0,
|
|
12
|
+
yPt: 0,
|
|
13
|
+
widthPt,
|
|
14
|
+
heightPt
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { flowAnchoredFrameBox };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as Alignment } from "./style-DkamR3aY.cjs";
|
|
2
|
+
import { t as ImageInit } from "./image-m_rfpuY8.cjs";
|
|
2
3
|
import { n as RunInit, t as OdtRun } from "./run-F8JN7Vy4.cjs";
|
|
3
4
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
4
5
|
//#region src/edit/odt/paragraph.d.ts
|
|
@@ -23,6 +24,7 @@ declare class OdtParagraph {
|
|
|
23
24
|
set styleId(value: string | undefined);
|
|
24
25
|
get alignment(): Alignment | undefined;
|
|
25
26
|
set alignment(value: Alignment | undefined);
|
|
27
|
+
insertImageAfter(image: ImageInit): void;
|
|
26
28
|
remove(): void;
|
|
27
29
|
}
|
|
28
30
|
declare function buildParagraph(pkg: Package, init?: ParagraphInit): XmlElement;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as Alignment } from "./style-DkamR3aY.js";
|
|
2
|
+
import { t as ImageInit } from "./image-DwrOnL_Z.js";
|
|
2
3
|
import { n as RunInit, t as OdtRun } from "./run-wB22_F5w.js";
|
|
3
4
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
4
5
|
//#region src/edit/odt/paragraph.d.ts
|
|
@@ -23,6 +24,7 @@ declare class OdtParagraph {
|
|
|
23
24
|
set styleId(value: string | undefined);
|
|
24
25
|
get alignment(): Alignment | undefined;
|
|
25
26
|
set alignment(value: Alignment | undefined);
|
|
27
|
+
insertImageAfter(image: ImageInit): void;
|
|
26
28
|
remove(): void;
|
|
27
29
|
}
|
|
28
30
|
declare function buildParagraph(pkg: Package, init?: ParagraphInit): XmlElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as Box } from "./geometry-DaJr8yQW.cjs";
|
|
2
|
-
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-
|
|
3
|
-
import { t as OdtList } from "./list-
|
|
2
|
+
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-Dlly6_E9.cjs";
|
|
3
|
+
import { t as OdtList } from "./list-DXRaCcT1.cjs";
|
|
4
4
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
5
5
|
//#region src/edit/odp/shape.d.ts
|
|
6
6
|
declare class OdpShape {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as Box } from "./geometry-DaJr8yQW.js";
|
|
2
|
-
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-
|
|
3
|
-
import { t as OdtList } from "./list-
|
|
2
|
+
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-kMJVZhAi.js";
|
|
3
|
+
import { t as OdtList } from "./list-7hZydHAV.js";
|
|
4
4
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
5
5
|
//#region src/edit/odp/shape.d.ts
|
|
6
6
|
declare class OdpShape {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-
|
|
1
|
+
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-kMJVZhAi.js";
|
|
2
2
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
3
3
|
//#region src/edit/odt/table.d.ts
|
|
4
4
|
interface TableInit {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-
|
|
1
|
+
import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-Dlly6_E9.cjs";
|
|
2
2
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
3
3
|
//#region src/edit/odt/table.d.ts
|
|
4
4
|
interface TableInit {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js.documents",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.71.0",
|
|
4
4
|
"description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"document-schema.js": "^2.2.4",
|
|
62
62
|
"fflate": "^0.8.3",
|
|
63
63
|
"markdown-codec": "^1.0.0",
|
|
64
|
-
"odf.js": "^2.
|
|
64
|
+
"odf.js": "^2.3.0",
|
|
65
65
|
"ooxml.js": "^2.6.10",
|
|
66
66
|
"pdf-codec": "^1.10.10",
|
|
67
67
|
"zod": "^4.4.3"
|