wordinweb 0.2.3 → 0.2.4
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.
|
@@ -5448,6 +5448,7 @@ function parseVmlPict(pict, ctx) {
|
|
|
5448
5448
|
const strokeColor = el16.attrs["strokecolor"];
|
|
5449
5449
|
const stroked = el16.attrs["stroked"] !== "f" && strokeColor !== void 0;
|
|
5450
5450
|
const ta = style.get("v-text-anchor");
|
|
5451
|
+
const rotation = parseFloat(style.get("rotation") ?? "0") || 0;
|
|
5451
5452
|
const vmlInsets = parseVmlInset(findDescendant(el16, "textbox")?.attrs["inset"]);
|
|
5452
5453
|
out.push({
|
|
5453
5454
|
kind: "anchor",
|
|
@@ -5471,6 +5472,7 @@ function parseVmlPict(pict, ctx) {
|
|
|
5471
5472
|
pctWidthRel: relOf(style.get("mso-width-relative")),
|
|
5472
5473
|
pctHeightRel: relOf(style.get("mso-height-relative")),
|
|
5473
5474
|
textAnchor: ta === "middle" ? "middle" : ta === "bottom" ? "bottom" : void 0,
|
|
5475
|
+
...rotation ? { rotation } : {},
|
|
5474
5476
|
...vmlInsets ? { insets: vmlInsets } : {},
|
|
5475
5477
|
srcDrawing: el16,
|
|
5476
5478
|
...ctx.independentTextboxStories ? { textboxStory: true } : {}
|
|
@@ -22774,6 +22776,12 @@ function insertWordArtAt(doc, caretT, text, preset = "plain") {
|
|
|
22774
22776
|
}[preset];
|
|
22775
22777
|
const docPr = descendant3(drawing, "docPr");
|
|
22776
22778
|
if (docPr) docPr.attrs.name = `WordArt ${docPr.attrs.id}`;
|
|
22779
|
+
const anchor = descendant3(drawing, "anchor");
|
|
22780
|
+
if (anchor) {
|
|
22781
|
+
const wrap = anchor.children.findIndex((child4) => localName(child4.name).startsWith("wrap"));
|
|
22782
|
+
if (wrap !== -1) anchor.children[wrap] = el6("wp:wrapNone");
|
|
22783
|
+
anchor.attrs.behindDoc = "0";
|
|
22784
|
+
}
|
|
22777
22785
|
if (preset === "plain") {
|
|
22778
22786
|
const height = String(Math.round(40 * EMU_PER_PX4));
|
|
22779
22787
|
const extent = descendant3(drawing, "extent");
|
|
@@ -22953,8 +22961,39 @@ var NS_WP4 = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDra
|
|
|
22953
22961
|
function el7(name, attrs = {}, children2 = [], text = "") {
|
|
22954
22962
|
return { name, attrs, children: children2, text };
|
|
22955
22963
|
}
|
|
22964
|
+
function isVmlShape(el16) {
|
|
22965
|
+
return ["shape", "rect"].includes(localName(el16.name));
|
|
22966
|
+
}
|
|
22967
|
+
function vmlStyle(el16) {
|
|
22968
|
+
const style = /* @__PURE__ */ new Map();
|
|
22969
|
+
for (const declaration of (el16.attrs.style ?? "").split(";")) {
|
|
22970
|
+
const colon = declaration.indexOf(":");
|
|
22971
|
+
if (colon > 0) style.set(declaration.slice(0, colon).trim(), declaration.slice(colon + 1).trim());
|
|
22972
|
+
}
|
|
22973
|
+
return style;
|
|
22974
|
+
}
|
|
22975
|
+
function setVmlStyle(el16, patch) {
|
|
22976
|
+
const style = vmlStyle(el16);
|
|
22977
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
22978
|
+
if (value === null) style.delete(key);
|
|
22979
|
+
else style.set(key, value);
|
|
22980
|
+
}
|
|
22981
|
+
el16.attrs.style = [...style].map(([key, value]) => `${key}:${value}`).join(";");
|
|
22982
|
+
}
|
|
22983
|
+
function vmlLengthPx(raw) {
|
|
22984
|
+
if (!raw) return 0;
|
|
22985
|
+
const match = /^(-?[\d.]+)\s*(pt|in|px)?$/.exec(raw.trim());
|
|
22986
|
+
if (!match) return 0;
|
|
22987
|
+
const value = parseFloat(match[1]);
|
|
22988
|
+
if (match[2] === "pt") return value * 4 / 3;
|
|
22989
|
+
if (match[2] === "in") return value * 96;
|
|
22990
|
+
return value;
|
|
22991
|
+
}
|
|
22992
|
+
function pxToVmlPt(px) {
|
|
22993
|
+
return `${Math.round(px * 75) / 100}pt`;
|
|
22994
|
+
}
|
|
22956
22995
|
function isFloatingDrawing(drawingEl) {
|
|
22957
|
-
return !!child(drawingEl, "anchor");
|
|
22996
|
+
return !!child(drawingEl, "anchor") || isVmlShape(drawingEl) && vmlStyle(drawingEl).get("position") === "absolute";
|
|
22958
22997
|
}
|
|
22959
22998
|
function imageAltText(drawingEl) {
|
|
22960
22999
|
const holder = child(drawingEl, "inline") ?? child(drawingEl, "anchor");
|
|
@@ -23069,7 +23108,20 @@ function setFloatingPosition(doc, drawingEl, xPx, yPx) {
|
|
|
23069
23108
|
}
|
|
23070
23109
|
function setFloatingPagePosition(doc, drawingEl, xPx, yPx) {
|
|
23071
23110
|
const anchor = child(drawingEl, "anchor");
|
|
23072
|
-
if (!anchor)
|
|
23111
|
+
if (!anchor) {
|
|
23112
|
+
if (!isVmlShape(drawingEl)) return false;
|
|
23113
|
+
setVmlStyle(drawingEl, {
|
|
23114
|
+
position: "absolute",
|
|
23115
|
+
"margin-left": pxToVmlPt(xPx),
|
|
23116
|
+
"margin-top": pxToVmlPt(yPx),
|
|
23117
|
+
"mso-position-horizontal": "absolute",
|
|
23118
|
+
"mso-position-horizontal-relative": "page",
|
|
23119
|
+
"mso-position-vertical": "absolute",
|
|
23120
|
+
"mso-position-vertical-relative": "page"
|
|
23121
|
+
});
|
|
23122
|
+
doc.refresh();
|
|
23123
|
+
return true;
|
|
23124
|
+
}
|
|
23073
23125
|
const set = (posName, px) => {
|
|
23074
23126
|
let posEl = child(anchor, posName);
|
|
23075
23127
|
if (!posEl) {
|
|
@@ -23088,7 +23140,16 @@ function setFloatingPagePosition(doc, drawingEl, xPx, yPx) {
|
|
|
23088
23140
|
}
|
|
23089
23141
|
function adjustFloatingPosition(doc, drawingEl, dxPx, dyPx) {
|
|
23090
23142
|
const anchor = child(drawingEl, "anchor");
|
|
23091
|
-
if (!anchor)
|
|
23143
|
+
if (!anchor) {
|
|
23144
|
+
if (!isVmlShape(drawingEl) || !isFloatingDrawing(drawingEl)) return false;
|
|
23145
|
+
const style = vmlStyle(drawingEl);
|
|
23146
|
+
setVmlStyle(drawingEl, {
|
|
23147
|
+
"margin-left": pxToVmlPt(vmlLengthPx(style.get("margin-left")) + dxPx),
|
|
23148
|
+
"margin-top": pxToVmlPt(vmlLengthPx(style.get("margin-top")) + dyPx)
|
|
23149
|
+
});
|
|
23150
|
+
doc.refresh();
|
|
23151
|
+
return true;
|
|
23152
|
+
}
|
|
23092
23153
|
const bump = (posName, deltaPx) => {
|
|
23093
23154
|
const posEl = child(anchor, posName);
|
|
23094
23155
|
if (!posEl) return;
|
|
@@ -23118,13 +23179,19 @@ function drawingTransform(drawingEl) {
|
|
|
23118
23179
|
}
|
|
23119
23180
|
function drawingRotation(drawingEl) {
|
|
23120
23181
|
const xfrm = drawingTransform(drawingEl);
|
|
23121
|
-
if (!xfrm) return 0;
|
|
23182
|
+
if (!xfrm) return isVmlShape(drawingEl) ? parseFloat(vmlStyle(drawingEl).get("rotation") ?? "0") || 0 : 0;
|
|
23122
23183
|
const key = Object.keys(xfrm.attrs).find((k) => localName(k) === "rot");
|
|
23123
23184
|
return key ? (parseInt(xfrm.attrs[key], 10) || 0) / 6e4 : 0;
|
|
23124
23185
|
}
|
|
23125
23186
|
function setDrawingRotation(doc, drawingEl, degrees) {
|
|
23126
23187
|
const xfrm = drawingTransform(drawingEl);
|
|
23127
|
-
if (!xfrm)
|
|
23188
|
+
if (!xfrm) {
|
|
23189
|
+
if (!isVmlShape(drawingEl)) return false;
|
|
23190
|
+
const normalized2 = (degrees % 360 + 360) % 360;
|
|
23191
|
+
setVmlStyle(drawingEl, { rotation: normalized2 === 0 ? null : String(Math.round(normalized2 * 100) / 100) });
|
|
23192
|
+
doc.refresh();
|
|
23193
|
+
return true;
|
|
23194
|
+
}
|
|
23128
23195
|
const key = Object.keys(xfrm.attrs).find((k) => localName(k) === "rot") ?? "rot";
|
|
23129
23196
|
const normalized = (degrees % 360 + 360) % 360;
|
|
23130
23197
|
if (normalized === 0) delete xfrm.attrs[key];
|
|
@@ -38342,4 +38409,4 @@ export {
|
|
|
38342
38409
|
cfb/cfb.js:
|
|
38343
38410
|
(*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
|
|
38344
38411
|
*/
|
|
38345
|
-
//# sourceMappingURL=chunk-
|
|
38412
|
+
//# sourceMappingURL=chunk-QH2L3NPL.js.map
|