ooxml-ui 1.29.1 → 1.30.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.
Files changed (95) hide show
  1. package/dist/chart/chartex-options-locales.d.ts +11 -0
  2. package/dist/chart/chartex-options.d.ts +37 -0
  3. package/dist/chart/data-sheet-locales.d.ts +3 -0
  4. package/dist/chart/format-pane-3d.d.ts.map +1 -1
  5. package/dist/chart/format-pane-advanced-intent.d.ts +6 -0
  6. package/dist/chart/format-pane-advanced-intent.d.ts.map +1 -0
  7. package/dist/chart/format-pane-advanced-space.d.ts +14 -0
  8. package/dist/chart/format-pane-advanced-space.d.ts.map +1 -0
  9. package/dist/chart/format-pane-analysis.d.ts +7 -0
  10. package/dist/chart/format-pane-analysis.d.ts.map +1 -0
  11. package/dist/chart/format-pane-axis.d.ts.map +1 -1
  12. package/dist/chart/format-pane-chartex.d.ts +4 -0
  13. package/dist/chart/format-pane-intent.d.ts +4 -3
  14. package/dist/chart/format-pane-intent.d.ts.map +1 -1
  15. package/dist/chart/format-pane-locales/de.d.ts.map +1 -1
  16. package/dist/chart/format-pane-locales/en.d.ts.map +1 -1
  17. package/dist/chart/format-pane-locales/es.d.ts.map +1 -1
  18. package/dist/chart/format-pane-locales/fr.d.ts.map +1 -1
  19. package/dist/chart/format-pane-locales/zh-CN.d.ts.map +1 -1
  20. package/dist/chart/format-pane-options.d.ts.map +1 -1
  21. package/dist/chart/format-pane-space.d.ts +6 -5
  22. package/dist/chart/format-pane-space.d.ts.map +1 -1
  23. package/dist/chart/format-pane-view.d.ts +19 -0
  24. package/dist/chart/format-pane-view.d.ts.map +1 -1
  25. package/dist/chart-format-locales.js +1 -1
  26. package/dist/{chunk-VM6ZTKB3.js → chunk-4OBMFPGF.js} +420 -0
  27. package/dist/{chunk-W2JD75LX.js → chunk-BKHWBIXP.js} +317 -100
  28. package/dist/chunk-E4H3Y7M4.js +462 -0
  29. package/dist/{chunk-WDOWQKKC.js → chunk-HNREZW5U.js} +909 -341
  30. package/dist/{chunk-YMZFOG2U.js → chunk-IE6HKH4X.js} +1 -1
  31. package/dist/{chunk-LNHFMJ2P.js → chunk-SBBFNAKM.js} +3 -3
  32. package/dist/{chunk-KSOHDEUI.js → chunk-SXVOXSTE.js} +1 -1
  33. package/dist/controls.js +2 -2
  34. package/dist/docx/chart-sheet-labels.d.ts +3 -0
  35. package/dist/docx/locales/en.d.ts +15 -0
  36. package/dist/docx/locales/smartart.d.ts +15 -0
  37. package/dist/docx/localization-strings.d.ts +15 -0
  38. package/dist/docx/ribbon-action.d.ts +4 -0
  39. package/dist/docx/smartart-format-galleries.d.ts +2 -0
  40. package/dist/docx.js +197 -43
  41. package/dist/index.js +6 -6
  42. package/dist/pptx/{chunk-UTBHXIDK.cjs → chunk-2CBK46AW.cjs} +46 -46
  43. package/dist/pptx/{chunk-DVLU476S.mjs → chunk-45OYSCLD.mjs} +1010 -381
  44. package/dist/pptx/{chunk-PATUICO4.cjs → chunk-46HIE4IE.cjs} +420 -0
  45. package/dist/pptx/{chunk-EHIQ4ANA.mjs → chunk-6MEBLCNK.mjs} +420 -0
  46. package/dist/pptx/{chunk-67UQWOEQ.cjs → chunk-CQYWHRZE.cjs} +31 -0
  47. package/dist/pptx/{chunk-YO3EMGXD.mjs → chunk-D7UYDESZ.mjs} +2 -2
  48. package/dist/pptx/{chunk-6MZFWTBS.mjs → chunk-LXEMMWVI.mjs} +30 -1
  49. package/dist/pptx/{chunk-BXCXY4HB.cjs → chunk-YMWEU56T.cjs} +1027 -392
  50. package/dist/pptx/dom/index.cjs +389 -389
  51. package/dist/pptx/dom/index.mjs +7 -7
  52. package/dist/pptx/export/html2canvas-clone.cjs +12 -4
  53. package/dist/pptx/export/html2canvas-clone.d.ts +17 -2
  54. package/dist/pptx/export/html2canvas-clone.d.ts.map +1 -1
  55. package/dist/pptx/export/html2canvas-clone.mjs +1 -1
  56. package/dist/pptx/i18n/index.cjs +6 -6
  57. package/dist/pptx/i18n/index.mjs +1 -1
  58. package/dist/pptx/index.cjs +3066 -3046
  59. package/dist/pptx/index.mjs +3 -3
  60. package/dist/pptx/render/collaboration-external-readiness.d.ts.map +1 -1
  61. package/dist/pptx/render/collaboration-live-patch.d.ts +3 -1
  62. package/dist/pptx/render/collaboration-live-patch.d.ts.map +1 -1
  63. package/dist/pptx/render/collaboration-reconcile.d.ts +1 -1
  64. package/dist/pptx/render/collaboration-reconcile.d.ts.map +1 -1
  65. package/dist/pptx/render/collaboration-text-target.d.ts +2 -1
  66. package/dist/pptx/render/collaboration-text-target.d.ts.map +1 -1
  67. package/dist/pptx/render/controller/collaboration-history.d.ts +22 -0
  68. package/dist/pptx/render/controller/collaboration-history.d.ts.map +1 -0
  69. package/dist/pptx/render/editor-keymap-chords.d.ts +3 -4
  70. package/dist/pptx/render/editor-keymap-chords.d.ts.map +1 -1
  71. package/dist/pptx/render/morph-animation.d.ts.map +1 -1
  72. package/dist/pptx/render/morph-plan.d.ts +2 -0
  73. package/dist/pptx/render/morph-plan.d.ts.map +1 -1
  74. package/dist/pptx/render/morph-text-slot.d.ts +7 -0
  75. package/dist/pptx/render/morph-text-slot.d.ts.map +1 -1
  76. package/dist/pptx/render/text-block-style.d.ts.map +1 -1
  77. package/dist/pptx/render/text-run-style.d.ts +2 -0
  78. package/dist/pptx/render/text-run-style.d.ts.map +1 -1
  79. package/dist/pptx/{smartart-insert-preview-DHQ47GXP.cjs → smartart-insert-preview-7OL7VWEK.cjs} +5 -5
  80. package/dist/pptx/{smartart-insert-preview-IQVC5LMF.mjs → smartart-insert-preview-SKFD7NCQ.mjs} +4 -4
  81. package/dist/smartart/smartart-effects.d.ts +3 -0
  82. package/dist/smartart/smartart-geometry.d.ts +5 -0
  83. package/dist/smartart/smartart-paint.d.ts +4 -0
  84. package/dist/smartart/smartart-svg.d.ts +4 -1
  85. package/dist/smartart/smartart-text.d.ts +4 -0
  86. package/dist/smartart.js +1 -1
  87. package/dist/teams.js +3 -3
  88. package/dist/visio/viewer-chart-editor.d.ts +2 -1
  89. package/dist/visio.js +36 -19
  90. package/dist/xlsx/chart-ex-pane.d.ts +11 -0
  91. package/dist/xlsx/grid/smartart.d.ts +3 -4
  92. package/dist/xlsx/ribbon/shared-gallery.d.ts +14 -0
  93. package/dist/xlsx.js +386 -139
  94. package/package.json +2 -2
  95. package/dist/chunk-UBBC5FH7.js +0 -31
