@json-to-office/core-pptx 0.26.0 → 0.27.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.
@@ -29,10 +29,14 @@ export interface ThemeContextOptions {
29
29
  defaultThemeName?: string;
30
30
  /**
31
31
  * Theme lookup for the base `props.theme` name. The plugin builder passes
32
- * its own (customThemes → constructor theme object → built-in); omit it to
33
- * use customThemes → built-in.
32
+ * its own (customThemes → doc-named built-in → constructor theme object →
33
+ * built-in); omit it to use customThemes → built-in. `authored` is true
34
+ * when the name came from the document's own `props.theme` (as opposed to
35
+ * `defaultThemeName` or the 'default' fallback), so the lookup can honor
36
+ * an explicitly doc-named built-in without the constructor object
37
+ * swallowing the default name too (#141).
34
38
  */
35
- resolveNamedTheme?: (name: string) => PptxThemeConfig;
39
+ resolveNamedTheme?: (name: string, authored: boolean) => PptxThemeConfig;
36
40
  }
37
41
  export interface GenerationThemeContext {
38
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"generationContext.d.ts","sourceRoot":"","sources":["../../src/core/generationContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,+BAA+B,EAC/B,eAAe,EACf,eAAe,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC/C,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,eAAe,CAAC;CACvD;AAED,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,QAAQ,EAAE,+BAA+B,CAAC;IAC1C,KAAK,EAAE,eAAe,CAAC;IACvB;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,+BAA+B,EAC3C,OAAO,GAAE,mBAAwB,GAChC,sBAAsB,CA6DxB"}
1
+ {"version":3,"file":"generationContext.d.ts","sourceRoot":"","sources":["../../src/core/generationContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,+BAA+B,EAC/B,eAAe,EACf,eAAe,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC/C,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,eAAe,CAAC;CAC1E;AAED,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,QAAQ,EAAE,+BAA+B,CAAC;IAC1C,KAAK,EAAE,eAAe,CAAC;IACvB;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,+BAA+B,EAC3C,OAAO,GAAE,mBAAwB,GAChC,sBAAsB,CA6DxB"}
package/dist/index.js CHANGED
@@ -214,6 +214,9 @@ var PPTX_THEMES = {
214
214
  function getPptxTheme(name) {
215
215
  return PPTX_THEMES[name] || DEFAULT_PPTX_THEME;
216
216
  }
217
+ function hasPptxTheme(name) {
218
+ return Object.prototype.hasOwnProperty.call(PPTX_THEMES, name);
219
+ }
217
220
  var pptxThemes = PPTX_THEMES;
218
221
 
219
222
  // src/utils/componentDefaults.ts
@@ -1927,8 +1930,9 @@ function resolveThemeContext(documentIn, options = {}) {
1927
1930
  if (typeof document.props.theme === "object" && document.props.theme !== null) {
1928
1931
  inlineTheme = document.props.theme;
1929
1932
  }
1930
- const baseThemeName = inlineTheme ? inlineTheme.name || "inline-theme" : document.props.theme ?? defaultThemeName ?? "default";
1931
- let theme = inlineTheme ?? (resolveNamedTheme ? resolveNamedTheme(baseThemeName) : customThemes?.[baseThemeName] ?? getPptxTheme(baseThemeName));
1933
+ const authoredThemeName = typeof document.props.theme === "string" ? document.props.theme : void 0;
1934
+ const baseThemeName = inlineTheme ? inlineTheme.name || "inline-theme" : authoredThemeName ?? defaultThemeName ?? "default";
1935
+ let theme = inlineTheme ?? (resolveNamedTheme ? resolveNamedTheme(baseThemeName, authoredThemeName !== void 0) : customThemes?.[baseThemeName] ?? getPptxTheme(baseThemeName));
1932
1936
  const mode = applyExportMode({ doc: document, theme, fonts });
1933
1937
  document = mode.doc;
1934
1938
  theme = mode.theme;
@@ -2499,7 +2503,7 @@ function createBuilderImpl(state) {
2499
2503
  fonts: state.fonts,
2500
2504
  warnings,
2501
2505
  defaultThemeName: typeof state.theme === "string" ? state.theme : void 0,
2502
- resolveNamedTheme: (name) => state.customThemes?.[name] ?? (typeof state.theme === "object" && state.theme !== null ? state.theme : getPptxTheme(name))
2506
+ resolveNamedTheme: (name, authored) => state.customThemes?.[name] ?? (authored && hasPptxTheme(name) ? getPptxTheme(name) : void 0) ?? (typeof state.theme === "object" && state.theme !== null ? state.theme : getPptxTheme(name))
2503
2507
  });
2504
2508
  const modedRoot = context.document;
2505
2509
  const resolvedTheme = context.theme;