ooxml.js 2.4.0 → 2.5.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 +40 -2
- package/dist/codec.cjs +28 -0
- package/dist/codec.d.cts +72 -0
- package/dist/codec.d.ts +72 -0
- package/dist/codec.js +24 -0
- package/dist/compact.cjs +162 -0
- package/dist/compact.d.cts +70 -0
- package/dist/compact.d.ts +70 -0
- package/dist/compact.js +152 -0
- package/dist/image/sniff.cjs +28 -0
- package/dist/image/sniff.d.cts +5 -0
- package/dist/image/sniff.d.ts +5 -0
- package/dist/image/sniff.js +27 -0
- package/dist/index.cjs +83 -3025
- package/dist/index.d.cts +22 -527
- package/dist/index.d.ts +22 -527
- package/dist/index.js +22 -2964
- package/dist/model/node.cjs +67 -0
- package/dist/model/node.d.cts +2 -0
- package/dist/model/node.d.ts +2 -0
- package/dist/model/node.js +58 -0
- package/dist/model/package.cjs +19 -0
- package/dist/model/package.d.cts +2 -0
- package/dist/model/package.d.ts +2 -0
- package/dist/model/package.js +15 -0
- package/dist/node-CkBWRjNR.d.cts +83 -0
- package/dist/node-CkBWRjNR.d.ts +83 -0
- package/dist/package-BUojjTXf.d.ts +114 -0
- package/dist/package-L24lkba-.d.cts +114 -0
- package/dist/package-io/read.cjs +33 -0
- package/dist/package-io/read.d.cts +5 -0
- package/dist/package-io/read.d.ts +5 -0
- package/dist/package-io/read.js +32 -0
- package/dist/package-io/write.cjs +18 -0
- package/dist/package-io/write.d.cts +5 -0
- package/dist/package-io/write.d.ts +5 -0
- package/dist/package-io/write.js +17 -0
- package/dist/typed/docx/read.cjs +332 -0
- package/dist/typed/docx/read.d.cts +52 -0
- package/dist/typed/docx/read.d.ts +52 -0
- package/dist/typed/docx/read.js +328 -0
- package/dist/typed/docx/styles.cjs +148 -0
- package/dist/typed/docx/styles.d.cts +29 -0
- package/dist/typed/docx/styles.d.ts +29 -0
- package/dist/typed/docx/styles.js +146 -0
- package/dist/typed/pptx/inherit.cjs +96 -0
- package/dist/typed/pptx/inherit.d.cts +30 -0
- package/dist/typed/pptx/inherit.d.ts +30 -0
- package/dist/typed/pptx/inherit.js +90 -0
- package/dist/typed/pptx/read.cjs +364 -0
- package/dist/typed/pptx/read.d.cts +44 -0
- package/dist/typed/pptx/read.d.ts +44 -0
- package/dist/typed/pptx/read.js +362 -0
- package/dist/typed/shared/color.cjs +85 -0
- package/dist/typed/shared/color.d.cts +9 -0
- package/dist/typed/shared/color.d.ts +9 -0
- package/dist/typed/shared/color.js +84 -0
- package/dist/typed/shared/drawingml.cjs +191 -0
- package/dist/typed/shared/drawingml.d.cts +40 -0
- package/dist/typed/shared/drawingml.d.ts +40 -0
- package/dist/typed/shared/drawingml.js +180 -0
- package/dist/typed/shared/metadata.cjs +44 -0
- package/dist/typed/shared/metadata.d.cts +16 -0
- package/dist/typed/shared/metadata.d.ts +16 -0
- package/dist/typed/shared/metadata.js +42 -0
- package/dist/typed/shared/source-path.cjs +18 -0
- package/dist/typed/shared/source-path.d.cts +5 -0
- package/dist/typed/shared/source-path.d.ts +5 -0
- package/dist/typed/shared/source-path.js +17 -0
- package/dist/typed/shared/units.cjs +55 -0
- package/dist/typed/shared/units.d.cts +20 -0
- package/dist/typed/shared/units.d.ts +20 -0
- package/dist/typed/shared/units.js +38 -0
- package/dist/typed/util.cjs +85 -0
- package/dist/typed/util.d.cts +18 -0
- package/dist/typed/util.d.ts +18 -0
- package/dist/typed/util.js +77 -0
- package/dist/typed/xlsx/a1.cjs +64 -0
- package/dist/typed/xlsx/a1.d.cts +19 -0
- package/dist/typed/xlsx/a1.d.ts +19 -0
- package/dist/typed/xlsx/a1.js +58 -0
- package/dist/typed/xlsx/build.cjs +456 -0
- package/dist/typed/xlsx/build.d.cts +6 -0
- package/dist/typed/xlsx/build.d.ts +6 -0
- package/dist/typed/xlsx/build.js +455 -0
- package/dist/typed/xlsx/content.cjs +257 -0
- package/dist/typed/xlsx/content.d.cts +6 -0
- package/dist/typed/xlsx/content.d.ts +6 -0
- package/dist/typed/xlsx/content.js +256 -0
- package/dist/typed/xlsx/defined-names.cjs +90 -0
- package/dist/typed/xlsx/defined-names.d.cts +20 -0
- package/dist/typed/xlsx/defined-names.d.ts +20 -0
- package/dist/typed/xlsx/defined-names.js +83 -0
- package/dist/typed/xlsx/print-settings.cjs +116 -0
- package/dist/typed/xlsx/print-settings.d.cts +8 -0
- package/dist/typed/xlsx/print-settings.d.ts +8 -0
- package/dist/typed/xlsx/print-settings.js +114 -0
- package/dist/typed/xlsx/shared-strings.cjs +35 -0
- package/dist/typed/xlsx/shared-strings.d.cts +12 -0
- package/dist/typed/xlsx/shared-strings.d.ts +12 -0
- package/dist/typed/xlsx/shared-strings.js +33 -0
- package/dist/typed/xlsx/units.cjs +21 -0
- package/dist/typed/xlsx/units.d.cts +8 -0
- package/dist/typed/xlsx/units.d.ts +8 -0
- package/dist/typed/xlsx/units.js +16 -0
- package/dist/typed/xlsx/util.cjs +53 -0
- package/dist/typed/xlsx/util.d.cts +10 -0
- package/dist/typed/xlsx/util.d.ts +10 -0
- package/dist/typed/xlsx/util.js +47 -0
- package/dist/typed/xlsx.cjs +140 -0
- package/dist/typed/xlsx.d.cts +43 -0
- package/dist/typed/xlsx.d.ts +43 -0
- package/dist/typed/xlsx.js +135 -0
- package/dist/util/base64.cjs +48 -0
- package/dist/util/base64.d.cts +5 -0
- package/dist/util/base64.d.ts +5 -0
- package/dist/util/base64.js +46 -0
- package/dist/xml/build.cjs +46 -0
- package/dist/xml/build.d.cts +5 -0
- package/dist/xml/build.d.ts +5 -0
- package/dist/xml/build.js +46 -0
- package/dist/xml/entities.cjs +7 -0
- package/dist/xml/entities.d.cts +4 -0
- package/dist/xml/entities.d.ts +4 -0
- package/dist/xml/entities.js +6 -0
- package/dist/xml/fragment.cjs +22 -0
- package/dist/xml/fragment.d.cts +6 -0
- package/dist/xml/fragment.d.ts +6 -0
- package/dist/xml/fragment.js +20 -0
- package/dist/xml/parse.cjs +88 -0
- package/dist/xml/parse.d.cts +5 -0
- package/dist/xml/parse.d.ts +5 -0
- package/dist/xml/parse.js +88 -0
- package/dist/zip.cjs +12 -0
- package/dist/zip.d.cts +5 -0
- package/dist/zip.d.ts +5 -0
- package/dist/zip.js +10 -0
- package/package.json +9 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_typed_util = require("../util.cjs");
|
|
3
|
+
const require_typed_shared_color = require("./color.cjs");
|
|
4
|
+
const require_typed_shared_units = require("./units.cjs");
|
|
5
|
+
let document_schema_js = require("document-schema.js");
|
|
6
|
+
//#region src/typed/shared/drawingml.ts
|
|
7
|
+
const ROTATION_UNITS_PER_DEGREE = 6e4;
|
|
8
|
+
function readXfrm(xfrm) {
|
|
9
|
+
if (xfrm === void 0) return;
|
|
10
|
+
const off = require_typed_util.childrenWithTag(xfrm, "a:off")[0];
|
|
11
|
+
const ext = require_typed_util.childrenWithTag(xfrm, "a:ext")[0];
|
|
12
|
+
if (off === void 0 || ext === void 0) return;
|
|
13
|
+
const x = require_typed_util.attr(off, "x");
|
|
14
|
+
const y = require_typed_util.attr(off, "y");
|
|
15
|
+
const cx = require_typed_util.attr(ext, "cx");
|
|
16
|
+
const cy = require_typed_util.attr(ext, "cy");
|
|
17
|
+
if (x === void 0 || y === void 0 || cx === void 0 || cy === void 0) return;
|
|
18
|
+
const rot = require_typed_util.attr(xfrm, "rot");
|
|
19
|
+
return {
|
|
20
|
+
xPt: require_typed_shared_units.emuToPt(Number(x)),
|
|
21
|
+
yPt: require_typed_shared_units.emuToPt(Number(y)),
|
|
22
|
+
widthPt: require_typed_shared_units.emuToPt(Number(cx)),
|
|
23
|
+
heightPt: require_typed_shared_units.emuToPt(Number(cy)),
|
|
24
|
+
rotationDeg: rot === void 0 ? 0 : Number(rot) / ROTATION_UNITS_PER_DEGREE,
|
|
25
|
+
flipH: require_typed_util.attr(xfrm, "flipH") === "1",
|
|
26
|
+
flipV: require_typed_util.attr(xfrm, "flipV") === "1"
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const CLR_SCHEME_SLOTS = [
|
|
30
|
+
"dk1",
|
|
31
|
+
"lt1",
|
|
32
|
+
"dk2",
|
|
33
|
+
"lt2",
|
|
34
|
+
"accent1",
|
|
35
|
+
"accent2",
|
|
36
|
+
"accent3",
|
|
37
|
+
"accent4",
|
|
38
|
+
"accent5",
|
|
39
|
+
"accent6",
|
|
40
|
+
"hlink",
|
|
41
|
+
"folHlink"
|
|
42
|
+
];
|
|
43
|
+
function readThemeSlotColor(colorEl) {
|
|
44
|
+
if (colorEl.tag === "a:srgbClr") {
|
|
45
|
+
const val = require_typed_util.attr(colorEl, "val");
|
|
46
|
+
return val === void 0 ? void 0 : (0, document_schema_js.rgbHexToColor)(val);
|
|
47
|
+
}
|
|
48
|
+
if (colorEl.tag === "a:sysClr") {
|
|
49
|
+
const lastClr = require_typed_util.attr(colorEl, "lastClr");
|
|
50
|
+
if (lastClr !== void 0) return (0, document_schema_js.rgbHexToColor)(lastClr);
|
|
51
|
+
return require_typed_util.attr(colorEl, "val") === "window" ? {
|
|
52
|
+
r: 1,
|
|
53
|
+
g: 1,
|
|
54
|
+
b: 1
|
|
55
|
+
} : {
|
|
56
|
+
r: 0,
|
|
57
|
+
g: 0,
|
|
58
|
+
b: 0
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function readClrScheme(clrSchemeEl) {
|
|
63
|
+
const map = /* @__PURE__ */ new Map();
|
|
64
|
+
for (const slot of CLR_SCHEME_SLOTS) {
|
|
65
|
+
const wrapper = require_typed_util.childrenWithTag(clrSchemeEl, `a:${slot}`)[0];
|
|
66
|
+
if (wrapper === void 0) continue;
|
|
67
|
+
const colorEl = wrapper.children.find((c) => c.type === "element");
|
|
68
|
+
if (colorEl === void 0) continue;
|
|
69
|
+
const color = readThemeSlotColor(colorEl);
|
|
70
|
+
if (color !== void 0) map.set(slot, color);
|
|
71
|
+
}
|
|
72
|
+
return map;
|
|
73
|
+
}
|
|
74
|
+
function readSchemeFont(fontSchemeEl, tag) {
|
|
75
|
+
if (fontSchemeEl === void 0) return;
|
|
76
|
+
const fontEl = require_typed_util.childrenWithTag(fontSchemeEl, tag)[0];
|
|
77
|
+
const latin = fontEl === void 0 ? void 0 : require_typed_util.childrenWithTag(fontEl, "a:latin")[0];
|
|
78
|
+
return latin === void 0 ? void 0 : require_typed_util.attr(latin, "typeface");
|
|
79
|
+
}
|
|
80
|
+
const DEFAULT_THEME_FONT = "Calibri";
|
|
81
|
+
const EMPTY_THEME = {
|
|
82
|
+
colorScheme: /* @__PURE__ */ new Map(),
|
|
83
|
+
majorFont: DEFAULT_THEME_FONT,
|
|
84
|
+
minorFont: DEFAULT_THEME_FONT
|
|
85
|
+
};
|
|
86
|
+
function readTheme(themeRoot) {
|
|
87
|
+
const clrSchemeEl = require_typed_util.elementsWithTag([themeRoot], "a:clrScheme")[0];
|
|
88
|
+
const colorScheme = clrSchemeEl === void 0 ? /* @__PURE__ */ new Map() : readClrScheme(clrSchemeEl);
|
|
89
|
+
const fontSchemeEl = require_typed_util.elementsWithTag([themeRoot], "a:fontScheme")[0];
|
|
90
|
+
return {
|
|
91
|
+
colorScheme,
|
|
92
|
+
majorFont: readSchemeFont(fontSchemeEl, "a:majorFont") ?? DEFAULT_THEME_FONT,
|
|
93
|
+
minorFont: readSchemeFont(fontSchemeEl, "a:minorFont") ?? DEFAULT_THEME_FONT
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function resolveThemeFontReference(typeface, theme) {
|
|
97
|
+
if (typeface === "+mj-lt") return theme.majorFont;
|
|
98
|
+
if (typeface === "+mn-lt") return theme.minorFont;
|
|
99
|
+
return typeface;
|
|
100
|
+
}
|
|
101
|
+
function readColorMap(clrMapEl) {
|
|
102
|
+
const map = /* @__PURE__ */ new Map();
|
|
103
|
+
if (clrMapEl === void 0) return map;
|
|
104
|
+
for (const a of clrMapEl.attributes) map.set(a.name, a.value);
|
|
105
|
+
return map;
|
|
106
|
+
}
|
|
107
|
+
function resolveSchemeColorSlot(schemeVal, colorMap) {
|
|
108
|
+
return colorMap.get(schemeVal) ?? schemeVal;
|
|
109
|
+
}
|
|
110
|
+
const COLOR_TRANSFORM_TAGS = /* @__PURE__ */ new Map([
|
|
111
|
+
["a:shade", "shade"],
|
|
112
|
+
["a:tint", "tint"],
|
|
113
|
+
["a:lumMod", "lumMod"],
|
|
114
|
+
["a:lumOff", "lumOff"]
|
|
115
|
+
]);
|
|
116
|
+
function readColorTransforms(container) {
|
|
117
|
+
const transforms = [];
|
|
118
|
+
for (const child of container.children) {
|
|
119
|
+
if (child.type !== "element") continue;
|
|
120
|
+
const kind = COLOR_TRANSFORM_TAGS.get(child.tag);
|
|
121
|
+
if (kind === void 0) continue;
|
|
122
|
+
const val = require_typed_util.attr(child, "val");
|
|
123
|
+
if (val === void 0) continue;
|
|
124
|
+
transforms.push({
|
|
125
|
+
kind,
|
|
126
|
+
value: Number(val)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return transforms;
|
|
130
|
+
}
|
|
131
|
+
function readSchemeColor(schemeClrEl, colorMap, theme) {
|
|
132
|
+
const val = require_typed_util.attr(schemeClrEl, "val");
|
|
133
|
+
if (val === void 0) return;
|
|
134
|
+
const base = theme.colorScheme.get(resolveSchemeColorSlot(val, colorMap));
|
|
135
|
+
return base === void 0 ? void 0 : require_typed_shared_color.applyColorTransforms(base, readColorTransforms(schemeClrEl));
|
|
136
|
+
}
|
|
137
|
+
function readSrgbColor(srgbClrEl) {
|
|
138
|
+
const val = require_typed_util.attr(srgbClrEl, "val");
|
|
139
|
+
return val === void 0 ? void 0 : require_typed_shared_color.applyColorTransforms((0, document_schema_js.rgbHexToColor)(val), readColorTransforms(srgbClrEl));
|
|
140
|
+
}
|
|
141
|
+
function readSolidFillColor(solidFillEl, colorMap, theme) {
|
|
142
|
+
if (solidFillEl === void 0) return;
|
|
143
|
+
const schemeClr = require_typed_util.childrenWithTag(solidFillEl, "a:schemeClr")[0];
|
|
144
|
+
if (schemeClr !== void 0) return readSchemeColor(schemeClr, colorMap, theme);
|
|
145
|
+
const srgbClr = require_typed_util.childrenWithTag(solidFillEl, "a:srgbClr")[0];
|
|
146
|
+
return srgbClr === void 0 ? void 0 : readSrgbColor(srgbClr);
|
|
147
|
+
}
|
|
148
|
+
function readGroupXfrm(xfrm) {
|
|
149
|
+
const base = readXfrm(xfrm);
|
|
150
|
+
if (base === void 0 || xfrm === void 0) return;
|
|
151
|
+
const chOff = require_typed_util.childrenWithTag(xfrm, "a:chOff")[0];
|
|
152
|
+
const chExt = require_typed_util.childrenWithTag(xfrm, "a:chExt")[0];
|
|
153
|
+
if (chOff === void 0 || chExt === void 0) return;
|
|
154
|
+
const cx = require_typed_util.attr(chOff, "x");
|
|
155
|
+
const cy = require_typed_util.attr(chOff, "y");
|
|
156
|
+
const ccx = require_typed_util.attr(chExt, "cx");
|
|
157
|
+
const ccy = require_typed_util.attr(chExt, "cy");
|
|
158
|
+
if (cx === void 0 || cy === void 0 || ccx === void 0 || ccy === void 0) return;
|
|
159
|
+
return {
|
|
160
|
+
offXPt: base.xPt,
|
|
161
|
+
offYPt: base.yPt,
|
|
162
|
+
extWidthPt: base.widthPt,
|
|
163
|
+
extHeightPt: base.heightPt,
|
|
164
|
+
childOffXPt: require_typed_shared_units.emuToPt(Number(cx)),
|
|
165
|
+
childOffYPt: require_typed_shared_units.emuToPt(Number(cy)),
|
|
166
|
+
childExtWidthPt: require_typed_shared_units.emuToPt(Number(ccx)),
|
|
167
|
+
childExtHeightPt: require_typed_shared_units.emuToPt(Number(ccy))
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function applyGroupTransform(group, childFrame) {
|
|
171
|
+
const scaleX = group.childExtWidthPt === 0 ? 1 : group.extWidthPt / group.childExtWidthPt;
|
|
172
|
+
const scaleY = group.childExtHeightPt === 0 ? 1 : group.extHeightPt / group.childExtHeightPt;
|
|
173
|
+
return {
|
|
174
|
+
xPt: group.offXPt + (childFrame.xPt - group.childOffXPt) * scaleX,
|
|
175
|
+
yPt: group.offYPt + (childFrame.yPt - group.childOffYPt) * scaleY,
|
|
176
|
+
widthPt: childFrame.widthPt * scaleX,
|
|
177
|
+
heightPt: childFrame.heightPt * scaleY
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
exports.EMPTY_THEME = EMPTY_THEME;
|
|
182
|
+
exports.applyGroupTransform = applyGroupTransform;
|
|
183
|
+
exports.readColorMap = readColorMap;
|
|
184
|
+
exports.readGroupXfrm = readGroupXfrm;
|
|
185
|
+
exports.readSchemeColor = readSchemeColor;
|
|
186
|
+
exports.readSolidFillColor = readSolidFillColor;
|
|
187
|
+
exports.readSrgbColor = readSrgbColor;
|
|
188
|
+
exports.readTheme = readTheme;
|
|
189
|
+
exports.readXfrm = readXfrm;
|
|
190
|
+
exports.resolveSchemeColorSlot = resolveSchemeColorSlot;
|
|
191
|
+
exports.resolveThemeFontReference = resolveThemeFontReference;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { l as XmlElement } from "../../node-CkBWRjNR.cjs";
|
|
2
|
+
import { Box, Color } from "document-schema.js";
|
|
3
|
+
//#region src/typed/shared/drawingml.d.ts
|
|
4
|
+
interface DrawingXfrm {
|
|
5
|
+
readonly xPt: number;
|
|
6
|
+
readonly yPt: number;
|
|
7
|
+
readonly widthPt: number;
|
|
8
|
+
readonly heightPt: number;
|
|
9
|
+
readonly rotationDeg: number;
|
|
10
|
+
readonly flipH: boolean;
|
|
11
|
+
readonly flipV: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare function readXfrm(xfrm: XmlElement | undefined): DrawingXfrm | undefined;
|
|
14
|
+
interface DrawingTheme {
|
|
15
|
+
readonly colorScheme: ReadonlyMap<string, Color>;
|
|
16
|
+
readonly majorFont: string;
|
|
17
|
+
readonly minorFont: string;
|
|
18
|
+
}
|
|
19
|
+
declare const EMPTY_THEME: DrawingTheme;
|
|
20
|
+
declare function readTheme(themeRoot: XmlElement): DrawingTheme;
|
|
21
|
+
declare function resolveThemeFontReference(typeface: string, theme: DrawingTheme): string;
|
|
22
|
+
declare function readColorMap(clrMapEl: XmlElement | undefined): ReadonlyMap<string, string>;
|
|
23
|
+
declare function resolveSchemeColorSlot(schemeVal: string, colorMap: ReadonlyMap<string, string>): string;
|
|
24
|
+
declare function readSchemeColor(schemeClrEl: XmlElement, colorMap: ReadonlyMap<string, string>, theme: DrawingTheme): Color | undefined;
|
|
25
|
+
declare function readSrgbColor(srgbClrEl: XmlElement): Color | undefined;
|
|
26
|
+
declare function readSolidFillColor(solidFillEl: XmlElement | undefined, colorMap: ReadonlyMap<string, string>, theme: DrawingTheme): Color | undefined;
|
|
27
|
+
interface GroupChildTransform {
|
|
28
|
+
readonly offXPt: number;
|
|
29
|
+
readonly offYPt: number;
|
|
30
|
+
readonly extWidthPt: number;
|
|
31
|
+
readonly extHeightPt: number;
|
|
32
|
+
readonly childOffXPt: number;
|
|
33
|
+
readonly childOffYPt: number;
|
|
34
|
+
readonly childExtWidthPt: number;
|
|
35
|
+
readonly childExtHeightPt: number;
|
|
36
|
+
}
|
|
37
|
+
declare function readGroupXfrm(xfrm: XmlElement | undefined): GroupChildTransform | undefined;
|
|
38
|
+
declare function applyGroupTransform(group: GroupChildTransform, childFrame: Box): Box;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { DrawingTheme, DrawingXfrm, EMPTY_THEME, GroupChildTransform, applyGroupTransform, readColorMap, readGroupXfrm, readSchemeColor, readSolidFillColor, readSrgbColor, readTheme, readXfrm, resolveSchemeColorSlot, resolveThemeFontReference };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { l as XmlElement } from "../../node-CkBWRjNR.js";
|
|
2
|
+
import { Box, Color } from "document-schema.js";
|
|
3
|
+
//#region src/typed/shared/drawingml.d.ts
|
|
4
|
+
interface DrawingXfrm {
|
|
5
|
+
readonly xPt: number;
|
|
6
|
+
readonly yPt: number;
|
|
7
|
+
readonly widthPt: number;
|
|
8
|
+
readonly heightPt: number;
|
|
9
|
+
readonly rotationDeg: number;
|
|
10
|
+
readonly flipH: boolean;
|
|
11
|
+
readonly flipV: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare function readXfrm(xfrm: XmlElement | undefined): DrawingXfrm | undefined;
|
|
14
|
+
interface DrawingTheme {
|
|
15
|
+
readonly colorScheme: ReadonlyMap<string, Color>;
|
|
16
|
+
readonly majorFont: string;
|
|
17
|
+
readonly minorFont: string;
|
|
18
|
+
}
|
|
19
|
+
declare const EMPTY_THEME: DrawingTheme;
|
|
20
|
+
declare function readTheme(themeRoot: XmlElement): DrawingTheme;
|
|
21
|
+
declare function resolveThemeFontReference(typeface: string, theme: DrawingTheme): string;
|
|
22
|
+
declare function readColorMap(clrMapEl: XmlElement | undefined): ReadonlyMap<string, string>;
|
|
23
|
+
declare function resolveSchemeColorSlot(schemeVal: string, colorMap: ReadonlyMap<string, string>): string;
|
|
24
|
+
declare function readSchemeColor(schemeClrEl: XmlElement, colorMap: ReadonlyMap<string, string>, theme: DrawingTheme): Color | undefined;
|
|
25
|
+
declare function readSrgbColor(srgbClrEl: XmlElement): Color | undefined;
|
|
26
|
+
declare function readSolidFillColor(solidFillEl: XmlElement | undefined, colorMap: ReadonlyMap<string, string>, theme: DrawingTheme): Color | undefined;
|
|
27
|
+
interface GroupChildTransform {
|
|
28
|
+
readonly offXPt: number;
|
|
29
|
+
readonly offYPt: number;
|
|
30
|
+
readonly extWidthPt: number;
|
|
31
|
+
readonly extHeightPt: number;
|
|
32
|
+
readonly childOffXPt: number;
|
|
33
|
+
readonly childOffYPt: number;
|
|
34
|
+
readonly childExtWidthPt: number;
|
|
35
|
+
readonly childExtHeightPt: number;
|
|
36
|
+
}
|
|
37
|
+
declare function readGroupXfrm(xfrm: XmlElement | undefined): GroupChildTransform | undefined;
|
|
38
|
+
declare function applyGroupTransform(group: GroupChildTransform, childFrame: Box): Box;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { DrawingTheme, DrawingXfrm, EMPTY_THEME, GroupChildTransform, applyGroupTransform, readColorMap, readGroupXfrm, readSchemeColor, readSolidFillColor, readSrgbColor, readTheme, readXfrm, resolveSchemeColorSlot, resolveThemeFontReference };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { attr, childrenWithTag, elementsWithTag } from "../util.js";
|
|
2
|
+
import { applyColorTransforms } from "./color.js";
|
|
3
|
+
import { emuToPt } from "./units.js";
|
|
4
|
+
import { rgbHexToColor } from "document-schema.js";
|
|
5
|
+
//#region src/typed/shared/drawingml.ts
|
|
6
|
+
const ROTATION_UNITS_PER_DEGREE = 6e4;
|
|
7
|
+
function readXfrm(xfrm) {
|
|
8
|
+
if (xfrm === void 0) return;
|
|
9
|
+
const off = childrenWithTag(xfrm, "a:off")[0];
|
|
10
|
+
const ext = childrenWithTag(xfrm, "a:ext")[0];
|
|
11
|
+
if (off === void 0 || ext === void 0) return;
|
|
12
|
+
const x = attr(off, "x");
|
|
13
|
+
const y = attr(off, "y");
|
|
14
|
+
const cx = attr(ext, "cx");
|
|
15
|
+
const cy = attr(ext, "cy");
|
|
16
|
+
if (x === void 0 || y === void 0 || cx === void 0 || cy === void 0) return;
|
|
17
|
+
const rot = attr(xfrm, "rot");
|
|
18
|
+
return {
|
|
19
|
+
xPt: emuToPt(Number(x)),
|
|
20
|
+
yPt: emuToPt(Number(y)),
|
|
21
|
+
widthPt: emuToPt(Number(cx)),
|
|
22
|
+
heightPt: emuToPt(Number(cy)),
|
|
23
|
+
rotationDeg: rot === void 0 ? 0 : Number(rot) / ROTATION_UNITS_PER_DEGREE,
|
|
24
|
+
flipH: attr(xfrm, "flipH") === "1",
|
|
25
|
+
flipV: attr(xfrm, "flipV") === "1"
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const CLR_SCHEME_SLOTS = [
|
|
29
|
+
"dk1",
|
|
30
|
+
"lt1",
|
|
31
|
+
"dk2",
|
|
32
|
+
"lt2",
|
|
33
|
+
"accent1",
|
|
34
|
+
"accent2",
|
|
35
|
+
"accent3",
|
|
36
|
+
"accent4",
|
|
37
|
+
"accent5",
|
|
38
|
+
"accent6",
|
|
39
|
+
"hlink",
|
|
40
|
+
"folHlink"
|
|
41
|
+
];
|
|
42
|
+
function readThemeSlotColor(colorEl) {
|
|
43
|
+
if (colorEl.tag === "a:srgbClr") {
|
|
44
|
+
const val = attr(colorEl, "val");
|
|
45
|
+
return val === void 0 ? void 0 : rgbHexToColor(val);
|
|
46
|
+
}
|
|
47
|
+
if (colorEl.tag === "a:sysClr") {
|
|
48
|
+
const lastClr = attr(colorEl, "lastClr");
|
|
49
|
+
if (lastClr !== void 0) return rgbHexToColor(lastClr);
|
|
50
|
+
return attr(colorEl, "val") === "window" ? {
|
|
51
|
+
r: 1,
|
|
52
|
+
g: 1,
|
|
53
|
+
b: 1
|
|
54
|
+
} : {
|
|
55
|
+
r: 0,
|
|
56
|
+
g: 0,
|
|
57
|
+
b: 0
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function readClrScheme(clrSchemeEl) {
|
|
62
|
+
const map = /* @__PURE__ */ new Map();
|
|
63
|
+
for (const slot of CLR_SCHEME_SLOTS) {
|
|
64
|
+
const wrapper = childrenWithTag(clrSchemeEl, `a:${slot}`)[0];
|
|
65
|
+
if (wrapper === void 0) continue;
|
|
66
|
+
const colorEl = wrapper.children.find((c) => c.type === "element");
|
|
67
|
+
if (colorEl === void 0) continue;
|
|
68
|
+
const color = readThemeSlotColor(colorEl);
|
|
69
|
+
if (color !== void 0) map.set(slot, color);
|
|
70
|
+
}
|
|
71
|
+
return map;
|
|
72
|
+
}
|
|
73
|
+
function readSchemeFont(fontSchemeEl, tag) {
|
|
74
|
+
if (fontSchemeEl === void 0) return;
|
|
75
|
+
const fontEl = childrenWithTag(fontSchemeEl, tag)[0];
|
|
76
|
+
const latin = fontEl === void 0 ? void 0 : childrenWithTag(fontEl, "a:latin")[0];
|
|
77
|
+
return latin === void 0 ? void 0 : attr(latin, "typeface");
|
|
78
|
+
}
|
|
79
|
+
const DEFAULT_THEME_FONT = "Calibri";
|
|
80
|
+
const EMPTY_THEME = {
|
|
81
|
+
colorScheme: /* @__PURE__ */ new Map(),
|
|
82
|
+
majorFont: DEFAULT_THEME_FONT,
|
|
83
|
+
minorFont: DEFAULT_THEME_FONT
|
|
84
|
+
};
|
|
85
|
+
function readTheme(themeRoot) {
|
|
86
|
+
const clrSchemeEl = elementsWithTag([themeRoot], "a:clrScheme")[0];
|
|
87
|
+
const colorScheme = clrSchemeEl === void 0 ? /* @__PURE__ */ new Map() : readClrScheme(clrSchemeEl);
|
|
88
|
+
const fontSchemeEl = elementsWithTag([themeRoot], "a:fontScheme")[0];
|
|
89
|
+
return {
|
|
90
|
+
colorScheme,
|
|
91
|
+
majorFont: readSchemeFont(fontSchemeEl, "a:majorFont") ?? DEFAULT_THEME_FONT,
|
|
92
|
+
minorFont: readSchemeFont(fontSchemeEl, "a:minorFont") ?? DEFAULT_THEME_FONT
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function resolveThemeFontReference(typeface, theme) {
|
|
96
|
+
if (typeface === "+mj-lt") return theme.majorFont;
|
|
97
|
+
if (typeface === "+mn-lt") return theme.minorFont;
|
|
98
|
+
return typeface;
|
|
99
|
+
}
|
|
100
|
+
function readColorMap(clrMapEl) {
|
|
101
|
+
const map = /* @__PURE__ */ new Map();
|
|
102
|
+
if (clrMapEl === void 0) return map;
|
|
103
|
+
for (const a of clrMapEl.attributes) map.set(a.name, a.value);
|
|
104
|
+
return map;
|
|
105
|
+
}
|
|
106
|
+
function resolveSchemeColorSlot(schemeVal, colorMap) {
|
|
107
|
+
return colorMap.get(schemeVal) ?? schemeVal;
|
|
108
|
+
}
|
|
109
|
+
const COLOR_TRANSFORM_TAGS = /* @__PURE__ */ new Map([
|
|
110
|
+
["a:shade", "shade"],
|
|
111
|
+
["a:tint", "tint"],
|
|
112
|
+
["a:lumMod", "lumMod"],
|
|
113
|
+
["a:lumOff", "lumOff"]
|
|
114
|
+
]);
|
|
115
|
+
function readColorTransforms(container) {
|
|
116
|
+
const transforms = [];
|
|
117
|
+
for (const child of container.children) {
|
|
118
|
+
if (child.type !== "element") continue;
|
|
119
|
+
const kind = COLOR_TRANSFORM_TAGS.get(child.tag);
|
|
120
|
+
if (kind === void 0) continue;
|
|
121
|
+
const val = attr(child, "val");
|
|
122
|
+
if (val === void 0) continue;
|
|
123
|
+
transforms.push({
|
|
124
|
+
kind,
|
|
125
|
+
value: Number(val)
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return transforms;
|
|
129
|
+
}
|
|
130
|
+
function readSchemeColor(schemeClrEl, colorMap, theme) {
|
|
131
|
+
const val = attr(schemeClrEl, "val");
|
|
132
|
+
if (val === void 0) return;
|
|
133
|
+
const base = theme.colorScheme.get(resolveSchemeColorSlot(val, colorMap));
|
|
134
|
+
return base === void 0 ? void 0 : applyColorTransforms(base, readColorTransforms(schemeClrEl));
|
|
135
|
+
}
|
|
136
|
+
function readSrgbColor(srgbClrEl) {
|
|
137
|
+
const val = attr(srgbClrEl, "val");
|
|
138
|
+
return val === void 0 ? void 0 : applyColorTransforms(rgbHexToColor(val), readColorTransforms(srgbClrEl));
|
|
139
|
+
}
|
|
140
|
+
function readSolidFillColor(solidFillEl, colorMap, theme) {
|
|
141
|
+
if (solidFillEl === void 0) return;
|
|
142
|
+
const schemeClr = childrenWithTag(solidFillEl, "a:schemeClr")[0];
|
|
143
|
+
if (schemeClr !== void 0) return readSchemeColor(schemeClr, colorMap, theme);
|
|
144
|
+
const srgbClr = childrenWithTag(solidFillEl, "a:srgbClr")[0];
|
|
145
|
+
return srgbClr === void 0 ? void 0 : readSrgbColor(srgbClr);
|
|
146
|
+
}
|
|
147
|
+
function readGroupXfrm(xfrm) {
|
|
148
|
+
const base = readXfrm(xfrm);
|
|
149
|
+
if (base === void 0 || xfrm === void 0) return;
|
|
150
|
+
const chOff = childrenWithTag(xfrm, "a:chOff")[0];
|
|
151
|
+
const chExt = childrenWithTag(xfrm, "a:chExt")[0];
|
|
152
|
+
if (chOff === void 0 || chExt === void 0) return;
|
|
153
|
+
const cx = attr(chOff, "x");
|
|
154
|
+
const cy = attr(chOff, "y");
|
|
155
|
+
const ccx = attr(chExt, "cx");
|
|
156
|
+
const ccy = attr(chExt, "cy");
|
|
157
|
+
if (cx === void 0 || cy === void 0 || ccx === void 0 || ccy === void 0) return;
|
|
158
|
+
return {
|
|
159
|
+
offXPt: base.xPt,
|
|
160
|
+
offYPt: base.yPt,
|
|
161
|
+
extWidthPt: base.widthPt,
|
|
162
|
+
extHeightPt: base.heightPt,
|
|
163
|
+
childOffXPt: emuToPt(Number(cx)),
|
|
164
|
+
childOffYPt: emuToPt(Number(cy)),
|
|
165
|
+
childExtWidthPt: emuToPt(Number(ccx)),
|
|
166
|
+
childExtHeightPt: emuToPt(Number(ccy))
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function applyGroupTransform(group, childFrame) {
|
|
170
|
+
const scaleX = group.childExtWidthPt === 0 ? 1 : group.extWidthPt / group.childExtWidthPt;
|
|
171
|
+
const scaleY = group.childExtHeightPt === 0 ? 1 : group.extHeightPt / group.childExtHeightPt;
|
|
172
|
+
return {
|
|
173
|
+
xPt: group.offXPt + (childFrame.xPt - group.childOffXPt) * scaleX,
|
|
174
|
+
yPt: group.offYPt + (childFrame.yPt - group.childOffYPt) * scaleY,
|
|
175
|
+
widthPt: childFrame.widthPt * scaleX,
|
|
176
|
+
heightPt: childFrame.heightPt * scaleY
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export { EMPTY_THEME, applyGroupTransform, readColorMap, readGroupXfrm, readSchemeColor, readSolidFillColor, readSrgbColor, readTheme, readXfrm, resolveSchemeColorSlot, resolveThemeFontReference };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_typed_util = require("../util.cjs");
|
|
3
|
+
let zod = require("zod");
|
|
4
|
+
//#region src/typed/shared/metadata.ts
|
|
5
|
+
const DocumentMetadataSchema = zod.z.object({
|
|
6
|
+
title: zod.z.string().optional(),
|
|
7
|
+
author: zod.z.string().optional(),
|
|
8
|
+
subject: zod.z.string().optional(),
|
|
9
|
+
keywords: zod.z.array(zod.z.string()).optional(),
|
|
10
|
+
creator: zod.z.string().optional(),
|
|
11
|
+
createdIso: zod.z.string().optional(),
|
|
12
|
+
modifiedIso: zod.z.string().optional()
|
|
13
|
+
});
|
|
14
|
+
const CORE_PROPERTIES_PATH = "docProps/core.xml";
|
|
15
|
+
const APP_PROPERTIES_PATH = "docProps/app.xml";
|
|
16
|
+
function firstElementText(root, tag) {
|
|
17
|
+
if (root === void 0) return;
|
|
18
|
+
const element = require_typed_util.childrenWithTag(root, tag)[0];
|
|
19
|
+
if (element === void 0) return;
|
|
20
|
+
const text = require_typed_util.textContent(element);
|
|
21
|
+
return text.length > 0 ? text : void 0;
|
|
22
|
+
}
|
|
23
|
+
function readKeywords(core) {
|
|
24
|
+
const raw = firstElementText(core, "cp:keywords");
|
|
25
|
+
if (raw === void 0) return;
|
|
26
|
+
const parts = raw.split(",").map((part) => part.trim()).filter((part) => part.length > 0);
|
|
27
|
+
return parts.length > 0 ? parts : void 0;
|
|
28
|
+
}
|
|
29
|
+
function readCoreProperties(pkg) {
|
|
30
|
+
const core = require_typed_util.rootElement(pkg.parts[CORE_PROPERTIES_PATH]);
|
|
31
|
+
const app = require_typed_util.rootElement(pkg.parts[APP_PROPERTIES_PATH]);
|
|
32
|
+
return {
|
|
33
|
+
title: firstElementText(core, "dc:title"),
|
|
34
|
+
author: firstElementText(core, "dc:creator"),
|
|
35
|
+
subject: firstElementText(core, "dc:subject"),
|
|
36
|
+
keywords: readKeywords(core),
|
|
37
|
+
creator: firstElementText(app, "Application"),
|
|
38
|
+
createdIso: firstElementText(core, "dcterms:created"),
|
|
39
|
+
modifiedIso: firstElementText(core, "dcterms:modified")
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.DocumentMetadataSchema = DocumentMetadataSchema;
|
|
44
|
+
exports.readCoreProperties = readCoreProperties;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { r as Package } from "../../package-L24lkba-.cjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/typed/shared/metadata.d.ts
|
|
4
|
+
declare const DocumentMetadataSchema: z.ZodObject<{
|
|
5
|
+
title: z.ZodOptional<z.ZodString>;
|
|
6
|
+
author: z.ZodOptional<z.ZodString>;
|
|
7
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
8
|
+
keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
9
|
+
creator: z.ZodOptional<z.ZodString>;
|
|
10
|
+
createdIso: z.ZodOptional<z.ZodString>;
|
|
11
|
+
modifiedIso: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
type DocumentMetadata = z.infer<typeof DocumentMetadataSchema>;
|
|
14
|
+
declare function readCoreProperties(pkg: Package): DocumentMetadata;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { DocumentMetadata, DocumentMetadataSchema, readCoreProperties };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { r as Package } from "../../package-BUojjTXf.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/typed/shared/metadata.d.ts
|
|
4
|
+
declare const DocumentMetadataSchema: z.ZodObject<{
|
|
5
|
+
title: z.ZodOptional<z.ZodString>;
|
|
6
|
+
author: z.ZodOptional<z.ZodString>;
|
|
7
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
8
|
+
keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
9
|
+
creator: z.ZodOptional<z.ZodString>;
|
|
10
|
+
createdIso: z.ZodOptional<z.ZodString>;
|
|
11
|
+
modifiedIso: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
type DocumentMetadata = z.infer<typeof DocumentMetadataSchema>;
|
|
14
|
+
declare function readCoreProperties(pkg: Package): DocumentMetadata;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { DocumentMetadata, DocumentMetadataSchema, readCoreProperties };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { childrenWithTag, rootElement, textContent } from "../util.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/typed/shared/metadata.ts
|
|
4
|
+
const DocumentMetadataSchema = z.object({
|
|
5
|
+
title: z.string().optional(),
|
|
6
|
+
author: z.string().optional(),
|
|
7
|
+
subject: z.string().optional(),
|
|
8
|
+
keywords: z.array(z.string()).optional(),
|
|
9
|
+
creator: z.string().optional(),
|
|
10
|
+
createdIso: z.string().optional(),
|
|
11
|
+
modifiedIso: z.string().optional()
|
|
12
|
+
});
|
|
13
|
+
const CORE_PROPERTIES_PATH = "docProps/core.xml";
|
|
14
|
+
const APP_PROPERTIES_PATH = "docProps/app.xml";
|
|
15
|
+
function firstElementText(root, tag) {
|
|
16
|
+
if (root === void 0) return;
|
|
17
|
+
const element = childrenWithTag(root, tag)[0];
|
|
18
|
+
if (element === void 0) return;
|
|
19
|
+
const text = textContent(element);
|
|
20
|
+
return text.length > 0 ? text : void 0;
|
|
21
|
+
}
|
|
22
|
+
function readKeywords(core) {
|
|
23
|
+
const raw = firstElementText(core, "cp:keywords");
|
|
24
|
+
if (raw === void 0) return;
|
|
25
|
+
const parts = raw.split(",").map((part) => part.trim()).filter((part) => part.length > 0);
|
|
26
|
+
return parts.length > 0 ? parts : void 0;
|
|
27
|
+
}
|
|
28
|
+
function readCoreProperties(pkg) {
|
|
29
|
+
const core = rootElement(pkg.parts[CORE_PROPERTIES_PATH]);
|
|
30
|
+
const app = rootElement(pkg.parts[APP_PROPERTIES_PATH]);
|
|
31
|
+
return {
|
|
32
|
+
title: firstElementText(core, "dc:title"),
|
|
33
|
+
author: firstElementText(core, "dc:creator"),
|
|
34
|
+
subject: firstElementText(core, "dc:subject"),
|
|
35
|
+
keywords: readKeywords(core),
|
|
36
|
+
creator: firstElementText(app, "Application"),
|
|
37
|
+
createdIso: firstElementText(core, "dcterms:created"),
|
|
38
|
+
modifiedIso: firstElementText(core, "dcterms:modified")
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { DocumentMetadataSchema, readCoreProperties };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/typed/shared/source-path.ts
|
|
3
|
+
function assignSourcePaths(blocks, prefix) {
|
|
4
|
+
blocks.forEach((block, blockIndex) => {
|
|
5
|
+
const blockPath = `${prefix}.blocks[${blockIndex}]`;
|
|
6
|
+
block.sourcePath = blockPath;
|
|
7
|
+
if (block.kind === "paragraph") block.runs.forEach((run, runIndex) => {
|
|
8
|
+
run.sourcePath = `${blockPath}.runs[${runIndex}]`;
|
|
9
|
+
});
|
|
10
|
+
else if (block.kind === "table") block.rows.forEach((row, rowIndex) => {
|
|
11
|
+
row.cells.forEach((cell, cellIndex) => {
|
|
12
|
+
assignSourcePaths(cell.blocks, `${blockPath}.rows[${rowIndex}].cells[${cellIndex}]`);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.assignSourcePaths = assignSourcePaths;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/typed/shared/source-path.ts
|
|
2
|
+
function assignSourcePaths(blocks, prefix) {
|
|
3
|
+
blocks.forEach((block, blockIndex) => {
|
|
4
|
+
const blockPath = `${prefix}.blocks[${blockIndex}]`;
|
|
5
|
+
block.sourcePath = blockPath;
|
|
6
|
+
if (block.kind === "paragraph") block.runs.forEach((run, runIndex) => {
|
|
7
|
+
run.sourcePath = `${blockPath}.runs[${runIndex}]`;
|
|
8
|
+
});
|
|
9
|
+
else if (block.kind === "table") block.rows.forEach((row, rowIndex) => {
|
|
10
|
+
row.cells.forEach((cell, cellIndex) => {
|
|
11
|
+
assignSourcePaths(cell.blocks, `${blockPath}.rows[${rowIndex}].cells[${cellIndex}]`);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { assignSourcePaths };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/typed/shared/units.ts
|
|
3
|
+
const POINTS_PER_INCH = 72;
|
|
4
|
+
const EMU_PER_INCH = 914400;
|
|
5
|
+
const TWIPS_PER_INCH = 1440;
|
|
6
|
+
const EMU_PER_POINT = EMU_PER_INCH / 72;
|
|
7
|
+
const TWIPS_PER_POINT = TWIPS_PER_INCH / 72;
|
|
8
|
+
const HALF_POINTS_PER_POINT = 2;
|
|
9
|
+
const DRAWINGML_FONT_SIZE_HUNDREDTHS_PER_POINT = 100;
|
|
10
|
+
const LINE_UNITS_PER_LINE = 240;
|
|
11
|
+
function emuToPt(emu) {
|
|
12
|
+
return emu / EMU_PER_POINT;
|
|
13
|
+
}
|
|
14
|
+
function ptToEmu(pt) {
|
|
15
|
+
return Math.round(pt * EMU_PER_POINT);
|
|
16
|
+
}
|
|
17
|
+
function twipsToPt(twips) {
|
|
18
|
+
return twips / 20;
|
|
19
|
+
}
|
|
20
|
+
function ptToTwips(pt) {
|
|
21
|
+
return Math.round(pt * 20);
|
|
22
|
+
}
|
|
23
|
+
function halfPointsToPt(halfPoints) {
|
|
24
|
+
return halfPoints / 2;
|
|
25
|
+
}
|
|
26
|
+
function ptToHalfPoints(pt) {
|
|
27
|
+
return Math.round(pt * 2);
|
|
28
|
+
}
|
|
29
|
+
function drawingMlFontSizeToPt(hundredths) {
|
|
30
|
+
return hundredths / 100;
|
|
31
|
+
}
|
|
32
|
+
function ptToDrawingMlFontSize(pt) {
|
|
33
|
+
return Math.round(pt * 100);
|
|
34
|
+
}
|
|
35
|
+
function lineUnitsToMultiplier(lineUnits) {
|
|
36
|
+
return lineUnits / 240;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.DRAWINGML_FONT_SIZE_HUNDREDTHS_PER_POINT = DRAWINGML_FONT_SIZE_HUNDREDTHS_PER_POINT;
|
|
40
|
+
exports.EMU_PER_INCH = EMU_PER_INCH;
|
|
41
|
+
exports.EMU_PER_POINT = EMU_PER_POINT;
|
|
42
|
+
exports.HALF_POINTS_PER_POINT = HALF_POINTS_PER_POINT;
|
|
43
|
+
exports.LINE_UNITS_PER_LINE = LINE_UNITS_PER_LINE;
|
|
44
|
+
exports.POINTS_PER_INCH = POINTS_PER_INCH;
|
|
45
|
+
exports.TWIPS_PER_INCH = TWIPS_PER_INCH;
|
|
46
|
+
exports.TWIPS_PER_POINT = TWIPS_PER_POINT;
|
|
47
|
+
exports.drawingMlFontSizeToPt = drawingMlFontSizeToPt;
|
|
48
|
+
exports.emuToPt = emuToPt;
|
|
49
|
+
exports.halfPointsToPt = halfPointsToPt;
|
|
50
|
+
exports.lineUnitsToMultiplier = lineUnitsToMultiplier;
|
|
51
|
+
exports.ptToDrawingMlFontSize = ptToDrawingMlFontSize;
|
|
52
|
+
exports.ptToEmu = ptToEmu;
|
|
53
|
+
exports.ptToHalfPoints = ptToHalfPoints;
|
|
54
|
+
exports.ptToTwips = ptToTwips;
|
|
55
|
+
exports.twipsToPt = twipsToPt;
|