@@ -2,9 +2,316 @@ import { parseSvgPreview } from './chunk-FN7IF6M6.js';
2
2
  import { OfficeElement, controlStyles, definer } from './chunk-QLHCGV4C.js';
3
3
  import { html, nothing } from 'lit';
4
4
  import { hexToRgbChannels } from 'ooxml-core/color';
5
- import { resolveDrawingColor, DIAGRAM_COLOR_SECTIONS, DIAGRAM_COLOR_ENTRIES, DIAGRAM_STYLE_ENTRIES, diagramDesignEdit, diagramNodeOutline } from 'ooxml-core/diagram';
5
+ import { resolveDrawingColor, buildRectPathGradientSvg, DIAGRAM_COLOR_SECTIONS, DIAGRAM_COLOR_ENTRIES, DIAGRAM_STYLE_ENTRIES, diagramDesignEdit, diagramNodeOutline } from 'ooxml-core/diagram';
6
+ import { evaluatePresetShape, ooxmlArcToSvg } from 'ooxml-core/geometry';
7
+ import { wrapStyledRuns, designTextWidthEm } from 'ooxml-core/text';
8
+ import { resolveDrawingOuterShadow } from 'ooxml-core/drawingml';
6
9
 
7
10
  var SVG_NS = "http://www.w3.org/2000/svg";
