wordinweb 0.1.11 → 0.1.12
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 +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +516 -340
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -4124,7 +4124,17 @@ function parseDrawing(drawing, ctx) {
|
|
|
4124
4124
|
const modelRel = modelRelId ? ctx.rels.get(modelRelId) : void 0;
|
|
4125
4125
|
if (rel && !rel.external) {
|
|
4126
4126
|
if (modelRel && !modelRel.external) {
|
|
4127
|
-
|
|
4127
|
+
const rot = child(child(el16, "trans"), "rot");
|
|
4128
|
+
const rotation = {
|
|
4129
|
+
x: (intAttr(rot, "ax") ?? 0) / 6e4,
|
|
4130
|
+
y: (intAttr(rot, "ay") ?? 0) / 6e4,
|
|
4131
|
+
z: (intAttr(rot, "az") ?? 0) / 6e4
|
|
4132
|
+
};
|
|
4133
|
+
model3D = {
|
|
4134
|
+
part: modelRel.target,
|
|
4135
|
+
posterPart: rel.target,
|
|
4136
|
+
...rotation.x || rotation.y || rotation.z ? { rotation } : {}
|
|
4137
|
+
};
|
|
4128
4138
|
}
|
|
4129
4139
|
const xfrm = path(el16, "spPr", "xfrm");
|
|
4130
4140
|
const off = child(xfrm, "off");
|
|
@@ -18073,7 +18083,7 @@ function renderPage(doc, page, zoom, urls, options, bindings, grips, images, dra
|
|
|
18073
18083
|
continue;
|
|
18074
18084
|
}
|
|
18075
18085
|
if (item.kind === "drawingHit" && !options.interactive) continue;
|
|
18076
|
-
const node = renderItem(doc, item, urls);
|
|
18086
|
+
const node = renderItem(doc, item, urls, options.interactive === true);
|
|
18077
18087
|
if (node) {
|
|
18078
18088
|
node.dataset.dxwItemKind = item.kind;
|
|
18079
18089
|
if ((item.kind === "rect" || item.kind === "edge") && item.role) {
|
|
@@ -18593,7 +18603,7 @@ function setItemLayer(element, item, frontLayer = 1) {
|
|
|
18593
18603
|
else if (item.z !== void 0) element.style.zIndex = String(item.z);
|
|
18594
18604
|
else if (item.front) element.style.zIndex = String(frontLayer);
|
|
18595
18605
|
}
|
|
18596
|
-
function renderItem(doc, item, urls) {
|
|
18606
|
+
function renderItem(doc, item, urls, interactive) {
|
|
18597
18607
|
switch (item.kind) {
|
|
18598
18608
|
case "rect": {
|
|
18599
18609
|
const el16 = document.createElement("div");
|
|
@@ -18836,6 +18846,83 @@ function renderItem(doc, item, urls) {
|
|
|
18836
18846
|
img.style.width = `${item.width}px`;
|
|
18837
18847
|
img.style.height = `${item.height}px`;
|
|
18838
18848
|
}
|
|
18849
|
+
if (item.model3D && interactive) {
|
|
18850
|
+
const modelBytes = doc.media(item.model3D.part);
|
|
18851
|
+
if (modelBytes) {
|
|
18852
|
+
const modelUrl = docMediaUrl(doc, item.model3D.part, () => {
|
|
18853
|
+
const buffer = modelBytes.buffer.slice(
|
|
18854
|
+
modelBytes.byteOffset,
|
|
18855
|
+
modelBytes.byteOffset + modelBytes.byteLength
|
|
18856
|
+
);
|
|
18857
|
+
return URL.createObjectURL(new Blob([buffer], { type: "model/gltf-binary" }));
|
|
18858
|
+
});
|
|
18859
|
+
const frame = document.createElement("div");
|
|
18860
|
+
frame.appendChild(node);
|
|
18861
|
+
const viewer = document.createElement("model-viewer");
|
|
18862
|
+
viewer.dataset.dxwModel3dViewer = "1";
|
|
18863
|
+
viewer.setAttribute("src", modelUrl);
|
|
18864
|
+
viewer.setAttribute("poster", img.src);
|
|
18865
|
+
viewer.setAttribute("alt", "3D model");
|
|
18866
|
+
viewer.setAttribute("loading", "eager");
|
|
18867
|
+
viewer.setAttribute("interaction-prompt", "none");
|
|
18868
|
+
viewer.style.cssText = "position:absolute;inset:0;width:100%;height:100%;background:transparent;cursor:grab;touch-action:none;";
|
|
18869
|
+
let rotation = { x: 0, y: 0, z: 0, ...item.model3D.rotation };
|
|
18870
|
+
const orient = () => {
|
|
18871
|
+
viewer.setAttribute("orientation", `${rotation.z}deg ${rotation.x}deg ${rotation.y}deg`);
|
|
18872
|
+
};
|
|
18873
|
+
orient();
|
|
18874
|
+
let pointerId = null;
|
|
18875
|
+
let startX = 0;
|
|
18876
|
+
let startY = 0;
|
|
18877
|
+
let startRotation = rotation;
|
|
18878
|
+
let moved = false;
|
|
18879
|
+
viewer.addEventListener("pointerdown", (event) => {
|
|
18880
|
+
if (event.button !== 0) return;
|
|
18881
|
+
event.preventDefault();
|
|
18882
|
+
event.stopPropagation();
|
|
18883
|
+
pointerId = event.pointerId;
|
|
18884
|
+
startX = event.clientX;
|
|
18885
|
+
startY = event.clientY;
|
|
18886
|
+
startRotation = rotation;
|
|
18887
|
+
moved = false;
|
|
18888
|
+
viewer.setPointerCapture(event.pointerId);
|
|
18889
|
+
viewer.style.cursor = "grabbing";
|
|
18890
|
+
});
|
|
18891
|
+
viewer.addEventListener("pointermove", (event) => {
|
|
18892
|
+
if (pointerId !== event.pointerId) return;
|
|
18893
|
+
const dx = event.clientX - startX;
|
|
18894
|
+
const dy = event.clientY - startY;
|
|
18895
|
+
if (!moved && Math.hypot(dx, dy) < 2) return;
|
|
18896
|
+
moved = true;
|
|
18897
|
+
rotation = {
|
|
18898
|
+
x: startRotation.x + dy * 0.5,
|
|
18899
|
+
y: startRotation.y + dx * 0.5,
|
|
18900
|
+
z: startRotation.z
|
|
18901
|
+
};
|
|
18902
|
+
orient();
|
|
18903
|
+
});
|
|
18904
|
+
const finish = (event, commit) => {
|
|
18905
|
+
if (pointerId !== event.pointerId) return;
|
|
18906
|
+
if (viewer.hasPointerCapture(event.pointerId)) viewer.releasePointerCapture(event.pointerId);
|
|
18907
|
+
pointerId = null;
|
|
18908
|
+
viewer.style.cursor = "grab";
|
|
18909
|
+
if (!moved) return;
|
|
18910
|
+
if (!commit) {
|
|
18911
|
+
rotation = startRotation;
|
|
18912
|
+
orient();
|
|
18913
|
+
return;
|
|
18914
|
+
}
|
|
18915
|
+
viewer.dispatchEvent(new CustomEvent("dxw-model3d-rotate", {
|
|
18916
|
+
bubbles: true,
|
|
18917
|
+
detail: rotation
|
|
18918
|
+
}));
|
|
18919
|
+
};
|
|
18920
|
+
viewer.addEventListener("pointerup", (event) => finish(event, true));
|
|
18921
|
+
viewer.addEventListener("pointercancel", (event) => finish(event, false));
|
|
18922
|
+
frame.appendChild(viewer);
|
|
18923
|
+
node = frame;
|
|
18924
|
+
}
|
|
18925
|
+
}
|
|
18839
18926
|
node.style.position = "absolute";
|
|
18840
18927
|
node.style.left = `${item.x}px`;
|
|
18841
18928
|
node.style.top = `${item.y}px`;
|
|
@@ -22190,6 +22277,253 @@ function requestTextInputDialog(anchor, options) {
|
|
|
22190
22277
|
});
|
|
22191
22278
|
}
|
|
22192
22279
|
|
|
22280
|
+
// ../core/src/edit/objects.ts
|
|
22281
|
+
var EMU_PER_PX6 = 9525;
|
|
22282
|
+
var NS_WP5 = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
|
|
22283
|
+
var NS_A4 = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
22284
|
+
var NS_PIC2 = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
22285
|
+
var NS_R3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
22286
|
+
var NS_MC = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
22287
|
+
var NS_AM3D = "http://schemas.microsoft.com/office/drawing/2017/model3d";
|
|
22288
|
+
var NS_WP15 = "http://schemas.microsoft.com/office/word/2012/wordprocessingDrawing";
|
|
22289
|
+
function el8(name, attrs = {}, children2 = [], text = "") {
|
|
22290
|
+
return { name, attrs, children: children2, text };
|
|
22291
|
+
}
|
|
22292
|
+
function prefixOf9(node) {
|
|
22293
|
+
return node.name.includes(":") ? node.name.slice(0, node.name.indexOf(":") + 1) : "";
|
|
22294
|
+
}
|
|
22295
|
+
function insertAfterCaretRun(doc, caretT, content) {
|
|
22296
|
+
const caretRun = doc.findParentOf(caretT);
|
|
22297
|
+
const parent = caretRun && doc.findParentOf(caretRun);
|
|
22298
|
+
if (!caretRun || !parent || localName(caretRun.name) !== "r") return false;
|
|
22299
|
+
const w = prefixOf9(caretRun);
|
|
22300
|
+
parent.children.splice(parent.children.indexOf(caretRun) + 1, 0, el8(`${w}r`, {}, [content]));
|
|
22301
|
+
doc.refresh();
|
|
22302
|
+
return true;
|
|
22303
|
+
}
|
|
22304
|
+
function pictureGraphic(relId, id, cx, cy, webVideo) {
|
|
22305
|
+
const blipChildren = webVideo ? [
|
|
22306
|
+
el8("a:extLst", {}, [
|
|
22307
|
+
el8("a:ext", { uri: "{9E29B28B-C9C2-4B96-BA92-6C9A3D8F4A6A}" }, [
|
|
22308
|
+
el8("wp15:webVideoPr", {
|
|
22309
|
+
"xmlns:wp15": NS_WP15,
|
|
22310
|
+
embeddedHtml: webVideo,
|
|
22311
|
+
w: "640",
|
|
22312
|
+
h: "360"
|
|
22313
|
+
})
|
|
22314
|
+
])
|
|
22315
|
+
])
|
|
22316
|
+
] : [];
|
|
22317
|
+
return el8("a:graphic", { "xmlns:a": NS_A4 }, [
|
|
22318
|
+
el8("a:graphicData", { uri: NS_PIC2 }, [
|
|
22319
|
+
el8("pic:pic", { "xmlns:pic": NS_PIC2 }, [
|
|
22320
|
+
el8("pic:nvPicPr", {}, [
|
|
22321
|
+
el8("pic:cNvPr", { id, name: `Picture ${id}` }),
|
|
22322
|
+
el8("pic:cNvPicPr", {}, [el8("a:picLocks", { noChangeAspect: "1" })])
|
|
22323
|
+
]),
|
|
22324
|
+
el8("pic:blipFill", {}, [
|
|
22325
|
+
el8("a:blip", { "xmlns:r": NS_R3, "r:embed": relId }, blipChildren),
|
|
22326
|
+
el8("a:stretch", {}, [el8("a:fillRect")])
|
|
22327
|
+
]),
|
|
22328
|
+
el8("pic:spPr", {}, [
|
|
22329
|
+
el8("a:xfrm", {}, [el8("a:off", { x: "0", y: "0" }), el8("a:ext", { cx, cy })]),
|
|
22330
|
+
el8("a:prstGeom", { prst: "rect" }, [el8("a:avLst")])
|
|
22331
|
+
])
|
|
22332
|
+
])
|
|
22333
|
+
])
|
|
22334
|
+
]);
|
|
22335
|
+
}
|
|
22336
|
+
function inlineDrawing(id, name, descr, cx, cy, graphic) {
|
|
22337
|
+
return el8("w:drawing", {}, [
|
|
22338
|
+
el8("wp:inline", { "xmlns:wp": NS_WP5, distT: "0", distB: "0", distL: "0", distR: "0" }, [
|
|
22339
|
+
el8("wp:extent", { cx, cy }),
|
|
22340
|
+
el8("wp:effectExtent", { l: "0", t: "0", r: "0", b: "0" }),
|
|
22341
|
+
el8("wp:docPr", { id, name, descr }),
|
|
22342
|
+
el8("wp:cNvGraphicFramePr", {}, [el8("a:graphicFrameLocks", { "xmlns:a": NS_A4, noChangeAspect: "1" })]),
|
|
22343
|
+
graphic
|
|
22344
|
+
])
|
|
22345
|
+
]);
|
|
22346
|
+
}
|
|
22347
|
+
function insertModel3DAt(doc, caretT, input) {
|
|
22348
|
+
const posterRelId = doc.addImageResource(input.poster, input.posterExt ?? "png");
|
|
22349
|
+
const model = doc.addModel3DResource(input.data);
|
|
22350
|
+
const id = String(doc.nextDrawingId());
|
|
22351
|
+
const width = 320;
|
|
22352
|
+
const height = 220;
|
|
22353
|
+
const cx = String(width * EMU_PER_PX6);
|
|
22354
|
+
const cy = String(height * EMU_PER_PX6);
|
|
22355
|
+
const modelGraphic = el8("a:graphic", { "xmlns:a": NS_A4 }, [
|
|
22356
|
+
el8("a:graphicData", { uri: NS_AM3D }, [
|
|
22357
|
+
el8("am3d:model3d", { "xmlns:am3d": NS_AM3D, "xmlns:r": NS_R3, "r:embed": model.relId }, [
|
|
22358
|
+
el8("am3d:spPr", {}, [
|
|
22359
|
+
el8("a:xfrm", {}, [el8("a:off", { x: "0", y: "0" }), el8("a:ext", { cx, cy })]),
|
|
22360
|
+
el8("a:prstGeom", { prst: "rect" }, [el8("a:avLst")])
|
|
22361
|
+
]),
|
|
22362
|
+
el8("am3d:camera", {}, [
|
|
22363
|
+
el8("am3d:pos", { x: "0", y: "0", z: "77741944" }),
|
|
22364
|
+
el8("am3d:up", { dx: "0", dy: "36000000", dz: "0" }),
|
|
22365
|
+
el8("am3d:lookAt", { x: "0", y: "0", z: "0" }),
|
|
22366
|
+
el8("am3d:perspective", { fov: "2700000" })
|
|
22367
|
+
]),
|
|
22368
|
+
el8("am3d:trans", {}, [
|
|
22369
|
+
el8("am3d:meterPerModelUnit", { n: "1", d: "1" }),
|
|
22370
|
+
el8("am3d:preTrans", { dx: "0", dy: "0", dz: "0" }),
|
|
22371
|
+
el8("am3d:scale", {}, [
|
|
22372
|
+
el8("am3d:sx", { n: "1000000", d: "1000000" }),
|
|
22373
|
+
el8("am3d:sy", { n: "1000000", d: "1000000" }),
|
|
22374
|
+
el8("am3d:sz", { n: "1000000", d: "1000000" })
|
|
22375
|
+
]),
|
|
22376
|
+
el8("am3d:rot", { ax: "0", ay: "0", az: "0" }),
|
|
22377
|
+
el8("am3d:postTrans", { dx: "0", dy: "0", dz: "0" })
|
|
22378
|
+
]),
|
|
22379
|
+
el8("am3d:raster", { rName: "Office3DRenderer", rVer: "16.0" }, [
|
|
22380
|
+
el8("am3d:blip", { "r:embed": posterRelId })
|
|
22381
|
+
]),
|
|
22382
|
+
el8("am3d:objViewport", { viewportSz: cx }),
|
|
22383
|
+
el8("am3d:ambientLight", {}, [
|
|
22384
|
+
el8("am3d:clr", {}, [el8("a:scrgbClr", { r: "50000", g: "50000", b: "50000" })]),
|
|
22385
|
+
el8("am3d:illuminance", { n: "500000", d: "1000000" })
|
|
22386
|
+
]),
|
|
22387
|
+
el8("am3d:ptLight", { rad: "0" }, [
|
|
22388
|
+
el8("am3d:clr", {}, [el8("a:scrgbClr", { r: "100000", g: "100000", b: "100000" })]),
|
|
22389
|
+
el8("am3d:intensity", { n: "1000000", d: "1000000" }),
|
|
22390
|
+
el8("am3d:pos", { x: "30000000", y: "50000000", z: "50000000" })
|
|
22391
|
+
])
|
|
22392
|
+
])
|
|
22393
|
+
])
|
|
22394
|
+
]);
|
|
22395
|
+
const alt = input.alt ?? "3D model";
|
|
22396
|
+
const choice = inlineDrawing(id, `3D Model ${id}`, alt, cx, cy, modelGraphic);
|
|
22397
|
+
const fallback = inlineDrawing(id, `3D Model ${id}`, alt, cx, cy, pictureGraphic(posterRelId, id, cx, cy));
|
|
22398
|
+
const alternate = el8("mc:AlternateContent", { "xmlns:mc": NS_MC }, [
|
|
22399
|
+
el8("mc:Choice", { Requires: "am3d", "xmlns:am3d": NS_AM3D }, [choice]),
|
|
22400
|
+
el8("mc:Fallback", {}, [fallback])
|
|
22401
|
+
]);
|
|
22402
|
+
return insertAfterCaretRun(doc, caretT, alternate);
|
|
22403
|
+
}
|
|
22404
|
+
function setModel3DRotation(doc, drawingEl, rotation) {
|
|
22405
|
+
let model;
|
|
22406
|
+
const visit = (node) => {
|
|
22407
|
+
if (model) return;
|
|
22408
|
+
if (localName(node.name) === "model3d") model = node;
|
|
22409
|
+
else for (const child4 of node.children) visit(child4);
|
|
22410
|
+
};
|
|
22411
|
+
visit(drawingEl);
|
|
22412
|
+
if (!model) return false;
|
|
22413
|
+
const trans = model.children.find((child4) => localName(child4.name) === "trans");
|
|
22414
|
+
if (!trans) return false;
|
|
22415
|
+
let rot = trans.children.find((child4) => localName(child4.name) === "rot");
|
|
22416
|
+
if (!rot) {
|
|
22417
|
+
rot = el8("am3d:rot");
|
|
22418
|
+
const post = trans.children.findIndex((child4) => localName(child4.name) === "postTrans");
|
|
22419
|
+
trans.children.splice(post === -1 ? trans.children.length : post, 0, rot);
|
|
22420
|
+
}
|
|
22421
|
+
const angle = (degrees) => {
|
|
22422
|
+
const normalized = (degrees % 360 + 360) % 360;
|
|
22423
|
+
return String(Math.round(normalized * 6e4));
|
|
22424
|
+
};
|
|
22425
|
+
rot.attrs.ax = angle(rotation.x);
|
|
22426
|
+
rot.attrs.ay = angle(rotation.y);
|
|
22427
|
+
rot.attrs.az = angle(rotation.z);
|
|
22428
|
+
doc.refresh();
|
|
22429
|
+
return true;
|
|
22430
|
+
}
|
|
22431
|
+
function normalizeWebVideoUrl(value) {
|
|
22432
|
+
try {
|
|
22433
|
+
const url = new URL(value.trim());
|
|
22434
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return null;
|
|
22435
|
+
if (url.hostname === "youtu.be") return `https://www.youtube.com/embed/${url.pathname.slice(1)}`;
|
|
22436
|
+
if (url.hostname.endsWith("youtube.com") && url.pathname === "/watch") {
|
|
22437
|
+
const id = url.searchParams.get("v");
|
|
22438
|
+
if (id) return `https://www.youtube.com/embed/${id}`;
|
|
22439
|
+
}
|
|
22440
|
+
if (url.hostname.endsWith("vimeo.com") && /^\/\d+\/?$/.test(url.pathname)) {
|
|
22441
|
+
return `https://player.vimeo.com/video/${url.pathname.replace(/\//g, "")}`;
|
|
22442
|
+
}
|
|
22443
|
+
return url.href;
|
|
22444
|
+
} catch {
|
|
22445
|
+
return null;
|
|
22446
|
+
}
|
|
22447
|
+
}
|
|
22448
|
+
function insertWebVideoAt(doc, caretT, input) {
|
|
22449
|
+
const url = normalizeWebVideoUrl(input.url);
|
|
22450
|
+
if (!url) return false;
|
|
22451
|
+
const posterRelId = doc.addImageResource(input.poster, input.posterExt ?? "png");
|
|
22452
|
+
const width = input.width ?? 320;
|
|
22453
|
+
const height = input.height ?? 180;
|
|
22454
|
+
const cx = String(Math.round(width * EMU_PER_PX6));
|
|
22455
|
+
const cy = String(Math.round(height * EMU_PER_PX6));
|
|
22456
|
+
const id = String(doc.nextDrawingId());
|
|
22457
|
+
const embeddedHtml = `<iframe width="640" height="360" src="${url}" frameborder="0" allowfullscreen=""></iframe>`;
|
|
22458
|
+
return insertAfterCaretRun(
|
|
22459
|
+
doc,
|
|
22460
|
+
caretT,
|
|
22461
|
+
inlineDrawing(id, `Online Video ${id}`, url, cx, cy, pictureGraphic(posterRelId, id, cx, cy, embeddedHtml))
|
|
22462
|
+
);
|
|
22463
|
+
}
|
|
22464
|
+
function insertEmbeddedObjectAt(doc, caretT, input) {
|
|
22465
|
+
const posterRelId = doc.addImageResource(input.poster, input.posterExt ?? "png");
|
|
22466
|
+
const wordDocument = input.filename.toLowerCase().endsWith(".docx");
|
|
22467
|
+
const object = wordDocument ? doc.addEmbeddedWordDocumentResource(input.data) : doc.addEmbeddedObjectResource(buildOlePackage(input.data, input.filename));
|
|
22468
|
+
const id = String(doc.nextDrawingId());
|
|
22469
|
+
const vmlId = 1024 + Number(id);
|
|
22470
|
+
const shapeTypeId = `_x0000_t${vmlId}`;
|
|
22471
|
+
const shapeId = `_x0000_i${vmlId}`;
|
|
22472
|
+
const width = 320;
|
|
22473
|
+
const height = 180;
|
|
22474
|
+
const objectEl = el8("w:object", {
|
|
22475
|
+
"xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
22476
|
+
"xmlns:v": "urn:schemas-microsoft-com:vml",
|
|
22477
|
+
"xmlns:o": "urn:schemas-microsoft-com:office:office",
|
|
22478
|
+
"xmlns:r": NS_R3,
|
|
22479
|
+
"w:dxaOrig": String(width * 15),
|
|
22480
|
+
"w:dyaOrig": String(height * 15)
|
|
22481
|
+
}, [
|
|
22482
|
+
el8("v:shapetype", {
|
|
22483
|
+
id: shapeTypeId,
|
|
22484
|
+
coordsize: "21600,21600",
|
|
22485
|
+
"o:spt": "75",
|
|
22486
|
+
"o:preferrelative": "t",
|
|
22487
|
+
path: "m@4@5l@4@11@9@11@9@5xe",
|
|
22488
|
+
filled: "f",
|
|
22489
|
+
stroked: "f"
|
|
22490
|
+
}, [
|
|
22491
|
+
el8("v:stroke", { joinstyle: "miter" }),
|
|
22492
|
+
el8("v:formulas", {}, [
|
|
22493
|
+
el8("v:f", { eqn: "if lineDrawn pixelLineWidth 0" }),
|
|
22494
|
+
el8("v:f", { eqn: "sum @0 1 0" }),
|
|
22495
|
+
el8("v:f", { eqn: "sum 0 0 @1" }),
|
|
22496
|
+
el8("v:f", { eqn: "prod @2 1 2" }),
|
|
22497
|
+
el8("v:f", { eqn: "prod @3 21600 pixelWidth" }),
|
|
22498
|
+
el8("v:f", { eqn: "prod @3 21600 pixelHeight" }),
|
|
22499
|
+
el8("v:f", { eqn: "sum @0 0 1" }),
|
|
22500
|
+
el8("v:f", { eqn: "prod @6 1 2" }),
|
|
22501
|
+
el8("v:f", { eqn: "prod @7 21600 pixelWidth" }),
|
|
22502
|
+
el8("v:f", { eqn: "sum @8 21600 0" }),
|
|
22503
|
+
el8("v:f", { eqn: "prod @7 21600 pixelHeight" }),
|
|
22504
|
+
el8("v:f", { eqn: "sum @10 21600 0" })
|
|
22505
|
+
]),
|
|
22506
|
+
el8("v:path", { "o:extrusionok": "f", gradientshapeok: "t", "o:connecttype": "rect" }),
|
|
22507
|
+
el8("o:lock", { "v:ext": "edit", aspectratio: "t" })
|
|
22508
|
+
]),
|
|
22509
|
+
el8("v:shape", {
|
|
22510
|
+
id: shapeId,
|
|
22511
|
+
type: `#${shapeTypeId}`,
|
|
22512
|
+
style: `width:${width * 0.75}pt;height:${height * 0.75}pt`,
|
|
22513
|
+
"o:ole": ""
|
|
22514
|
+
}, [el8("v:imagedata", { "r:id": posterRelId, "o:title": input.filename })]),
|
|
22515
|
+
el8("o:OLEObject", {
|
|
22516
|
+
Type: "Embed",
|
|
22517
|
+
ProgID: wordDocument ? "Word.Document.12" : "Package",
|
|
22518
|
+
ShapeID: shapeId,
|
|
22519
|
+
DrawAspect: "Content",
|
|
22520
|
+
ObjectID: `_${1e9 + Number(id)}`,
|
|
22521
|
+
"r:id": object.relId
|
|
22522
|
+
}, wordDocument ? [el8("o:FieldCodes", {}, [], "\\s")] : [])
|
|
22523
|
+
]);
|
|
22524
|
+
return insertAfterCaretRun(doc, caretT, objectEl);
|
|
22525
|
+
}
|
|
22526
|
+
|
|
22193
22527
|
// ../core/src/edit/grapheme.ts
|
|
22194
22528
|
var segmenter = null;
|
|
22195
22529
|
var segmenterTried = false;
|
|
@@ -22231,8 +22565,8 @@ function graphemeStep(text, offset, delta) {
|
|
|
22231
22565
|
}
|
|
22232
22566
|
|
|
22233
22567
|
// ../core/src/edit/clipboard.ts
|
|
22234
|
-
var
|
|
22235
|
-
var
|
|
22568
|
+
var el9 = (name, attrs = {}, children2 = [], text = "") => ({ name, attrs, children: children2, text });
|
|
22569
|
+
var prefixOf10 = (node) => node.name.includes(":") ? node.name.slice(0, node.name.indexOf(":") + 1) : "";
|
|
22236
22570
|
function colorValue(value) {
|
|
22237
22571
|
if (!value) return void 0;
|
|
22238
22572
|
const hex = value.match(/^#([0-9a-f]{6})$/i);
|
|
@@ -22243,7 +22577,7 @@ function colorValue(value) {
|
|
|
22243
22577
|
}
|
|
22244
22578
|
function runPropsXml(w, props) {
|
|
22245
22579
|
const children2 = [];
|
|
22246
|
-
const add = (name, attrs = {}) => children2.push(
|
|
22580
|
+
const add = (name, attrs = {}) => children2.push(el9(`${w}${name}`, attrs));
|
|
22247
22581
|
if (props.bold) add("b");
|
|
22248
22582
|
if (props.italic) add("i");
|
|
22249
22583
|
if (props.underline && props.underline !== "none") add("u", { [`${w}val`]: props.underline });
|
|
@@ -22264,10 +22598,10 @@ function runPropsXml(w, props) {
|
|
|
22264
22598
|
if (props.verticalAlign && props.verticalAlign !== "baseline") {
|
|
22265
22599
|
add("vertAlign", { [`${w}val`]: props.verticalAlign });
|
|
22266
22600
|
}
|
|
22267
|
-
return children2.length ?
|
|
22601
|
+
return children2.length ? el9(`${w}rPr`, {}, children2) : null;
|
|
22268
22602
|
}
|
|
22269
22603
|
function paragraphFragment(paragraph, segments) {
|
|
22270
|
-
const w =
|
|
22604
|
+
const w = prefixOf10(paragraph);
|
|
22271
22605
|
const children2 = [];
|
|
22272
22606
|
const pPr = child(paragraph, "pPr");
|
|
22273
22607
|
if (pPr) {
|
|
@@ -22288,9 +22622,9 @@ function paragraphFragment(paragraph, segments) {
|
|
|
22288
22622
|
const text = node.text.slice(segment.start, segment.end);
|
|
22289
22623
|
if (!text) continue;
|
|
22290
22624
|
const rPr = runPropsXml(w, segment.props);
|
|
22291
|
-
children2.push(
|
|
22625
|
+
children2.push(el9(`${w}r`, {}, [
|
|
22292
22626
|
...rPr ? [rPr] : [],
|
|
22293
|
-
|
|
22627
|
+
el9(`${w}t`, { "xml:space": "preserve" }, [], text)
|
|
22294
22628
|
]));
|
|
22295
22629
|
}
|
|
22296
22630
|
return;
|
|
@@ -22298,7 +22632,7 @@ function paragraphFragment(paragraph, segments) {
|
|
|
22298
22632
|
for (const childNode of node.children) visit(childNode);
|
|
22299
22633
|
};
|
|
22300
22634
|
visit(paragraph);
|
|
22301
|
-
return
|
|
22635
|
+
return el9(paragraph.name, { ...paragraph.attrs }, children2);
|
|
22302
22636
|
}
|
|
22303
22637
|
function trimTable(source, copy, selected) {
|
|
22304
22638
|
if (localName(source.name) === "t") {
|
|
@@ -22367,65 +22701,65 @@ function htmlStyle(node, inherited) {
|
|
|
22367
22701
|
}
|
|
22368
22702
|
function htmlRPr(w, style) {
|
|
22369
22703
|
const children2 = [];
|
|
22370
|
-
if (style.bold) children2.push(
|
|
22371
|
-
if (style.italic) children2.push(
|
|
22372
|
-
if (style.underline) children2.push(
|
|
22373
|
-
if (style.strike) children2.push(
|
|
22374
|
-
if (style.color) children2.push(
|
|
22375
|
-
if (style.font) children2.push(
|
|
22376
|
-
if (style.sizeHalfPoints) children2.push(
|
|
22377
|
-
return children2.length ?
|
|
22704
|
+
if (style.bold) children2.push(el9(`${w}b`));
|
|
22705
|
+
if (style.italic) children2.push(el9(`${w}i`));
|
|
22706
|
+
if (style.underline) children2.push(el9(`${w}u`, { [`${w}val`]: "single" }));
|
|
22707
|
+
if (style.strike) children2.push(el9(`${w}strike`));
|
|
22708
|
+
if (style.color) children2.push(el9(`${w}color`, { [`${w}val`]: style.color }));
|
|
22709
|
+
if (style.font) children2.push(el9(`${w}rFonts`, { [`${w}ascii`]: style.font, [`${w}hAnsi`]: style.font }));
|
|
22710
|
+
if (style.sizeHalfPoints) children2.push(el9(`${w}sz`, { [`${w}val`]: String(style.sizeHalfPoints) }));
|
|
22711
|
+
return children2.length ? el9(`${w}rPr`, {}, children2) : null;
|
|
22378
22712
|
}
|
|
22379
22713
|
function inlineRuns(node, w, inherited = {}) {
|
|
22380
22714
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
22381
22715
|
const text = node.textContent?.replace(/\s+/g, " ") ?? "";
|
|
22382
22716
|
if (!text) return [];
|
|
22383
22717
|
const rPr = htmlRPr(w, inherited);
|
|
22384
|
-
return [
|
|
22718
|
+
return [el9(`${w}r`, {}, [...rPr ? [rPr] : [], el9(`${w}t`, { "xml:space": "preserve" }, [], text)])];
|
|
22385
22719
|
}
|
|
22386
22720
|
if (node.nodeType !== Node.ELEMENT_NODE) return [];
|
|
22387
22721
|
const element = node;
|
|
22388
|
-
if (element.tagName.toLowerCase() === "br") return [
|
|
22722
|
+
if (element.tagName.toLowerCase() === "br") return [el9(`${w}r`, {}, [el9(`${w}br`)])];
|
|
22389
22723
|
const style = htmlStyle(element, inherited);
|
|
22390
22724
|
return Array.from(element.childNodes).flatMap((childNode) => inlineRuns(childNode, w, style));
|
|
22391
22725
|
}
|
|
22392
22726
|
function htmlParagraph(node, w) {
|
|
22393
22727
|
const tag = node.tagName.toLowerCase();
|
|
22394
22728
|
const pPrChildren = [];
|
|
22395
|
-
if (/^h[1-6]$/.test(tag)) pPrChildren.push(
|
|
22729
|
+
if (/^h[1-6]$/.test(tag)) pPrChildren.push(el9(`${w}pStyle`, { [`${w}val`]: `Heading${tag[1]}` }));
|
|
22396
22730
|
const align = node.style.textAlign;
|
|
22397
22731
|
if (["left", "center", "right", "justify"].includes(align)) {
|
|
22398
|
-
pPrChildren.push(
|
|
22732
|
+
pPrChildren.push(el9(`${w}jc`, { [`${w}val`]: align === "justify" ? "both" : align }));
|
|
22399
22733
|
}
|
|
22400
22734
|
const runs = inlineRuns(node, w);
|
|
22401
|
-
return
|
|
22402
|
-
...pPrChildren.length ? [
|
|
22403
|
-
...runs.length ? runs : [
|
|
22735
|
+
return el9(`${w}p`, {}, [
|
|
22736
|
+
...pPrChildren.length ? [el9(`${w}pPr`, {}, pPrChildren)] : [],
|
|
22737
|
+
...runs.length ? runs : [el9(`${w}r`, {}, [el9(`${w}t`, { "xml:space": "preserve" })])]
|
|
22404
22738
|
]);
|
|
22405
22739
|
}
|
|
22406
22740
|
function htmlTable(node, w, contentTwips) {
|
|
22407
22741
|
const rowNodes = Array.from(node.querySelectorAll(":scope > thead > tr, :scope > tbody > tr, :scope > tfoot > tr, :scope > tr"));
|
|
22408
22742
|
const cols = Math.max(1, ...rowNodes.map((row) => Array.from(row.children).reduce((n, cellNode) => n + Number(cellNode.getAttribute("colspan") || 1), 0)));
|
|
22409
22743
|
const colWidth = Math.floor(contentTwips / cols);
|
|
22410
|
-
const border = (name) =>
|
|
22411
|
-
const rows = rowNodes.map((row) =>
|
|
22744
|
+
const border = (name) => el9(`${w}${name}`, { [`${w}val`]: "single", [`${w}sz`]: "4", [`${w}color`]: "auto" });
|
|
22745
|
+
const rows = rowNodes.map((row) => el9(`${w}tr`, {}, Array.from(row.children).map((cellNode) => {
|
|
22412
22746
|
const span = Math.max(1, Number(cellNode.getAttribute("colspan") || 1));
|
|
22413
|
-
const tcPr = [
|
|
22414
|
-
if (span > 1) tcPr.push(
|
|
22747
|
+
const tcPr = [el9(`${w}tcW`, { [`${w}w`]: String(colWidth * span), [`${w}type`]: "dxa" })];
|
|
22748
|
+
if (span > 1) tcPr.push(el9(`${w}gridSpan`, { [`${w}val`]: String(span) }));
|
|
22415
22749
|
const fill = colorValue(cellNode.style.backgroundColor);
|
|
22416
|
-
if (fill) tcPr.push(
|
|
22750
|
+
if (fill) tcPr.push(el9(`${w}shd`, { [`${w}val`]: "clear", [`${w}fill`]: fill }));
|
|
22417
22751
|
const paragraphs = Array.from(cellNode.children).filter((childNode) => /^(p|div|h[1-6]|li)$/i.test(childNode.tagName)).map((childNode) => htmlParagraph(childNode, w));
|
|
22418
|
-
return
|
|
22419
|
-
|
|
22752
|
+
return el9(`${w}tc`, {}, [
|
|
22753
|
+
el9(`${w}tcPr`, {}, tcPr),
|
|
22420
22754
|
...paragraphs.length ? paragraphs : [htmlParagraph(cellNode, w)]
|
|
22421
22755
|
]);
|
|
22422
22756
|
})));
|
|
22423
|
-
return
|
|
22424
|
-
|
|
22425
|
-
|
|
22426
|
-
|
|
22757
|
+
return el9(`${w}tbl`, {}, [
|
|
22758
|
+
el9(`${w}tblPr`, {}, [
|
|
22759
|
+
el9(`${w}tblW`, { [`${w}w`]: "0", [`${w}type`]: "auto" }),
|
|
22760
|
+
el9(`${w}tblBorders`, {}, ["top", "left", "bottom", "right", "insideH", "insideV"].map(border))
|
|
22427
22761
|
]),
|
|
22428
|
-
|
|
22762
|
+
el9(`${w}tblGrid`, {}, Array.from({ length: cols }, () => el9(`${w}gridCol`, { [`${w}w`]: String(colWidth) }))),
|
|
22429
22763
|
...rows
|
|
22430
22764
|
]);
|
|
22431
22765
|
}
|
|
@@ -22483,10 +22817,10 @@ function clipboardBlocksHtml(blocks) {
|
|
|
22483
22817
|
}
|
|
22484
22818
|
|
|
22485
22819
|
// ../core/src/edit/suggest.ts
|
|
22486
|
-
function
|
|
22820
|
+
function prefixOf11(e) {
|
|
22487
22821
|
return e.name.includes(":") ? e.name.slice(0, e.name.indexOf(":") + 1) : "";
|
|
22488
22822
|
}
|
|
22489
|
-
function
|
|
22823
|
+
function el10(name, attrs = {}, children2 = [], text = "") {
|
|
22490
22824
|
return { name, attrs, children: children2, text };
|
|
22491
22825
|
}
|
|
22492
22826
|
function attrByLocal(e, local) {
|
|
@@ -22530,14 +22864,14 @@ function insertSuggestedText(doc, t, offset, text, meta) {
|
|
|
22530
22864
|
t.text = t.text.slice(0, offset) + text + t.text.slice(offset);
|
|
22531
22865
|
return { t, offset: offset + text.length };
|
|
22532
22866
|
}
|
|
22533
|
-
const w =
|
|
22867
|
+
const w = prefixOf11(rEl);
|
|
22534
22868
|
const rPr = rEl.children.find((c) => localName(c.name) === "rPr");
|
|
22535
22869
|
if (localName(parent.name) === "del") {
|
|
22536
22870
|
const grand = doc.findParentOf(parent);
|
|
22537
22871
|
if (!grand) return null;
|
|
22538
22872
|
const delIdx = grand.children.indexOf(parent);
|
|
22539
22873
|
const newT2 = textLike(t, t.name, text);
|
|
22540
|
-
const ins2 =
|
|
22874
|
+
const ins2 = el10(`${w}ins`, revAttrs(w, meta), [runLike(rEl, rPr, [newT2])]);
|
|
22541
22875
|
const at = offset <= 0 ? delIdx : delIdx + 1;
|
|
22542
22876
|
grand.children.splice(at, 0, ins2);
|
|
22543
22877
|
return { t: newT2, offset: text.length };
|
|
@@ -22552,7 +22886,7 @@ function insertSuggestedText(doc, t, offset, text, meta) {
|
|
|
22552
22886
|
if (offset > 0) beforeChildren.push(textLike(t, t.name, t.text.slice(0, offset)));
|
|
22553
22887
|
if (beforeChildren.length > 0) replacement.push(runLike(rEl, rPr, beforeChildren));
|
|
22554
22888
|
const newT = textLike(t, t.name, text);
|
|
22555
|
-
const ins =
|
|
22889
|
+
const ins = el10(`${w}ins`, revAttrs(w, meta), [runLike(rEl, rPr, [newT])]);
|
|
22556
22890
|
replacement.push(ins);
|
|
22557
22891
|
const afterChildren = [];
|
|
22558
22892
|
if (offset < t.text.length) afterChildren.push(textLike(t, t.name, t.text.slice(offset)));
|
|
@@ -22592,7 +22926,7 @@ function deleteOneRange(doc, t, start, end, meta) {
|
|
|
22592
22926
|
t.text = t.text.slice(0, start) + t.text.slice(end);
|
|
22593
22927
|
return { t, offset: start };
|
|
22594
22928
|
}
|
|
22595
|
-
const w =
|
|
22929
|
+
const w = prefixOf11(rEl);
|
|
22596
22930
|
const rPr = rEl.children.find((c) => localName(c.name) === "rPr");
|
|
22597
22931
|
const tIdx = rEl.children.indexOf(t);
|
|
22598
22932
|
const idx = parent.children.indexOf(rEl);
|
|
@@ -22609,7 +22943,7 @@ function deleteOneRange(doc, t, start, end, meta) {
|
|
|
22609
22943
|
}
|
|
22610
22944
|
if (beforeChildren.length > 0) replacement.push(runLike(rEl, rPr, beforeChildren));
|
|
22611
22945
|
const deletedT = textLike(t, delTextName, t.text.slice(start, end));
|
|
22612
|
-
const del =
|
|
22946
|
+
const del = el10(`${w}del`, revAttrs(w, meta), [runLike(rEl, rPr, [deletedT])]);
|
|
22613
22947
|
replacement.push(del);
|
|
22614
22948
|
const afterChildren = [];
|
|
22615
22949
|
if (end < t.text.length) afterChildren.push(textLike(t, t.name, t.text.slice(end)));
|
|
@@ -22638,24 +22972,24 @@ function coalesceDeletions(parent, del, author) {
|
|
|
22638
22972
|
}
|
|
22639
22973
|
}
|
|
22640
22974
|
function ensurePPrRPr(pEl) {
|
|
22641
|
-
const w =
|
|
22975
|
+
const w = prefixOf11(pEl);
|
|
22642
22976
|
let pPr = pEl.children.find((c) => localName(c.name) === "pPr");
|
|
22643
22977
|
if (!pPr) {
|
|
22644
|
-
pPr =
|
|
22978
|
+
pPr = el10(`${w}pPr`);
|
|
22645
22979
|
pEl.children.unshift(pPr);
|
|
22646
22980
|
}
|
|
22647
22981
|
let rPr = pPr.children.find((c) => localName(c.name) === "rPr");
|
|
22648
22982
|
if (!rPr) {
|
|
22649
|
-
rPr =
|
|
22983
|
+
rPr = el10(`${w}rPr`);
|
|
22650
22984
|
pPr.children.push(rPr);
|
|
22651
22985
|
}
|
|
22652
22986
|
return rPr;
|
|
22653
22987
|
}
|
|
22654
22988
|
function markParagraphGlyph(pEl, kind, meta) {
|
|
22655
|
-
const w =
|
|
22989
|
+
const w = prefixOf11(pEl);
|
|
22656
22990
|
const rPr = ensurePPrRPr(pEl);
|
|
22657
22991
|
const existingIdx = rPr.children.findIndex((c) => localName(c.name) === kind);
|
|
22658
|
-
const mark =
|
|
22992
|
+
const mark = el10(`${w}${kind}`, revAttrs(w, meta));
|
|
22659
22993
|
if (existingIdx !== -1) rPr.children[existingIdx] = mark;
|
|
22660
22994
|
else rPr.children.unshift(mark);
|
|
22661
22995
|
return mark;
|
|
@@ -23139,6 +23473,30 @@ var _DocxEditor = class _DocxEditor {
|
|
|
23139
23473
|
this.imageOverlay = null;
|
|
23140
23474
|
this.imageToolbar = null;
|
|
23141
23475
|
this.wordArtTextEditor = null;
|
|
23476
|
+
/** First press selects a model; subsequent drags belong to its 3D viewport. */
|
|
23477
|
+
this.onModel3DPointerDown = (event) => {
|
|
23478
|
+
const binding = this.model3DBinding(event.target);
|
|
23479
|
+
const src = binding?.item.src;
|
|
23480
|
+
if (!binding || !src || this.selectedImage?.src === src) return;
|
|
23481
|
+
if (this.regionOf(src) === "hf" !== this.inHeaderFooter) return;
|
|
23482
|
+
event.preventDefault();
|
|
23483
|
+
event.stopPropagation();
|
|
23484
|
+
this.selectImage(binding.el, src, binding.item);
|
|
23485
|
+
};
|
|
23486
|
+
this.onModel3DRotate = (event) => {
|
|
23487
|
+
const binding = this.model3DBinding(event.target);
|
|
23488
|
+
const src = binding?.item.src;
|
|
23489
|
+
const detail = event.detail;
|
|
23490
|
+
if (!binding || !src || !detail || ![detail.x, detail.y, detail.z].every(Number.isFinite)) return;
|
|
23491
|
+
event.stopPropagation();
|
|
23492
|
+
const rect = binding.el.getBoundingClientRect();
|
|
23493
|
+
const near = { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
|
|
23494
|
+
this.host.history?.checkpoint();
|
|
23495
|
+
if (setModel3DRotation(this.host.doc, src, detail)) {
|
|
23496
|
+
this.host.rerender(void 0, "local");
|
|
23497
|
+
this.reselectImage(src, near);
|
|
23498
|
+
}
|
|
23499
|
+
};
|
|
23142
23500
|
// ---------- watermarks / WordArt: select + edit ----------
|
|
23143
23501
|
this.selectedWordArt = null;
|
|
23144
23502
|
this.wordArtOverlay = null;
|
|
@@ -23162,6 +23520,7 @@ var _DocxEditor = class _DocxEditor {
|
|
|
23162
23520
|
if (this.wordArtOverlay?.contains(e.target)) return;
|
|
23163
23521
|
if (this.wordArtTextEditor?.input.contains(e.target)) return;
|
|
23164
23522
|
if (this.selectedInkGroup?.overlay.contains(e.target)) return;
|
|
23523
|
+
if (e.target?.closest?.("[data-dxw-model3d-viewer]")) return;
|
|
23165
23524
|
this.deselectInkGroup();
|
|
23166
23525
|
this.deselectImage();
|
|
23167
23526
|
this.deselectWordArt();
|
|
@@ -24188,7 +24547,9 @@ var _DocxEditor = class _DocxEditor {
|
|
|
24188
24547
|
c.tabIndex = 0;
|
|
24189
24548
|
c.style.outline = "none";
|
|
24190
24549
|
c.addEventListener("mousedown", this.onGripMouseDown, true);
|
|
24550
|
+
c.addEventListener("pointerdown", this.onModel3DPointerDown, true);
|
|
24191
24551
|
c.addEventListener("mouseup", this.onMouseUp);
|
|
24552
|
+
c.addEventListener("dxw-model3d-rotate", this.onModel3DRotate);
|
|
24192
24553
|
c.addEventListener("keydown", this.onKeyDown);
|
|
24193
24554
|
c.appendChild(this.imeEl);
|
|
24194
24555
|
this.imeEl.addEventListener("compositionstart", this.onCompositionStart);
|
|
@@ -24207,7 +24568,9 @@ var _DocxEditor = class _DocxEditor {
|
|
|
24207
24568
|
if (this.host.history) this.host.history.applyTextChanges = null;
|
|
24208
24569
|
const c = this.host.container;
|
|
24209
24570
|
c.removeEventListener("mousedown", this.onGripMouseDown, true);
|
|
24571
|
+
c.removeEventListener("pointerdown", this.onModel3DPointerDown, true);
|
|
24210
24572
|
c.removeEventListener("mouseup", this.onMouseUp);
|
|
24573
|
+
c.removeEventListener("dxw-model3d-rotate", this.onModel3DRotate);
|
|
24211
24574
|
c.removeEventListener("keydown", this.onKeyDown);
|
|
24212
24575
|
this.imeEl.removeEventListener("compositionstart", this.onCompositionStart);
|
|
24213
24576
|
this.imeEl.removeEventListener("compositionupdate", this.onCompositionUpdate);
|
|
@@ -24954,6 +25317,10 @@ var _DocxEditor = class _DocxEditor {
|
|
|
24954
25317
|
document.addEventListener("mouseup", onUp);
|
|
24955
25318
|
return true;
|
|
24956
25319
|
}
|
|
25320
|
+
model3DBinding(target) {
|
|
25321
|
+
const viewer = target?.closest?.("[data-dxw-model3d-viewer]");
|
|
25322
|
+
return viewer ? this.host.getHandle()?.images.find((binding) => binding.el.contains(viewer)) : void 0;
|
|
25323
|
+
}
|
|
24957
25324
|
/** First click selects a text box as an object; the second click edits only
|
|
24958
25325
|
* its story, even when the source shape lives in a header part. */
|
|
24959
25326
|
startTextboxTextInteraction(e, target) {
|
|
@@ -25049,9 +25416,11 @@ var _DocxEditor = class _DocxEditor {
|
|
|
25049
25416
|
];
|
|
25050
25417
|
for (const [mode, label] of modes) {
|
|
25051
25418
|
const b = document.createElement("button");
|
|
25419
|
+
b.type = "button";
|
|
25052
25420
|
b.textContent = label;
|
|
25053
25421
|
const active = mode === "inline" && !isFloating || isFloating && this.currentWrap(src) === mode;
|
|
25054
|
-
b.
|
|
25422
|
+
b.setAttribute("aria-pressed", String(active));
|
|
25423
|
+
b.style.cssText = `border:1px solid ${active ? "#8ab4f8" : "transparent"};border-radius:4px;padding:3px 7px;cursor:pointer;color:${active ? "#174ea6" : "#3c4043"};font-weight:${active ? "600" : "400"};background:${active ? "#d2e3fc" : "transparent"};`;
|
|
25055
25424
|
b.addEventListener("mousedown", (me) => {
|
|
25056
25425
|
me.preventDefault();
|
|
25057
25426
|
me.stopPropagation();
|
|
@@ -25157,6 +25526,13 @@ var _DocxEditor = class _DocxEditor {
|
|
|
25157
25526
|
});
|
|
25158
25527
|
});
|
|
25159
25528
|
}
|
|
25529
|
+
const drawingBinding = kind === "drawing" ? this.host.getHandle()?.drawings.find((binding) => binding.item.src === src) : void 0;
|
|
25530
|
+
if (drawingBinding?.item.textboxStory && !isDrawingWordArt(src)) {
|
|
25531
|
+
extra("Edit text", "Edit shape text", () => {
|
|
25532
|
+
const rect = drawingBinding.el.getBoundingClientRect();
|
|
25533
|
+
this.enterTextboxStory(src, rect.left + rect.width / 2, rect.top + rect.height / 2);
|
|
25534
|
+
});
|
|
25535
|
+
}
|
|
25160
25536
|
if (kind === "drawing" && isDrawingWordArt(src)) {
|
|
25161
25537
|
extra("Edit text", "Edit WordArt text", () => this.editDrawingWordArt(src));
|
|
25162
25538
|
}
|
|
@@ -25180,6 +25556,15 @@ var _DocxEditor = class _DocxEditor {
|
|
|
25180
25556
|
this.deselectImage();
|
|
25181
25557
|
});
|
|
25182
25558
|
}
|
|
25559
|
+
if (el16.dataset.dxwModel3d) {
|
|
25560
|
+
extra("Reset 3D", "Reset 3D rotation", () => {
|
|
25561
|
+
this.host.history?.checkpoint();
|
|
25562
|
+
if (setModel3DRotation(this.host.doc, src, { x: 0, y: 0, z: 0 })) {
|
|
25563
|
+
this.host.rerender(void 0, "local");
|
|
25564
|
+
this.reselectImage(src);
|
|
25565
|
+
}
|
|
25566
|
+
});
|
|
25567
|
+
}
|
|
25183
25568
|
const surface = el16.parentElement;
|
|
25184
25569
|
surface.appendChild(overlay);
|
|
25185
25570
|
const zoom = this.host.zoom ?? 1;
|
|
@@ -25389,6 +25774,7 @@ var _DocxEditor = class _DocxEditor {
|
|
|
25389
25774
|
/** Handle mousedown on images / their resize handle. Returns true if consumed. */
|
|
25390
25775
|
startImageInteraction(e, target) {
|
|
25391
25776
|
const zoom = this.host.zoom ?? 1;
|
|
25777
|
+
if (target.closest?.("[data-dxw-model3d-viewer]")) return true;
|
|
25392
25778
|
if (target.dataset.dxwImgHandle && this.selectedImage) {
|
|
25393
25779
|
e.preventDefault();
|
|
25394
25780
|
e.stopPropagation();
|
|
@@ -27282,7 +27668,7 @@ function isRelatedHistoryPart(name) {
|
|
|
27282
27668
|
}
|
|
27283
27669
|
|
|
27284
27670
|
// ../core/src/edit/comments.ts
|
|
27285
|
-
function
|
|
27671
|
+
function el11(name, attrs = {}, children2 = [], text = "") {
|
|
27286
27672
|
return { name, attrs, children: children2, text };
|
|
27287
27673
|
}
|
|
27288
27674
|
function addComment(doc, segments, text, author, initials) {
|
|
@@ -27306,15 +27692,15 @@ function addComment(doc, segments, text, author, initials) {
|
|
|
27306
27692
|
}
|
|
27307
27693
|
const newId = String(idNum + 1);
|
|
27308
27694
|
const startIdx = firstP.children.indexOf(firstR);
|
|
27309
|
-
firstP.children.splice(startIdx, 0,
|
|
27695
|
+
firstP.children.splice(startIdx, 0, el11(`${w}commentRangeStart`, { [`${w}id`]: newId }));
|
|
27310
27696
|
const endIdx = lastP.children.indexOf(lastR);
|
|
27311
27697
|
lastP.children.splice(
|
|
27312
27698
|
endIdx + 1,
|
|
27313
27699
|
0,
|
|
27314
|
-
|
|
27315
|
-
|
|
27316
|
-
|
|
27317
|
-
|
|
27700
|
+
el11(`${w}commentRangeEnd`, { [`${w}id`]: newId }),
|
|
27701
|
+
el11(`${w}r`, {}, [
|
|
27702
|
+
el11(`${w}rPr`, {}, [el11(`${w}rStyle`, { [`${w}val`]: "CommentReference" })]),
|
|
27703
|
+
el11(`${w}commentReference`, { [`${w}id`]: newId })
|
|
27318
27704
|
])
|
|
27319
27705
|
);
|
|
27320
27706
|
const usedParaIds = new Set(doc.comments.map((c) => c.paraId).filter(Boolean));
|
|
@@ -27323,7 +27709,7 @@ function addComment(doc, segments, text, author, initials) {
|
|
|
27323
27709
|
paraId2 = Math.floor(Math.random() * 4294967280 + 1).toString(16).toUpperCase().padStart(8, "0");
|
|
27324
27710
|
} while (usedParaIds.has(paraId2));
|
|
27325
27711
|
commentsRoot.children.push(
|
|
27326
|
-
|
|
27712
|
+
el11(
|
|
27327
27713
|
`${w}comment`,
|
|
27328
27714
|
{
|
|
27329
27715
|
[`${w}id`]: newId,
|
|
@@ -27332,13 +27718,13 @@ function addComment(doc, segments, text, author, initials) {
|
|
|
27332
27718
|
[`${w}date`]: (/* @__PURE__ */ new Date()).toISOString()
|
|
27333
27719
|
},
|
|
27334
27720
|
[
|
|
27335
|
-
|
|
27721
|
+
el11(
|
|
27336
27722
|
`${w}p`,
|
|
27337
27723
|
{
|
|
27338
27724
|
"xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
|
|
27339
27725
|
"w14:paraId": paraId2
|
|
27340
27726
|
},
|
|
27341
|
-
[
|
|
27727
|
+
[el11(`${w}r`, {}, [el11(`${w}t`, { "xml:space": "preserve" }, [], text)])]
|
|
27342
27728
|
)
|
|
27343
27729
|
]
|
|
27344
27730
|
)
|
|
@@ -27433,7 +27819,7 @@ function replyToComment(doc, parentId, text, author, initials) {
|
|
|
27433
27819
|
}
|
|
27434
27820
|
const replyParaId = freshParaId();
|
|
27435
27821
|
commentsRoot.children.push(
|
|
27436
|
-
|
|
27822
|
+
el11(
|
|
27437
27823
|
`${w}comment`,
|
|
27438
27824
|
{
|
|
27439
27825
|
[`${w}id`]: newId,
|
|
@@ -27442,13 +27828,13 @@ function replyToComment(doc, parentId, text, author, initials) {
|
|
|
27442
27828
|
[`${w}date`]: (/* @__PURE__ */ new Date()).toISOString()
|
|
27443
27829
|
},
|
|
27444
27830
|
[
|
|
27445
|
-
|
|
27831
|
+
el11(
|
|
27446
27832
|
`${w}p`,
|
|
27447
27833
|
{
|
|
27448
27834
|
"xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
|
|
27449
27835
|
"w14:paraId": replyParaId
|
|
27450
27836
|
},
|
|
27451
|
-
[
|
|
27837
|
+
[el11(`${w}r`, {}, [el11(`${w}t`, { "xml:space": "preserve" }, [], text)])]
|
|
27452
27838
|
)
|
|
27453
27839
|
]
|
|
27454
27840
|
)
|
|
@@ -27464,11 +27850,11 @@ function replyToComment(doc, parentId, text, author, initials) {
|
|
|
27464
27850
|
);
|
|
27465
27851
|
if (!hasParentEx) {
|
|
27466
27852
|
extRoot.children.push(
|
|
27467
|
-
|
|
27853
|
+
el11("w15:commentEx", { "w15:paraId": parentParaId, "w15:done": "0" })
|
|
27468
27854
|
);
|
|
27469
27855
|
}
|
|
27470
27856
|
extRoot.children.push(
|
|
27471
|
-
|
|
27857
|
+
el11("w15:commentEx", {
|
|
27472
27858
|
"w15:paraId": replyParaId,
|
|
27473
27859
|
"w15:paraIdParent": parentParaId,
|
|
27474
27860
|
"w15:done": "0"
|
|
@@ -27486,19 +27872,19 @@ function insertReplyMarkers(el0, parentId, newId, w) {
|
|
|
27486
27872
|
const c = el0.children[i];
|
|
27487
27873
|
const ln = localName(c.name);
|
|
27488
27874
|
if (ln === "commentRangeStart" && attr(c, "id") === parentId) {
|
|
27489
|
-
el0.children.splice(i + 1, 0,
|
|
27875
|
+
el0.children.splice(i + 1, 0, el11(`${w}commentRangeStart`, { [`${w}id`]: newId }));
|
|
27490
27876
|
touched = true;
|
|
27491
27877
|
i++;
|
|
27492
27878
|
continue;
|
|
27493
27879
|
}
|
|
27494
27880
|
if (ln === "commentRangeEnd" && attr(c, "id") === parentId) {
|
|
27495
|
-
el0.children.splice(i + 1, 0,
|
|
27881
|
+
el0.children.splice(i + 1, 0, el11(`${w}commentRangeEnd`, { [`${w}id`]: newId }));
|
|
27496
27882
|
touched = true;
|
|
27497
27883
|
i++;
|
|
27498
27884
|
continue;
|
|
27499
27885
|
}
|
|
27500
27886
|
if (ln === "r" && c.children.some((rc) => localName(rc.name) === "commentReference" && attr(rc, "id") === parentId)) {
|
|
27501
|
-
el0.children.splice(i + 1, 0,
|
|
27887
|
+
el0.children.splice(i + 1, 0, el11(`${w}r`, {}, [el11(`${w}commentReference`, { [`${w}id`]: newId })]));
|
|
27502
27888
|
touched = true;
|
|
27503
27889
|
i++;
|
|
27504
27890
|
continue;
|
|
@@ -27535,7 +27921,7 @@ function stripMarkers(el16, id) {
|
|
|
27535
27921
|
}
|
|
27536
27922
|
|
|
27537
27923
|
// ../core/src/edit/links.ts
|
|
27538
|
-
function
|
|
27924
|
+
function prefixOf12(e) {
|
|
27539
27925
|
return e.name.includes(":") ? e.name.slice(0, e.name.indexOf(":") + 1) : "";
|
|
27540
27926
|
}
|
|
27541
27927
|
function hyperlinkOf(doc, t) {
|
|
@@ -27580,7 +27966,7 @@ function setLink(doc, segments, url) {
|
|
|
27580
27966
|
if (runsByPara.size === 0) return false;
|
|
27581
27967
|
const relId = doc.addHyperlinkRel(url);
|
|
27582
27968
|
for (const [pEl, runs] of runsByPara) {
|
|
27583
|
-
const w =
|
|
27969
|
+
const w = prefixOf12(pEl);
|
|
27584
27970
|
const first = pEl.children.indexOf(runs[0]);
|
|
27585
27971
|
for (const rEl of runs) {
|
|
27586
27972
|
let rPr = rEl.children.find((c) => localName(c.name) === "rPr");
|
|
@@ -27627,13 +28013,13 @@ function removeLink(doc, t) {
|
|
|
27627
28013
|
|
|
27628
28014
|
// ../core/src/edit/paragraph.ts
|
|
27629
28015
|
var INDENT_STEP_TWIPS = 720;
|
|
27630
|
-
function
|
|
28016
|
+
function prefixOf13(e) {
|
|
27631
28017
|
return e.name.includes(":") ? e.name.slice(0, e.name.indexOf(":") + 1) : "";
|
|
27632
28018
|
}
|
|
27633
28019
|
function ensurePPr(pEl) {
|
|
27634
28020
|
let pPr = pEl.children.find((c) => localName(c.name) === "pPr");
|
|
27635
28021
|
if (!pPr) {
|
|
27636
|
-
pPr = { name: `${
|
|
28022
|
+
pPr = { name: `${prefixOf13(pEl)}pPr`, attrs: {}, children: [], text: "" };
|
|
27637
28023
|
pEl.children.unshift(pPr);
|
|
27638
28024
|
}
|
|
27639
28025
|
return pPr;
|
|
@@ -27654,7 +28040,7 @@ function adjustIndent(doc, targets, direction) {
|
|
|
27654
28040
|
if (paragraphs.size === 0) return false;
|
|
27655
28041
|
let touched = false;
|
|
27656
28042
|
for (const pEl of paragraphs) {
|
|
27657
|
-
const w =
|
|
28043
|
+
const w = prefixOf13(pEl);
|
|
27658
28044
|
const pPr = ensurePPr(pEl);
|
|
27659
28045
|
let ind = pPr.children.find((c) => localName(c.name) === "ind");
|
|
27660
28046
|
if (!ind) {
|
|
@@ -27724,7 +28110,7 @@ function setDropCapAt(doc, target, mode, lines = 3) {
|
|
|
27724
28110
|
}
|
|
27725
28111
|
if (dropParagraph) {
|
|
27726
28112
|
const frame = dropCapFrame(dropParagraph);
|
|
27727
|
-
const w2 =
|
|
28113
|
+
const w2 = prefixOf13(dropParagraph);
|
|
27728
28114
|
frame.attrs[attrKey(frame, "dropCap", w2)] = mode;
|
|
27729
28115
|
frame.attrs[attrKey(frame, "lines", w2)] = String(lines);
|
|
27730
28116
|
frame.attrs[attrKey(frame, "hSpace", w2)] = "144";
|
|
@@ -27750,7 +28136,7 @@ function setDropCapAt(doc, target, mode, lines = 3) {
|
|
|
27750
28136
|
if (chars.length === 0) return false;
|
|
27751
28137
|
const letter = chars.shift();
|
|
27752
28138
|
sourceText.text = chars.join("");
|
|
27753
|
-
const w =
|
|
28139
|
+
const w = prefixOf13(paragraph);
|
|
27754
28140
|
const rPr = sourceRun.children.find((child4) => localName(child4.name) === "rPr");
|
|
27755
28141
|
const capRun = {
|
|
27756
28142
|
name: `${w}r`,
|
|
@@ -27794,7 +28180,7 @@ function setParagraphSpacing(doc, targets, patch) {
|
|
|
27794
28180
|
const paragraphs = paragraphsOf(doc, targets);
|
|
27795
28181
|
if (paragraphs.size === 0) return false;
|
|
27796
28182
|
for (const pEl of paragraphs) {
|
|
27797
|
-
const w =
|
|
28183
|
+
const w = prefixOf13(pEl);
|
|
27798
28184
|
const pPr = ensurePPr(pEl);
|
|
27799
28185
|
let sp = pPr.children.find((c) => localName(c.name) === "spacing");
|
|
27800
28186
|
if (!sp) {
|
|
@@ -27909,7 +28295,7 @@ function transformCase(doc, segments, mode) {
|
|
|
27909
28295
|
}
|
|
27910
28296
|
|
|
27911
28297
|
// ../core/src/edit/notes.ts
|
|
27912
|
-
function
|
|
28298
|
+
function el12(name, attrs = {}, children2 = [], text = "") {
|
|
27913
28299
|
return { name, attrs, children: children2, text };
|
|
27914
28300
|
}
|
|
27915
28301
|
function insertFootnote(doc, t, offset, text) {
|
|
@@ -27929,9 +28315,9 @@ function insertFootnote(doc, t, offset, text) {
|
|
|
27929
28315
|
const newId = maxId + 1;
|
|
27930
28316
|
const rw = rEl.name.includes(":") ? rEl.name.slice(0, rEl.name.indexOf(":") + 1) : "";
|
|
27931
28317
|
const rPr = rEl.children.find((c) => localName(c.name) === "rPr");
|
|
27932
|
-
const refRun =
|
|
27933
|
-
|
|
27934
|
-
|
|
28318
|
+
const refRun = el12(`${rw}r`, {}, [
|
|
28319
|
+
el12(`${rw}rPr`, {}, [el12(`${rw}rStyle`, { [`${rw}val`]: "FootnoteReference" })]),
|
|
28320
|
+
el12(`${rw}footnoteReference`, { [`${rw}id`]: String(newId) })
|
|
27935
28321
|
]);
|
|
27936
28322
|
const rIdx = pEl.children.indexOf(rEl);
|
|
27937
28323
|
if (offset >= t.text.length) {
|
|
@@ -27939,20 +28325,20 @@ function insertFootnote(doc, t, offset, text) {
|
|
|
27939
28325
|
} else if (offset <= 0) {
|
|
27940
28326
|
pEl.children.splice(rIdx, 0, refRun);
|
|
27941
28327
|
} else {
|
|
27942
|
-
const tailT =
|
|
28328
|
+
const tailT = el12(`${rw}t`, { "xml:space": "preserve" }, [], t.text.slice(offset));
|
|
27943
28329
|
t.text = t.text.slice(0, offset);
|
|
27944
|
-
const tail =
|
|
28330
|
+
const tail = el12(`${rw}r`, {}, [...rPr ? [cloneShallow(rPr)] : [], tailT]);
|
|
27945
28331
|
pEl.children.splice(rIdx + 1, 0, refRun, tail);
|
|
27946
28332
|
}
|
|
27947
28333
|
notesRoot.children.push(
|
|
27948
|
-
|
|
27949
|
-
|
|
27950
|
-
|
|
27951
|
-
|
|
27952
|
-
|
|
27953
|
-
|
|
28334
|
+
el12(`${w}footnote`, { [`${w}id`]: String(newId) }, [
|
|
28335
|
+
el12(`${w}p`, {}, [
|
|
28336
|
+
el12(`${w}pPr`, {}, [el12(`${w}pStyle`, { [`${w}val`]: "FootnoteText" })]),
|
|
28337
|
+
el12(`${w}r`, {}, [
|
|
28338
|
+
el12(`${w}rPr`, {}, [el12(`${w}rStyle`, { [`${w}val`]: "FootnoteReference" })]),
|
|
28339
|
+
el12(`${w}footnoteRef`)
|
|
27954
28340
|
]),
|
|
27955
|
-
|
|
28341
|
+
el12(`${w}r`, {}, [el12(`${w}t`, { "xml:space": "preserve" }, [], " " + text.trim())])
|
|
27956
28342
|
])
|
|
27957
28343
|
])
|
|
27958
28344
|
);
|
|
@@ -27965,7 +28351,7 @@ function cloneShallow(e) {
|
|
|
27965
28351
|
}
|
|
27966
28352
|
|
|
27967
28353
|
// ../core/src/edit/fields.ts
|
|
27968
|
-
function
|
|
28354
|
+
function el13(name, attrs = {}, children2 = [], text = "") {
|
|
27969
28355
|
return { name, attrs, children: children2, text };
|
|
27970
28356
|
}
|
|
27971
28357
|
function cloneDeep2(e) {
|
|
@@ -27981,8 +28367,8 @@ function insertElementsAt(doc, t, offset, inserted) {
|
|
|
27981
28367
|
const tIdx = rEl.children.indexOf(t);
|
|
27982
28368
|
if (rIdx < 0 || tIdx < 0) return false;
|
|
27983
28369
|
const at = Math.max(0, Math.min(offset, t.text.length));
|
|
27984
|
-
const makeText = (text) =>
|
|
27985
|
-
const makeRun = (content) =>
|
|
28370
|
+
const makeText = (text) => el13(t.name, { ...t.attrs, "xml:space": "preserve" }, [], text);
|
|
28371
|
+
const makeRun = (content) => el13(rEl.name, { ...rEl.attrs }, [...rPr ? [cloneDeep2(rPr)] : [], ...content]);
|
|
27986
28372
|
const before = rEl.children.slice(0, tIdx).filter((child4) => localName(child4.name) !== "rPr");
|
|
27987
28373
|
const after = rEl.children.slice(tIdx + 1).filter((child4) => localName(child4.name) !== "rPr");
|
|
27988
28374
|
let beforeRun;
|
|
@@ -28015,11 +28401,11 @@ function insertField(doc, t, offset, instruction, cachedResult = "") {
|
|
|
28015
28401
|
if (!rEl || localName(rEl.name) !== "r") return false;
|
|
28016
28402
|
const w = rEl.name.includes(":") ? rEl.name.slice(0, rEl.name.indexOf(":") + 1) : "";
|
|
28017
28403
|
const rPr = rEl.children.find((c) => localName(c.name) === "rPr");
|
|
28018
|
-
const resultRun =
|
|
28404
|
+
const resultRun = el13(`${w}r`, {}, [
|
|
28019
28405
|
...rPr ? [cloneDeep2(rPr)] : [],
|
|
28020
|
-
|
|
28406
|
+
el13(`${w}t`, { "xml:space": "preserve" }, [], cachedResult)
|
|
28021
28407
|
]);
|
|
28022
|
-
const field =
|
|
28408
|
+
const field = el13(`${w}fldSimple`, { [`${w}instr`]: ` ${clean} ` }, [resultRun]);
|
|
28023
28409
|
return insertElementsAt(doc, t, offset, [field]);
|
|
28024
28410
|
}
|
|
28025
28411
|
function insertPageField(doc, t, offset, kind = "page") {
|
|
@@ -28027,9 +28413,9 @@ function insertPageField(doc, t, offset, kind = "page") {
|
|
|
28027
28413
|
if (!rEl || localName(rEl.name) !== "r") return false;
|
|
28028
28414
|
const rw = rEl.name.includes(":") ? rEl.name.slice(0, rEl.name.indexOf(":") + 1) : "";
|
|
28029
28415
|
const rPr = rEl.children.find((c) => localName(c.name) === "rPr");
|
|
28030
|
-
const run = (content) =>
|
|
28031
|
-
const textRun = (s) => run(
|
|
28032
|
-
const fld = (instr) =>
|
|
28416
|
+
const run = (content) => el13(`${rw}r`, {}, [...rPr ? [cloneDeep2(rPr)] : [], content]);
|
|
28417
|
+
const textRun = (s) => run(el13(`${rw}t`, { "xml:space": "preserve" }, [], s));
|
|
28418
|
+
const fld = (instr) => el13(`${rw}fldSimple`, { [`${rw}instr`]: ` ${instr} \\* MERGEFORMAT ` }, [textRun("1")]);
|
|
28033
28419
|
const inserted = kind === "page" ? [fld("PAGE")] : [textRun("Page "), fld("PAGE"), textRun(" of "), fld("NUMPAGES")];
|
|
28034
28420
|
return insertElementsAt(doc, t, offset, inserted);
|
|
28035
28421
|
}
|
|
@@ -28040,15 +28426,15 @@ function insertDateTimeField(doc, t, offset, kind, picture) {
|
|
|
28040
28426
|
|
|
28041
28427
|
// ../core/src/edit/charts.ts
|
|
28042
28428
|
import { strToU8 as strToU83, zipSync as zipSync2 } from "fflate";
|
|
28043
|
-
var
|
|
28044
|
-
var
|
|
28045
|
-
var
|
|
28429
|
+
var EMU_PER_PX7 = 9525;
|
|
28430
|
+
var NS_WP6 = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
|
|
28431
|
+
var NS_A5 = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
28046
28432
|
var NS_C = "http://schemas.openxmlformats.org/drawingml/2006/chart";
|
|
28047
|
-
var
|
|
28048
|
-
function
|
|
28433
|
+
var NS_R4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
28434
|
+
function el14(name, attrs = {}, children2 = [], text = "") {
|
|
28049
28435
|
return { name, attrs, children: children2, text };
|
|
28050
28436
|
}
|
|
28051
|
-
function
|
|
28437
|
+
function prefixOf14(node) {
|
|
28052
28438
|
return node.name.includes(":") ? node.name.slice(0, node.name.indexOf(":") + 1) : "";
|
|
28053
28439
|
}
|
|
28054
28440
|
function descendant4(node, name) {
|
|
@@ -28115,7 +28501,7 @@ function buildChartWorkbook(input) {
|
|
|
28115
28501
|
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>`
|
|
28116
28502
|
),
|
|
28117
28503
|
"xl/workbook.xml": strToU83(
|
|
28118
|
-
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="${
|
|
28504
|
+
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="${NS_R4}"><bookViews><workbookView/></bookViews><sheets><sheet name="Data" sheetId="1" r:id="rId1"/></sheets><calcPr calcId="191029"/></workbook>`
|
|
28119
28505
|
),
|
|
28120
28506
|
"xl/_rels/workbook.xml.rels": strToU83(
|
|
28121
28507
|
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/></Relationships>`
|
|
@@ -28156,7 +28542,7 @@ function chartPlot(data) {
|
|
|
28156
28542
|
}
|
|
28157
28543
|
function buildChartXml(input, workbookRelId = "rId1") {
|
|
28158
28544
|
const data = normalizeChartData(input);
|
|
28159
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><c:chartSpace xmlns:c="${NS_C}" xmlns:a="${
|
|
28545
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><c:chartSpace xmlns:c="${NS_C}" xmlns:a="${NS_A5}" xmlns:r="${NS_R4}"><c:date1904 val="0"/><c:lang val="en-US"/><c:roundedCorners val="0"/><c:style val="2"/><c:chart>${chartTitle(data.title)}<c:autoTitleDeleted val="${data.title ? "0" : "1"}"/><c:plotArea><c:layout/>${chartPlot(data)}</c:plotArea><c:legend><c:legendPos val="r"/><c:layout/><c:overlay val="0"/></c:legend><c:plotVisOnly val="1"/><c:dispBlanksAs val="gap"/><c:showDLblsOverMax val="0"/></c:chart><c:externalData r:id="${escapeXml2(workbookRelId)}"><c:autoUpdate val="0"/></c:externalData></c:chartSpace>`;
|
|
28160
28546
|
}
|
|
28161
28547
|
function insertChartAt(doc, caretT, input) {
|
|
28162
28548
|
const caretRun = doc.findParentOf(caretT);
|
|
@@ -28164,23 +28550,23 @@ function insertChartAt(doc, caretT, input) {
|
|
|
28164
28550
|
if (!caretRun || !parent || localName(caretRun.name) !== "r") return null;
|
|
28165
28551
|
const data = normalizeChartData(input);
|
|
28166
28552
|
const { relId } = doc.addChartResource(buildChartXml(data), buildChartWorkbook(data));
|
|
28167
|
-
const w =
|
|
28553
|
+
const w = prefixOf14(caretRun);
|
|
28168
28554
|
const id = String(doc.nextDrawingId());
|
|
28169
|
-
const cx = String(Math.round(480 *
|
|
28170
|
-
const cy = String(Math.round(288 *
|
|
28171
|
-
const drawing =
|
|
28172
|
-
|
|
28173
|
-
|
|
28174
|
-
|
|
28175
|
-
|
|
28176
|
-
|
|
28177
|
-
|
|
28178
|
-
|
|
28555
|
+
const cx = String(Math.round(480 * EMU_PER_PX7));
|
|
28556
|
+
const cy = String(Math.round(288 * EMU_PER_PX7));
|
|
28557
|
+
const drawing = el14(`${w}drawing`, {}, [
|
|
28558
|
+
el14("wp:inline", { "xmlns:wp": NS_WP6, distT: "0", distB: "0", distL: "0", distR: "0" }, [
|
|
28559
|
+
el14("wp:extent", { cx, cy }),
|
|
28560
|
+
el14("wp:docPr", { id, name: `Chart ${id}` }),
|
|
28561
|
+
el14("wp:cNvGraphicFramePr"),
|
|
28562
|
+
el14("a:graphic", { "xmlns:a": NS_A5 }, [
|
|
28563
|
+
el14("a:graphicData", { uri: NS_C }, [
|
|
28564
|
+
el14("c:chart", { "xmlns:c": NS_C, "xmlns:r": NS_R4, "r:id": relId })
|
|
28179
28565
|
])
|
|
28180
28566
|
])
|
|
28181
28567
|
])
|
|
28182
28568
|
]);
|
|
28183
|
-
parent.children.splice(parent.children.indexOf(caretRun) + 1, 0,
|
|
28569
|
+
parent.children.splice(parent.children.indexOf(caretRun) + 1, 0, el14(`${w}r`, {}, [drawing]));
|
|
28184
28570
|
doc.refresh();
|
|
28185
28571
|
return drawing;
|
|
28186
28572
|
}
|
|
@@ -28202,226 +28588,6 @@ function setChartData(doc, drawing, input) {
|
|
|
28202
28588
|
return true;
|
|
28203
28589
|
}
|
|
28204
28590
|
|
|
28205
|
-
// ../core/src/edit/objects.ts
|
|
28206
|
-
var EMU_PER_PX7 = 9525;
|
|
28207
|
-
var NS_WP6 = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
|
|
28208
|
-
var NS_A5 = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
28209
|
-
var NS_PIC2 = "http://schemas.openxmlformats.org/drawingml/2006/picture";
|
|
28210
|
-
var NS_R4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
28211
|
-
var NS_MC = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
28212
|
-
var NS_AM3D = "http://schemas.microsoft.com/office/drawing/2017/model3d";
|
|
28213
|
-
var NS_WP15 = "http://schemas.microsoft.com/office/word/2012/wordprocessingDrawing";
|
|
28214
|
-
function el14(name, attrs = {}, children2 = [], text = "") {
|
|
28215
|
-
return { name, attrs, children: children2, text };
|
|
28216
|
-
}
|
|
28217
|
-
function prefixOf14(node) {
|
|
28218
|
-
return node.name.includes(":") ? node.name.slice(0, node.name.indexOf(":") + 1) : "";
|
|
28219
|
-
}
|
|
28220
|
-
function insertAfterCaretRun(doc, caretT, content) {
|
|
28221
|
-
const caretRun = doc.findParentOf(caretT);
|
|
28222
|
-
const parent = caretRun && doc.findParentOf(caretRun);
|
|
28223
|
-
if (!caretRun || !parent || localName(caretRun.name) !== "r") return false;
|
|
28224
|
-
const w = prefixOf14(caretRun);
|
|
28225
|
-
parent.children.splice(parent.children.indexOf(caretRun) + 1, 0, el14(`${w}r`, {}, [content]));
|
|
28226
|
-
doc.refresh();
|
|
28227
|
-
return true;
|
|
28228
|
-
}
|
|
28229
|
-
function pictureGraphic(relId, id, cx, cy, webVideo) {
|
|
28230
|
-
const blipChildren = webVideo ? [
|
|
28231
|
-
el14("a:extLst", {}, [
|
|
28232
|
-
el14("a:ext", { uri: "{9E29B28B-C9C2-4B96-BA92-6C9A3D8F4A6A}" }, [
|
|
28233
|
-
el14("wp15:webVideoPr", {
|
|
28234
|
-
"xmlns:wp15": NS_WP15,
|
|
28235
|
-
embeddedHtml: webVideo,
|
|
28236
|
-
w: "640",
|
|
28237
|
-
h: "360"
|
|
28238
|
-
})
|
|
28239
|
-
])
|
|
28240
|
-
])
|
|
28241
|
-
] : [];
|
|
28242
|
-
return el14("a:graphic", { "xmlns:a": NS_A5 }, [
|
|
28243
|
-
el14("a:graphicData", { uri: NS_PIC2 }, [
|
|
28244
|
-
el14("pic:pic", { "xmlns:pic": NS_PIC2 }, [
|
|
28245
|
-
el14("pic:nvPicPr", {}, [
|
|
28246
|
-
el14("pic:cNvPr", { id, name: `Picture ${id}` }),
|
|
28247
|
-
el14("pic:cNvPicPr", {}, [el14("a:picLocks", { noChangeAspect: "1" })])
|
|
28248
|
-
]),
|
|
28249
|
-
el14("pic:blipFill", {}, [
|
|
28250
|
-
el14("a:blip", { "xmlns:r": NS_R4, "r:embed": relId }, blipChildren),
|
|
28251
|
-
el14("a:stretch", {}, [el14("a:fillRect")])
|
|
28252
|
-
]),
|
|
28253
|
-
el14("pic:spPr", {}, [
|
|
28254
|
-
el14("a:xfrm", {}, [el14("a:off", { x: "0", y: "0" }), el14("a:ext", { cx, cy })]),
|
|
28255
|
-
el14("a:prstGeom", { prst: "rect" }, [el14("a:avLst")])
|
|
28256
|
-
])
|
|
28257
|
-
])
|
|
28258
|
-
])
|
|
28259
|
-
]);
|
|
28260
|
-
}
|
|
28261
|
-
function inlineDrawing(id, name, descr, cx, cy, graphic) {
|
|
28262
|
-
return el14("w:drawing", {}, [
|
|
28263
|
-
el14("wp:inline", { "xmlns:wp": NS_WP6, distT: "0", distB: "0", distL: "0", distR: "0" }, [
|
|
28264
|
-
el14("wp:extent", { cx, cy }),
|
|
28265
|
-
el14("wp:effectExtent", { l: "0", t: "0", r: "0", b: "0" }),
|
|
28266
|
-
el14("wp:docPr", { id, name, descr }),
|
|
28267
|
-
el14("wp:cNvGraphicFramePr", {}, [el14("a:graphicFrameLocks", { "xmlns:a": NS_A5, noChangeAspect: "1" })]),
|
|
28268
|
-
graphic
|
|
28269
|
-
])
|
|
28270
|
-
]);
|
|
28271
|
-
}
|
|
28272
|
-
function insertModel3DAt(doc, caretT, input) {
|
|
28273
|
-
const posterRelId = doc.addImageResource(input.poster, input.posterExt ?? "png");
|
|
28274
|
-
const model = doc.addModel3DResource(input.data);
|
|
28275
|
-
const id = String(doc.nextDrawingId());
|
|
28276
|
-
const width = 320;
|
|
28277
|
-
const height = 220;
|
|
28278
|
-
const cx = String(width * EMU_PER_PX7);
|
|
28279
|
-
const cy = String(height * EMU_PER_PX7);
|
|
28280
|
-
const modelGraphic = el14("a:graphic", { "xmlns:a": NS_A5 }, [
|
|
28281
|
-
el14("a:graphicData", { uri: NS_AM3D }, [
|
|
28282
|
-
el14("am3d:model3d", { "xmlns:am3d": NS_AM3D, "xmlns:r": NS_R4, "r:embed": model.relId }, [
|
|
28283
|
-
el14("am3d:spPr", {}, [
|
|
28284
|
-
el14("a:xfrm", {}, [el14("a:off", { x: "0", y: "0" }), el14("a:ext", { cx, cy })]),
|
|
28285
|
-
el14("a:prstGeom", { prst: "rect" }, [el14("a:avLst")])
|
|
28286
|
-
]),
|
|
28287
|
-
el14("am3d:camera", {}, [
|
|
28288
|
-
el14("am3d:pos", { x: "0", y: "0", z: "77741944" }),
|
|
28289
|
-
el14("am3d:up", { dx: "0", dy: "36000000", dz: "0" }),
|
|
28290
|
-
el14("am3d:lookAt", { x: "0", y: "0", z: "0" }),
|
|
28291
|
-
el14("am3d:perspective", { fov: "2700000" })
|
|
28292
|
-
]),
|
|
28293
|
-
el14("am3d:trans", {}, [
|
|
28294
|
-
el14("am3d:meterPerModelUnit", { n: "1", d: "1" }),
|
|
28295
|
-
el14("am3d:preTrans", { dx: "0", dy: "0", dz: "0" }),
|
|
28296
|
-
el14("am3d:scale", {}, [
|
|
28297
|
-
el14("am3d:sx", { n: "1000000", d: "1000000" }),
|
|
28298
|
-
el14("am3d:sy", { n: "1000000", d: "1000000" }),
|
|
28299
|
-
el14("am3d:sz", { n: "1000000", d: "1000000" })
|
|
28300
|
-
]),
|
|
28301
|
-
el14("am3d:rot", { ax: "0", ay: "0", az: "0" }),
|
|
28302
|
-
el14("am3d:postTrans", { dx: "0", dy: "0", dz: "0" })
|
|
28303
|
-
]),
|
|
28304
|
-
el14("am3d:raster", { rName: "Office3DRenderer", rVer: "16.0" }, [
|
|
28305
|
-
el14("am3d:blip", { "r:embed": posterRelId })
|
|
28306
|
-
]),
|
|
28307
|
-
el14("am3d:objViewport", { viewportSz: cx }),
|
|
28308
|
-
el14("am3d:ambientLight", {}, [
|
|
28309
|
-
el14("am3d:clr", {}, [el14("a:scrgbClr", { r: "50000", g: "50000", b: "50000" })]),
|
|
28310
|
-
el14("am3d:illuminance", { n: "500000", d: "1000000" })
|
|
28311
|
-
]),
|
|
28312
|
-
el14("am3d:ptLight", { rad: "0" }, [
|
|
28313
|
-
el14("am3d:clr", {}, [el14("a:scrgbClr", { r: "100000", g: "100000", b: "100000" })]),
|
|
28314
|
-
el14("am3d:intensity", { n: "1000000", d: "1000000" }),
|
|
28315
|
-
el14("am3d:pos", { x: "30000000", y: "50000000", z: "50000000" })
|
|
28316
|
-
])
|
|
28317
|
-
])
|
|
28318
|
-
])
|
|
28319
|
-
]);
|
|
28320
|
-
const alt = input.alt ?? "3D model";
|
|
28321
|
-
const choice = inlineDrawing(id, `3D Model ${id}`, alt, cx, cy, modelGraphic);
|
|
28322
|
-
const fallback = inlineDrawing(id, `3D Model ${id}`, alt, cx, cy, pictureGraphic(posterRelId, id, cx, cy));
|
|
28323
|
-
const alternate = el14("mc:AlternateContent", { "xmlns:mc": NS_MC }, [
|
|
28324
|
-
el14("mc:Choice", { Requires: "am3d", "xmlns:am3d": NS_AM3D }, [choice]),
|
|
28325
|
-
el14("mc:Fallback", {}, [fallback])
|
|
28326
|
-
]);
|
|
28327
|
-
return insertAfterCaretRun(doc, caretT, alternate);
|
|
28328
|
-
}
|
|
28329
|
-
function normalizeWebVideoUrl(value) {
|
|
28330
|
-
try {
|
|
28331
|
-
const url = new URL(value.trim());
|
|
28332
|
-
if (url.protocol !== "http:" && url.protocol !== "https:") return null;
|
|
28333
|
-
if (url.hostname === "youtu.be") return `https://www.youtube.com/embed/${url.pathname.slice(1)}`;
|
|
28334
|
-
if (url.hostname.endsWith("youtube.com") && url.pathname === "/watch") {
|
|
28335
|
-
const id = url.searchParams.get("v");
|
|
28336
|
-
if (id) return `https://www.youtube.com/embed/${id}`;
|
|
28337
|
-
}
|
|
28338
|
-
if (url.hostname.endsWith("vimeo.com") && /^\/\d+\/?$/.test(url.pathname)) {
|
|
28339
|
-
return `https://player.vimeo.com/video/${url.pathname.replace(/\//g, "")}`;
|
|
28340
|
-
}
|
|
28341
|
-
return url.href;
|
|
28342
|
-
} catch {
|
|
28343
|
-
return null;
|
|
28344
|
-
}
|
|
28345
|
-
}
|
|
28346
|
-
function insertWebVideoAt(doc, caretT, input) {
|
|
28347
|
-
const url = normalizeWebVideoUrl(input.url);
|
|
28348
|
-
if (!url) return false;
|
|
28349
|
-
const posterRelId = doc.addImageResource(input.poster, input.posterExt ?? "png");
|
|
28350
|
-
const width = input.width ?? 320;
|
|
28351
|
-
const height = input.height ?? 180;
|
|
28352
|
-
const cx = String(Math.round(width * EMU_PER_PX7));
|
|
28353
|
-
const cy = String(Math.round(height * EMU_PER_PX7));
|
|
28354
|
-
const id = String(doc.nextDrawingId());
|
|
28355
|
-
const embeddedHtml = `<iframe width="640" height="360" src="${url}" frameborder="0" allowfullscreen=""></iframe>`;
|
|
28356
|
-
return insertAfterCaretRun(
|
|
28357
|
-
doc,
|
|
28358
|
-
caretT,
|
|
28359
|
-
inlineDrawing(id, `Online Video ${id}`, url, cx, cy, pictureGraphic(posterRelId, id, cx, cy, embeddedHtml))
|
|
28360
|
-
);
|
|
28361
|
-
}
|
|
28362
|
-
function insertEmbeddedObjectAt(doc, caretT, input) {
|
|
28363
|
-
const posterRelId = doc.addImageResource(input.poster, input.posterExt ?? "png");
|
|
28364
|
-
const wordDocument = input.filename.toLowerCase().endsWith(".docx");
|
|
28365
|
-
const object = wordDocument ? doc.addEmbeddedWordDocumentResource(input.data) : doc.addEmbeddedObjectResource(buildOlePackage(input.data, input.filename));
|
|
28366
|
-
const id = String(doc.nextDrawingId());
|
|
28367
|
-
const vmlId = 1024 + Number(id);
|
|
28368
|
-
const shapeTypeId = `_x0000_t${vmlId}`;
|
|
28369
|
-
const shapeId = `_x0000_i${vmlId}`;
|
|
28370
|
-
const width = 320;
|
|
28371
|
-
const height = 180;
|
|
28372
|
-
const objectEl = el14("w:object", {
|
|
28373
|
-
"xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
28374
|
-
"xmlns:v": "urn:schemas-microsoft-com:vml",
|
|
28375
|
-
"xmlns:o": "urn:schemas-microsoft-com:office:office",
|
|
28376
|
-
"xmlns:r": NS_R4,
|
|
28377
|
-
"w:dxaOrig": String(width * 15),
|
|
28378
|
-
"w:dyaOrig": String(height * 15)
|
|
28379
|
-
}, [
|
|
28380
|
-
el14("v:shapetype", {
|
|
28381
|
-
id: shapeTypeId,
|
|
28382
|
-
coordsize: "21600,21600",
|
|
28383
|
-
"o:spt": "75",
|
|
28384
|
-
"o:preferrelative": "t",
|
|
28385
|
-
path: "m@4@5l@4@11@9@11@9@5xe",
|
|
28386
|
-
filled: "f",
|
|
28387
|
-
stroked: "f"
|
|
28388
|
-
}, [
|
|
28389
|
-
el14("v:stroke", { joinstyle: "miter" }),
|
|
28390
|
-
el14("v:formulas", {}, [
|
|
28391
|
-
el14("v:f", { eqn: "if lineDrawn pixelLineWidth 0" }),
|
|
28392
|
-
el14("v:f", { eqn: "sum @0 1 0" }),
|
|
28393
|
-
el14("v:f", { eqn: "sum 0 0 @1" }),
|
|
28394
|
-
el14("v:f", { eqn: "prod @2 1 2" }),
|
|
28395
|
-
el14("v:f", { eqn: "prod @3 21600 pixelWidth" }),
|
|
28396
|
-
el14("v:f", { eqn: "prod @3 21600 pixelHeight" }),
|
|
28397
|
-
el14("v:f", { eqn: "sum @0 0 1" }),
|
|
28398
|
-
el14("v:f", { eqn: "prod @6 1 2" }),
|
|
28399
|
-
el14("v:f", { eqn: "prod @7 21600 pixelWidth" }),
|
|
28400
|
-
el14("v:f", { eqn: "sum @8 21600 0" }),
|
|
28401
|
-
el14("v:f", { eqn: "prod @7 21600 pixelHeight" }),
|
|
28402
|
-
el14("v:f", { eqn: "sum @10 21600 0" })
|
|
28403
|
-
]),
|
|
28404
|
-
el14("v:path", { "o:extrusionok": "f", gradientshapeok: "t", "o:connecttype": "rect" }),
|
|
28405
|
-
el14("o:lock", { "v:ext": "edit", aspectratio: "t" })
|
|
28406
|
-
]),
|
|
28407
|
-
el14("v:shape", {
|
|
28408
|
-
id: shapeId,
|
|
28409
|
-
type: `#${shapeTypeId}`,
|
|
28410
|
-
style: `width:${width * 0.75}pt;height:${height * 0.75}pt`,
|
|
28411
|
-
"o:ole": ""
|
|
28412
|
-
}, [el14("v:imagedata", { "r:id": posterRelId, "o:title": input.filename })]),
|
|
28413
|
-
el14("o:OLEObject", {
|
|
28414
|
-
Type: "Embed",
|
|
28415
|
-
ProgID: wordDocument ? "Word.Document.12" : "Package",
|
|
28416
|
-
ShapeID: shapeId,
|
|
28417
|
-
DrawAspect: "Content",
|
|
28418
|
-
ObjectID: `_${1e9 + Number(id)}`,
|
|
28419
|
-
"r:id": object.relId
|
|
28420
|
-
}, wordDocument ? [el14("o:FieldCodes", {}, [], "\\s")] : [])
|
|
28421
|
-
]);
|
|
28422
|
-
return insertAfterCaretRun(doc, caretT, objectEl);
|
|
28423
|
-
}
|
|
28424
|
-
|
|
28425
28591
|
// ../core/src/edit/references.ts
|
|
28426
28592
|
function el15(name, attrs = {}) {
|
|
28427
28593
|
return { name, attrs, children: [], text: "" };
|
|
@@ -29729,7 +29895,10 @@ function EquationMenu({ api }) {
|
|
|
29729
29895
|
}
|
|
29730
29896
|
};
|
|
29731
29897
|
return /* @__PURE__ */ jsxs("span", { ref: rootRef, style: { position: "relative", display: "inline-block" }, children: [
|
|
29732
|
-
/* @__PURE__ */
|
|
29898
|
+
/* @__PURE__ */ jsxs("button", { title: "Insert equation", style: btnStyle(open), onMouseDown: (event) => event.preventDefault(), onClick: () => setOpen(!open), children: [
|
|
29899
|
+
/* @__PURE__ */ jsx("span", { style: { fontFamily: "'Cambria Math', serif", fontSize: 18 }, children: "\u03C0" }),
|
|
29900
|
+
/* @__PURE__ */ jsx("span", { style: { marginLeft: 5 }, children: "Equation" })
|
|
29901
|
+
] }),
|
|
29733
29902
|
open && /* @__PURE__ */ jsxs("div", { style: { position: "absolute", top: 28, right: 0, zIndex: 100, width: 340, padding: 10, background: T.popoverBg, border: `1px solid ${T.border}`, borderRadius: 8, boxShadow: T.popoverShadow }, children: [
|
|
29734
29903
|
/* @__PURE__ */ jsx("div", { style: { font: "600 12px system-ui, sans-serif", marginBottom: 5, color: T.fg }, children: "Linear equation" }),
|
|
29735
29904
|
/* @__PURE__ */ jsx(
|
|
@@ -31742,6 +31911,11 @@ function DocxView({
|
|
|
31742
31911
|
const effZoomRef = useRef2(effectiveZoom);
|
|
31743
31912
|
effZoomRef.current = effectiveZoom;
|
|
31744
31913
|
const applyZoomRef = useRef2(null);
|
|
31914
|
+
useEffect2(() => {
|
|
31915
|
+
if (editable && typeof window !== "undefined" && !customElements.get("model-viewer")) {
|
|
31916
|
+
void import("@google/model-viewer");
|
|
31917
|
+
}
|
|
31918
|
+
}, [editable]);
|
|
31745
31919
|
const recomputeFit = useCallback2(() => {
|
|
31746
31920
|
const c = containerRef.current;
|
|
31747
31921
|
if (!c) return;
|
|
@@ -32188,8 +32362,10 @@ function DocxView({
|
|
|
32188
32362
|
const target = insertionTarget();
|
|
32189
32363
|
if (!target) return false;
|
|
32190
32364
|
history.checkpoint();
|
|
32191
|
-
|
|
32365
|
+
const drawing = insertShapeAt(doc, target.t, preset, text);
|
|
32366
|
+
if (!drawing) return false;
|
|
32192
32367
|
pages = rerender(doc, void 0, "global");
|
|
32368
|
+
editor?.reselectDrawing(drawing);
|
|
32193
32369
|
return true;
|
|
32194
32370
|
},
|
|
32195
32371
|
insertWordArt: (text, preset = "plain") => {
|