@json-to-office/core-pptx 0.21.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/chart.d.ts.map +1 -1
- package/dist/components/highcharts.d.ts.map +1 -1
- package/dist/components/image.d.ts +2 -5
- package/dist/components/image.d.ts.map +1 -1
- package/dist/components/text.d.ts +2 -5
- package/dist/components/text.d.ts.map +1 -1
- package/dist/core/structure.d.ts.map +1 -1
- package/dist/index.js +154 -55
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/color.d.ts +16 -4
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/hyperlink.d.ts +40 -0
- package/dist/utils/hyperlink.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../src/components/chart.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIjE,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,eAAe,EAAE,CAAC;IAExB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,KAAK,CAAC,EAA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B,oBAAoB,CAClC,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,SAAS,EAChB,QAAQ,CAAC,EAAE,eAAe,EAAE,GAC3B,IAAI,CA2KN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highcharts.d.ts","sourceRoot":"","sources":["../../src/components/highcharts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"highcharts.d.ts","sourceRoot":"","sources":["../../src/components/highcharts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAuGtE,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,eAAe,EACtB,QAAQ,CAAC,EAAE,eAAe,EAAE,EAC5B,cAAc,CAAC,EAAE,uBAAuB,GACvC,OAAO,CAAC,IAAI,CAAC,CAgBf"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type PptxGenJS from 'pptxgenjs';
|
|
5
5
|
import type { PptxThemeConfig, PipelineWarning } from '../types';
|
|
6
|
+
import { type HyperlinkProps } from '../utils/hyperlink';
|
|
6
7
|
interface ImageComponentProps {
|
|
7
8
|
path?: string;
|
|
8
9
|
base64?: string;
|
|
@@ -26,11 +27,7 @@ interface ImageComponentProps {
|
|
|
26
27
|
angle?: number;
|
|
27
28
|
opacity?: number;
|
|
28
29
|
};
|
|
29
|
-
hyperlink?:
|
|
30
|
-
url?: string;
|
|
31
|
-
slide?: number;
|
|
32
|
-
tooltip?: string;
|
|
33
|
-
};
|
|
30
|
+
hyperlink?: HyperlinkProps;
|
|
34
31
|
alt?: string;
|
|
35
32
|
}
|
|
36
33
|
export declare function renderImageComponent(slide: PptxGenJS.Slide, props: ImageComponentProps, theme: PptxThemeConfig, warnings?: PipelineWarning[], slideWidth?: number, slideHeight?: number): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/components/image.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/components/image.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIjE,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AA4BzE,UAAU,mBAAmB;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA2DD,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,eAAe,EACtB,QAAQ,CAAC,EAAE,eAAe,EAAE,EAC5B,UAAU,SAAK,EACf,WAAW,SAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAoJf"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type PptxGenJS from 'pptxgenjs';
|
|
5
5
|
import type { PptxThemeConfig, StyleName, PipelineWarning, SlideContext } from '../types';
|
|
6
|
+
import { type HyperlinkProps } from '../utils/hyperlink';
|
|
6
7
|
interface TextComponentProps {
|
|
7
8
|
text: string;
|
|
8
9
|
x?: number | string;
|
|
@@ -43,11 +44,7 @@ interface TextComponentProps {
|
|
|
43
44
|
color: string;
|
|
44
45
|
transparency?: number;
|
|
45
46
|
};
|
|
46
|
-
hyperlink?:
|
|
47
|
-
url?: string;
|
|
48
|
-
slide?: number;
|
|
49
|
-
tooltip?: string;
|
|
50
|
-
};
|
|
47
|
+
hyperlink?: HyperlinkProps;
|
|
51
48
|
lineSpacing?: number;
|
|
52
49
|
charSpacing?: number;
|
|
53
50
|
paraSpaceBefore?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/components/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EACV,eAAe,EACf,SAAS,EACT,eAAe,EACf,YAAY,EACb,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/components/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EACV,eAAe,EACf,SAAS,EACT,eAAe,EACf,YAAY,EACb,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzE,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,MAAM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file":"structure.d.ts","sourceRoot":"","sources":["../../src/core/structure.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAGV,+BAA+B,EAC/B,qBAAqB,EAGtB,MAAM,UAAU,CAAC;AAQlB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../../src/core/structure.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAGV,+BAA+B,EAC/B,qBAAqB,EAGtB,MAAM,UAAU,CAAC;AAQlB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAmCrD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,+BAA+B,EACzC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,qBAAqB,CAmJvB"}
|
package/dist/index.js
CHANGED
|
@@ -306,8 +306,82 @@ function resolveComponentTree(components, theme) {
|
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
+
// src/utils/hyperlink.ts
|
|
310
|
+
var HYPERLINK_SLIDE_UNRESOLVED = "HYPERLINK_SLIDE_UNRESOLVED";
|
|
311
|
+
function remapHyperlink(hyperlink, map) {
|
|
312
|
+
if (hyperlink.url || hyperlink.slide == null) return hyperlink;
|
|
313
|
+
const rendered = map.get(hyperlink.slide);
|
|
314
|
+
if (rendered === void 0) {
|
|
315
|
+
const { slide, ...rest } = hyperlink;
|
|
316
|
+
return { ...rest, unresolvedSlideRef: slide };
|
|
317
|
+
}
|
|
318
|
+
return rendered === hyperlink.slide ? hyperlink : { ...hyperlink, slide: rendered };
|
|
319
|
+
}
|
|
320
|
+
function remapHyperlinkProps(props, map) {
|
|
321
|
+
const hyperlink = props.hyperlink;
|
|
322
|
+
if (!hyperlink || typeof hyperlink !== "object") return props;
|
|
323
|
+
const remapped = remapHyperlink(hyperlink, map);
|
|
324
|
+
return remapped === hyperlink ? props : { ...props, hyperlink: remapped };
|
|
325
|
+
}
|
|
326
|
+
function remapHyperlinkSlideRefs(component, map) {
|
|
327
|
+
const hyperlink = component.props?.hyperlink;
|
|
328
|
+
let next = component;
|
|
329
|
+
if (hyperlink && typeof hyperlink === "object") {
|
|
330
|
+
const remapped = remapHyperlink(hyperlink, map);
|
|
331
|
+
if (remapped !== hyperlink) {
|
|
332
|
+
next = { ...next, props: { ...next.props, hyperlink: remapped } };
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (next.children && next.children.length > 0) {
|
|
336
|
+
next = {
|
|
337
|
+
...next,
|
|
338
|
+
children: next.children.map(
|
|
339
|
+
(child) => remapHyperlinkSlideRefs(child, map)
|
|
340
|
+
)
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
return next;
|
|
344
|
+
}
|
|
345
|
+
function applyHyperlink(opts, hyperlink, componentName, warnings) {
|
|
346
|
+
if (!hyperlink) return;
|
|
347
|
+
if (hyperlink.url) {
|
|
348
|
+
opts.hyperlink = { url: hyperlink.url, tooltip: hyperlink.tooltip };
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (hyperlink.unresolvedSlideRef != null) {
|
|
352
|
+
const message = `hyperlink.slide ${hyperlink.unresolvedSlideRef} matches no slide in the generated presentation (slide disabled, or index out of range) \u2014 hyperlink dropped`;
|
|
353
|
+
if (warnings) {
|
|
354
|
+
warnings.push({
|
|
355
|
+
code: HYPERLINK_SLIDE_UNRESOLVED,
|
|
356
|
+
message,
|
|
357
|
+
component: componentName
|
|
358
|
+
});
|
|
359
|
+
} else {
|
|
360
|
+
console.warn(message);
|
|
361
|
+
}
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
if (hyperlink.slide) {
|
|
365
|
+
opts.hyperlink = { slide: hyperlink.slide, tooltip: hyperlink.tooltip };
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
309
369
|
// src/core/structure.ts
|
|
310
370
|
import { mergeWithDefaults as mergeWithDefaults2 } from "@json-to-office/shared";
|
|
371
|
+
function isSlideEnabled(child) {
|
|
372
|
+
return !("enabled" in child && child.enabled === false);
|
|
373
|
+
}
|
|
374
|
+
function buildSlideIndexMap(children) {
|
|
375
|
+
const map = /* @__PURE__ */ new Map();
|
|
376
|
+
let authored = 0;
|
|
377
|
+
let rendered = 0;
|
|
378
|
+
for (const child of children) {
|
|
379
|
+
if (!isSlideComponent(child)) continue;
|
|
380
|
+
authored++;
|
|
381
|
+
if (isSlideEnabled(child)) map.set(authored, ++rendered);
|
|
382
|
+
}
|
|
383
|
+
return map;
|
|
384
|
+
}
|
|
311
385
|
function processPresentation(document, options) {
|
|
312
386
|
const { props, children = [] } = document;
|
|
313
387
|
const baseTheme = typeof props.theme === "object" && props.theme !== null ? props.theme : options?.customThemes?.[props.theme ?? "default"] ?? getPptxTheme(props.theme ?? "default");
|
|
@@ -321,34 +395,41 @@ function processPresentation(document, options) {
|
|
|
321
395
|
} : baseTheme;
|
|
322
396
|
const slideWidth = props.slideWidth ?? 10;
|
|
323
397
|
const slideHeight = props.slideHeight ?? 7.5;
|
|
398
|
+
const slideIndexMap = buildSlideIndexMap(children);
|
|
324
399
|
let templates;
|
|
325
400
|
if (props.templates && props.templates.length > 0) {
|
|
326
401
|
templates = props.templates.map((m) => {
|
|
327
402
|
const effectiveGrid = mergeGridConfigs(props.grid, m.grid);
|
|
328
403
|
const resolvedPhs = m.placeholders?.map((ph) => {
|
|
329
|
-
|
|
404
|
+
const phDefaults = ph.defaults;
|
|
405
|
+
const defaultProps = phDefaults?.props ? remapHyperlinkProps(phDefaults.props, slideIndexMap) : void 0;
|
|
406
|
+
const base = phDefaults && defaultProps && defaultProps !== phDefaults.props ? { ...ph, defaults: { ...phDefaults, props: defaultProps } } : ph;
|
|
407
|
+
if (!base.grid) return base;
|
|
330
408
|
const abs = resolveGridPosition(
|
|
331
|
-
|
|
409
|
+
base.grid,
|
|
332
410
|
effectiveGrid,
|
|
333
411
|
slideWidth,
|
|
334
412
|
slideHeight
|
|
335
413
|
);
|
|
336
414
|
return {
|
|
337
|
-
...
|
|
338
|
-
x:
|
|
339
|
-
y:
|
|
340
|
-
w:
|
|
341
|
-
h:
|
|
415
|
+
...base,
|
|
416
|
+
x: base.x ?? abs.x,
|
|
417
|
+
y: base.y ?? abs.y,
|
|
418
|
+
w: base.w ?? abs.w,
|
|
419
|
+
h: base.h ?? abs.h,
|
|
342
420
|
grid: void 0
|
|
343
421
|
};
|
|
344
422
|
});
|
|
345
423
|
const defaultedObjects = m.objects ? resolveComponentTree(m.objects, theme) : void 0;
|
|
346
424
|
const resolvedObjects = defaultedObjects?.map(
|
|
347
|
-
(obj) =>
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
425
|
+
(obj) => remapHyperlinkSlideRefs(
|
|
426
|
+
resolveComponentGridPosition(
|
|
427
|
+
obj,
|
|
428
|
+
effectiveGrid,
|
|
429
|
+
slideWidth,
|
|
430
|
+
slideHeight
|
|
431
|
+
),
|
|
432
|
+
slideIndexMap
|
|
352
433
|
)
|
|
353
434
|
);
|
|
354
435
|
return { ...m, placeholders: resolvedPhs, objects: resolvedObjects };
|
|
@@ -357,13 +438,18 @@ function processPresentation(document, options) {
|
|
|
357
438
|
const slides = [];
|
|
358
439
|
for (const child of children) {
|
|
359
440
|
if (isSlideComponent(child)) {
|
|
441
|
+
if (!isSlideEnabled(child)) continue;
|
|
360
442
|
const slideComponents = [];
|
|
361
443
|
if (child.children) {
|
|
362
444
|
for (const slideChild of child.children) {
|
|
363
445
|
slideComponents.push(slideChild);
|
|
364
446
|
}
|
|
365
447
|
}
|
|
366
|
-
const resolvedComponents = resolveComponentTree(
|
|
448
|
+
const resolvedComponents = resolveComponentTree(
|
|
449
|
+
slideComponents,
|
|
450
|
+
theme
|
|
451
|
+
).map((component) => remapHyperlinkSlideRefs(component, slideIndexMap));
|
|
452
|
+
const placeholders = child.props.placeholders;
|
|
367
453
|
slides.push({
|
|
368
454
|
components: resolvedComponents,
|
|
369
455
|
background: child.props.background,
|
|
@@ -371,7 +457,12 @@ function processPresentation(document, options) {
|
|
|
371
457
|
layout: child.props.layout,
|
|
372
458
|
hidden: child.props.hidden,
|
|
373
459
|
template: child.props.template,
|
|
374
|
-
placeholders:
|
|
460
|
+
placeholders: placeholders ? Object.fromEntries(
|
|
461
|
+
Object.entries(placeholders).map(([name, component]) => [
|
|
462
|
+
name,
|
|
463
|
+
remapHyperlinkSlideRefs(component, slideIndexMap)
|
|
464
|
+
])
|
|
465
|
+
) : void 0
|
|
375
466
|
});
|
|
376
467
|
}
|
|
377
468
|
}
|
|
@@ -400,6 +491,7 @@ import PptxGenJS from "pptxgenjs";
|
|
|
400
491
|
|
|
401
492
|
// src/utils/color.ts
|
|
402
493
|
import { SEMANTIC_COLOR_NAMES } from "@json-to-office/shared-pptx";
|
|
494
|
+
import { DEFAULT_CHART_THEME_COLORS } from "@json-to-office/shared";
|
|
403
495
|
var SEMANTIC_TO_THEME_KEY = {
|
|
404
496
|
...Object.fromEntries(SEMANTIC_COLOR_NAMES.map((n) => [n, n])),
|
|
405
497
|
// Aliases (PowerPoint XML compat)
|
|
@@ -411,26 +503,49 @@ var SEMANTIC_TO_THEME_KEY = {
|
|
|
411
503
|
bg1: "background",
|
|
412
504
|
bg2: "background2"
|
|
413
505
|
};
|
|
414
|
-
|
|
415
|
-
"
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
506
|
+
function chainToHex(value, theme, seen) {
|
|
507
|
+
const bare = value.startsWith("#") ? value.slice(1) : value;
|
|
508
|
+
if (/^[0-9A-Fa-f]{6}$/.test(bare)) return bare;
|
|
509
|
+
if (/^[0-9A-Fa-f]{3}$/.test(bare)) {
|
|
510
|
+
return bare[0] + bare[0] + bare[1] + bare[1] + bare[2] + bare[2];
|
|
511
|
+
}
|
|
512
|
+
const themeKey = SEMANTIC_TO_THEME_KEY[value];
|
|
513
|
+
if (!themeKey || seen.has(themeKey)) return void 0;
|
|
514
|
+
seen.add(themeKey);
|
|
515
|
+
const next = theme?.colors?.[themeKey];
|
|
516
|
+
if (typeof next !== "string" || next.length === 0) return void 0;
|
|
517
|
+
return chainToHex(next, theme, seen)?.toUpperCase();
|
|
518
|
+
}
|
|
519
|
+
function definedChartColorTokens(theme) {
|
|
520
|
+
const colors = theme?.colors;
|
|
521
|
+
if (!colors) return [];
|
|
522
|
+
return DEFAULT_CHART_THEME_COLORS.filter((token) => {
|
|
523
|
+
const themeKey = SEMANTIC_TO_THEME_KEY[token] ?? token;
|
|
524
|
+
const value = colors[themeKey];
|
|
525
|
+
if (typeof value !== "string" || value.length === 0) return false;
|
|
526
|
+
return chainToHex(value, theme, /* @__PURE__ */ new Set([themeKey])) !== void 0;
|
|
527
|
+
});
|
|
528
|
+
}
|
|
422
529
|
function resolveColor(color, theme, warnings) {
|
|
423
530
|
const themeKey = SEMANTIC_TO_THEME_KEY[color];
|
|
424
531
|
if (themeKey) {
|
|
425
532
|
const resolved = theme.colors[themeKey];
|
|
426
|
-
if (resolved)
|
|
427
|
-
|
|
533
|
+
if (resolved) {
|
|
534
|
+
const hex = chainToHex(resolved, theme, /* @__PURE__ */ new Set([themeKey]));
|
|
535
|
+
if (hex) return hex;
|
|
536
|
+
warn(
|
|
537
|
+
warnings,
|
|
538
|
+
W.UNKNOWN_COLOR,
|
|
539
|
+
`Theme color "${themeKey}" is "${resolved}", which is not a hex color or a theme color name; falling back to primary`
|
|
540
|
+
);
|
|
541
|
+
return resolvePrimary(theme);
|
|
542
|
+
}
|
|
428
543
|
warn(
|
|
429
544
|
warnings,
|
|
430
545
|
W.THEME_COLOR_FALLBACK,
|
|
431
546
|
`Theme color "${themeKey}" not defined, falling back to primary`
|
|
432
547
|
);
|
|
433
|
-
return
|
|
548
|
+
return resolvePrimary(theme);
|
|
434
549
|
}
|
|
435
550
|
const bare = color.startsWith("#") ? color.slice(1) : color;
|
|
436
551
|
if (/^[0-9A-Fa-f]{3}$/.test(bare)) {
|
|
@@ -445,6 +560,10 @@ function resolveColor(color, theme, warnings) {
|
|
|
445
560
|
}
|
|
446
561
|
return bare;
|
|
447
562
|
}
|
|
563
|
+
function resolvePrimary(theme) {
|
|
564
|
+
const primary = theme.colors.primary;
|
|
565
|
+
return chainToHex(primary, theme, /* @__PURE__ */ new Set(["primary"])) ?? (primary.startsWith("#") ? primary.slice(1) : primary);
|
|
566
|
+
}
|
|
448
567
|
|
|
449
568
|
// src/utils/fontAliasContext.ts
|
|
450
569
|
import { synthesizeFamilyName } from "@json-to-office/shared";
|
|
@@ -540,19 +659,7 @@ function renderTextComponent(slide, props, theme, warnings, slideCtx) {
|
|
|
540
659
|
opts.fill.transparency = props.fill.transparency;
|
|
541
660
|
}
|
|
542
661
|
}
|
|
543
|
-
|
|
544
|
-
if (props.hyperlink.url) {
|
|
545
|
-
opts.hyperlink = {
|
|
546
|
-
url: props.hyperlink.url,
|
|
547
|
-
tooltip: props.hyperlink.tooltip
|
|
548
|
-
};
|
|
549
|
-
} else if (props.hyperlink.slide) {
|
|
550
|
-
opts.hyperlink = {
|
|
551
|
-
slide: props.hyperlink.slide,
|
|
552
|
-
tooltip: props.hyperlink.tooltip
|
|
553
|
-
};
|
|
554
|
-
}
|
|
555
|
-
}
|
|
662
|
+
applyHyperlink(opts, props.hyperlink, "text", warnings);
|
|
556
663
|
const lineSpacing = props.lineSpacing ?? style?.lineSpacing;
|
|
557
664
|
if (lineSpacing !== void 0) opts.lineSpacing = lineSpacing;
|
|
558
665
|
const charSpacing = props.charSpacing ?? style?.charSpacing;
|
|
@@ -730,19 +837,7 @@ async function renderImageComponent(slide, props, theme, warnings, slideWidth =
|
|
|
730
837
|
opacity: props.shadow.opacity ?? 0.5
|
|
731
838
|
};
|
|
732
839
|
}
|
|
733
|
-
|
|
734
|
-
if (props.hyperlink.url) {
|
|
735
|
-
opts.hyperlink = {
|
|
736
|
-
url: props.hyperlink.url,
|
|
737
|
-
tooltip: props.hyperlink.tooltip
|
|
738
|
-
};
|
|
739
|
-
} else if (props.hyperlink.slide) {
|
|
740
|
-
opts.hyperlink = {
|
|
741
|
-
slide: props.hyperlink.slide,
|
|
742
|
-
tooltip: props.hyperlink.tooltip
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
}
|
|
840
|
+
applyHyperlink(opts, props.hyperlink, "image", warnings);
|
|
746
841
|
if (props.alt) opts.altText = props.alt;
|
|
747
842
|
slide.addImage(opts);
|
|
748
843
|
}
|
|
@@ -1130,9 +1225,10 @@ Cause: ${error instanceof Error ? error.message : String(error)}`
|
|
|
1130
1225
|
}
|
|
1131
1226
|
function withThemeColors(props, theme, warnings) {
|
|
1132
1227
|
if (!props.options || props.options.colors || !theme?.colors) return props;
|
|
1133
|
-
const palette =
|
|
1228
|
+
const palette = definedChartColorTokens(theme).map(
|
|
1134
1229
|
(token) => `#${resolveColor(token, theme, warnings)}`
|
|
1135
1230
|
);
|
|
1231
|
+
if (palette.length === 0) return props;
|
|
1136
1232
|
return {
|
|
1137
1233
|
...props,
|
|
1138
1234
|
options: { ...props.options, colors: palette }
|
|
@@ -1166,7 +1262,6 @@ var CHART_TYPE_MAP = {
|
|
|
1166
1262
|
radar: "radar",
|
|
1167
1263
|
scatter: "scatter"
|
|
1168
1264
|
};
|
|
1169
|
-
var DEFAULT_THEME_COLORS = DEFAULT_CHART_THEME_COLORS;
|
|
1170
1265
|
function renderChartComponent(slide, props, theme, _pptx, warnings) {
|
|
1171
1266
|
const chartType = CHART_TYPE_MAP[props.type];
|
|
1172
1267
|
if (!chartType) {
|
|
@@ -1213,8 +1308,12 @@ function renderChartComponent(slide, props, theme, _pptx, warnings) {
|
|
|
1213
1308
|
if (props.y !== void 0) opts.y = props.y;
|
|
1214
1309
|
if (props.w !== void 0) opts.w = props.w;
|
|
1215
1310
|
if (props.h !== void 0) opts.h = props.h;
|
|
1216
|
-
const colorSources = props.chartColors ??
|
|
1217
|
-
|
|
1311
|
+
const colorSources = props.chartColors ?? definedChartColorTokens(theme);
|
|
1312
|
+
if (colorSources.length > 0) {
|
|
1313
|
+
opts.chartColors = colorSources.map(
|
|
1314
|
+
(c) => resolveColor(c, theme, warnings)
|
|
1315
|
+
);
|
|
1316
|
+
}
|
|
1218
1317
|
const themeTextColor = resolveColor("text", theme, warnings);
|
|
1219
1318
|
opts.titleColor = props.titleColor ? resolveColor(props.titleColor, theme, warnings) : themeTextColor;
|
|
1220
1319
|
opts.legendColor = props.legendColor ? resolveColor(props.legendColor, theme, warnings) : themeTextColor;
|