11
+ function drawingPathData(path, width, height) {
12
+ const sx = path.width ? width / path.width : 1;
13
+ const sy = path.height ? height / path.height : 1;
14
+ const out = [];
15
+ let px = 0;
16
+ let py = 0;
17
+ let startX = 0;
18
+ let startY = 0;
19
+ for (const command of path.commands) {
20
+ if (command.op === "A") {
21
+ const arc = ooxmlArcToSvg(
22
+ command.wR * sx,
23
+ command.hR * sy,
24
+ command.startAngle * 6e4,
25
+ command.swingAngle * 6e4,
26
+ px,
27
+ py
28
+ );
29
+ if (arc) {
30
+ out.push(arc.svg);
31
+ px = arc.endX;
32
+ py = arc.endY;
33
+ }
34
+ } else if (command.op === "Z") {
35
+ out.push("Z");
36
+ px = startX;
37
+ py = startY;
38
+ } else {
39
+ px = command.x * sx;
40
+ py = command.y * sy;
41
+ if (command.op === "M" || command.op === "L") {
42
+ out.push(`${command.op}${px} ${py}`);
43
+ if (command.op === "M") {
44
+ startX = px;
45
+ startY = py;
46
+ }
47
+ } else if (command.op === "C")
48
+ out.push(
49
+ `C${command.x1 * sx} ${command.y1 * sy} ${command.x2 * sx} ${command.y2 * sy} ${px} ${py}`
50
+ );
51
+ else if (command.op === "Q") out.push(`Q${command.x1 * sx} ${command.y1 * sy} ${px} ${py}`);
52
+ }
53
+ }
54
+ return out.join(" ");
55
+ }
56
+ function diagramShapeElement(doc, shape, approximated) {
57
+ const width = shape.frame.width / 9525;
58
+ const height = shape.frame.height / 9525;
59
+ if (!shape.paths?.length && ["rect", "ellipse"].includes(shape.geometry)) {
60
+ const element = doc.createElementNS(SVG_NS, shape.geometry === "ellipse" ? "ellipse" : "rect");
61
+ if (shape.geometry === "ellipse") {
62
+ element.setAttribute("cx", String(width / 2));
63
+ element.setAttribute("cy", String(height / 2));
64
+ element.setAttribute("rx", String(width / 2));
65
+ element.setAttribute("ry", String(height / 2));
66
+ } else {
67
+ element.setAttribute("width", String(width));
68
+ element.setAttribute("height", String(height));
69
+ }
70
+ return element;
71
+ }
72
+ const evaluated = shape.paths?.length ? void 0 : evaluatePresetShape(shape.geometry, width, height, shape.adjustments);
73
+ const paths = shape.paths?.map((path) => ({
74
+ d: drawingPathData(path, width, height),
75
+ fill: path.fill,
76
+ stroke: path.stroke
77
+ })) ?? evaluated?.paths;
78
+ if (paths?.length) {
79
+ const group = doc.createElementNS(SVG_NS, "g");
80
+ for (const path of paths) {
81
+ const element = doc.createElementNS(SVG_NS, "path");
82
+ element.setAttribute("d", path.d);
83
+ if (path.fill === "none") element.setAttribute("fill", "none");
84
+ if (path.stroke === false) element.setAttribute("stroke", "none");
85
+ group.append(element);
86
+ }
87
+ return group;
88
+ }
89
+ if (!approximated.includes(shape.geometry)) approximated.push(shape.geometry);
90
+ const rect2 = doc.createElementNS(SVG_NS, "rect");
91
+ rect2.setAttribute("width", String(width));
92
+ rect2.setAttribute("height", String(height));
93
+ rect2.setAttribute("data-approximated", shape.geometry);
94
+ return rect2;
95
+ }
96
+ var NS = "http://www.w3.org/2000/svg";
97
+ var serial = 0;
98
+ function diagramFill(doc, defs, fill, scheme, report) {
99
+ if (!fill || fill.kind === "none") return "none";
100
+ if (fill.kind === "solid") return colorToCss(fill.color, scheme, report) ?? "none";
101
+ if (fill.kind !== "gradient") {
102
+ if (!report.approximatedFills.includes(fill.kind)) report.approximatedFills.push(fill.kind);
103
+ return "#d1d5db";
104
+ }
105
+ const id = `office-smartart-paint-${++serial}`;
106
+ if (fill.path === "rect") {
107
+ const stops = fill.stops.flatMap((stop) => {
108
+ const color = resolveDrawingColor(stop.color, { scheme: (name) => scheme[name] });
109
+ return color ? [{ position: stop.position, color: color.hex, opacity: color.alpha }] : [];
110
+ });
111
+ const pattern = doc.createElementNS(NS, "pattern");
112
+ pattern.id = id;
113
+ pattern.setAttribute("width", "1");
114
+ pattern.setAttribute("height", "1");
115
+ pattern.setAttribute("patternContentUnits", "objectBoundingBox");
116
+ const image = doc.createElementNS(NS, "image");
117
+ image.setAttribute("width", "1");
118
+ image.setAttribute("height", "1");
119
+ image.setAttribute("preserveAspectRatio", "none");
120
+ image.setAttribute(
121
+ "href",
122
+ `data:image/svg+xml,${encodeURIComponent(buildRectPathGradientSvg(stops, void 0, fill.fillToRect, { bands: 40, independentOpacity: true }))}`
123
+ );
124
+ pattern.append(image);
125
+ defs.append(pattern);
126
+ return `url(#${id})`;
127
+ }
128
+ const radial = Boolean(fill.path);
129
+ const gradient = doc.createElementNS(NS, radial ? "radialGradient" : "linearGradient");
130
+ gradient.id = id;
131
+ if (radial) {
132
+ const rect2 = fill.fillToRect;
133
+ gradient.setAttribute("cx", String(rect2 ? (rect2.l + 1 - rect2.r) / 2 : 0.5));
134
+ gradient.setAttribute("cy", String(rect2 ? (rect2.t + 1 - rect2.b) / 2 : 0.5));
135
+ gradient.setAttribute("r", "0.5");
136
+ if (fill.path !== "circle" && !report.approximatedFills.includes(`gradient:${fill.path}`))
137
+ report.approximatedFills.push(`gradient:${fill.path}`);
138
+ } else {
139
+ const radians = (fill.angle ?? 0) * Math.PI / 180;
140
+ const dx = Math.cos(radians) / 2;
141
+ const dy = Math.sin(radians) / 2;
142
+ gradient.setAttribute("x1", String(0.5 - dx));
143
+ gradient.setAttribute("y1", String(0.5 - dy));
144
+ gradient.setAttribute("x2", String(0.5 + dx));
145
+ gradient.setAttribute("y2", String(0.5 + dy));
146
+ }
147
+ for (const stop of fill.stops) {
148
+ const element = doc.createElementNS(NS, "stop");
149
+ element.setAttribute("offset", `${stop.position}%`);
150
+ element.setAttribute("stop-color", colorToCss(stop.color, scheme, report) ?? "#808080");
151
+ gradient.append(element);
152
+ }
153
+ defs.append(gradient);
154
+ return `url(#${id})`;
155
+ }
156
+ var NS2 = "http://www.w3.org/2000/svg";
157
+ function runStyle(element, run, fonts, scheme, report) {
158
+ if (run.sizePt !== void 0) element.setAttribute("font-size", String(run.sizePt * 96 / 72));
159
+ if (run.bold !== void 0) element.setAttribute("font-weight", run.bold ? "700" : "400");
160
+ if (run.italic !== void 0)
161
+ element.setAttribute("font-style", run.italic ? "italic" : "normal");
162
+ if (run.underline !== void 0)
163
+ element.setAttribute("text-decoration", run.underline ? "underline" : "none");
164
+ if (run.color)
165
+ element.setAttribute("fill", colorToCss(run.color, scheme, report) ?? "currentColor");
166
+ const typeface = run.typeface;
167
+ const font = typeface === "+mj-lt" ? fonts.major : typeface === "+mn-lt" ? fonts.minor : typeface;
168
+ if (font) element.setAttribute("font-family", font);
169
+ }
170
+ function diagramTextElement(doc, shape, scheme, fonts, report) {
171
+ const frame = shape.textFrame ?? shape.frame;
172
+ const ox = (frame.x - shape.frame.x) / 9525;
173
+ const oy = (frame.y - shape.frame.y) / 9525;
174
+ const w = frame.width / 9525;
175
+ const h = frame.height / 9525;
176
+ const sourceParagraphs = shape.text?.paragraphs ?? [];
177
+ const insets = shape.text?.insetsEmu;
178
+ const contentX = ox + (insets?.left ?? 0) / 9525;
179
+ const contentY = oy + (insets?.top ?? 0) / 9525;
180
+ const contentWidth = Math.max(1, w - ((insets?.left ?? 0) + (insets?.right ?? 0)) / 9525);
181
+ const contentHeight = Math.max(1, h - ((insets?.top ?? 0) + (insets?.bottom ?? 0)) / 9525);
182
+ const paragraphs = sourceParagraphs.flatMap((paragraph, paragraphIndex) => {
183
+ const runs = paragraph.runs.map((run) => ({ ...paragraph.defaultProperties, ...run }));
184
+ const measure = (content, run) => {
185
+ const family = run.typeface === "+mj-lt" ? fonts.major : run.typeface === "+mn-lt" ? fonts.minor : run.typeface;
186
+ const em = designTextWidthEm(content, family ?? fonts.minor ?? "Arial", run.bold);
187
+ if (em === void 0) {
188
+ const issue = `font-metrics:${family ?? fonts.minor ?? "Arial"}`;
189
+ if (!report.approximatedText?.includes(issue))
190
+ report.approximatedText = [...report.approximatedText ?? [], issue];
191
+ }
192
+ return (em ?? [...content].length * 0.5) * (run.sizePt ?? 12) * 96 / 72;
193
+ };
194
+ const maxWidth = shape.body?.bodyProperties?.wrap === "none" ? Infinity : contentWidth;
195
+ const plain = runs.map((run) => run.text).join("");
196
+ let offset = 0;
197
+ const lines = wrapStyledRuns(runs, maxWidth, measure, { breakWords: true });
198
+ return lines.map((line2, index) => {
199
+ const content = line2.map((run) => run.text).join("");
200
+ const start = plain.indexOf(content, offset);
201
+ const separator = start >= offset ? plain.slice(offset, start) : "";
202
+ offset = Math.max(offset, start + content.length);
203
+ return {
204
+ ...paragraph,
205
+ runs: line2,
206
+ separatorBefore: index === 0 && paragraphIndex > 0 ? "\n" : separator,
207
+ first: index === 0,
208
+ last: index === lines.length - 1
209
+ };
210
+ });
211
+ });
212
+ const first = paragraphs[0]?.runs[0];
213
+ const size = (first?.sizePt ?? 12) * 96 / 72;
214
+ const text = doc.createElementNS(NS2, "text");
215
+ text.setAttribute("x", String(ox + w / 2));
216
+ text.setAttribute("y", String(oy + h / 2));
217
+ text.setAttribute("text-anchor", "middle");
218
+ text.setAttribute("dominant-baseline", "central");
219
+ text.setAttribute("font-size", String(size));
220
+ text.setAttribute(
221
+ "fill",
222
+ colorToCss(first?.color ?? shape.style?.font?.color, scheme, report) ?? "currentColor"
223
+ );
224
+ const ref = shape.style?.font?.fontIndex;
225
+ const inherited = ref === "major" ? fonts.major : ref === "minor" ? fonts.minor : void 0;
226
+ if (inherited) text.setAttribute("font-family", inherited);
227
+ if (first) runStyle(text, first, fonts, scheme, report);
228
+ const body = shape.body?.bodyProperties;
229
+ if (body && (body.vertical && body.vertical !== "horz" || body.rotation || (body.columnCount ?? 1) > 1))
230
+ report.approximatedText = [
231
+ .../* @__PURE__ */ new Set([...report.approximatedText ?? [], "vertical-or-multicolumn"])
232
+ ];
233
+ if (shape.body?.paragraphs.some(
234
+ (paragraph) => paragraph.properties?.bullet && paragraph.properties.bullet.kind !== "none" || paragraph.properties?.tabStops?.length
235
+ ))
236
+ report.approximatedText = [.../* @__PURE__ */ new Set([...report.approximatedText ?? [], "bullets-or-tabs"])];
237
+ const spacing = (value, nominal) => value ? value.unit === "points" ? value.value * 96 / 72 : value.value * nominal : 0;
238
+ const heights = paragraphs.map((paragraph) => {
239
+ const nominal = Math.max(size, ...paragraph.runs.map((run) => (run.sizePt ?? 12) * 96 / 72));
240
+ return {
241
+ line: paragraph.lineSpacing ? spacing(paragraph.lineSpacing, nominal) : nominal * 1.2,
242
+ before: paragraph.first ? spacing(paragraph.spaceBefore, nominal) : 0,
243
+ after: paragraph.last ? spacing(paragraph.spaceAfter, nominal) : 0
244
+ };
245
+ });
246
+ const totalHeight = heights.reduce(
247
+ (sum, value) => sum + value.line + value.before + value.after,
248
+ 0
249
+ );
250
+ const anchor = shape.text?.anchor;
251
+ let y = anchor === "t" ? contentY : anchor === "b" ? contentY + contentHeight - totalHeight : contentY + (contentHeight - totalHeight) / 2;
252
+ paragraphs.forEach((paragraph, index) => {
253
+ if (paragraph.separatorBefore) text.append(doc.createTextNode(paragraph.separatorBefore));
254
+ const line2 = doc.createElementNS(NS2, "tspan");
255
+ const align = paragraph.align;
256
+ const x = align === "l" ? contentX : align === "r" ? contentX + contentWidth : contentX + contentWidth / 2;
257
+ const height = heights[index] ?? { line: size, before: 0, after: 0 };
258
+ y += height.before;
259
+ line2.setAttribute("x", String(x));
260
+ line2.setAttribute("y", String(y + height.line / 2));
261
+ line2.setAttribute("text-anchor", align === "l" ? "start" : align === "r" ? "end" : "middle");
262
+ for (const run of paragraph.runs) {
263
+ const span = doc.createElementNS(NS2, "tspan");
264
+ span.textContent = run.text;
265
+ runStyle(
266
+ span,
267
+ { bold: false, italic: false, underline: false, ...paragraph.defaultProperties, ...run },
268
+ fonts,
269
+ scheme,
270
+ report
271
+ );
272
+ line2.append(span);
273
+ }
274
+ text.append(line2);
275
+ y += height.line + height.after;
276
+ });
277
+ return text;
278
+ }
279
+ var NS3 = "http://www.w3.org/2000/svg";
280
+ var serial2 = 0;
281
+ function diagramEffects(doc, defs, body, shape, scheme, report) {
282
+ for (const effect of shape.effects?.effects ?? []) {
283
+ const shadow = effect.kind === "outerShadow" ? resolveDrawingOuterShadow(effect, { scheme: (name) => scheme[name] }) : void 0;
284
+ if (!shadow) {
285
+ report.unappliedEffects = [.../* @__PURE__ */ new Set([...report.unappliedEffects ?? [], effect.kind])];
286
+ continue;
287
+ }
288
+ const filter = doc.createElementNS(NS3, "filter");
289
+ filter.id = `office-smartart-shadow-${++serial2}`;
290
+ filter.setAttribute("filterUnits", "userSpaceOnUse");
291
+ const pad = Math.max(
292
+ shadow.blur * 3 + Math.abs(shadow.dx),
293
+ shadow.blur * 3 + Math.abs(shadow.dy),
294
+ 1
295
+ );
296
+ filter.setAttribute("x", String(-pad));
297
+ filter.setAttribute("y", String(-pad));
298
+ filter.setAttribute("width", String(shape.frame.width / 9525 + pad * 2));
299
+ filter.setAttribute("height", String(shape.frame.height / 9525 + pad * 2));
300
+ filter.setAttribute("color-interpolation-filters", "sRGB");
301
+ const drop = doc.createElementNS(NS3, "feDropShadow");
302
+ drop.setAttribute("dx", String(shadow.dx));
303
+ drop.setAttribute("dy", String(shadow.dy));
304
+ drop.setAttribute("stdDeviation", String(shadow.blur / 2));
305
+ drop.setAttribute("flood-color", shadow.color);
306
+ drop.setAttribute("flood-opacity", String(shadow.opacity));
307
+ filter.append(drop);
308
+ defs.append(filter);
309
+ body.setAttribute("filter", `url(#${filter.id})`);
310
+ }
311
+ }
312
+
313
+ // src/smartart/smartart-svg.ts
314
+ var SVG_NS2 = "http://www.w3.org/2000/svg";
8
315
  var EMU_PER_PX = 9525;
