documents.js 1.70.1 → 1.72.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.cjs +15 -1
- package/dist/edit/odp/slide.d.cts +3 -2
- package/dist/edit/odp/slide.d.ts +3 -2
- package/dist/edit/odp/slide.js +15 -1
- 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/edit/pptx/slide.cjs +10 -0
- package/dist/edit/pptx/slide.d.cts +2 -1
- package/dist/edit/pptx/slide.d.ts +2 -1
- package/dist/edit/pptx/slide.js +11 -1
- package/dist/edit/pptx/table.cjs +7 -0
- package/dist/edit/pptx/table.d.cts +2 -2
- package/dist/edit/pptx/table.d.ts +2 -2
- package/dist/edit/pptx/table.js +7 -1
- package/dist/image-DwrOnL_Z.d.ts +14 -0
- package/dist/image-m_rfpuY8.d.cts +14 -0
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- 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-C3CPZ--2.d.cts → table-CfRjVOFN.d.cts} +2 -1
- package/dist/{table-Db91eorq.d.ts → table-L5SxKy8_.d.ts} +2 -1
- 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 +1 -1
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";
|
|
@@ -42,7 +42,7 @@ import { CreateOdtOptions, OdtBody, OdtEditor, createOdt, openOdt } from "./edit
|
|
|
42
42
|
import { CreateEmptyOdtPackageOptions } from "./edit/odt/scaffold.cjs";
|
|
43
43
|
import { BuildPptxPackageOptions, buildPptxPackage } from "./edit/pptx/content.cjs";
|
|
44
44
|
import { n as DrawingRunInit, r as PptxShape, t as DrawingParagraphInit } from "./shape-BhkP6HB8.cjs";
|
|
45
|
-
import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-
|
|
45
|
+
import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-CfRjVOFN.cjs";
|
|
46
46
|
import { PptxSlide, SlideImageInit as SlideImageInit$1, SlideTableInit as SlideTableInit$1, TextBoxInit as TextBoxInit$2 } from "./edit/pptx/slide.cjs";
|
|
47
47
|
import { CreatePptxOptions, PptxEditor, createPptx, openPptx } from "./edit/pptx/editor.cjs";
|
|
48
48
|
import { CreateEmptyPptxPackageOptions } from "./edit/pptx/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";
|
|
@@ -42,7 +42,7 @@ import { CreateOdtOptions, OdtBody, OdtEditor, createOdt, openOdt } from "./edit
|
|
|
42
42
|
import { CreateEmptyOdtPackageOptions } from "./edit/odt/scaffold.js";
|
|
43
43
|
import { BuildPptxPackageOptions, buildPptxPackage } from "./edit/pptx/content.js";
|
|
44
44
|
import { n as DrawingRunInit, r as PptxShape, t as DrawingParagraphInit } from "./shape-BjX3wlig.js";
|
|
45
|
-
import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-
|
|
45
|
+
import { i as PptxTableRow, n as PptxTableCell, r as PptxTableInit, t as PptxTable } from "./table-L5SxKy8_.js";
|
|
46
46
|
import { PptxSlide, SlideImageInit as SlideImageInit$1, SlideTableInit as SlideTableInit$1, TextBoxInit as TextBoxInit$2 } from "./edit/pptx/slide.js";
|
|
47
47
|
import { CreatePptxOptions, PptxEditor, createPptx, openPptx } from "./edit/pptx/editor.js";
|
|
48
48
|
import { CreateEmptyPptxPackageOptions } from "./edit/pptx/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 {
|
|
@@ -31,5 +31,6 @@ declare class PptxTable {
|
|
|
31
31
|
}
|
|
32
32
|
declare function buildDrawingTable(init: PptxTableInit): XmlElement;
|
|
33
33
|
declare function buildTableGraphicFrame(frame: Box, tableElement: XmlElement, shapeId: number, rotationDeg: number | undefined): XmlElement;
|
|
34
|
+
declare function findGraphicFrameTable(graphicFrame: XmlElement): XmlElement | undefined;
|
|
34
35
|
//#endregion
|
|
35
|
-
export { buildDrawingTable as a, PptxTableRow as i, PptxTableCell as n, buildTableGraphicFrame as o, PptxTableInit as r, PptxTable as t };
|
|
36
|
+
export { buildDrawingTable as a, PptxTableRow as i, PptxTableCell as n, buildTableGraphicFrame as o, PptxTableInit as r, findGraphicFrameTable as s, PptxTable as t };
|
|
@@ -31,5 +31,6 @@ declare class PptxTable {
|
|
|
31
31
|
}
|
|
32
32
|
declare function buildDrawingTable(init: PptxTableInit): XmlElement;
|
|
33
33
|
declare function buildTableGraphicFrame(frame: Box, tableElement: XmlElement, shapeId: number, rotationDeg: number | undefined): XmlElement;
|
|
34
|
+
declare function findGraphicFrameTable(graphicFrame: XmlElement): XmlElement | undefined;
|
|
34
35
|
//#endregion
|
|
35
|
-
export { buildDrawingTable as a, PptxTableRow as i, PptxTableCell as n, buildTableGraphicFrame as o, PptxTableInit as r, PptxTable as t };
|
|
36
|
+
export { buildDrawingTable as a, PptxTableRow as i, PptxTableCell as n, buildTableGraphicFrame as o, PptxTableInit as r, findGraphicFrameTable as s, PptxTable as t };
|
|
@@ -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