@json-to-office/core-pptx 0.8.4 → 0.11.1
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/shape.d.ts +1 -0
- package/dist/components/shape.d.ts.map +1 -1
- package/dist/components/table.d.ts +1 -0
- package/dist/components/table.d.ts.map +1 -1
- package/dist/components/text.d.ts +1 -0
- package/dist/components/text.d.ts.map +1 -1
- package/dist/core/fontResolution.d.ts +14 -0
- package/dist/core/fontResolution.d.ts.map +1 -0
- package/dist/core/generator.d.ts +2 -1
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/index.js +254 -30
- package/dist/index.js.map +1 -1
- package/dist/plugin/createPresentationGenerator.d.ts +3 -1
- package/dist/plugin/createPresentationGenerator.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/fontAliasContext.d.ts +21 -0
- package/dist/utils/fontAliasContext.d.ts.map +1 -0
- package/dist/utils/warn.d.ts +1 -0
- package/dist/utils/warn.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/components/shape.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/components/shape.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,KAAK,E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B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAuED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,SAAS,EACf,QAAQ,CAAC,EAAE,eAAe,EAAE,GAC3B,IAAI,CAyHN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/components/table.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/components/table.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAcjE,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B;AAED,UAAU,mBAAmB;IAC3B,IAAI,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,EAA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ACd,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,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,SAAS,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAaD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,KAAK,EAAE,kBAAkB,EACzB,KAAK,EAAE,eAAe,EACtB,QAAQ,CAAC,EAAE,eAAe,EAAE,EAC5B,QAAQ,CAAC,EAAE,YAAY,GACtB,IAAI,CAiIN"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared font-resolution helper used by BOTH entry paths into renderPresentation:
|
|
3
|
+
*
|
|
4
|
+
* - core/generator.ts → generateBufferWithWarnings (non-plugin)
|
|
5
|
+
* - plugin/createPresentationGenerator.ts → generate (plugin-aware)
|
|
6
|
+
*
|
|
7
|
+
* Keeping it in one place ensures both paths validate, materialize, and fire
|
|
8
|
+
* the `onResolved` side-channel consumed by the LibreOffice preview stager.
|
|
9
|
+
*/
|
|
10
|
+
import type { FontRuntimeOpts, ResolvedFont } from '@json-to-office/shared';
|
|
11
|
+
import type { PipelineWarning, PresentationComponentDefinition } from '../types';
|
|
12
|
+
import type { PptxThemeConfig } from '../types';
|
|
13
|
+
export declare function resolveDocumentFonts(document: PresentationComponentDefinition, theme: PptxThemeConfig, warnings: PipelineWarning[], fonts?: FontRuntimeOpts): Promise<ResolvedFont[]>;
|
|
14
|
+
//# sourceMappingURL=fontResolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fontResolution.d.ts","sourceRoot":"","sources":["../../src/core/fontResolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAW5E,OAAO,KAAK,EACV,eAAe,EACf,+BAA+B,EAChC,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAGhD,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,+BAA+B,EACzC,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,eAAe,EAAE,EAC3B,KAAK,CAAC,EAAE,eAAe,GACtB,OAAO,CAAC,YAAY,EAAE,CAAC,CAsDzB"}
|
package/dist/core/generator.d.ts
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
/// <reference types="node" />
|
|
6
6
|
import PptxGenJS from 'pptxgenjs';
|
|
7
7
|
import type { PresentationComponentDefinition, PptxThemeConfig, PipelineWarning } from '../types';
|
|
8
|
-
import type { ServicesConfig } from '@json-to-office/shared';
|
|
8
|
+
import type { ServicesConfig, FontRuntimeOpts } from '@json-to-office/shared';
|
|
9
9
|
/**
|
|
10
10
|
* Options for the generation pipeline
|
|
11
11
|
*/
|
|
12
12
|
export interface GenerationOptions {
|
|
13
13
|
customThemes?: Record<string, PptxThemeConfig>;
|
|
14
14
|
services?: ServicesConfig;
|
|
15
|
+
fonts?: FontRuntimeOpts;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Result from generateBufferWithWarnings
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC,OAAO,KAAK,EACV,+BAA+B,EAC/B,eAAe,EACf,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC,OAAO,KAAK,EACV,+BAA+B,EAC/B,eAAe,EACf,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAO9E;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB;AAID;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,OAAO,GAClB,UAAU,IAAI,+BAA+B,CAI/C;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,+BAA+B,EACzC,OAAO,CAAC,EAAE,iBAAiB,EAC3B,QAAQ,CAAC,EAAE,eAAe,EAAE,GAC3B,OAAO,CAAC,SAAS,CAAC,CAOpB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,MAAM,GAAG,+BAA+B,EACpD,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED;;GAEG;AACH,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,MAAM,GAAG,+BAA+B,EACpD,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,gBAAgB,CAAC,CAoE3B;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,GAAG,+BAA+B,EACpD,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAIf;AAyBD;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,SAAS,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;CAQjC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,8 @@ var W = {
|
|
|
26
26
|
THEME_COLOR_FALLBACK: "THEME_COLOR_FALLBACK",
|
|
27
27
|
UNKNOWN_COLOR: "UNKNOWN_COLOR",
|
|
28
28
|
GRID_POSITION_CLAMPED: "GRID_POSITION_CLAMPED",
|
|
29
|
-
IMAGE_ZERO_BOX: "IMAGE_ZERO_BOX"
|
|
29
|
+
IMAGE_ZERO_BOX: "IMAGE_ZERO_BOX",
|
|
30
|
+
FONT_UNRESOLVED: "FONT_UNRESOLVED"
|
|
30
31
|
};
|
|
31
32
|
function warn(warnings, code, message, extra) {
|
|
32
33
|
if (warnings) {
|
|
@@ -429,6 +430,25 @@ function resolveColor(color, theme, warnings) {
|
|
|
429
430
|
return bare;
|
|
430
431
|
}
|
|
431
432
|
|
|
433
|
+
// src/utils/fontAliasContext.ts
|
|
434
|
+
import { synthesizeFamilyName } from "@json-to-office/shared";
|
|
435
|
+
function applyFontWeight(params) {
|
|
436
|
+
if (!params.family) {
|
|
437
|
+
const weight2 = params.fontWeight ?? (params.bold === true ? 700 : void 0);
|
|
438
|
+
return {
|
|
439
|
+
bold: weight2 != null ? weight2 >= 600 : params.bold,
|
|
440
|
+
italic: params.italic
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
const weight = params.fontWeight ?? (params.bold === true ? 700 : void 0);
|
|
444
|
+
const synth = synthesizeFamilyName(
|
|
445
|
+
params.family,
|
|
446
|
+
weight,
|
|
447
|
+
params.italic === true
|
|
448
|
+
);
|
|
449
|
+
return { fontFace: synth.family, bold: synth.bold, italic: synth.italic };
|
|
450
|
+
}
|
|
451
|
+
|
|
432
452
|
// src/components/text.ts
|
|
433
453
|
function resolvePagePlaceholders(text, ctx) {
|
|
434
454
|
const { slideNumber, totalSlides, pageNumberFormat } = ctx;
|
|
@@ -451,11 +471,27 @@ function renderTextComponent(slide, props, theme, warnings, slideCtx) {
|
|
|
451
471
|
}
|
|
452
472
|
opts.fontSize = props.fontSize ?? style?.fontSize ?? theme.defaults.fontSize;
|
|
453
473
|
opts.fontFace = props.fontFace ?? style?.fontFace ?? (isHeadingStyle ? theme.fonts.heading : theme.fonts.body);
|
|
454
|
-
opts.color = resolveColor(
|
|
474
|
+
opts.color = resolveColor(
|
|
475
|
+
props.color ?? style?.fontColor ?? theme.defaults.fontColor,
|
|
476
|
+
theme,
|
|
477
|
+
warnings
|
|
478
|
+
);
|
|
455
479
|
const bold = props.bold ?? style?.bold;
|
|
456
480
|
const italic = props.italic ?? style?.italic;
|
|
481
|
+
const fontWeight = props.fontWeight ?? style?.fontWeight;
|
|
457
482
|
if (bold != null) opts.bold = bold;
|
|
458
483
|
if (italic != null) opts.italic = italic;
|
|
484
|
+
if (fontWeight != null || bold === true) {
|
|
485
|
+
const w = applyFontWeight({
|
|
486
|
+
family: opts.fontFace,
|
|
487
|
+
fontWeight,
|
|
488
|
+
italic,
|
|
489
|
+
bold
|
|
490
|
+
});
|
|
491
|
+
if (w.fontFace !== void 0) opts.fontFace = w.fontFace;
|
|
492
|
+
if (w.bold !== void 0) opts.bold = w.bold;
|
|
493
|
+
if (w.italic !== void 0) opts.italic = w.italic;
|
|
494
|
+
}
|
|
459
495
|
if (props.strike) opts.strike = true;
|
|
460
496
|
if (props.underline !== void 0) {
|
|
461
497
|
if (typeof props.underline === "boolean") {
|
|
@@ -503,7 +539,8 @@ function renderTextComponent(slide, props, theme, warnings, slideCtx) {
|
|
|
503
539
|
if (lineSpacing !== void 0) opts.lineSpacing = lineSpacing;
|
|
504
540
|
const charSpacing = props.charSpacing ?? style?.charSpacing;
|
|
505
541
|
if (charSpacing !== void 0) opts.charSpacing = charSpacing;
|
|
506
|
-
if (props.paraSpaceBefore !== void 0)
|
|
542
|
+
if (props.paraSpaceBefore !== void 0)
|
|
543
|
+
opts.paraSpaceBefore = props.paraSpaceBefore;
|
|
507
544
|
const paraSpaceAfter = props.paraSpaceAfter ?? style?.paraSpaceAfter;
|
|
508
545
|
if (paraSpaceAfter !== void 0) opts.paraSpaceAfter = paraSpaceAfter;
|
|
509
546
|
if (props.breakLine) opts.breakLine = true;
|
|
@@ -710,9 +747,16 @@ function buildShapeOpts(props, theme, warnings) {
|
|
|
710
747
|
}
|
|
711
748
|
if (props.line) {
|
|
712
749
|
opts.line = {};
|
|
713
|
-
if (props.line.color)
|
|
714
|
-
|
|
715
|
-
|
|
750
|
+
if (props.line.color)
|
|
751
|
+
opts.line.color = resolveColor(
|
|
752
|
+
props.line.color,
|
|
753
|
+
theme,
|
|
754
|
+
warnings
|
|
755
|
+
);
|
|
756
|
+
if (props.line.width)
|
|
757
|
+
opts.line.width = props.line.width;
|
|
758
|
+
if (props.line.dashType)
|
|
759
|
+
opts.line.dashType = props.line.dashType;
|
|
716
760
|
}
|
|
717
761
|
if (props.rotate !== void 0) opts.rotate = props.rotate;
|
|
718
762
|
if (props.rectRadius !== void 0) opts.rectRadius = props.rectRadius;
|
|
@@ -732,7 +776,9 @@ function renderShapeComponent(slide, props, theme, pptx, warnings) {
|
|
|
732
776
|
const shapeTypeName = SHAPE_TYPE_MAP[props.type] || props.type;
|
|
733
777
|
const shapeType = pptx.ShapeType[shapeTypeName];
|
|
734
778
|
if (!shapeType) {
|
|
735
|
-
warn(warnings, W.UNKNOWN_SHAPE, `Unknown shape type: ${props.type}`, {
|
|
779
|
+
warn(warnings, W.UNKNOWN_SHAPE, `Unknown shape type: ${props.type}`, {
|
|
780
|
+
component: "shape"
|
|
781
|
+
});
|
|
736
782
|
return;
|
|
737
783
|
}
|
|
738
784
|
const style = props.style ? theme.styles?.[props.style] : void 0;
|
|
@@ -742,32 +788,69 @@ function renderShapeComponent(slide, props, theme, pptx, warnings) {
|
|
|
742
788
|
opts.shape = shapeType;
|
|
743
789
|
opts.fontSize = props.fontSize ?? style?.fontSize ?? theme.defaults.fontSize;
|
|
744
790
|
opts.fontFace = props.fontFace ?? style?.fontFace ?? (isHeadingStyle ? theme.fonts.heading : theme.fonts.body);
|
|
745
|
-
|
|
791
|
+
const preAliasFamily = opts.fontFace;
|
|
792
|
+
opts.color = resolveColor(
|
|
793
|
+
props.fontColor ?? style?.fontColor ?? theme.defaults.fontColor,
|
|
794
|
+
theme,
|
|
795
|
+
warnings
|
|
796
|
+
);
|
|
746
797
|
const bold = props.bold ?? style?.bold;
|
|
747
798
|
const italic = props.italic ?? style?.italic;
|
|
748
|
-
|
|
749
|
-
if (italic != null) opts.italic = italic;
|
|
799
|
+
const fontWeight = props.fontWeight ?? style?.fontWeight;
|
|
750
800
|
const charSpacing = props.charSpacing ?? style?.charSpacing;
|
|
751
801
|
if (charSpacing !== void 0) opts.charSpacing = charSpacing;
|
|
752
802
|
const align = props.align ?? style?.align;
|
|
753
803
|
if (align) opts.align = align;
|
|
754
804
|
opts.valign = props.valign ?? "top";
|
|
755
805
|
if (Array.isArray(props.text)) {
|
|
806
|
+
if (bold != null) opts.bold = bold;
|
|
807
|
+
if (italic != null) opts.italic = italic;
|
|
756
808
|
const textSegments = props.text.map((seg) => {
|
|
757
809
|
const segOpts = {};
|
|
758
810
|
if (seg.fontSize != null) segOpts.fontSize = seg.fontSize;
|
|
759
811
|
if (seg.fontFace != null) segOpts.fontFace = seg.fontFace;
|
|
760
|
-
if (seg.color != null)
|
|
761
|
-
|
|
762
|
-
if (seg.italic != null) segOpts.italic = seg.italic;
|
|
812
|
+
if (seg.color != null)
|
|
813
|
+
segOpts.color = resolveColor(seg.color, theme, warnings);
|
|
763
814
|
if (seg.breakLine != null) segOpts.breakLine = seg.breakLine;
|
|
764
815
|
if (seg.charSpacing != null) segOpts.charSpacing = seg.charSpacing;
|
|
765
816
|
if (seg.spaceBefore != null) segOpts.paraSpaceBefore = seg.spaceBefore;
|
|
766
817
|
if (seg.spaceAfter != null) segOpts.paraSpaceAfter = seg.spaceAfter;
|
|
818
|
+
const segWeight = seg.fontWeight;
|
|
819
|
+
const effWeight = segWeight ?? fontWeight;
|
|
820
|
+
const effBold = seg.bold ?? bold;
|
|
821
|
+
const effItalic = seg.italic ?? italic;
|
|
822
|
+
if (effBold != null) segOpts.bold = effBold;
|
|
823
|
+
if (effItalic != null) segOpts.italic = effItalic;
|
|
824
|
+
if (effWeight != null || effBold === true) {
|
|
825
|
+
if (seg.fontFace == null) {
|
|
826
|
+
const w = applyFontWeight({
|
|
827
|
+
family: preAliasFamily,
|
|
828
|
+
fontWeight: effWeight,
|
|
829
|
+
italic: effItalic,
|
|
830
|
+
bold: effBold
|
|
831
|
+
});
|
|
832
|
+
if (w.fontFace !== void 0) segOpts.fontFace = w.fontFace;
|
|
833
|
+
if (w.bold !== void 0) segOpts.bold = w.bold;
|
|
834
|
+
if (w.italic !== void 0) segOpts.italic = w.italic;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
767
837
|
return { text: seg.text, options: segOpts };
|
|
768
838
|
});
|
|
769
839
|
slide.addText(textSegments, opts);
|
|
770
840
|
} else {
|
|
841
|
+
if (bold != null) opts.bold = bold;
|
|
842
|
+
if (italic != null) opts.italic = italic;
|
|
843
|
+
if (fontWeight != null || bold === true) {
|
|
844
|
+
const w = applyFontWeight({
|
|
845
|
+
family: preAliasFamily,
|
|
846
|
+
fontWeight,
|
|
847
|
+
italic,
|
|
848
|
+
bold
|
|
849
|
+
});
|
|
850
|
+
if (w.fontFace !== void 0) opts.fontFace = w.fontFace;
|
|
851
|
+
if (w.bold !== void 0) opts.bold = w.bold;
|
|
852
|
+
if (w.italic !== void 0) opts.italic = w.italic;
|
|
853
|
+
}
|
|
771
854
|
slide.addText(props.text, opts);
|
|
772
855
|
}
|
|
773
856
|
} else {
|
|
@@ -830,14 +913,19 @@ function renderTableComponent(slide, props, theme, pptx, warnings) {
|
|
|
830
913
|
return { text: applyTextVariationSelector(cell), options: opts2 };
|
|
831
914
|
}
|
|
832
915
|
const cellOpts = {};
|
|
833
|
-
if (cell.color)
|
|
916
|
+
if (cell.color)
|
|
917
|
+
cellOpts.color = resolveColor(cell.color, theme, warnings);
|
|
834
918
|
if (bgFill) {
|
|
835
919
|
const isHeader = rowIndex === 0;
|
|
836
920
|
if (!isCorner) {
|
|
837
921
|
const resolvedFill = cell.fill ? resolveColor(cell.fill, theme, warnings) : isHeader ? headerFill : bgFill;
|
|
838
922
|
cellOpts.fill = { color: resolvedFill };
|
|
839
923
|
}
|
|
840
|
-
cellOpts.border = buildBorderRadiusBorders(
|
|
924
|
+
cellOpts.border = buildBorderRadiusBorders(
|
|
925
|
+
rowIndex,
|
|
926
|
+
colIndex,
|
|
927
|
+
row.length
|
|
928
|
+
);
|
|
841
929
|
} else if (cell.fill) {
|
|
842
930
|
cellOpts.fill = { color: resolveColor(cell.fill, theme, warnings) };
|
|
843
931
|
}
|
|
@@ -845,6 +933,17 @@ function renderTableComponent(slide, props, theme, pptx, warnings) {
|
|
|
845
933
|
if (cell.fontFace) cellOpts.fontFace = cell.fontFace;
|
|
846
934
|
if (cell.bold) cellOpts.bold = true;
|
|
847
935
|
if (cell.italic) cellOpts.italic = true;
|
|
936
|
+
if (cell.fontWeight != null || cell.bold === true) {
|
|
937
|
+
const w = applyFontWeight({
|
|
938
|
+
family: cellOpts.fontFace ?? props.fontFace ?? theme.fonts.body,
|
|
939
|
+
fontWeight: cell.fontWeight,
|
|
940
|
+
italic: cell.italic,
|
|
941
|
+
bold: cell.bold
|
|
942
|
+
});
|
|
943
|
+
if (w.fontFace !== void 0) cellOpts.fontFace = w.fontFace;
|
|
944
|
+
if (w.bold !== void 0) cellOpts.bold = w.bold;
|
|
945
|
+
if (w.italic !== void 0) cellOpts.italic = w.italic;
|
|
946
|
+
}
|
|
848
947
|
if (cell.align) cellOpts.align = cell.align;
|
|
849
948
|
if (cell.valign) cellOpts.valign = cell.valign;
|
|
850
949
|
if (cell.colspan) cellOpts.colspan = cell.colspan;
|
|
@@ -867,7 +966,8 @@ function renderTableComponent(slide, props, theme, pptx, warnings) {
|
|
|
867
966
|
color: resolveColor(props.border.color ?? "000000", theme, warnings)
|
|
868
967
|
};
|
|
869
968
|
}
|
|
870
|
-
if (props.fill)
|
|
969
|
+
if (props.fill)
|
|
970
|
+
opts.fill = { color: resolveColor(props.fill, theme, warnings) };
|
|
871
971
|
opts.fontSize = props.fontSize ?? theme.defaults.fontSize;
|
|
872
972
|
opts.fontFace = props.fontFace ?? theme.fonts.body;
|
|
873
973
|
if (props.color) opts.color = resolveColor(props.color, theme, warnings);
|
|
@@ -928,7 +1028,12 @@ function renderTableComponent(slide, props, theme, pptx, warnings) {
|
|
|
928
1028
|
}
|
|
929
1029
|
if (bgFill && borderRadiusTableW !== void 0) {
|
|
930
1030
|
opts.w = borderRadiusTableW;
|
|
931
|
-
opts.border = [
|
|
1031
|
+
opts.border = [
|
|
1032
|
+
{ type: "none" },
|
|
1033
|
+
{ type: "none" },
|
|
1034
|
+
{ type: "none" },
|
|
1035
|
+
{ type: "none" }
|
|
1036
|
+
];
|
|
932
1037
|
}
|
|
933
1038
|
slide.addTable(tableRows, opts);
|
|
934
1039
|
}
|
|
@@ -1368,7 +1473,60 @@ async function renderPresentation(processed, warnings) {
|
|
|
1368
1473
|
return pptx;
|
|
1369
1474
|
}
|
|
1370
1475
|
|
|
1476
|
+
// src/core/fontResolution.ts
|
|
1477
|
+
import {
|
|
1478
|
+
collectFontNamesFromPptx,
|
|
1479
|
+
validateFontReferences,
|
|
1480
|
+
FontRegistry
|
|
1481
|
+
} from "@json-to-office/shared";
|
|
1482
|
+
import {
|
|
1483
|
+
loadFileFontSource,
|
|
1484
|
+
FontDiskCache,
|
|
1485
|
+
fetchVariableFontSource
|
|
1486
|
+
} from "@json-to-office/shared/fonts/node";
|
|
1487
|
+
async function resolveDocumentFonts(document, theme, warnings, fonts) {
|
|
1488
|
+
const names = /* @__PURE__ */ new Set();
|
|
1489
|
+
for (const n of collectFontNamesFromPptx(document)) names.add(n);
|
|
1490
|
+
for (const n of collectFontNamesFromPptx(theme)) names.add(n);
|
|
1491
|
+
if (names.size === 0) return [];
|
|
1492
|
+
const validation = validateFontReferences({
|
|
1493
|
+
referencedNames: names,
|
|
1494
|
+
registeredEntries: fonts?.extraEntries
|
|
1495
|
+
});
|
|
1496
|
+
if (validation.warnings.length > 0) {
|
|
1497
|
+
if (fonts?.strict) {
|
|
1498
|
+
throw new Error(
|
|
1499
|
+
`Unresolved font references (strict mode):
|
|
1500
|
+
` + validation.warnings.map((w) => ` - ${w.message}`).join("\n")
|
|
1501
|
+
);
|
|
1502
|
+
}
|
|
1503
|
+
for (const w of validation.warnings) {
|
|
1504
|
+
warn(warnings, W.FONT_UNRESOLVED, w.message, {
|
|
1505
|
+
component: "fontRegistry"
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
if (!fonts?.onResolved) return [];
|
|
1510
|
+
const registry = new FontRegistry({
|
|
1511
|
+
opts: fonts,
|
|
1512
|
+
fileLoader: loadFileFontSource,
|
|
1513
|
+
variableLoader: fetchVariableFontSource,
|
|
1514
|
+
diskCache: fonts?.googleFonts?.cacheDir ? new FontDiskCache(fonts.googleFonts.cacheDir) : void 0
|
|
1515
|
+
});
|
|
1516
|
+
const resolved = await registry.resolveMany(names);
|
|
1517
|
+
for (const r of resolved) {
|
|
1518
|
+
for (const msg of r.warnings) {
|
|
1519
|
+
warn(warnings, W.FONT_UNRESOLVED, msg, {
|
|
1520
|
+
component: "fontRegistry"
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
fonts.onResolved(resolved);
|
|
1525
|
+
return resolved;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1371
1528
|
// src/core/generator.ts
|
|
1529
|
+
import { applyExportMode, scopedThemeName } from "@json-to-office/shared";
|
|
1372
1530
|
function isPresentationComponentDefinition(definition) {
|
|
1373
1531
|
if (typeof definition !== "object" || definition === null) return false;
|
|
1374
1532
|
const def = definition;
|
|
@@ -1397,7 +1555,47 @@ async function generateBufferWithWarnings(jsonConfig, options) {
|
|
|
1397
1555
|
component = jsonConfig;
|
|
1398
1556
|
}
|
|
1399
1557
|
const warnings = [];
|
|
1400
|
-
const
|
|
1558
|
+
const baseThemeName = component.props?.theme ?? "default";
|
|
1559
|
+
let resolvedTheme = options?.customThemes?.[baseThemeName] ?? getPptxTheme(baseThemeName);
|
|
1560
|
+
const mode = applyExportMode({
|
|
1561
|
+
doc: component,
|
|
1562
|
+
theme: resolvedTheme,
|
|
1563
|
+
fonts: options?.fonts
|
|
1564
|
+
});
|
|
1565
|
+
component = mode.doc;
|
|
1566
|
+
resolvedTheme = mode.theme;
|
|
1567
|
+
for (const w of mode.warnings) {
|
|
1568
|
+
warnings.push({
|
|
1569
|
+
code: w.code,
|
|
1570
|
+
message: w.message,
|
|
1571
|
+
component: "fontRegistry"
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
await resolveDocumentFonts(
|
|
1575
|
+
component,
|
|
1576
|
+
resolvedTheme,
|
|
1577
|
+
warnings,
|
|
1578
|
+
options?.fonts
|
|
1579
|
+
);
|
|
1580
|
+
const themeName = scopedThemeName(baseThemeName, options?.fonts?.mode);
|
|
1581
|
+
if (themeName !== baseThemeName) {
|
|
1582
|
+
component = {
|
|
1583
|
+
...component,
|
|
1584
|
+
props: { ...component.props, theme: themeName }
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
const effectiveOptions = {
|
|
1588
|
+
...options,
|
|
1589
|
+
customThemes: {
|
|
1590
|
+
...options?.customThemes ?? {},
|
|
1591
|
+
[themeName]: resolvedTheme
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
const pptx = await generatePresentation(
|
|
1595
|
+
component,
|
|
1596
|
+
effectiveOptions,
|
|
1597
|
+
warnings
|
|
1598
|
+
);
|
|
1401
1599
|
const data = await pptx.write({ outputType: "nodebuffer" });
|
|
1402
1600
|
const buffer = await neutralizeTableStyle(data);
|
|
1403
1601
|
return { buffer, warnings };
|
|
@@ -1557,6 +1755,7 @@ async function exportPluginSchema(customComponents, outputPath, options = {}) {
|
|
|
1557
1755
|
}
|
|
1558
1756
|
|
|
1559
1757
|
// src/plugin/createPresentationGenerator.ts
|
|
1758
|
+
import { applyExportMode as applyExportMode2, scopedThemeName as scopedThemeName2 } from "@json-to-office/shared";
|
|
1560
1759
|
var MEDIUM_STYLE_2_ACCENT_12 = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}";
|
|
1561
1760
|
var NO_STYLE_NO_GRID2 = "{2D5ABB26-0587-4C30-8999-92F81FD0307C}";
|
|
1562
1761
|
async function neutralizeTableStyle2(buffer) {
|
|
@@ -1680,7 +1879,8 @@ function createBuilderImpl(state) {
|
|
|
1680
1879
|
theme: state.theme,
|
|
1681
1880
|
customThemes: state.customThemes,
|
|
1682
1881
|
debug: state.debug,
|
|
1683
|
-
services: state.services
|
|
1882
|
+
services: state.services,
|
|
1883
|
+
fonts: state.fonts
|
|
1684
1884
|
};
|
|
1685
1885
|
return createBuilderImpl(
|
|
1686
1886
|
newState
|
|
@@ -1692,20 +1892,43 @@ function createBuilderImpl(state) {
|
|
|
1692
1892
|
if (!internalDocument || internalDocument.name !== "pptx") {
|
|
1693
1893
|
throw new Error("Top-level component must be a pptx component");
|
|
1694
1894
|
}
|
|
1695
|
-
const
|
|
1696
|
-
const
|
|
1895
|
+
const docThemeName = internalDocument.props.theme;
|
|
1896
|
+
const baseThemeName = docThemeName ?? (typeof state.theme === "string" ? state.theme : "default");
|
|
1897
|
+
let resolvedTheme = state.customThemes?.[baseThemeName] ?? (typeof state.theme === "object" && state.theme !== null ? state.theme : getPptxTheme(baseThemeName));
|
|
1697
1898
|
const warnings = [];
|
|
1698
|
-
const
|
|
1699
|
-
internalDocument
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
)
|
|
1703
|
-
|
|
1704
|
-
|
|
1899
|
+
const mode = applyExportMode2({
|
|
1900
|
+
doc: internalDocument,
|
|
1901
|
+
theme: resolvedTheme,
|
|
1902
|
+
fonts: state.fonts
|
|
1903
|
+
});
|
|
1904
|
+
resolvedTheme = mode.theme;
|
|
1905
|
+
for (const w of mode.warnings) {
|
|
1906
|
+
warnings.push({
|
|
1907
|
+
code: w.code,
|
|
1908
|
+
message: w.message,
|
|
1909
|
+
component: "fontRegistry"
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
const processedChildren = mode.doc.children ? await processAllSlides(mode.doc.children, warnings, resolvedTheme) : [];
|
|
1913
|
+
const themeName = scopedThemeName2(baseThemeName, state.fonts?.mode);
|
|
1914
|
+
const docWithScopedTheme = themeName !== baseThemeName ? {
|
|
1915
|
+
...mode.doc,
|
|
1916
|
+
props: { ...mode.doc.props, theme: themeName },
|
|
1705
1917
|
children: processedChildren
|
|
1918
|
+
} : { ...mode.doc, children: processedChildren };
|
|
1919
|
+
const processedDocument = docWithScopedTheme;
|
|
1920
|
+
await resolveDocumentFonts(
|
|
1921
|
+
processedDocument,
|
|
1922
|
+
resolvedTheme,
|
|
1923
|
+
warnings,
|
|
1924
|
+
state.fonts
|
|
1925
|
+
);
|
|
1926
|
+
const effectiveCustomThemes = {
|
|
1927
|
+
...state.customThemes ?? {},
|
|
1928
|
+
[themeName]: resolvedTheme
|
|
1706
1929
|
};
|
|
1707
1930
|
const processed = processPresentation(processedDocument, {
|
|
1708
|
-
customThemes:
|
|
1931
|
+
customThemes: effectiveCustomThemes,
|
|
1709
1932
|
services: state.services
|
|
1710
1933
|
});
|
|
1711
1934
|
const pptx = await renderPresentation(processed, warnings);
|
|
@@ -1817,7 +2040,8 @@ function createPresentationGenerator(options = {}) {
|
|
|
1817
2040
|
theme: options.theme,
|
|
1818
2041
|
customThemes: options.customThemes,
|
|
1819
2042
|
debug: options.debug ?? false,
|
|
1820
|
-
services: options.services
|
|
2043
|
+
services: options.services,
|
|
2044
|
+
fonts: options.fonts
|
|
1821
2045
|
};
|
|
1822
2046
|
return createBuilderImpl(initialState);
|
|
1823
2047
|
}
|