9
316
  function colorToCss(color, scheme, report) {
10
317
  if (!color) return void 0;
@@ -24,66 +331,6 @@ function colorToCss(color, scheme, report) {
24
331
  if (color.kind === "system" && !color.fallback) return void 0;
25
332
  return "#9ca3af";
26
333
  }
27
- function fillToCss(fill, scheme, report) {
28
- if (!fill) return "none";
29
- if (fill.kind === "none") return "none";
30
- if (fill.kind === "solid") return colorToCss(fill.color, scheme, report) ?? "none";
31
- if (!report.approximatedFills.includes(fill.kind)) report.approximatedFills.push(fill.kind);
32
- if (fill.kind === "gradient") return colorToCss(fill.stops[0]?.color, scheme, report) ?? "none";
33
- return "#d1d5db";
34
- }
35
- function pathData(path, widthPx, heightPx) {
36
- const sx = path.width ? widthPx / path.width : 1;
37
- const sy = path.height ? heightPx / path.height : 1;
38
- const x = (v) => +(v * sx).toFixed(2);
39
- const y = (v) => +(v * sy).toFixed(2);
40
- const out = [];
41
- for (const c of path.commands) {
42
- if (c.op === "M" || c.op === "L") out.push(`${c.op}${x(c.x)} ${y(c.y)}`);
43
- else if (c.op === "C")
44
- out.push(`C${x(c.x1)} ${y(c.y1)} ${x(c.x2)} ${y(c.y2)} ${x(c.x)} ${y(c.y)}`);
45
- else if (c.op === "Q") out.push(`Q${x(c.x1)} ${y(c.y1)} ${x(c.x)} ${y(c.y)}`);
46
- else if (c.op === "Z") out.push("Z");
47
- }
48
- return out.join("");
49
- }
50
- var hasArc = (shape) => Boolean(shape.paths?.some((p) => p.commands.some((c) => c.op === "A")));
51
- function shapeElement(doc, shape, report) {
52
- const { frame } = shape;
53
- const w = frame.width / EMU_PER_PX;
54
- const h = frame.height / EMU_PER_PX;
55
- if (shape.paths?.length) {
56
- const el = doc.createElementNS(SVG_NS, "g");
57
- for (const path of shape.paths) {
58
- const p = doc.createElementNS(SVG_NS, "path");
59
- p.setAttribute("d", pathData(path, w, h));
60
- el.append(p);
61
- }
62
- if (hasArc(shape) && !report.approximatedGeometries.includes("custom:arc")) {
63
- report.approximatedGeometries.push("custom:arc");
64
- }
65
- return el;
66
- }
67
- if (shape.geometry === "ellipse") {
68
- const e = doc.createElementNS(SVG_NS, "ellipse");
69
- e.setAttribute("rx", String(w / 2));
70
- e.setAttribute("ry", String(h / 2));
71
- e.setAttribute("cx", String(w / 2));
72
- e.setAttribute("cy", String(h / 2));
73
- return e;
74
- }
75
- const rect2 = doc.createElementNS(SVG_NS, "rect");
76
- rect2.setAttribute("width", String(w));
77
- rect2.setAttribute("height", String(h));
78
- if (shape.geometry === "roundRect") {
79
- const adj = (shape.adjustments?.adj ?? 16667) / 1e5;
80
- rect2.setAttribute("rx", String(Math.min(w, h) * adj));
81
- } else if (shape.geometry !== "rect" && !report.approximatedGeometries.includes(shape.geometry)) {
82
- report.approximatedGeometries.push(shape.geometry);
83
- rect2.setAttribute("data-approximated", shape.geometry);
84
- }
85
- return rect2;
86
- }
87
334
  function renderDiagramDrawing(doc, drawing, scheme = {}, fonts = {}) {
88
335
  const report = {
89
336
  shapeCount: drawing.shapes.length,
@@ -91,14 +338,16 @@ function renderDiagramDrawing(doc, drawing, scheme = {}, fonts = {}) {
91
338
  flattened3d: 0,
92
339
  approximatedFills: []
93
340
  };
94
- const svg = doc.createElementNS(SVG_NS, "svg");
341
+ const svg = doc.createElementNS(SVG_NS2, "svg");
342
+ const defs = doc.createElementNS(SVG_NS2, "defs");
343
+ svg.append(defs);
95
344
  let right = 0;
96
345
  let bottom = 0;
97
346
  for (const shape of drawing.shapes) {
98
347
  const { frame } = shape;
99
348
  right = Math.max(right, (frame.x + frame.width) / EMU_PER_PX);
100
349
  bottom = Math.max(bottom, (frame.y + frame.height) / EMU_PER_PX);
101
- const group = doc.createElementNS(SVG_NS, "g");
350
+ const group = doc.createElementNS(SVG_NS2, "g");
102
351
  group.dataset.modelId = shape.modelId;
103
352
  const cx = frame.width / EMU_PER_PX / 2;
104
353
  const cy = frame.height / EMU_PER_PX / 2;
@@ -110,9 +359,10 @@ function renderDiagramDrawing(doc, drawing, scheme = {}, fonts = {}) {
110
359
  transform.push(`translate(${cx} ${cy}) scale(${fx} ${fy}) translate(${-cx} ${-cy})`);
111
360
  }
112
361
  group.setAttribute("transform", transform.join(" "));
113
- const body = shapeElement(doc, shape, report);
114
- body.setAttribute("fill", fillToCss(shape.fill, scheme, report));
115
- const stroke = shape.line?.fill?.kind === "solid" ? colorToCss(shape.line.fill.color, scheme, report) : void 0;
362
+ const body = diagramShapeElement(doc, shape, report.approximatedGeometries);
363
+ body.setAttribute("fill", diagramFill(doc, defs, shape.fill, scheme, report));
364
+ diagramEffects(doc, defs, body, shape, scheme, report);
365
+ const stroke = shape.line?.fill && shape.line.widthEmu !== 0 ? diagramFill(doc, defs, shape.line.fill, scheme, report) : void 0;
116
366
  body.setAttribute("stroke", stroke ?? "none");
117
367
  if (stroke)
118
368
  body.setAttribute(
@@ -124,46 +374,13 @@ function renderDiagramDrawing(doc, drawing, scheme = {}, fonts = {}) {
124
374
  report.flattened3d += 1;
125
375
  group.setAttribute("data-flattened-3d", "");
126
376
  }
127
- if (shape.text?.text) group.append(textElement(doc, shape, scheme, fonts, report));
377
+ if (shape.text?.text) group.append(diagramTextElement(doc, shape, scheme, fonts, report));
128
378
  svg.append(group);
129
379
  }
130
380
  svg.setAttribute("viewBox", `0 0 ${Math.max(right, 1)} ${Math.max(bottom, 1)}`);
131
381
  svg.setAttribute("overflow", "visible");
132
382
  return { svg, report };
133
383
  }
134
- function textElement(doc, shape, scheme, fonts, report) {
135
- const frame = shape.textFrame ?? {
136
- x: shape.frame.x,
137
- y: shape.frame.y,
138
- width: shape.frame.width,
139
- height: shape.frame.height
140
- };
141
- const ox = (frame.x - shape.frame.x) / EMU_PER_PX;
142
- const oy = (frame.y - shape.frame.y) / EMU_PER_PX;
143
- const w = frame.width / EMU_PER_PX;
144
- const h = frame.height / EMU_PER_PX;
145
- const text = doc.createElementNS(SVG_NS, "text");
146
- const first = shape.text?.paragraphs[0]?.runs[0];
147
- const sizePx = (first?.sizePt ?? 12) * 96 / 72;
148
- text.setAttribute("x", String(ox + w / 2));
149
- text.setAttribute("y", String(oy + h / 2));
150
- text.setAttribute("text-anchor", "middle");
151
- text.setAttribute("dominant-baseline", "central");
152
- text.setAttribute("font-size", String(sizePx));
153
- text.setAttribute(
154
- "fill",
155
- colorToCss(first?.color ?? shape.style?.font?.color, scheme, report) ?? "currentColor"
156
- );
157
- if (first?.bold) text.setAttribute("font-weight", "700");
158
- if (first?.italic) text.setAttribute("font-style", "italic");
159
- const ref = shape.style?.font?.fontIndex;
160
- const inherited = ref === "major" ? fonts.major : ref === "minor" ? fonts.minor : void 0;
161
- const typeface = first?.typeface;
162
- const font = typeface === "+mj-lt" ? fonts.major : typeface === "+mn-lt" ? fonts.minor : typeface ?? inherited;
163
- if (font) text.setAttribute("font-family", font);
164
- text.textContent = shape.text?.paragraphs.map((p) => p.runs.map((r) => r.text).join("")).join(" ") ?? "";
165
- return text;
166
- }
167
384
 
168
385
  // raw-css:/home/runner/work/ooxml/ooxml/src/ui/src/smartart/smartart.css?raw
169
386
  var smartart_default = ":host {\n display: block;\n}\nsvg {\n display: block;\n width: 100%;\n height: auto;\n max-height: 100%;\n}\ntext {\n pointer-events: none;\n}\ntext:not([font-family]) {\n font-family: var(--office-font);\n}\n.empty {\n padding: var(--office-space-2);\n font-size: var(--office-font-size-sm);\n color: var(--office-muted-foreground);\n}\n@media (forced-colors: active) {\n text {\n fill: CanvasText;\n }\n}\n";