pptxgenjs-plus 4.3.9 → 4.4.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/pptxgen.bundle.js +30 -30
- package/dist/pptxgen.cjs.js +1243 -889
- package/dist/pptxgen.es.js +1224 -870
- package/dist/pptxgen.min.js +32 -32
- package/package.json +14 -6
- package/types/core.d.ts +5979 -0
- package/types/index.d.mts +227 -0
- package/types/index.d.ts +226 -6257
package/dist/pptxgen.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* PptxGenJS 4.
|
|
1
|
+
/* PptxGenJS 4.4.0 @ 2026-12-05T02:10:07.387Z */
|
|
2
2
|
|
|
3
3
|
import { JSZip } from "@node-projects/jszip";
|
|
4
4
|
import { parseXml } from "@rgrove/parse-xml";
|
|
@@ -1541,6 +1541,59 @@ const XML_ILLEGAL_CHARS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]|
|
|
|
1541
1541
|
const points = Number(pt) || 0;
|
|
1542
1542
|
return isNaN(points) ? 0 : Math.round(points * (/* inlined export .ONEPT */12700));
|
|
1543
1543
|
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Round a value into an inclusive integer range.
|
|
1546
|
+
* Non-finite inputs (`NaN`, `Infinity`, `-Infinity`) fall back to `min`.
|
|
1547
|
+
* Prevents out-of-range OOXML attributes (`ST_TextFontSize`, `ST_LineWidth`, `ST_TextSpacing*`,
|
|
1548
|
+
* `ST_GapAmount`, ...) from triggering PowerPoint repair dialogs.
|
|
1549
|
+
* @param {number} val - value to clamp
|
|
1550
|
+
* @param {number} min - inclusive lower bound
|
|
1551
|
+
* @param {number} max - inclusive upper bound
|
|
1552
|
+
* @returns {number} clamped integer
|
|
1553
|
+
*/ function clampInt(val, min, max) {
|
|
1554
|
+
if (!Number.isFinite(val)) return min === 0 ? 0 : min;
|
|
1555
|
+
const res = Math.round(Math.min(max, Math.max(min, val)));
|
|
1556
|
+
return res === 0 ? 0 : res;
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* Clamp an EMU extent to `ST_PositiveCoordinate` (finite non-negative integer `>= 0`).
|
|
1560
|
+
* Zero is legal (e.g. hairline rules); negative or non-finite values clamp to 0.
|
|
1561
|
+
* @param {number} val - extent in EMU
|
|
1562
|
+
* @returns {number} non-negative integer EMU
|
|
1563
|
+
*/ function positiveExtent(val) {
|
|
1564
|
+
if (!Number.isFinite(val) || val <= 0) return 0;
|
|
1565
|
+
return Math.round(val);
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Convert a font size in points into OOXML `ST_TextFontSize` hundredths of a point (`100..400000`, i.e. 1pt..4000pt).
|
|
1569
|
+
* @param {number} val - font size in points
|
|
1570
|
+
* @returns {number} clamped `sz` attribute value
|
|
1571
|
+
*/ function fontSizeToSz(val) {
|
|
1572
|
+
return clampInt(val * 100, 100, 400000);
|
|
1573
|
+
}
|
|
1574
|
+
/**
|
|
1575
|
+
* Clamp an EMU line width to `ST_LineWidth` (`0..20116800`, i.e. 0..1584pt).
|
|
1576
|
+
* @param {number} val - line width in EMU
|
|
1577
|
+
* @returns {number} clamped `w` attribute value in EMU
|
|
1578
|
+
*/ function clampLineWidth(val) {
|
|
1579
|
+
return clampInt(val, 0, 20116800);
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Convert a line width in points into an EMU `a:ln@w` value clamped to `ST_LineWidth` (`0..20116800`).
|
|
1583
|
+
* @param {number|string|undefined} pt - line width in points
|
|
1584
|
+
* @returns {number} clamped `w` attribute value in EMU
|
|
1585
|
+
*/ function valToLineWidth(pt) {
|
|
1586
|
+
return clampLineWidth(valToPts(pt));
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Convert a 0..100 transparency percentage into an OOXML `a:alpha@val` (`ST_PositiveFixedPercentage`, `0..100000`).
|
|
1590
|
+
* Non-finite inputs default to opaque (`100000`).
|
|
1591
|
+
* @param {number} transparency - transparency percent (0 = opaque, 100 = fully transparent)
|
|
1592
|
+
* @returns {number} clamped `a:alpha@val` in `0..100000`
|
|
1593
|
+
*/ function clampAlphaPct(transparency) {
|
|
1594
|
+
if (!Number.isFinite(transparency)) return 100000;
|
|
1595
|
+
return clampInt((100 - transparency) * 1000, 0, 100000);
|
|
1596
|
+
}
|
|
1544
1597
|
/**
|
|
1545
1598
|
* Convert a margin component to EMU (same dual-unit rule as table cells)
|
|
1546
1599
|
* - `>= 1` → points (`valToPts`)
|
|
@@ -1820,9 +1873,9 @@ const FLAG_COLOR_MODIFIERS = [
|
|
|
1820
1873
|
}
|
|
1821
1874
|
function createGlowElement(glow) {
|
|
1822
1875
|
let strXml = '';
|
|
1823
|
-
const size = Math.round(glow.size * (/* inlined export .ONEPT */12700));
|
|
1876
|
+
const size = positiveExtent(Math.round(glow.size * (/* inlined export .ONEPT */12700)));
|
|
1824
1877
|
const color = glow.color;
|
|
1825
|
-
const opacity =
|
|
1878
|
+
const opacity = clampInt(glow.opacity * 100000, 0, 100000);
|
|
1826
1879
|
strXml += `<a:glow rad="${size}">`;
|
|
1827
1880
|
strXml += createColorElement(color, `<a:alpha val="${opacity}"/>`);
|
|
1828
1881
|
strXml += '</a:glow>';
|
|
@@ -1875,7 +1928,7 @@ function createGlowElement(glow) {
|
|
|
1875
1928
|
return soleColor ? `<a:solidFill>${createColorElement(soleColor, fallbackInner)}</a:solidFill>` : '';
|
|
1876
1929
|
}
|
|
1877
1930
|
const gsLst = stops.map((stop)=>{
|
|
1878
|
-
const inner = typeof stop.transparency === 'number' ? `<a:alpha val="${
|
|
1931
|
+
const inner = typeof stop.transparency === 'number' ? `<a:alpha val="${clampAlphaPct(stop.transparency)}"/>` : '';
|
|
1879
1932
|
return `<a:gs pos="${stop.pos}">${createColorElement(stop.color, inner)}</a:gs>`;
|
|
1880
1933
|
}).join('');
|
|
1881
1934
|
const rotateWithShape = (gradient === null || gradient === void 0 ? void 0 : gradient.rotateWithShape) === false || (gradient === null || gradient === void 0 ? void 0 : gradient.rotWithShape) === false ? 0 : 1;
|
|
@@ -1946,8 +1999,8 @@ function createGlowElement(glow) {
|
|
|
1946
1999
|
if (props.type) fillType = props.type;
|
|
1947
2000
|
else if (((_props_image = props.image) === null || _props_image === void 0 ? void 0 : _props_image._rId) || props._rId) fillType = 'image';
|
|
1948
2001
|
if (props.color) colorVal = props.color;
|
|
1949
|
-
if (props.alpha) internalElements += `<a:alpha val="${
|
|
1950
|
-
if (props.transparency) internalElements += `<a:alpha val="${
|
|
2002
|
+
if (props.alpha) internalElements += `<a:alpha val="${clampAlphaPct(props.alpha)}"/>`; // DEPRECATED: @deprecated v3.3.0
|
|
2003
|
+
if (props.transparency) internalElements += `<a:alpha val="${clampAlphaPct(props.transparency)}"/>`;
|
|
1951
2004
|
}
|
|
1952
2005
|
const isBareColor = typeof props === 'string' || isModifiedThemeColor(props) || isColorProps(props);
|
|
1953
2006
|
switch(fillType){
|
|
@@ -2899,173 +2952,632 @@ function gen_tables_object_spread(target) {
|
|
|
2899
2952
|
});
|
|
2900
2953
|
}
|
|
2901
2954
|
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
* | `p:cNvPr` (shapes, pictures) | `a:hlinkClick` (20.1.2.2.22) | `a:hlinkHover` (20.1.2.2.23) |
|
|
2910
|
-
* | `a:rPr` (text runs) | `a:hlinkClick` | `a:hlinkMouseOver` (21.1.2.3.6) |
|
|
2911
|
-
*
|
|
2912
|
-
* Emitting `a:hlinkHover` inside `a:rPr` — or `a:hlinkMouseOver` inside `p:cNvPr` — produces markup
|
|
2913
|
-
* PowerPoint cannot parse, so the host decides the element name here rather than at each call site.
|
|
2914
|
-
*/
|
|
2915
|
-
/**
|
|
2916
|
-
* Build one `a:hlinkClick` / mouse-over element
|
|
2917
|
-
* @param {HyperlinkProps} link - link props
|
|
2918
|
-
* @param {'click' | 'hover'} trigger - which interaction this element describes
|
|
2919
|
-
* @param {HyperlinkHost} host - the element the link is attached to
|
|
2920
|
-
* @param {string} children - child elements (`a:snd`, `a:extLst`); self-closes when empty
|
|
2921
|
-
* @returns {string} XML string
|
|
2922
|
-
*/ function genXmlHyperlink(link, trigger, host, children = '') {
|
|
2923
|
-
var _link__rId;
|
|
2924
|
-
const tag = trigger === 'click' ? 'a:hlinkClick' : host === 'run' ? 'a:hlinkMouseOver' : 'a:hlinkHover';
|
|
2925
|
-
let attrs = `r:id="rId${(_link__rId = link._rId) !== null && _link__rId !== void 0 ? _link__rId : 0}"`;
|
|
2926
|
-
if (link.slide) {
|
|
2927
|
-
// an internal jump has no URL; the action attribute names the target kind
|
|
2928
|
-
attrs += ' action="ppaction://hlinksldjump"';
|
|
2929
|
-
} else {
|
|
2930
|
-
attrs += ' invalidUrl="" action="" tgtFrame=""';
|
|
2955
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2956
|
+
try {
|
|
2957
|
+
var info = gen[key](arg);
|
|
2958
|
+
var value = info.value;
|
|
2959
|
+
} catch (error) {
|
|
2960
|
+
reject(error);
|
|
2961
|
+
return;
|
|
2931
2962
|
}
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
// both default to false in the schema, so only write them when turned on
|
|
2935
|
-
if (link.highlightClick === true) attrs += ' highlightClick="1"';
|
|
2936
|
-
if (link.stopSoundsOnClick === true) attrs += ' endSnd="1"';
|
|
2937
|
-
const sound = genXmlHyperlinkSound(link);
|
|
2938
|
-
const inner = sound + children;
|
|
2939
|
-
return inner ? `<${tag} ${attrs}>${inner}</${tag}>` : `<${tag} ${attrs}/>`;
|
|
2940
|
-
}
|
|
2941
|
-
/**
|
|
2942
|
-
* Build the `a:snd` action sound (ECMA-376 20.1.2.2.32 `CT_EmbeddedWAVAudioFile`)
|
|
2943
|
-
* - the relationship is resolved when the object is created, so `_sndRId` is set by then
|
|
2944
|
-
* @param {HyperlinkProps} link - link props
|
|
2945
|
-
* @returns {string} XML string
|
|
2946
|
-
*/ function genXmlHyperlinkSound(link) {
|
|
2947
|
-
var _link_sound_name;
|
|
2948
|
-
var _link_sound;
|
|
2949
|
-
if (!((_link_sound = link.sound) === null || _link_sound === void 0 ? void 0 : _link_sound._sndRId)) return '';
|
|
2950
|
-
return `<a:snd r:embed="rId${link.sound._sndRId}" name="${encodeXmlEntities((_link_sound_name = link.sound.name) !== null && _link_sound_name !== void 0 ? _link_sound_name : 'sound.wav')}"/>`;
|
|
2963
|
+
if (info.done) resolve(value);
|
|
2964
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
2951
2965
|
}
|
|
2952
|
-
|
|
2953
|
-
function
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2966
|
+
function _async_to_generator(fn) {
|
|
2967
|
+
return function() {
|
|
2968
|
+
var self = this, args = arguments;
|
|
2969
|
+
return new Promise(function(resolve, reject) {
|
|
2970
|
+
var gen = fn.apply(self, args);
|
|
2971
|
+
function _next(value) {
|
|
2972
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
2973
|
+
}
|
|
2974
|
+
function _throw(err) {
|
|
2975
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2976
|
+
}
|
|
2977
|
+
_next(undefined);
|
|
2960
2978
|
});
|
|
2961
|
-
}
|
|
2962
|
-
return obj;
|
|
2979
|
+
};
|
|
2963
2980
|
}
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2981
|
+
/**
|
|
2982
|
+
* PptxGenJS: Media Methods
|
|
2983
|
+
*/
|
|
2984
|
+
|
|
2985
|
+
/** Images are measured in pixels; PowerPoint slide dimensions are inches at 96 DPI */ const IMAGE_DPI = 96;
|
|
2986
|
+
/**
|
|
2987
|
+
* Deck-scoped content-hash buckets keyed by `target._allocChartId` (shared across all slides,
|
|
2988
|
+
* layouts, and master in one `PptxGenJS` instance) so identical raster images share one OPC media
|
|
2989
|
+
* part across the entire deck without leaking across presentations.
|
|
2990
|
+
*/ const deckImageBuckets = new WeakMap();
|
|
2991
|
+
function getDeckImageBuckets(target) {
|
|
2992
|
+
var _target__allocChartId;
|
|
2993
|
+
const deckKey = (_target__allocChartId = target._allocChartId) !== null && _target__allocChartId !== void 0 ? _target__allocChartId : target;
|
|
2994
|
+
let buckets = deckImageBuckets.get(deckKey);
|
|
2995
|
+
if (!buckets) {
|
|
2996
|
+
buckets = new Map();
|
|
2997
|
+
deckImageBuckets.set(deckKey, buckets);
|
|
2998
|
+
}
|
|
2999
|
+
return buckets;
|
|
3000
|
+
}
|
|
3001
|
+
function isDedupeImageRel(rel) {
|
|
3002
|
+
if (!rel || rel.isLinked || rel.isSvgPng) return false;
|
|
3003
|
+
if (typeof rel.data !== 'string' || !rel.data || rel.data === IMG_BROKEN) return false;
|
|
3004
|
+
const type = typeof rel.type === 'string' ? rel.type.toLowerCase() : '';
|
|
3005
|
+
const extn = typeof rel.extn === 'string' ? rel.extn.toLowerCase() : '';
|
|
3006
|
+
if (extn === 'svg' || type === 'image/svg+xml') return false;
|
|
3007
|
+
return type === 'image' || type.startsWith('image/');
|
|
3008
|
+
}
|
|
3009
|
+
function getRelDataBody(data) {
|
|
3010
|
+
const commaIdx = data.indexOf(',');
|
|
3011
|
+
return commaIdx >= 0 ? data.substring(commaIdx + 1) : data;
|
|
3012
|
+
}
|
|
3013
|
+
function fnv1aHash(str) {
|
|
3014
|
+
let hash = 2166136261;
|
|
3015
|
+
for(let idx = 0; idx < str.length; idx++){
|
|
3016
|
+
hash ^= str.charCodeAt(idx);
|
|
3017
|
+
hash = Math.imul(hash, 16777619);
|
|
3018
|
+
}
|
|
3019
|
+
return (hash >>> 0).toString(16);
|
|
3020
|
+
}
|
|
3021
|
+
/**
|
|
3022
|
+
* Deduplicate one raster image relationship against the deck-scoped content-hash table.
|
|
3023
|
+
* When an identical image payload already exists on any slide/layout in this presentation,
|
|
3024
|
+
* rewrites `rel.Target` to reuse the existing OPC media part and marks `rel.isDuplicate = true`
|
|
3025
|
+
* while keeping `rel.rId` and `rel.data` intact.
|
|
3026
|
+
*/ function dedupeImageMediaRel(target, rel) {
|
|
3027
|
+
var _buckets_get;
|
|
3028
|
+
if (!isDedupeImageRel(rel)) return;
|
|
3029
|
+
const body = getRelDataBody(rel.data);
|
|
3030
|
+
if (!body) return;
|
|
3031
|
+
const normExtn = (rel.extn || 'png').toLowerCase() === 'jpg' ? 'jpeg' : (rel.extn || 'png').toLowerCase();
|
|
3032
|
+
const key = `${normExtn}|${body.length}|${fnv1aHash(body)}`;
|
|
3033
|
+
const buckets = getDeckImageBuckets(target);
|
|
3034
|
+
const bucket = (_buckets_get = buckets.get(key)) !== null && _buckets_get !== void 0 ? _buckets_get : [];
|
|
3035
|
+
const existing = bucket.find((entry)=>entry.data === body);
|
|
3036
|
+
if (existing) {
|
|
3037
|
+
if (existing.target !== rel.Target) {
|
|
3038
|
+
rel.isDuplicate = true;
|
|
3039
|
+
rel.Target = existing.target;
|
|
2972
3040
|
}
|
|
2973
|
-
|
|
2974
|
-
|
|
3041
|
+
} else {
|
|
3042
|
+
bucket.push({
|
|
3043
|
+
data: body,
|
|
3044
|
+
target: rel.Target
|
|
2975
3045
|
});
|
|
3046
|
+
buckets.set(key, bucket);
|
|
2976
3047
|
}
|
|
2977
|
-
return target;
|
|
2978
|
-
}
|
|
2979
|
-
function line_ownKeys(object, enumerableOnly) {
|
|
2980
|
-
var keys = Object.keys(object);
|
|
2981
|
-
if (Object.getOwnPropertySymbols) {
|
|
2982
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
2983
|
-
if (enumerableOnly) {
|
|
2984
|
-
symbols = symbols.filter(function(sym) {
|
|
2985
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
2986
|
-
});
|
|
2987
|
-
}
|
|
2988
|
-
keys.push.apply(keys, symbols);
|
|
2989
|
-
}
|
|
2990
|
-
return keys;
|
|
2991
3048
|
}
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
}
|
|
3000
|
-
return target;
|
|
3049
|
+
/**
|
|
3050
|
+
* Deduplicate all resolved raster image relationships on a slide/layout deck-wide.
|
|
3051
|
+
* Runs after `encodeSlideMediaRels` resolves so path-loaded images are deduplicated too.
|
|
3052
|
+
*/ function dedupeSlideMediaRels(layout) {
|
|
3053
|
+
var _layout__relsMedia;
|
|
3054
|
+
;
|
|
3055
|
+
((_layout__relsMedia = layout._relsMedia) !== null && _layout__relsMedia !== void 0 ? _layout__relsMedia : []).forEach((rel)=>dedupeImageMediaRel(layout, rel));
|
|
3001
3056
|
}
|
|
3002
3057
|
/**
|
|
3003
|
-
*
|
|
3058
|
+
* Read the natural pixel dimensions of a raster image from its header bytes.
|
|
3059
|
+
* Self-contained replacement for the `image-size` package (PNG/JPEG/GIF/BMP).
|
|
3060
|
+
* Format refs: PNG spec §11.2.2 (IHDR is always the first chunk, width/height big-endian at bytes 16-24);
|
|
3061
|
+
* JPEG (JFIF) SOF0-SOF15 markers carry height then width big-endian; GIF87a/89a logical-screen descriptor
|
|
3062
|
+
* little-endian at bytes 6-10; BMP DIB header little-endian at bytes 18-26. SVG is sized separately (gen-objects).
|
|
3004
3063
|
*
|
|
3005
|
-
*
|
|
3006
|
-
*
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
const compound = COMPOUND_TYPES.has(String(line.compound)) ? ` cmpd="${String(line.compound)}"` : '';
|
|
3022
|
-
if (line.compound && !COMPOUND_TYPES.has(String(line.compound))) {
|
|
3023
|
-
console.warn(`[pptxgenjs] line \`compound\` must be one of ${[
|
|
3024
|
-
...COMPOUND_TYPES
|
|
3025
|
-
].join(', ')} - "${String(line.compound)}" ignored`);
|
|
3064
|
+
* Declared dims are header-only (we never decode pixels), so clamp to a sane ceiling: a maliciously crafted
|
|
3065
|
+
* header can claim 0xFFFFFFFF px and emit a ~44-million-inch slide (a corrupt pptx). PowerPoint's max slide is
|
|
3066
|
+
* 56 in (5376 px @ 96 DPI); 100 000 px is generous headroom for legit high-res sources while rejecting bombs.
|
|
3067
|
+
*/ const MAX_IMAGE_PX = 100000;
|
|
3068
|
+
function imageDimensions(bytes) {
|
|
3069
|
+
if (bytes.length < 10) return {} // every supported header's dims start at/after byte 6
|
|
3070
|
+
;
|
|
3071
|
+
const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
3072
|
+
const sane = (w, h)=>w > 0 && h > 0 && w <= MAX_IMAGE_PX && h <= MAX_IMAGE_PX ? {
|
|
3073
|
+
width: w,
|
|
3074
|
+
height: h
|
|
3075
|
+
} : {};
|
|
3076
|
+
// PNG: 8-byte signature 89 50 4E 47 0D 0A 1A 0A, then IHDR length(4)+type(4)+width(4)+height(4)
|
|
3077
|
+
if (bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) {
|
|
3078
|
+
if (bytes.length < 24) return {};
|
|
3079
|
+
return sane(dv.getUint32(16, false), dv.getUint32(20, false));
|
|
3026
3080
|
}
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
if (line.type !== 'none' && (line.color || hasGrad)) {
|
|
3031
|
-
xml += genXmlColorSelection(hasGrad && !line.type ? line_object_spread_props(line_object_spread({}, line), {
|
|
3032
|
-
type: 'gradient'
|
|
3033
|
-
}) : line);
|
|
3081
|
+
// GIF: 'GIF87a'/'GIF89a', logical screen width/height little-endian at bytes 6-10
|
|
3082
|
+
if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46) {
|
|
3083
|
+
return sane(dv.getUint16(6, true), dv.getUint16(8, true));
|
|
3034
3084
|
}
|
|
3035
|
-
//
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
xml += genXmlArrow('a:headEnd', line.beginArrowType, line.beginArrowSize);
|
|
3040
|
-
xml += genXmlArrow('a:tailEnd', line.endArrowType, line.endArrowSize);
|
|
3041
|
-
xml += `</${tag}>`;
|
|
3042
|
-
return xml;
|
|
3043
|
-
}
|
|
3044
|
-
/** The dash choice: a custom pattern when given, otherwise the preset */ function genXmlDash(line) {
|
|
3045
|
-
var _line_custDash;
|
|
3046
|
-
const stops = ((_line_custDash = line.custDash) !== null && _line_custDash !== void 0 ? _line_custDash : []).filter((stop)=>{
|
|
3047
|
-
const ok = typeof (stop === null || stop === void 0 ? void 0 : stop.dash) === 'number' && isFinite(stop.dash) && stop.dash > 0 && typeof stop.space === 'number' && isFinite(stop.space) && stop.space >= 0;
|
|
3048
|
-
if (!ok) console.warn('[pptxgenjs] each `custDash` stop needs a positive `dash` and a non-negative `space` (percent of line width) - stop ignored');
|
|
3049
|
-
return ok;
|
|
3050
|
-
});
|
|
3051
|
-
if (stops.length > 0) {
|
|
3052
|
-
const items = stops.map((stop)=>`<a:ds d="${Math.round(stop.dash * 1000)}" sp="${Math.round(stop.space * 1000)}"/>`).join('');
|
|
3053
|
-
return `<a:custDash>${items}</a:custDash>`;
|
|
3085
|
+
// BMP: 'BM', DIB width/height little-endian at bytes 18-26 (signed; height may be negative = top-down)
|
|
3086
|
+
if (bytes[0] === 0x42 && bytes[1] === 0x4d) {
|
|
3087
|
+
if (bytes.length < 26) return {};
|
|
3088
|
+
return sane(Math.abs(dv.getInt32(18, true)), Math.abs(dv.getInt32(22, true)));
|
|
3054
3089
|
}
|
|
3055
|
-
|
|
3090
|
+
// JPEG: FF D8, then walk marker segments until a Start-Of-Frame (C0-CF except C4/C8/CC) carries the dims
|
|
3091
|
+
if (bytes[0] === 0xff && bytes[1] === 0xd8) {
|
|
3092
|
+
let off = 2;
|
|
3093
|
+
while(off + 9 <= bytes.length){
|
|
3094
|
+
if (bytes[off] !== 0xff) {
|
|
3095
|
+
off++;
|
|
3096
|
+
continue;
|
|
3097
|
+
}
|
|
3098
|
+
const marker = bytes[off + 1];
|
|
3099
|
+
const isSOF = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
|
|
3100
|
+
if (isSOF) return sane(dv.getUint16(off + 7, false), dv.getUint16(off + 5, false));
|
|
3101
|
+
if (marker === 0xd8 || marker === 0xd9 || marker >= 0xd0 && marker <= 0xd7) {
|
|
3102
|
+
off += 2;
|
|
3103
|
+
continue;
|
|
3104
|
+
} // no length
|
|
3105
|
+
const segLen = dv.getUint16(off + 2, false);
|
|
3106
|
+
off += 2 + segLen;
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
return {};
|
|
3056
3110
|
}
|
|
3057
|
-
/**
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3111
|
+
/**
|
|
3112
|
+
* Natural pixel size from encoded image bytes (PNG/JPEG/GIF/BMP headers).
|
|
3113
|
+
* Returns null when the payload is missing, not a supported raster, or claims 0×0
|
|
3114
|
+
* (`imageDimensions` already rejects zero and bomb-sized headers).
|
|
3115
|
+
*
|
|
3116
|
+
* contain/cover `a:srcRect` (ECMA-376 §5.1.10.55) needs the *blip* aspect, not the
|
|
3117
|
+
* placement box — using w/h as imgSize makes srcRect a no-op whenever they match the sizing box.
|
|
3118
|
+
*/ function getImagePixelSize(base64Data) {
|
|
3119
|
+
if (typeof base64Data !== 'string' || !base64Data || base64Data === IMG_BROKEN) return null;
|
|
3120
|
+
try {
|
|
3121
|
+
const dims = imageDimensions(base64ToBytes(base64Data));
|
|
3122
|
+
if (dims.width && dims.height) return {
|
|
3123
|
+
w: dims.width,
|
|
3124
|
+
h: dims.height
|
|
3125
|
+
};
|
|
3126
|
+
} catch (unused) {
|
|
3127
|
+
// unrecognized / truncated payload
|
|
3064
3128
|
}
|
|
3065
|
-
|
|
3066
|
-
return '';
|
|
3129
|
+
return null;
|
|
3067
3130
|
}
|
|
3068
|
-
|
|
3131
|
+
/**
|
|
3132
|
+
* Size images added without `w`/`h` to their natural dimensions (issue #34)
|
|
3133
|
+
* @note must run after `encodeSlideMediaRels` has resolved - it reads the encoded image bytes
|
|
3134
|
+
* @param {PresSlide | SlideLayout} layout - slide layout
|
|
3135
|
+
*/ function applyNaturalImageSizes(layout) {
|
|
3136
|
+
// Media bytes for path-based images are now loaded; deduplicate identical raster payloads deck-wide
|
|
3137
|
+
// before slide/layout `.rels` and zip parts are emitted.
|
|
3138
|
+
dedupeSlideMediaRels(layout);
|
|
3139
|
+
layout._slideObjects.filter((obj)=>{
|
|
3140
|
+
var _obj_options;
|
|
3141
|
+
return obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.image */"image") && ((_obj_options = obj.options) === null || _obj_options === void 0 ? void 0 : _obj_options._sizeFromImage);
|
|
3142
|
+
}).forEach((obj)=>{
|
|
3143
|
+
var _layout__relsMedia_find;
|
|
3144
|
+
const strData = (_layout__relsMedia_find = layout._relsMedia.find((rel)=>rel.rId === obj.imageRid)) === null || _layout__relsMedia_find === void 0 ? void 0 : _layout__relsMedia_find.data;
|
|
3145
|
+
if (!obj.options || typeof strData !== 'string' || !strData || strData === IMG_BROKEN) return;
|
|
3146
|
+
// An image bound to a placeholder inherits the placeholder's w/h (slide XML resolves it); sizing it
|
|
3147
|
+
// to its natural pixel dims instead would collapse it to ~px/96 inches (issue #996).
|
|
3148
|
+
if (obj.options.placeholder) return;
|
|
3149
|
+
try {
|
|
3150
|
+
const dims = imageDimensions(base64ToBytes(strData));
|
|
3151
|
+
if (dims.width && dims.height) {
|
|
3152
|
+
obj.options.w = dims.width / IMAGE_DPI;
|
|
3153
|
+
obj.options.h = dims.height / IMAGE_DPI;
|
|
3154
|
+
}
|
|
3155
|
+
} catch (_ex) {
|
|
3156
|
+
// Unreadable/unsupported image: keep the 1x1 inch default
|
|
3157
|
+
}
|
|
3158
|
+
});
|
|
3159
|
+
}
|
|
3160
|
+
/** Select relations that still need their local or remote media encoded. */ function getMediaCandidates(layout) {
|
|
3161
|
+
return layout._relsMedia.filter((rel)=>!rel.isLinked && rel.type !== 'online' && !rel.data && (!rel.path || rel.path && !rel.path.includes('preencoded')));
|
|
3162
|
+
}
|
|
3163
|
+
/**
|
|
3164
|
+
* Mark repeated source paths so only the first relation performs I/O.
|
|
3165
|
+
*
|
|
3166
|
+
* Mutates `isDuplicate`; subsequent helpers copy the first result to every duplicate.
|
|
3167
|
+
*/ function markDuplicateMedia(candidates) {
|
|
3168
|
+
const paths = new Set();
|
|
3169
|
+
candidates.forEach((rel)=>{
|
|
3170
|
+
var _rel_path;
|
|
3171
|
+
const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
|
|
3172
|
+
rel.isDuplicate = paths.has(path);
|
|
3173
|
+
paths.add(path);
|
|
3174
|
+
});
|
|
3175
|
+
}
|
|
3176
|
+
/** Copy an encoded or broken source relation's data to every duplicate path. */ function copyMediaToDuplicates(candidates, rel) {
|
|
3177
|
+
candidates.filter((duplicate)=>duplicate.isDuplicate && duplicate.path === rel.path).forEach((duplicate)=>duplicate.data = rel.data);
|
|
3178
|
+
}
|
|
3179
|
+
/** Mark a failed source and all duplicates with the sentinel expected by package generation. */ function markMediaBroken(candidates, rel) {
|
|
3180
|
+
rel.data = IMG_BROKEN;
|
|
3181
|
+
copyMediaToDuplicates(candidates, rel);
|
|
3182
|
+
}
|
|
3183
|
+
function mediaLoadFailed(candidates, rel, message, onError) {
|
|
3184
|
+
markMediaBroken(candidates, rel);
|
|
3185
|
+
if (onError === 'placeholder') {
|
|
3186
|
+
console.warn(`WARN: Unable to load image, using placeholder: ${rel.path}${message ? ` (${message})` : ''}`);
|
|
3187
|
+
return 'done';
|
|
3188
|
+
}
|
|
3189
|
+
throw new Error(message);
|
|
3190
|
+
}
|
|
3191
|
+
/**
|
|
3192
|
+
* Read one Node-local media source and encode it as base64.
|
|
3193
|
+
*
|
|
3194
|
+
* A read failure is recorded before rejection so duplicate references remain consistent.
|
|
3195
|
+
*/ function readNodeMediaFile(rel, candidates, fs, onError) {
|
|
3196
|
+
return _async_to_generator(function*() {
|
|
3197
|
+
try {
|
|
3198
|
+
var _rel_path;
|
|
3199
|
+
var _rel_fill;
|
|
3200
|
+
const relPath = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
|
|
3201
|
+
const svgFill = typeof ((_rel_fill = rel.fill) === null || _rel_fill === void 0 ? void 0 : _rel_fill.color) === 'string' ? rel.fill.color : undefined;
|
|
3202
|
+
if (svgFill && (rel.type === 'image/svg+xml' || rel.extn === 'svg')) {
|
|
3203
|
+
const svgText = applySvgFillColor(fs.readFileSync(relPath, 'utf8'), svgFill);
|
|
3204
|
+
rel.data = utf8ToBase64(svgText);
|
|
3205
|
+
} else {
|
|
3206
|
+
const bitmap = fs.readFileSync(relPath);
|
|
3207
|
+
rel.data = bytesToBase64(new Uint8Array(bitmap));
|
|
3208
|
+
if (svgFill && typeof rel.data === 'string') {
|
|
3209
|
+
rel.data = applySvgFillToDataUrl(rel.data, svgFill);
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
copyMediaToDuplicates(candidates, rel);
|
|
3213
|
+
return 'done';
|
|
3214
|
+
} catch (ex) {
|
|
3215
|
+
return mediaLoadFailed(candidates, rel, `ERROR: Unable to read media: "${rel.path}"\n${String(ex)}`, onError);
|
|
3216
|
+
}
|
|
3217
|
+
})();
|
|
3218
|
+
}
|
|
3219
|
+
/**
|
|
3220
|
+
* Load one HTTP(S) source in Node, draining error responses and handling both request and response errors.
|
|
3221
|
+
*/ function loadNodeMediaUrl(rel, candidates, https, http, onError) {
|
|
3222
|
+
var _rel_path;
|
|
3223
|
+
const httpMod = ((_rel_path = rel.path) === null || _rel_path === void 0 ? void 0 : _rel_path.startsWith('http://')) ? http : https;
|
|
3224
|
+
return new Promise((resolve, reject)=>{
|
|
3225
|
+
const fail = (message)=>{
|
|
3226
|
+
try {
|
|
3227
|
+
resolve(mediaLoadFailed(candidates, rel, message, onError));
|
|
3228
|
+
} catch (ex) {
|
|
3229
|
+
reject(ex);
|
|
3230
|
+
}
|
|
3231
|
+
};
|
|
3232
|
+
try {
|
|
3233
|
+
var _rel_path;
|
|
3234
|
+
const req = httpMod.get((_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '', (res)=>{
|
|
3235
|
+
var _res_statusCode;
|
|
3236
|
+
const status = (_res_statusCode = res.statusCode) !== null && _res_statusCode !== void 0 ? _res_statusCode : 0;
|
|
3237
|
+
if (status < 200 || status > 299) {
|
|
3238
|
+
res.resume(); // drain so the socket is freed
|
|
3239
|
+
fail(`ERROR! Unable to load image (HTTP ${status}): ${rel.path}`);
|
|
3240
|
+
return;
|
|
3241
|
+
}
|
|
3242
|
+
let raw = '';
|
|
3243
|
+
res.setEncoding('binary'); // IMPORTANT: Only binary encoding works
|
|
3244
|
+
res.on('data', (chunk)=>raw += chunk);
|
|
3245
|
+
res.on('end', ()=>{
|
|
3246
|
+
rel.data = binaryStringToBase64(raw);
|
|
3247
|
+
copyMediaToDuplicates(candidates, rel);
|
|
3248
|
+
resolve('done');
|
|
3249
|
+
});
|
|
3250
|
+
res.on('error', ()=>fail(`ERROR! Unable to load image (response): ${rel.path}`));
|
|
3251
|
+
});
|
|
3252
|
+
// NOTE: without this, a DNS/TLS/connection failure emits an unhandled 'error' and kills the process
|
|
3253
|
+
req.on('error', (ex)=>fail(`ERROR! Unable to load image (request): ${rel.path}\n${String(ex)}`));
|
|
3254
|
+
} catch (ex) {
|
|
3255
|
+
fail(`ERROR! Unable to load image (https.get): ${rel.path}\n${String(ex)}`);
|
|
3256
|
+
}
|
|
3257
|
+
});
|
|
3258
|
+
}
|
|
3259
|
+
/**
|
|
3260
|
+
* Fetch one browser media source and convert its Blob response to a data URL.
|
|
3261
|
+
* SVG previews are produced only after the source relation has been populated.
|
|
3262
|
+
*/ function loadBrowserMedia(rel, candidates, onError) {
|
|
3263
|
+
return new Promise((resolve, reject)=>{
|
|
3264
|
+
var _rel_path;
|
|
3265
|
+
const fail = (message)=>{
|
|
3266
|
+
try {
|
|
3267
|
+
resolve(mediaLoadFailed(candidates, rel, message, onError));
|
|
3268
|
+
} catch (ex) {
|
|
3269
|
+
reject(ex);
|
|
3270
|
+
}
|
|
3271
|
+
};
|
|
3272
|
+
const xhr = new XMLHttpRequest();
|
|
3273
|
+
xhr.onload = ()=>{
|
|
3274
|
+
// status 0 = non-HTTP schemes (file://); anything outside 2xx is an error page, not image bytes
|
|
3275
|
+
if (xhr.status !== 0 && (xhr.status < 200 || xhr.status > 299)) {
|
|
3276
|
+
fail(`ERROR! HTTP status ${xhr.status} loading image: ${rel.path}`);
|
|
3277
|
+
return;
|
|
3278
|
+
}
|
|
3279
|
+
const reader = new FileReader();
|
|
3280
|
+
reader.onloadend = ()=>{
|
|
3281
|
+
if (typeof reader.result === 'string') rel.data = reader.result;
|
|
3282
|
+
copyMediaToDuplicates(candidates, rel);
|
|
3283
|
+
if (!rel.isSvgPng) resolve('done');
|
|
3284
|
+
else createSvgPngPreview(rel).then(()=>resolve('done')).catch(reject);
|
|
3285
|
+
};
|
|
3286
|
+
reader.readAsDataURL(xhr.response);
|
|
3287
|
+
};
|
|
3288
|
+
xhr.onerror = ()=>{
|
|
3289
|
+
fail(`ERROR! Unable to load image (xhr.onerror): ${rel.path}`);
|
|
3290
|
+
};
|
|
3291
|
+
xhr.open('GET', (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '');
|
|
3292
|
+
xhr.responseType = 'blob';
|
|
3293
|
+
xhr.send();
|
|
3294
|
+
});
|
|
3295
|
+
}
|
|
3296
|
+
/** Route one source relation to the loader valid for the active runtime. */ function encodeMediaRelation(rel, candidates, isNode, modules, loadNodeModules, onError) {
|
|
3297
|
+
return _async_to_generator(function*() {
|
|
3298
|
+
var _rel_path;
|
|
3299
|
+
if (!modules.https) yield loadNodeModules();
|
|
3300
|
+
const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
|
|
3301
|
+
if (isNode && modules.fs && !path.startsWith('http')) return readNodeMediaFile(rel, candidates, modules.fs, onError);
|
|
3302
|
+
if (isNode && modules.https && modules.http && path.startsWith('http')) return loadNodeMediaUrl(rel, candidates, modules.https, modules.http, onError);
|
|
3303
|
+
return loadBrowserMedia(rel, candidates, onError);
|
|
3304
|
+
})();
|
|
3305
|
+
}
|
|
3306
|
+
/**
|
|
3307
|
+
* Append SVG preview work synchronously because the caller immediately snapshots `promises`.
|
|
3308
|
+
* Node cannot rasterize SVG here, so it keeps the historical broken-preview sentinel behavior.
|
|
3309
|
+
*/ function addSvgPreviewPromises(layout, isNode, promises) {
|
|
3310
|
+
layout._relsMedia.filter((rel)=>rel.isSvgPng && rel.data).forEach((rel)=>{
|
|
3311
|
+
// NOTE: must push synchronously - the caller snapshots this array as soon as we return
|
|
3312
|
+
if (isNode) {
|
|
3313
|
+
// SVG is not supported in Node (more info: https://github.com/gitbrent/PptxGenJS/issues/401)
|
|
3314
|
+
rel.data = IMG_BROKEN;
|
|
3315
|
+
promises.push(Promise.resolve('done'));
|
|
3316
|
+
} else {
|
|
3317
|
+
promises.push(createSvgPngPreview(rel));
|
|
3318
|
+
}
|
|
3319
|
+
});
|
|
3320
|
+
}
|
|
3321
|
+
/**
|
|
3322
|
+
* Encode Image/Audio/Video into base64
|
|
3323
|
+
* @param {PresSlide | SlideLayout} layout - slide layout
|
|
3324
|
+
* @return {Promise} promise
|
|
3325
|
+
*/ function encodeSlideMediaRels(layout, opts) {
|
|
3326
|
+
// STEP 1: Detect a real Node process. Browser bundles often polyfill `process`
|
|
3327
|
+
// (and even `process.versions.node`), so also require a document-less runtime.
|
|
3328
|
+
const isNode = isNodeRuntime();
|
|
3329
|
+
const modules = {};
|
|
3330
|
+
// STEP 2: Lazy-load Node built-ins if needed. The specifier is built at runtime
|
|
3331
|
+
// so browser bundlers cannot statically resolve `node:https` / `https`.
|
|
3332
|
+
const loadNodeDeps = isNode ? ()=>_async_to_generator(function*() {
|
|
3333
|
+
;
|
|
3334
|
+
({ default: modules.fs } = yield importNodeBuiltin('fs'));
|
|
3335
|
+
({ default: modules.https } = yield importNodeBuiltin('https'));
|
|
3336
|
+
({ default: modules.http } = yield importNodeBuiltin('http'));
|
|
3337
|
+
})() : ()=>_async_to_generator(function*() {})();
|
|
3338
|
+
// Immediately start it when we know we’re in Node
|
|
3339
|
+
if (isNode) loadNodeDeps();
|
|
3340
|
+
// STEP 3: Prepare promises list
|
|
3341
|
+
const imageProms = [];
|
|
3342
|
+
// A: Capture all audio/image/video candidates for encoding (filtering online/pre-encoded)
|
|
3343
|
+
const candidateRels = getMediaCandidates(layout);
|
|
3344
|
+
// B: PERF: Mark dupes (same `path`) to avoid loading the same media over-and-over!
|
|
3345
|
+
markDuplicateMedia(candidateRels);
|
|
3346
|
+
// STEP 4: Read/Encode each unique media item
|
|
3347
|
+
const onError = (opts === null || opts === void 0 ? void 0 : opts.onError) === 'placeholder' ? 'placeholder' : 'throw';
|
|
3348
|
+
candidateRels.filter((rel)=>!rel.isDuplicate).forEach((rel)=>imageProms.push(encodeMediaRelation(rel, candidateRels, isNode, modules, loadNodeDeps, onError)));
|
|
3349
|
+
// STEP 5: SVG-PNG previews
|
|
3350
|
+
// ......: "SVG:" base64 data still requires a png to be generated
|
|
3351
|
+
// ......: (`isSvgPng` flag this as the preview image, not the SVG itself)
|
|
3352
|
+
addSvgPreviewPromises(layout, isNode, imageProms);
|
|
3353
|
+
return imageProms;
|
|
3354
|
+
}
|
|
3355
|
+
/**
|
|
3356
|
+
* Create SVG preview image
|
|
3357
|
+
* @param {ISlideRelMedia} rel - slide rel
|
|
3358
|
+
* @return {Promise} promise
|
|
3359
|
+
*/ function createSvgPngPreview(rel) {
|
|
3360
|
+
return _async_to_generator(function*() {
|
|
3361
|
+
return yield new Promise((resolve, reject)=>{
|
|
3362
|
+
// A: Create
|
|
3363
|
+
const image = new Image();
|
|
3364
|
+
// Shared error handler (also wired to `image.onerror`); the reason string is informational only
|
|
3365
|
+
const handleError = ()=>{
|
|
3366
|
+
rel.data = IMG_BROKEN;
|
|
3367
|
+
reject(new Error(`ERROR! Unable to load image (image.onerror): ${rel.path}`));
|
|
3368
|
+
};
|
|
3369
|
+
// B: Set onload event
|
|
3370
|
+
image.onload = ()=>{
|
|
3371
|
+
// First: Check for any errors: This is the best method (try/catch wont work, etc.)
|
|
3372
|
+
if (image.width + image.height === 0) {
|
|
3373
|
+
handleError();
|
|
3374
|
+
}
|
|
3375
|
+
const canvas = document.createElement('canvas');
|
|
3376
|
+
const ctx = canvas.getContext('2d');
|
|
3377
|
+
if (!ctx) {
|
|
3378
|
+
handleError();
|
|
3379
|
+
return;
|
|
3380
|
+
}
|
|
3381
|
+
canvas.width = image.width;
|
|
3382
|
+
canvas.height = image.height;
|
|
3383
|
+
ctx.drawImage(image, 0, 0);
|
|
3384
|
+
// Users running on local machine will get the following error:
|
|
3385
|
+
// "SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported."
|
|
3386
|
+
// when the canvas.toDataURL call executes below.
|
|
3387
|
+
try {
|
|
3388
|
+
rel.data = canvas.toDataURL(rel.type);
|
|
3389
|
+
resolve('done');
|
|
3390
|
+
} catch (_ex) {
|
|
3391
|
+
handleError();
|
|
3392
|
+
}
|
|
3393
|
+
};
|
|
3394
|
+
image.onerror = handleError;
|
|
3395
|
+
// C: Load image
|
|
3396
|
+
image.src = typeof rel.data === 'string' ? rel.data : IMG_BROKEN;
|
|
3397
|
+
});
|
|
3398
|
+
})();
|
|
3399
|
+
}
|
|
3400
|
+
|
|
3401
|
+
/**
|
|
3402
|
+
* Hyperlinks and mouse-over actions.
|
|
3403
|
+
*
|
|
3404
|
+
* DrawingML gives the same concept two element names depending on where it appears:
|
|
3405
|
+
*
|
|
3406
|
+
* | host | click | mouse-over |
|
|
3407
|
+
* | :-- | :-- | :-- |
|
|
3408
|
+
* | `p:cNvPr` (shapes, pictures) | `a:hlinkClick` (20.1.2.2.22) | `a:hlinkHover` (20.1.2.2.23) |
|
|
3409
|
+
* | `a:rPr` (text runs) | `a:hlinkClick` | `a:hlinkMouseOver` (21.1.2.3.6) |
|
|
3410
|
+
*
|
|
3411
|
+
* Emitting `a:hlinkHover` inside `a:rPr` — or `a:hlinkMouseOver` inside `p:cNvPr` — produces markup
|
|
3412
|
+
* PowerPoint cannot parse, so the host decides the element name here rather than at each call site.
|
|
3413
|
+
*/
|
|
3414
|
+
/**
|
|
3415
|
+
* Build one `a:hlinkClick` / mouse-over element
|
|
3416
|
+
* @param {HyperlinkProps} link - link props
|
|
3417
|
+
* @param {'click' | 'hover'} trigger - which interaction this element describes
|
|
3418
|
+
* @param {HyperlinkHost} host - the element the link is attached to
|
|
3419
|
+
* @param {string} children - child elements (`a:snd`, `a:extLst`); self-closes when empty
|
|
3420
|
+
* @returns {string} XML string
|
|
3421
|
+
*/ function genXmlHyperlink(link, trigger, host, children = '') {
|
|
3422
|
+
var _link__rId;
|
|
3423
|
+
const tag = trigger === 'click' ? 'a:hlinkClick' : host === 'run' ? 'a:hlinkMouseOver' : 'a:hlinkHover';
|
|
3424
|
+
let attrs = `r:id="rId${(_link__rId = link._rId) !== null && _link__rId !== void 0 ? _link__rId : 0}"`;
|
|
3425
|
+
if (link.slide) {
|
|
3426
|
+
// an internal jump has no URL; the action attribute names the target kind
|
|
3427
|
+
attrs += ' action="ppaction://hlinksldjump"';
|
|
3428
|
+
} else {
|
|
3429
|
+
attrs += ' invalidUrl="" action="" tgtFrame=""';
|
|
3430
|
+
}
|
|
3431
|
+
attrs += ` tooltip="${link.tooltip ? encodeXmlEntities(link.tooltip) : ''}"`;
|
|
3432
|
+
if (!link.slide) attrs += ' history="1"';
|
|
3433
|
+
// both default to false in the schema, so only write them when turned on
|
|
3434
|
+
if (link.highlightClick === true) attrs += ' highlightClick="1"';
|
|
3435
|
+
if (link.stopSoundsOnClick === true) attrs += ' endSnd="1"';
|
|
3436
|
+
const sound = genXmlHyperlinkSound(link);
|
|
3437
|
+
const inner = sound + children;
|
|
3438
|
+
return inner ? `<${tag} ${attrs}>${inner}</${tag}>` : `<${tag} ${attrs}/>`;
|
|
3439
|
+
}
|
|
3440
|
+
/**
|
|
3441
|
+
* Build the `a:snd` action sound (ECMA-376 20.1.2.2.32 `CT_EmbeddedWAVAudioFile`)
|
|
3442
|
+
* - the relationship is resolved when the object is created, so `_sndRId` is set by then
|
|
3443
|
+
* @param {HyperlinkProps} link - link props
|
|
3444
|
+
* @returns {string} XML string
|
|
3445
|
+
*/ function genXmlHyperlinkSound(link) {
|
|
3446
|
+
var _link_sound_name;
|
|
3447
|
+
var _link_sound;
|
|
3448
|
+
if (!((_link_sound = link.sound) === null || _link_sound === void 0 ? void 0 : _link_sound._sndRId)) return '';
|
|
3449
|
+
return `<a:snd r:embed="rId${link.sound._sndRId}" name="${encodeXmlEntities((_link_sound_name = link.sound.name) !== null && _link_sound_name !== void 0 ? _link_sound_name : 'sound.wav')}"/>`;
|
|
3450
|
+
}
|
|
3451
|
+
|
|
3452
|
+
function line_define_property(obj, key, value) {
|
|
3453
|
+
if (key in obj) {
|
|
3454
|
+
Object.defineProperty(obj, key, {
|
|
3455
|
+
value: value,
|
|
3456
|
+
enumerable: true,
|
|
3457
|
+
configurable: true,
|
|
3458
|
+
writable: true
|
|
3459
|
+
});
|
|
3460
|
+
} else obj[key] = value;
|
|
3461
|
+
return obj;
|
|
3462
|
+
}
|
|
3463
|
+
function line_object_spread(target) {
|
|
3464
|
+
for(var i = 1; i < arguments.length; i++){
|
|
3465
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
3466
|
+
var ownKeys = Object.keys(source);
|
|
3467
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
3468
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
3469
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
3470
|
+
}));
|
|
3471
|
+
}
|
|
3472
|
+
ownKeys.forEach(function(key) {
|
|
3473
|
+
line_define_property(target, key, source[key]);
|
|
3474
|
+
});
|
|
3475
|
+
}
|
|
3476
|
+
return target;
|
|
3477
|
+
}
|
|
3478
|
+
function line_ownKeys(object, enumerableOnly) {
|
|
3479
|
+
var keys = Object.keys(object);
|
|
3480
|
+
if (Object.getOwnPropertySymbols) {
|
|
3481
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
3482
|
+
if (enumerableOnly) {
|
|
3483
|
+
symbols = symbols.filter(function(sym) {
|
|
3484
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
3485
|
+
});
|
|
3486
|
+
}
|
|
3487
|
+
keys.push.apply(keys, symbols);
|
|
3488
|
+
}
|
|
3489
|
+
return keys;
|
|
3490
|
+
}
|
|
3491
|
+
function line_object_spread_props(target, source) {
|
|
3492
|
+
source = source != null ? source : {};
|
|
3493
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
3494
|
+
else {
|
|
3495
|
+
line_ownKeys(Object(source)).forEach(function(key) {
|
|
3496
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
3497
|
+
});
|
|
3498
|
+
}
|
|
3499
|
+
return target;
|
|
3500
|
+
}
|
|
3501
|
+
/**
|
|
3502
|
+
* PptxGenJS: Line properties (`a:ln` and its aliases)
|
|
3503
|
+
*
|
|
3504
|
+
* The same `CT_LineProperties` content model is used by shape outlines (`a:ln`), underlines
|
|
3505
|
+
* (`a:uLn`), and table cell borders, so the element name is a parameter rather than baked in.
|
|
3506
|
+
*/
|
|
3507
|
+
|
|
3508
|
+
const LINE_ALIGNS = new Set([
|
|
3509
|
+
'in',
|
|
3510
|
+
'ctr',
|
|
3511
|
+
'out'
|
|
3512
|
+
]);
|
|
3513
|
+
/**
|
|
3514
|
+
* Create a line element
|
|
3515
|
+
* @param {ShapeLineProps} line - line options
|
|
3516
|
+
* @param {string} tag - element name; `a:ln` for a shape outline, `a:uLn` for an underline
|
|
3517
|
+
* @return {string} XML
|
|
3518
|
+
*/ function genXmlLine(line, tag = 'a:ln') {
|
|
3519
|
+
// Explicit "no stroke" — emit `<a:noFill/>` so PowerPoint/Slides do not fall back to theme stroke
|
|
3520
|
+
if (line.type === 'none') {
|
|
3521
|
+
return `<${tag}><a:noFill/></${tag}>`;
|
|
3522
|
+
}
|
|
3523
|
+
// ECMA-376 §5.1.2.1.34: `<a:ln>` carries `w`, `cap`, `cmpd`, and `algn` attributes
|
|
3524
|
+
const cap = line.cap && [
|
|
3525
|
+
'flat',
|
|
3526
|
+
'sq',
|
|
3527
|
+
'rnd'
|
|
3528
|
+
].includes(line.cap) ? ` cap="${line.cap}"` : '';
|
|
3529
|
+
const compound = COMPOUND_TYPES.has(String(line.compound)) ? ` cmpd="${String(line.compound)}"` : '';
|
|
3530
|
+
if (line.compound && !COMPOUND_TYPES.has(String(line.compound))) {
|
|
3531
|
+
console.warn(`[pptxgenjs] line \`compound\` must be one of ${[
|
|
3532
|
+
...COMPOUND_TYPES
|
|
3533
|
+
].join(', ')} - "${String(line.compound)}" ignored`);
|
|
3534
|
+
}
|
|
3535
|
+
const align = line.align && LINE_ALIGNS.has(line.align) ? ` algn="${line.align}"` : '';
|
|
3536
|
+
if (line.align && !LINE_ALIGNS.has(line.align)) {
|
|
3537
|
+
console.warn(`[pptxgenjs] line \`align\` must be 'in' | 'ctr' | 'out' - "${String(line.align)}" ignored`);
|
|
3538
|
+
}
|
|
3539
|
+
const attrs = (line.width ? ` w="${valToLineWidth(line.width)}"` : '') + cap + compound + align;
|
|
3540
|
+
let xml = `<${tag}${attrs}>`;
|
|
3541
|
+
const hasGrad = !!(line.gradient || line.type === 'gradient' || line.type === 'linearGradient');
|
|
3542
|
+
if (line.color || hasGrad) {
|
|
3543
|
+
xml += genXmlColorSelection(hasGrad && !line.type ? line_object_spread_props(line_object_spread({}, line), {
|
|
3544
|
+
type: 'gradient'
|
|
3545
|
+
}) : line);
|
|
3546
|
+
}
|
|
3547
|
+
// CT_LineProperties sequence: fill, dash, join, headEnd, tailEnd. A custom pattern replaces
|
|
3548
|
+
// the preset one - emitting both would be ambiguous, since `a:custDash` is the same choice.
|
|
3549
|
+
xml += genXmlDash(line);
|
|
3550
|
+
xml += genXmlJoin(line);
|
|
3551
|
+
xml += genXmlArrow('a:headEnd', line.beginArrowType, line.beginArrowSize);
|
|
3552
|
+
xml += genXmlArrow('a:tailEnd', line.endArrowType, line.endArrowSize);
|
|
3553
|
+
xml += `</${tag}>`;
|
|
3554
|
+
return xml;
|
|
3555
|
+
}
|
|
3556
|
+
/** The dash choice: a custom pattern when given, otherwise the preset */ function genXmlDash(line) {
|
|
3557
|
+
var _line_custDash;
|
|
3558
|
+
const stops = ((_line_custDash = line.custDash) !== null && _line_custDash !== void 0 ? _line_custDash : []).filter((stop)=>{
|
|
3559
|
+
const ok = typeof (stop === null || stop === void 0 ? void 0 : stop.dash) === 'number' && isFinite(stop.dash) && stop.dash > 0 && typeof stop.space === 'number' && isFinite(stop.space) && stop.space >= 0;
|
|
3560
|
+
if (!ok) console.warn('[pptxgenjs] each `custDash` stop needs a positive `dash` and a non-negative `space` (percent of line width) - stop ignored');
|
|
3561
|
+
return ok;
|
|
3562
|
+
});
|
|
3563
|
+
if (stops.length > 0) {
|
|
3564
|
+
const items = stops.map((stop)=>`<a:ds d="${Math.round(stop.dash * 1000)}" sp="${Math.round(stop.space * 1000)}"/>`).join('');
|
|
3565
|
+
return `<a:custDash>${items}</a:custDash>`;
|
|
3566
|
+
}
|
|
3567
|
+
return line.dashType ? `<a:prstDash val="${line.dashType}"/>` : '';
|
|
3568
|
+
}
|
|
3569
|
+
/** The join choice: `a:round`, `a:bevel`, or `a:miter` with its limit */ function genXmlJoin(line) {
|
|
3570
|
+
if (!line.join) return '';
|
|
3571
|
+
if (line.join === 'round') return '<a:round/>';
|
|
3572
|
+
if (line.join === 'bevel') return '<a:bevel/>';
|
|
3573
|
+
if (line.join === 'miter') {
|
|
3574
|
+
const lim = typeof line.miterLimit === 'number' && isFinite(line.miterLimit) && line.miterLimit >= 0 ? line.miterLimit : 800;
|
|
3575
|
+
return `<a:miter lim="${Math.round(lim * 1000)}"/>`;
|
|
3576
|
+
}
|
|
3577
|
+
console.warn(`[pptxgenjs] line \`join\` must be 'round' | 'bevel' | 'miter' - "${String(line.join)}" ignored`);
|
|
3578
|
+
return '';
|
|
3579
|
+
}
|
|
3580
|
+
function resolveArrowSize(size) {
|
|
3069
3581
|
if (!size) return undefined;
|
|
3070
3582
|
if (typeof size === 'string') return {
|
|
3071
3583
|
width: size,
|
|
@@ -3187,7 +3699,7 @@ function text_object_spread_props(target, source) {
|
|
|
3187
3699
|
if (bullet.color) xml += `<a:buClr>${createColorElement(bullet.color)}</a:buClr>`;
|
|
3188
3700
|
// `a:buSzPct` and `a:buSzPts` are the same choice, so only one may appear
|
|
3189
3701
|
if (typeof bullet.sizePts === 'number' && isFinite(bullet.sizePts) && bullet.sizePts > 0) {
|
|
3190
|
-
xml += `<a:buSzPts val="${
|
|
3702
|
+
xml += `<a:buSzPts val="${fontSizeToSz(bullet.sizePts)}"/>`;
|
|
3191
3703
|
} else {
|
|
3192
3704
|
const pct = typeof bullet.size === 'number' && isFinite(bullet.size) ? Math.min(400, Math.max(25, bullet.size)) : 100;
|
|
3193
3705
|
if (typeof bullet.size === 'number' && (bullet.size < 25 || bullet.size > 400)) {
|
|
@@ -3198,6 +3710,20 @@ function text_object_spread_props(target, source) {
|
|
|
3198
3710
|
if (bullet.fontFace) xml += `<a:buFont typeface="${encodeXmlEntities(bullet.fontFace)}"/>`;
|
|
3199
3711
|
return xml;
|
|
3200
3712
|
}
|
|
3713
|
+
/**
|
|
3714
|
+
* Compute `marL` and hanging `indent` attributes for a bulleted paragraph (`a:pPr`).
|
|
3715
|
+
* When `bullet.hangingIndentRatio` is provided, `bullet.indent` acts as the base left margin
|
|
3716
|
+
* (`before text` indent) and the hanging indent is `round(marL * hangingIndentRatio)`.
|
|
3717
|
+
*/ function genXmlBulletMarginIndent(options) {
|
|
3718
|
+
const bullet = typeof options.bullet === 'object' ? options.bullet : {};
|
|
3719
|
+
const bulletMarL = valToPts(bullet.indent || (/* inlined export .DEF_BULLET_MARGIN */27));
|
|
3720
|
+
const indentLevel = options.indentLevel && options.indentLevel > 0 ? options.indentLevel : 0;
|
|
3721
|
+
if (typeof bullet.hangingIndentRatio === 'number' && Number.isFinite(bullet.hangingIndentRatio) && bullet.hangingIndentRatio > 0) {
|
|
3722
|
+
const hangingIndent = Math.round(bulletMarL * bullet.hangingIndentRatio);
|
|
3723
|
+
return ` marL="${bulletMarL * (indentLevel || 1)}" indent="-${hangingIndent}"`;
|
|
3724
|
+
}
|
|
3725
|
+
return ` marL="${indentLevel > 0 ? bulletMarL + bulletMarL * indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
|
|
3726
|
+
}
|
|
3201
3727
|
/**
|
|
3202
3728
|
* Generate XML Paragraph Properties
|
|
3203
3729
|
* @param {ISlideObject|TextProps} textObj - text object
|
|
@@ -3210,7 +3736,6 @@ function text_object_spread_props(target, source) {
|
|
|
3210
3736
|
let strXmlParaSpc = '';
|
|
3211
3737
|
let strXmlTabStops = '';
|
|
3212
3738
|
const tag = isDefault ? 'a:lvl1pPr' : 'a:pPr';
|
|
3213
|
-
let bulletMarL = valToPts((/* inlined export .DEF_BULLET_MARGIN */27));
|
|
3214
3739
|
const options = (_textObj_options = textObj.options) !== null && _textObj_options !== void 0 ? _textObj_options : {};
|
|
3215
3740
|
let paragraphPropXml = `<${tag}${options.rtlMode ? ' rtl="1" ' : ''}`;
|
|
3216
3741
|
// A: Build paragraphProperties
|
|
@@ -3235,10 +3760,12 @@ function text_object_spread_props(target, source) {
|
|
|
3235
3760
|
break;
|
|
3236
3761
|
}
|
|
3237
3762
|
}
|
|
3763
|
+
// `a:spcPts` is ST_TextSpacingPoint (0..158400, i.e. 0..1584pt) and `a:spcPct` is
|
|
3764
|
+
// ST_TextSpacingPercent (0..13200000) - out-of-range spacing is a schema violation
|
|
3238
3765
|
if (options.lineSpacing) {
|
|
3239
|
-
strXmlLnSpc = `<a:lnSpc><a:spcPts val="${
|
|
3766
|
+
strXmlLnSpc = `<a:lnSpc><a:spcPts val="${clampInt(options.lineSpacing * 100, 0, 158400)}"/></a:lnSpc>`;
|
|
3240
3767
|
} else if (options.lineSpacingMultiple) {
|
|
3241
|
-
strXmlLnSpc = `<a:lnSpc><a:spcPct val="${
|
|
3768
|
+
strXmlLnSpc = `<a:lnSpc><a:spcPct val="${clampInt(options.lineSpacingMultiple * 100000, 0, 13200000)}"/></a:lnSpc>`;
|
|
3242
3769
|
}
|
|
3243
3770
|
// OPTION: indent
|
|
3244
3771
|
if (options.indentLevel && !isNaN(Number(options.indentLevel)) && options.indentLevel > 0) {
|
|
@@ -3261,28 +3788,28 @@ function text_object_spread_props(target, source) {
|
|
|
3261
3788
|
if (para.hangingPunct === false) paragraphPropXml += ' hangingPunct="0"';
|
|
3262
3789
|
// OPTION: Paragraph Spacing: Before/After
|
|
3263
3790
|
if (options.paraSpaceBefore && !isNaN(Number(options.paraSpaceBefore)) && options.paraSpaceBefore > 0) {
|
|
3264
|
-
strXmlParaSpc += `<a:spcBef><a:spcPts val="${
|
|
3791
|
+
strXmlParaSpc += `<a:spcBef><a:spcPts val="${clampInt(options.paraSpaceBefore * 100, 0, 158400)}"/></a:spcBef>`;
|
|
3265
3792
|
}
|
|
3266
3793
|
if (options.paraSpaceAfter && !isNaN(Number(options.paraSpaceAfter)) && options.paraSpaceAfter > 0) {
|
|
3267
|
-
strXmlParaSpc += `<a:spcAft><a:spcPts val="${
|
|
3794
|
+
strXmlParaSpc += `<a:spcAft><a:spcPts val="${clampInt(options.paraSpaceAfter * 100, 0, 158400)}"/></a:spcAft>`;
|
|
3268
3795
|
}
|
|
3269
3796
|
// OPTION: bullet
|
|
3270
3797
|
// NOTE: OOXML uses the unicode character set for Bullets
|
|
3271
3798
|
// EX: Unicode Character 'BULLET' (U+2022) ==> '<a:buChar char="•"/>'
|
|
3272
3799
|
if (typeof options.bullet === 'object') {
|
|
3273
|
-
var _options_bullet;
|
|
3274
|
-
if ((_options_bullet = options.bullet) === null || _options_bullet === void 0 ? void 0 : _options_bullet.indent) bulletMarL = valToPts(options.bullet.indent);
|
|
3275
3800
|
const buPrefix = genXmlBulletPrefix(options.bullet);
|
|
3276
|
-
const buIndent =
|
|
3801
|
+
const buIndent = genXmlBulletMarginIndent(options);
|
|
3277
3802
|
if (options.bullet.image && options.bullet._imageRId) {
|
|
3278
3803
|
// `a:buBlip` replaces the character or number bullet entirely
|
|
3279
3804
|
paragraphPropXml += buIndent;
|
|
3280
3805
|
strXmlBullet = `${buPrefix}<a:buBlip><a:blip r:embed="rId${options.bullet._imageRId}"/></a:buBlip>`;
|
|
3281
3806
|
} else if (options.bullet.type && options.bullet.type.toString().toLowerCase() === 'number') {
|
|
3807
|
+
var _ref, _options_bullet_numberStartAt;
|
|
3282
3808
|
// NOTE: only `type: 'number'` is a distinct branch; any other `type` (e.g. 'bullet') falls through to the char-bullet cases below (issue #1432)
|
|
3283
3809
|
paragraphPropXml += buIndent;
|
|
3284
3810
|
// auto-numbered bullets fall back to the major latin face when none is given
|
|
3285
|
-
strXmlBullet = `${buPrefix}${options.bullet.fontFace ? '' : '<a:buFont typeface="+mj-lt"/>'}<a:buAutoNum type="${options.bullet.numberType || options.bullet.style || 'arabicPeriod'}" startAt="${
|
|
3811
|
+
strXmlBullet = `${buPrefix}${options.bullet.fontFace ? '' : '<a:buFont typeface="+mj-lt"/>'}<a:buAutoNum type="${options.bullet.numberType || options.bullet.style || 'arabicPeriod'}" startAt="${// ST_TextBulletStartAtNum is 1..32767
|
|
3812
|
+
clampInt(Number((_ref = (_options_bullet_numberStartAt = options.bullet.numberStartAt) !== null && _options_bullet_numberStartAt !== void 0 ? _options_bullet_numberStartAt : options.bullet.startAt) !== null && _ref !== void 0 ? _ref : 1), 1, 32767)}"/>`;
|
|
3286
3813
|
} else if (options.bullet.characterCode) {
|
|
3287
3814
|
let bulletCode = `&#x${options.bullet.characterCode};`;
|
|
3288
3815
|
// Check value for hex-ness (s/b 4 char hex)
|
|
@@ -3307,7 +3834,7 @@ function text_object_spread_props(target, source) {
|
|
|
3307
3834
|
strXmlBullet = `${buPrefix}<a:buChar char="${(/* inlined export .BULLET_TYPES.DEFAULT */"•")}"/>`;
|
|
3308
3835
|
}
|
|
3309
3836
|
} else if (options.bullet) {
|
|
3310
|
-
paragraphPropXml +=
|
|
3837
|
+
paragraphPropXml += genXmlBulletMarginIndent(options);
|
|
3311
3838
|
strXmlBullet = `<a:buSzPct val="100000"/><a:buChar char="${(/* inlined export .BULLET_TYPES.DEFAULT */"•")}"/>`;
|
|
3312
3839
|
} else if (!options.bullet) {
|
|
3313
3840
|
// We only add this when the user explicitely asks for no bullet, otherwise, it can override the master defaults!
|
|
@@ -3338,9 +3865,11 @@ function text_object_spread_props(target, source) {
|
|
|
3338
3865
|
const runPropsTag = isDefault ? 'a:defRPr' : 'a:rPr';
|
|
3339
3866
|
// BEGIN runProperties (ex: `<a:rPr lang="en-US" sz="1600" b="1" dirty="0">`)
|
|
3340
3867
|
runProps += '<' + runPropsTag + ' lang="' + (opts.lang ? opts.lang : 'en-US') + '"' + (opts.lang ? ' altLang="en-US"' : '');
|
|
3341
|
-
runProps += opts.fontSize ? ` sz="${
|
|
3342
|
-
|
|
3343
|
-
|
|
3868
|
+
runProps += opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '';
|
|
3869
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.bold) === false) runProps += ' b="0"';
|
|
3870
|
+
else if (opts === null || opts === void 0 ? void 0 : opts.bold) runProps += ' b="1"';
|
|
3871
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.italic) === false) runProps += ' i="0"';
|
|
3872
|
+
else if (opts === null || opts === void 0 ? void 0 : opts.italic) runProps += ' i="1"';
|
|
3344
3873
|
if ((opts === null || opts === void 0 ? void 0 : opts.strike) === true) warnDeprecatedOnce('strike-boolean', '`strike: true` is deprecated - use `strike: "sngStrike"` (or `"dblStrike"`)');
|
|
3345
3874
|
runProps += (opts === null || opts === void 0 ? void 0 : opts.strike) ? ` strike="${typeof opts.strike === 'string' ? opts.strike : 'sngStrike'}"` : '';
|
|
3346
3875
|
if (typeof opts.underline === 'object' && ((_opts_underline = opts.underline) === null || _opts_underline === void 0 ? void 0 : _opts_underline.style)) {
|
|
@@ -3374,7 +3903,7 @@ function text_object_spread_props(target, source) {
|
|
|
3374
3903
|
// CT_TextCharacterProperties child order: ln, fill, effect, highlight, uLn, uFill, latin, ea, cs, sym
|
|
3375
3904
|
if (opts.color || opts.gradient || opts.fontFace || opts.fontFaceEa || opts.fontFaceCs || opts.fontFaceSym || opts.outline || opts.glow || opts.highlight || run.underlineLine || typeof opts.underline === 'object' && opts.underline.color) {
|
|
3376
3905
|
if (opts.outline && typeof opts.outline === 'object') {
|
|
3377
|
-
runProps += `<a:ln w="${
|
|
3906
|
+
runProps += `<a:ln w="${valToLineWidth(opts.outline.size || 0.75)}">${genXmlColorSelection({
|
|
3378
3907
|
color: opts.outline.color || 'FFFFFF',
|
|
3379
3908
|
transparency: opts.outline.transparency
|
|
3380
3909
|
})}</a:ln>`;
|
|
@@ -3391,7 +3920,11 @@ function text_object_spread_props(target, source) {
|
|
|
3391
3920
|
});
|
|
3392
3921
|
const resolvedGlow = resolveGlowOptions(opts.glow);
|
|
3393
3922
|
if (resolvedGlow) runProps += `<a:effectLst>${createGlowElement(resolvedGlow)}</a:effectLst>`;
|
|
3394
|
-
if (opts.highlight)
|
|
3923
|
+
if (opts.highlight) {
|
|
3924
|
+
const highlightColor = typeof opts.highlight === 'string' ? opts.highlight : opts.highlight.color;
|
|
3925
|
+
const highlightAlpha = typeof opts.highlight === 'object' && opts.highlight.transparency ? `<a:alpha val="${clampAlphaPct(opts.highlight.transparency)}"/>` : '';
|
|
3926
|
+
runProps += `<a:highlight>${createColorElement(highlightColor, highlightAlpha)}</a:highlight>`;
|
|
3927
|
+
}
|
|
3395
3928
|
if (run.underlineLine === 'text') runProps += '<a:uLnTx/>';
|
|
3396
3929
|
else if (run.underlineLine && typeof run.underlineLine === 'object') runProps += genXmlLine(run.underlineLine, 'a:uLn');
|
|
3397
3930
|
if (typeof opts.underline === 'object' && opts.underline.color) runProps += `<a:uFill>${genXmlColorSelection(opts.underline.color)}</a:uFill>`;
|
|
@@ -3717,18 +4250,20 @@ function genXmlTextRun(textObj) {
|
|
|
3717
4250
|
const arrLines = [];
|
|
3718
4251
|
let arrTexts = [];
|
|
3719
4252
|
arrTextObjects.forEach((textObj, idx)=>{
|
|
3720
|
-
var _textObj_options, _textObj_options1, _textObj_options2, _textObj_options3;
|
|
4253
|
+
var _textObj_options, _textObj_options1, _arrTexts__options, _textObj_options2, _textObj_options3;
|
|
3721
4254
|
// OMML-only runs use empty `text` but must still emit content
|
|
3722
4255
|
if (!textObj.text && ((_textObj_options = textObj.options) === null || _textObj_options === void 0 ? void 0 : _textObj_options.omml)) textObj.text = '';
|
|
3723
4256
|
// A: Align or Bullet trigger new line
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
4257
|
+
// Compare explicit run align against the current paragraph's effective align so inline runs
|
|
4258
|
+
// that omit `options.align` (e.g. inline OMML, bold runs, or `softBreakBefore` runs) stay
|
|
4259
|
+
// inside the same `<a:p>` instead of splitting into spurious hard paragraphs.
|
|
4260
|
+
const currAlign = (_textObj_options1 = textObj.options) === null || _textObj_options1 === void 0 ? void 0 : _textObj_options1.align;
|
|
4261
|
+
const paraAlign = arrTexts.length > 0 ? ((_arrTexts__options = arrTexts[0].options) === null || _arrTexts__options === void 0 ? void 0 : _arrTexts__options.align) || opts.align : undefined;
|
|
4262
|
+
if (arrTexts.length > 0 && currAlign && currAlign !== paraAlign) {
|
|
4263
|
+
// Only start a new paragraph when effective align *changes*
|
|
4264
|
+
arrLines.push(arrTexts);
|
|
4265
|
+
arrTexts = [];
|
|
4266
|
+
} else if (arrTexts.length > 0 && ((_textObj_options2 = textObj.options) === null || _textObj_options2 === void 0 ? void 0 : _textObj_options2.bullet)) {
|
|
3732
4267
|
arrLines.push(arrTexts);
|
|
3733
4268
|
arrTexts = [];
|
|
3734
4269
|
if (textObj.options) textObj.options.breakLine = false; // For cases with both `bullet` and `brekaLine` - prevent double lineBreak
|
|
@@ -3797,7 +4332,7 @@ function genXmlTextRun(textObj) {
|
|
|
3797
4332
|
// `glow` / softEdge / reflection belong on the shape effectLst (not per-run), unless set on the run itself
|
|
3798
4333
|
// `omml` is a run-level math payload — inheriting it would replace sibling plain-text runs
|
|
3799
4334
|
if (key === 'glow' || key === 'softEdge' || key === 'reflection' || key === 'shadow' || key === 'blur' || key === 'fillOverlay' || key === 'effectDag' || key === 'omml') return;
|
|
3800
|
-
if (key !== 'bullet' &&
|
|
4335
|
+
if (key !== 'bullet' && textOpts[key] === undefined) textOpts[key] = val;
|
|
3801
4336
|
});
|
|
3802
4337
|
// D: Add formatted textrun
|
|
3803
4338
|
strSlideXml += genXmlTextRun(textObj);
|
|
@@ -3814,17 +4349,17 @@ function genXmlTextRun(textObj) {
|
|
|
3814
4349
|
const ea = opts.fontFaceEa || opts.fontFace;
|
|
3815
4350
|
const cs = opts.fontFaceCs || opts.fontFace;
|
|
3816
4351
|
if (latin || ea || cs) {
|
|
3817
|
-
strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${
|
|
4352
|
+
strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '') + ' dirty="0">';
|
|
3818
4353
|
if (latin) strSlideXml += `<a:latin typeface="${encodeXmlEntities(latin)}" charset="0"/>`;
|
|
3819
4354
|
if (ea) strSlideXml += `<a:ea typeface="${encodeXmlEntities(ea)}" charset="0"/>`;
|
|
3820
4355
|
if (cs) strSlideXml += `<a:cs typeface="${encodeXmlEntities(cs)}" charset="0"/>`;
|
|
3821
4356
|
strSlideXml += '</a:endParaRPr>';
|
|
3822
4357
|
} else {
|
|
3823
|
-
strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${
|
|
4358
|
+
strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '') + ' dirty="0"/>';
|
|
3824
4359
|
}
|
|
3825
4360
|
} else if (reqsClosingFontSize) {
|
|
3826
4361
|
// Empty [lineBreak] lines should not contain runProp, however, they need to specify fontSize in `endParaRPr`
|
|
3827
|
-
strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${
|
|
4362
|
+
strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '') + ' dirty="0"/>';
|
|
3828
4363
|
} else {
|
|
3829
4364
|
strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}" dirty="0"/>`; // Added 20180101 to address PPT-2007 issues
|
|
3830
4365
|
}
|
|
@@ -4140,6 +4675,20 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
4140
4675
|
|
|
4141
4676
|
|
|
4142
4677
|
|
|
4678
|
+
|
|
4679
|
+
function normalizeExtn(extn) {
|
|
4680
|
+
if (!extn || typeof extn !== 'string') return '';
|
|
4681
|
+
return extn.trim().replace(/^\./, '').toLowerCase();
|
|
4682
|
+
}
|
|
4683
|
+
function extractPathExtn(rawPath) {
|
|
4684
|
+
if (!rawPath) return 'png';
|
|
4685
|
+
const cleanPath = rawPath.split('?')[0].split('#')[0];
|
|
4686
|
+
const fileName = cleanPath.substring(Math.max(cleanPath.lastIndexOf('/'), cleanPath.lastIndexOf('\\')) + 1);
|
|
4687
|
+
const dotIdx = fileName.lastIndexOf('.');
|
|
4688
|
+
if (dotIdx <= 0 || dotIdx === fileName.length - 1) return 'png';
|
|
4689
|
+
const candidate = fileName.substring(dotIdx + 1).toLowerCase();
|
|
4690
|
+
return /^[a-z0-9]{1,8}$/.test(candidate) ? candidate : 'png';
|
|
4691
|
+
}
|
|
4143
4692
|
/** Valid OOXML preset-geometry strings (the values of `SHAPE_TYPE`) - anything else corrupts the file. */ const VALID_SHAPE_PRESETS = new Set(Object.values(core_enums_SHAPE_TYPE));
|
|
4144
4693
|
/** Type guard: true when `arr` is a flat (1-level) array rather than a nested one. */ function isFlatStringArray(arr) {
|
|
4145
4694
|
return Array.isArray(arr) && (arr.length === 0 || !Array.isArray(arr[0]));
|
|
@@ -4477,10 +5026,11 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
4477
5026
|
const v3DPerspective = options.v3DPerspective;
|
|
4478
5027
|
options.v3DPerspective = v3DPerspective !== undefined && !isNaN(v3DPerspective) && v3DPerspective >= 0 && v3DPerspective <= 240 ? v3DPerspective : 30;
|
|
4479
5028
|
// D: Options: chart
|
|
5029
|
+
// `c:gapWidth`/`c:gapDepth` are ST_GapAmount (0..500); clamp finite values to 0..500
|
|
4480
5030
|
const barGapWidthPct = options.barGapWidthPct;
|
|
4481
|
-
options.barGapWidthPct = barGapWidthPct
|
|
5031
|
+
options.barGapWidthPct = typeof barGapWidthPct === 'number' && Number.isFinite(barGapWidthPct) ? clampInt(barGapWidthPct, 0, 500) : 150;
|
|
4482
5032
|
const barGapDepthPct = options.barGapDepthPct;
|
|
4483
|
-
options.barGapDepthPct = barGapDepthPct
|
|
5033
|
+
options.barGapDepthPct = typeof barGapDepthPct === 'number' && Number.isFinite(barGapDepthPct) ? clampInt(barGapDepthPct, 0, 500) : 150;
|
|
4484
5034
|
options.chartColors = Array.isArray(options.chartColors) ? options.chartColors : options._type === core_enums_CHART_TYPE.PIE || options._type === core_enums_CHART_TYPE.DOUGHNUT ? PIECHART_COLORS : BARCHART_COLORS;
|
|
4485
5035
|
options.chartColorsOpacity = options.chartColorsOpacity && !isNaN(options.chartColorsOpacity) ? options.chartColorsOpacity : undefined;
|
|
4486
5036
|
// DEPRECATED: v3.11.0 - use `plotArea.border` vvv
|
|
@@ -4692,14 +5242,14 @@ function isSvgFillSource(data, path) {
|
|
|
4692
5242
|
});
|
|
4693
5243
|
return svgRid;
|
|
4694
5244
|
}
|
|
4695
|
-
let extn = (path
|
|
5245
|
+
let extn = extractPathExtn(path);
|
|
4696
5246
|
const mime = data ? /image\/([\w+]+);/.exec(data) : null;
|
|
4697
|
-
if (mime === null || mime === void 0 ? void 0 : mime[1]) extn = mime[1] === 'svg+xml' ? 'svg' : mime[1];
|
|
5247
|
+
if (mime === null || mime === void 0 ? void 0 : mime[1]) extn = mime[1].toLowerCase() === 'svg+xml' ? 'svg' : mime[1].toLowerCase();
|
|
4698
5248
|
if (extn === 'jpg') extn = 'jpeg';
|
|
4699
5249
|
const imgType = 'image/' + extn;
|
|
4700
5250
|
const dupeItem = target._relsMedia.filter((item)=>item.type === imgType && !item.isDuplicate && !item.isSvgPng && (path && item.path === path || data && item.data && item.data === data))[0];
|
|
4701
5251
|
const rId = getNewRelId(target);
|
|
4702
|
-
|
|
5252
|
+
const mediaRel = {
|
|
4703
5253
|
path: path || 'preencoded.' + extn,
|
|
4704
5254
|
type: imgType,
|
|
4705
5255
|
extn,
|
|
@@ -4707,7 +5257,9 @@ function isSvgFillSource(data, path) {
|
|
|
4707
5257
|
rId,
|
|
4708
5258
|
isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
|
|
4709
5259
|
Target: (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/${imageTargetStem(target)}.${extn}`
|
|
4710
|
-
}
|
|
5260
|
+
};
|
|
5261
|
+
dedupeImageMediaRel(target, mediaRel);
|
|
5262
|
+
target._relsMedia.push(mediaRel);
|
|
4711
5263
|
return rId;
|
|
4712
5264
|
}
|
|
4713
5265
|
function isStructuredImageFill(fill) {
|
|
@@ -4747,7 +5299,7 @@ function resolveObjectImageFills(target, options) {
|
|
|
4747
5299
|
if ((_options_fillOverlay = options.fillOverlay) === null || _options_fillOverlay === void 0 ? void 0 : _options_fillOverlay.fill) resolveImageFill(target, options.fillOverlay.fill);
|
|
4748
5300
|
}
|
|
4749
5301
|
function addImageDefinition(target, opt) {
|
|
4750
|
-
var _opt_fillOverlay
|
|
5302
|
+
var _opt_fillOverlay;
|
|
4751
5303
|
if ((_opt_fillOverlay = opt.fillOverlay) === null || _opt_fillOverlay === void 0 ? void 0 : _opt_fillOverlay.fill) resolveImageFill(target, opt.fillOverlay.fill);
|
|
4752
5304
|
const newObject = {
|
|
4753
5305
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"),
|
|
@@ -4783,14 +5335,17 @@ function addImageDefinition(target, opt) {
|
|
|
4783
5335
|
return;
|
|
4784
5336
|
}
|
|
4785
5337
|
// STEP 1: Set extension
|
|
4786
|
-
//
|
|
4787
|
-
|
|
5338
|
+
// Honor explicit `opt.extn` (for extensionless signed CDN URLs); otherwise parse from path safely.
|
|
5339
|
+
const explicitExtn = normalizeExtn(opt.extn);
|
|
5340
|
+
let strImgExtn = explicitExtn || extractPathExtn(strImagePath);
|
|
4788
5341
|
// However, pre-encoded images can be whatever mime-type they want (and good for them!)
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
5342
|
+
if (!explicitExtn) {
|
|
5343
|
+
const strImageMimeMatch = strImageData ? /image\/(\w+);/.exec(strImageData) : null;
|
|
5344
|
+
if (strImageMimeMatch && strImageMimeMatch.length > 0) {
|
|
5345
|
+
strImgExtn = strImageMimeMatch[1].toLowerCase();
|
|
5346
|
+
} else if (strImageData === null || strImageData === void 0 ? void 0 : strImageData.toLowerCase().includes('image/svg+xml')) {
|
|
5347
|
+
strImgExtn = 'svg';
|
|
5348
|
+
}
|
|
4794
5349
|
}
|
|
4795
5350
|
// STEP 2: Set type/path
|
|
4796
5351
|
newObject._type = (/* inlined export .SLIDE_OBJECT_TYPES.image */"image");
|
|
@@ -4882,10 +5437,10 @@ function addImageDefinition(target, opt) {
|
|
|
4882
5437
|
} else {
|
|
4883
5438
|
// PERF: Duplicate media should reuse existing `Target` value and not create an additional copy.
|
|
4884
5439
|
// OPC (ECMA-376 Part 2) lets many relationships point at one part, so identical image bytes are stored once.
|
|
4885
|
-
// Match on the source path
|
|
4886
|
-
const imgType = 'image/' + strImgExtn;
|
|
5440
|
+
// Match on the source path within slide, and across the entire deck on identical base64 content hash.
|
|
5441
|
+
const imgType = strImgExtn === 'jpg' ? 'image/jpeg' : 'image/' + strImgExtn;
|
|
4887
5442
|
const dupeItem = target._relsMedia.filter((item)=>item.type === imgType && !item.isDuplicate && !item.isSvgPng && (strImagePath && item.path === strImagePath || strImageData && item.data && item.data === strImageData))[0];
|
|
4888
|
-
|
|
5443
|
+
const mediaRel = {
|
|
4889
5444
|
path: strImagePath || 'preencoded.' + strImgExtn,
|
|
4890
5445
|
type: imgType,
|
|
4891
5446
|
extn: strImgExtn,
|
|
@@ -4893,7 +5448,9 @@ function addImageDefinition(target, opt) {
|
|
|
4893
5448
|
rId: imageRelId,
|
|
4894
5449
|
isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
|
|
4895
5450
|
Target: (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/${imageTargetStem(target)}.${strImgExtn}`
|
|
4896
|
-
}
|
|
5451
|
+
};
|
|
5452
|
+
dedupeImageMediaRel(target, mediaRel);
|
|
5453
|
+
target._relsMedia.push(mediaRel);
|
|
4897
5454
|
newObject.imageRid = imageRelId;
|
|
4898
5455
|
}
|
|
4899
5456
|
// STEP 5: Hyperlink support
|
|
@@ -5428,8 +5985,10 @@ function nextExtPartName(target, prefix, extn) {
|
|
|
5428
5985
|
bullet._imageRId = rId;
|
|
5429
5986
|
}
|
|
5430
5987
|
function addShapeDefinition(target, shapeName, opts) {
|
|
5988
|
+
var _options_styleRef;
|
|
5431
5989
|
const options = typeof opts === 'object' ? opts : {};
|
|
5432
|
-
|
|
5990
|
+
// With a theme `lnRef` and no explicit line, omit `<a:ln>` so the stroke inherits from the theme (matches `styleRef.fill` in slide.ts)
|
|
5991
|
+
if (!options.line && !((_options_styleRef = options.styleRef) === null || _options_styleRef === void 0 ? void 0 : _options_styleRef.line)) options.line = {
|
|
5433
5992
|
type: 'none'
|
|
5434
5993
|
};
|
|
5435
5994
|
resolveHyperlinkRels(target, options.hyperlink);
|
|
@@ -5450,28 +6009,29 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
5450
6009
|
throw new Error(`Invalid shape "${shapeName}" - use a \`pptxgen.ShapeType\` value (ex: \`pptxgen.ShapeType.oval\` = 'ellipse')`);
|
|
5451
6010
|
}
|
|
5452
6011
|
// 1: ShapeLineProps defaults
|
|
5453
|
-
const
|
|
5454
|
-
const
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
6012
|
+
const lineSrc = typeof options.line === 'object' && options.line !== null ? options.line : {};
|
|
6013
|
+
const hasConnectorEnds = lineSrc.sourceId != null || lineSrc.targetId != null;
|
|
6014
|
+
const newLineOpts = gen_objects_object_spread_props(gen_objects_object_spread({}, lineSrc), {
|
|
6015
|
+
type: lineSrc.type || (lineSrc.gradient ? 'gradient' : 'solid'),
|
|
6016
|
+
color: lineSrc.color || (/* inlined export .DEF_SHAPE_LINE_COLOR */"333333"),
|
|
6017
|
+
transparency: lineSrc.transparency || 0,
|
|
6018
|
+
gradient: lineSrc.gradient,
|
|
6019
|
+
width: lineSrc.width || 1,
|
|
6020
|
+
dashType: lineSrc.dashType || 'solid',
|
|
6021
|
+
cap: lineSrc.cap,
|
|
6022
|
+
beginArrowType: lineSrc.beginArrowType || undefined,
|
|
6023
|
+
endArrowType: lineSrc.endArrowType || undefined,
|
|
5464
6024
|
// ZentoSoft connectors
|
|
5465
|
-
sourceId:
|
|
5466
|
-
targetId:
|
|
5467
|
-
sourceAnchorPos:
|
|
5468
|
-
targetAnchorPos:
|
|
5469
|
-
isConnector:
|
|
5470
|
-
curveadjust:
|
|
5471
|
-
_sourceName:
|
|
5472
|
-
_targetName:
|
|
6025
|
+
sourceId: lineSrc.sourceId,
|
|
6026
|
+
targetId: lineSrc.targetId,
|
|
6027
|
+
sourceAnchorPos: lineSrc.sourceAnchorPos,
|
|
6028
|
+
targetAnchorPos: lineSrc.targetAnchorPos,
|
|
6029
|
+
isConnector: lineSrc.isConnector || hasConnectorEnds,
|
|
6030
|
+
curveadjust: lineSrc.curveadjust,
|
|
6031
|
+
_sourceName: lineSrc._sourceName,
|
|
6032
|
+
_targetName: lineSrc._targetName
|
|
5473
6033
|
});
|
|
5474
|
-
if (typeof options.line === 'object' && options.line.type !== 'none') options.line = newLineOpts;
|
|
6034
|
+
if (typeof options.line === 'object' && options.line !== null && options.line.type !== 'none') options.line = newLineOpts;
|
|
5475
6035
|
// 2: Set options defaults
|
|
5476
6036
|
const shapeOpts = options;
|
|
5477
6037
|
shapeOpts._explicitX = options.x !== undefined && options.x !== null;
|
|
@@ -5500,11 +6060,35 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
5500
6060
|
* @param {Function} addSlide - method
|
|
5501
6061
|
* @param {Function} getSlide - method
|
|
5502
6062
|
*/ function addTableDefinition(target, tableRows, options, slideLayout, presLayout, addSlide, getSlide) {
|
|
6063
|
+
var _ref;
|
|
6064
|
+
var _target__slideLayout;
|
|
5503
6065
|
const slides = [
|
|
5504
6066
|
target
|
|
5505
6067
|
] // Create array of Slides as more may be added by auto-paging
|
|
5506
6068
|
;
|
|
5507
|
-
|
|
6069
|
+
let opt = options && typeof options === 'object' ? gen_objects_object_spread({}, options) : {};
|
|
6070
|
+
const explicitX = opt.x !== undefined && opt.x !== null;
|
|
6071
|
+
const explicitY = opt.y !== undefined && opt.y !== null;
|
|
6072
|
+
const explicitW = opt.w !== undefined && opt.w !== null;
|
|
6073
|
+
const explicitH = opt.h !== undefined && opt.h !== null;
|
|
6074
|
+
// PR #1151: resolve layout placeholder defaults under caller options so caller overrides placeholder defaults
|
|
6075
|
+
const layoutObjs = (_ref = (_target__slideLayout = target._slideLayout) === null || _target__slideLayout === void 0 ? void 0 : _target__slideLayout._slideObjects) !== null && _ref !== void 0 ? _ref : slideLayout === null || slideLayout === void 0 ? void 0 : slideLayout._slideObjects;
|
|
6076
|
+
if (opt.placeholder && layoutObjs) {
|
|
6077
|
+
const placeHold = layoutObjs.find((item)=>{
|
|
6078
|
+
var _item_options;
|
|
6079
|
+
return item._type === (/* inlined export .SLIDE_OBJECT_TYPES.placeholder */"placeholder") && ((_item_options = item.options) === null || _item_options === void 0 ? void 0 : _item_options.placeholder) === opt.placeholder;
|
|
6080
|
+
});
|
|
6081
|
+
if (placeHold === null || placeHold === void 0 ? void 0 : placeHold.options) {
|
|
6082
|
+
const _placeHold_options = placeHold.options, { _bodyProp: _bp, line: _ln, objectName: _on, sId: _sId, shape: _sh } = _placeHold_options, placeHoldOpts = _object_without_properties(_placeHold_options, [
|
|
6083
|
+
"_bodyProp",
|
|
6084
|
+
"line",
|
|
6085
|
+
"objectName",
|
|
6086
|
+
"sId",
|
|
6087
|
+
"shape"
|
|
6088
|
+
]);
|
|
6089
|
+
opt = gen_objects_object_spread({}, placeHoldOpts, opt);
|
|
6090
|
+
}
|
|
6091
|
+
}
|
|
5508
6092
|
opt.objectName = opt.objectName ? encodeXmlEntities(opt.objectName) : `Table ${target._slideObjects.filter((obj)=>obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.table */"table")).length}`;
|
|
5509
6093
|
// STEP 1: REALITY-CHECK
|
|
5510
6094
|
{
|
|
@@ -5533,21 +6117,40 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
5533
6117
|
if (Array.isArray(row)) {
|
|
5534
6118
|
row.forEach((cell)=>{
|
|
5535
6119
|
var _newCell_options;
|
|
5536
|
-
// A:
|
|
6120
|
+
// A: Clone cell options so caller-supplied objects are never mutated (PR #1553)
|
|
5537
6121
|
const newCell = {
|
|
5538
6122
|
_type: (/* inlined export .SLIDE_OBJECT_TYPES.tablecell */"tablecell"),
|
|
5539
6123
|
text: '',
|
|
5540
|
-
options: typeof cell === 'object' && cell.options ? cell.options : {}
|
|
6124
|
+
options: typeof cell === 'object' && cell !== null && cell.options && typeof cell.options === 'object' ? gen_objects_object_spread({}, cell.options) : {}
|
|
5541
6125
|
};
|
|
5542
6126
|
// B:
|
|
5543
6127
|
if (typeof cell === 'string' || typeof cell === 'number') newCell.text = cell.toString();
|
|
5544
|
-
else if (cell.text) {
|
|
6128
|
+
else if (cell && typeof cell === 'object' && cell.text !== undefined && cell.text !== null) {
|
|
5545
6129
|
// Cell can contain complex text type, or string, or number
|
|
5546
6130
|
if (typeof cell.text === 'string' || typeof cell.text === 'number') newCell.text = cell.text.toString();
|
|
5547
|
-
else if (cell.text)
|
|
5548
|
-
|
|
5549
|
-
|
|
6131
|
+
else if (Array.isArray(cell.text)) {
|
|
6132
|
+
var _newCell_options1;
|
|
6133
|
+
// Clone runs and their options so caller objects are never mutated; inherit lang without overwriting explicit run lang
|
|
6134
|
+
const inheritedLang = ((_newCell_options1 = newCell.options) === null || _newCell_options1 === void 0 ? void 0 : _newCell_options1.lang) || opt.lang;
|
|
6135
|
+
newCell.text = cell.text.map((run)=>{
|
|
6136
|
+
if (!run || typeof run !== 'object') return run;
|
|
6137
|
+
const runOpts = run.options && typeof run.options === 'object' ? gen_objects_object_spread({}, run.options) : undefined;
|
|
6138
|
+
if (inheritedLang && !(runOpts === null || runOpts === void 0 ? void 0 : runOpts.lang)) {
|
|
6139
|
+
return gen_objects_object_spread_props(gen_objects_object_spread({}, run), {
|
|
6140
|
+
options: gen_objects_object_spread_props(gen_objects_object_spread({}, runOpts), {
|
|
6141
|
+
lang: inheritedLang
|
|
6142
|
+
})
|
|
6143
|
+
});
|
|
6144
|
+
}
|
|
6145
|
+
return gen_objects_object_spread_props(gen_objects_object_spread({}, run), {
|
|
6146
|
+
options: runOpts
|
|
6147
|
+
});
|
|
6148
|
+
});
|
|
6149
|
+
} else {
|
|
6150
|
+
newCell.text = cell.text;
|
|
6151
|
+
}
|
|
5550
6152
|
}
|
|
6153
|
+
if (opt.lang && newCell.options && !newCell.options.lang) newCell.options.lang = opt.lang;
|
|
5551
6154
|
// C: Set cell borders
|
|
5552
6155
|
const cellOpts = (_newCell_options = newCell.options) !== null && _newCell_options !== void 0 ? _newCell_options : {};
|
|
5553
6156
|
newCell.options = cellOpts;
|
|
@@ -5566,12 +6169,15 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
5566
6169
|
}
|
|
5567
6170
|
];
|
|
5568
6171
|
// CASE 1: border interface is: BorderOptions | [BorderOptions, BorderOptions, BorderOptions, BorderOptions]
|
|
6172
|
+
// Defensively shallow-copy caller border arrays so we never mutate them in place (PR #1541)
|
|
5569
6173
|
const cellBorder = !Array.isArray(initialBorder) && typeof initialBorder === 'object' ? [
|
|
5570
6174
|
initialBorder,
|
|
5571
6175
|
initialBorder,
|
|
5572
6176
|
initialBorder,
|
|
5573
6177
|
initialBorder
|
|
5574
|
-
] :
|
|
6178
|
+
] : [
|
|
6179
|
+
...initialBorder
|
|
6180
|
+
];
|
|
5575
6181
|
cellOpts.border = cellBorder;
|
|
5576
6182
|
// Handle: [null, null, {type:'solid'}, null]
|
|
5577
6183
|
if (!cellBorder[0]) cellBorder[0] = {
|
|
@@ -5620,10 +6226,10 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
5620
6226
|
});
|
|
5621
6227
|
// STEP 3: Set options
|
|
5622
6228
|
const tableOpts = opt;
|
|
5623
|
-
tableOpts._explicitX =
|
|
5624
|
-
tableOpts._explicitY =
|
|
5625
|
-
tableOpts._explicitW =
|
|
5626
|
-
tableOpts._explicitH =
|
|
6229
|
+
tableOpts._explicitX = explicitX;
|
|
6230
|
+
tableOpts._explicitY = explicitY;
|
|
6231
|
+
tableOpts._explicitW = explicitW;
|
|
6232
|
+
tableOpts._explicitH = explicitH;
|
|
5627
6233
|
opt.x = getSmartParseNumber(opt.x || (opt.x === 0 ? 0 : (/* inlined export .EMU */914400) / 2), 'X', presLayout);
|
|
5628
6234
|
opt.y = getSmartParseNumber(opt.y || (opt.y === 0 ? 0 : (/* inlined export .EMU */914400) / 2), 'Y', presLayout);
|
|
5629
6235
|
if (opt.h) opt.h = getSmartParseNumber(opt.h, 'Y', presLayout); // NOTE: Dont set default `h` - leaving it null triggers auto-rowH in `makeXMLSlide()`
|
|
@@ -5645,7 +6251,9 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
5645
6251
|
console.warn('addTable `border` option must be an object. Ex: `{border: {type:\'none\'}}`');
|
|
5646
6252
|
opt.border = undefined;
|
|
5647
6253
|
} else if (Array.isArray(opt.border)) {
|
|
5648
|
-
const optBorder =
|
|
6254
|
+
const optBorder = [
|
|
6255
|
+
...opt.border
|
|
6256
|
+
];
|
|
5649
6257
|
[
|
|
5650
6258
|
0,
|
|
5651
6259
|
1,
|
|
@@ -5662,6 +6270,7 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
5662
6270
|
type: 'none'
|
|
5663
6271
|
};
|
|
5664
6272
|
});
|
|
6273
|
+
opt.border = optBorder;
|
|
5665
6274
|
}
|
|
5666
6275
|
opt.autoPage = typeof opt.autoPage === 'boolean' ? opt.autoPage : false;
|
|
5667
6276
|
opt.autoPageRepeatHeader = typeof opt.autoPageRepeatHeader === 'boolean' ? opt.autoPageRepeatHeader : false;
|
|
@@ -6008,21 +6617,29 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
6008
6617
|
// B: Handle media
|
|
6009
6618
|
if (props && (props.path || props.data)) {
|
|
6010
6619
|
// Allow the use of only the data key (`path` isnt reqd)
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
;
|
|
6014
|
-
if (
|
|
6620
|
+
const explicitExtn = normalizeExtn(props.extn);
|
|
6621
|
+
props.path = props.path || `preencoded.${explicitExtn || 'png'}`;
|
|
6622
|
+
let strImgExtn = explicitExtn || extractPathExtn(props.path);
|
|
6623
|
+
if (!explicitExtn && props.data) {
|
|
6624
|
+
const bkgdMimeMatch = /image\/([\w+]+);/.exec(props.data);
|
|
6625
|
+
if (bkgdMimeMatch === null || bkgdMimeMatch === void 0 ? void 0 : bkgdMimeMatch[1]) {
|
|
6626
|
+
strImgExtn = bkgdMimeMatch[1].toLowerCase() === 'svg+xml' ? 'svg' : bkgdMimeMatch[1].toLowerCase();
|
|
6627
|
+
}
|
|
6628
|
+
}
|
|
6629
|
+
if (strImgExtn === 'jpg') strImgExtn = 'jpeg'; // base64-encoded jpg's come out as "data:image/jpeg;base64,/9j/[...]", so correct extension to avoid content warnings at PPT startup
|
|
6015
6630
|
target._relsMedia = target._relsMedia || [];
|
|
6016
6631
|
const intRels = target._relsMedia.length + 1;
|
|
6017
6632
|
// NOTE: `Target` cannot have spaces (eg:"Slide 1-image-1.jpg") or a "presentation is corrupt" warning comes up
|
|
6018
|
-
|
|
6633
|
+
const bkgdRel = {
|
|
6019
6634
|
path: props.path,
|
|
6020
6635
|
type: (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"),
|
|
6021
6636
|
extn: strImgExtn,
|
|
6022
6637
|
data: props.data || undefined,
|
|
6023
6638
|
rId: intRels,
|
|
6024
6639
|
Target: `../media/${(target._name || '').replace(/\s+/gi, '-')}-image-${target._relsMedia.length + 1}.${strImgExtn}`
|
|
6025
|
-
}
|
|
6640
|
+
};
|
|
6641
|
+
dedupeImageMediaRel(target, bkgdRel);
|
|
6642
|
+
target._relsMedia.push(bkgdRel);
|
|
6026
6643
|
target._bkgdImgRid = intRels;
|
|
6027
6644
|
}
|
|
6028
6645
|
}
|
|
@@ -6039,8 +6656,14 @@ function addShapeDefinition(target, shapeName, opts) {
|
|
|
6039
6656
|
text
|
|
6040
6657
|
];
|
|
6041
6658
|
textObjs.forEach((text, idx)=>{
|
|
6042
|
-
// IMPORTANT: `options` are lost due to recursion/copy!
|
|
6043
|
-
if (!Array.isArray(text) && options && options[idx] && options[idx].hyperlink)
|
|
6659
|
+
// IMPORTANT: `options` are lost due to recursion/copy! Preserve explicit run `lang` over cell `lang` (PR #1553).
|
|
6660
|
+
if (!Array.isArray(text) && options && options[idx] && options[idx].hyperlink) {
|
|
6661
|
+
var _text_options;
|
|
6662
|
+
const preservedLang = ((_text_options = text.options) === null || _text_options === void 0 ? void 0 : _text_options.lang) || options[idx].lang;
|
|
6663
|
+
text.options = gen_objects_object_spread({}, text.options, options[idx], preservedLang ? {
|
|
6664
|
+
lang: preservedLang
|
|
6665
|
+
} : {});
|
|
6666
|
+
}
|
|
6044
6667
|
// NOTE: `text` can be an array of other `text` objects (table cell word-level formatting), continue parsing using recursion
|
|
6045
6668
|
if (Array.isArray(text)) {
|
|
6046
6669
|
const cellOpts = [];
|
|
@@ -6707,11 +7330,11 @@ function createShadowElement(shadow) {
|
|
|
6707
7330
|
}
|
|
6708
7331
|
let strXml = '<a:effectLst>';
|
|
6709
7332
|
const type = shadow.type;
|
|
6710
|
-
const blur = valToPts(shadow.blur);
|
|
6711
|
-
const offset = valToPts(shadow.offset);
|
|
7333
|
+
const blur = Math.max(0, valToPts(shadow.blur));
|
|
7334
|
+
const offset = Math.max(0, valToPts(shadow.offset));
|
|
6712
7335
|
const angle = Math.round(shadow.angle * 60000);
|
|
6713
7336
|
const color = shadow.color;
|
|
6714
|
-
const opacity =
|
|
7337
|
+
const opacity = clampAlphaPct(100 - shadow.opacity * 100);
|
|
6715
7338
|
const rotShape = shadow.rotateWithShape ? 1 : 0;
|
|
6716
7339
|
strXml += `<a:${type}Shdw sx="100000" sy="100000" kx="0" ky="0" algn="bl" blurRad="${blur}" rotWithShape="${rotShape}" dist="${offset}" dir="${angle}">`;
|
|
6717
7340
|
strXml += `<a:srgbClr val="${color}">`;
|
|
@@ -6727,7 +7350,7 @@ function createShadowElement(shadow) {
|
|
|
6727
7350
|
*/ function createGridLineElement(glOpts) {
|
|
6728
7351
|
let strXml = '<c:majorGridlines>';
|
|
6729
7352
|
strXml += ' <c:spPr>';
|
|
6730
|
-
strXml += ` <a:ln w="${
|
|
7353
|
+
strXml += ` <a:ln w="${valToLineWidth(glOpts.size || DEF_CHART_GRIDLINE.size)}" cap="${createLineCap(glOpts.cap || DEF_CHART_GRIDLINE.cap)}">`;
|
|
6731
7354
|
strXml += ` <a:solidFill>${createColorElement(glOpts.color || DEF_CHART_GRIDLINE.color)}</a:solidFill>`;
|
|
6732
7355
|
strXml += ' <a:prstDash val="' + (glOpts.style || DEF_CHART_GRIDLINE.style) + '"/><a:round/>';
|
|
6733
7356
|
strXml += ' </a:ln>';
|
|
@@ -6765,7 +7388,7 @@ function createLineCap(lineCap) {
|
|
|
6765
7388
|
if (chartDash && CHART_LINE_DASH_TYPES.includes(chartDash)) return chartDash;
|
|
6766
7389
|
return 'solid';
|
|
6767
7390
|
}
|
|
6768
|
-
/** Area charts use `c:grouping` / ST_Grouping (standard|stacked|percentStacked), not ST_BarGrouping. */ const AREA_GROUPING = [
|
|
7391
|
+
/** Area and line charts use `c:grouping` / ST_Grouping (standard|stacked|percentStacked), not ST_BarGrouping. */ const AREA_GROUPING = [
|
|
6769
7392
|
'standard',
|
|
6770
7393
|
'stacked',
|
|
6771
7394
|
'percentStacked'
|
|
@@ -6843,7 +7466,7 @@ function firstLabelLevel(data) {
|
|
|
6843
7466
|
// `outEnd` is invalid on the layouts that draw labels inside their segments
|
|
6844
7467
|
const defaultPos = chartType === 'treemap' || chartType === 'sunburst' || chartType === 'funnel' ? 'ctr' : 'outEnd';
|
|
6845
7468
|
const pos = (_opts_dataLabelPosition = opts.dataLabelPosition) !== null && _opts_dataLabelPosition !== void 0 ? _opts_dataLabelPosition : defaultPos;
|
|
6846
|
-
const size =
|
|
7469
|
+
const size = fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12));
|
|
6847
7470
|
const txPr = '<cx:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>' + `<a:defRPr sz="${size}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}">` + `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>` + `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace || 'Arial')}"/>` + '</a:defRPr></a:pPr></a:p></cx:txPr>';
|
|
6848
7471
|
const numFmt = opts.dataLabelFormatCode ? `<cx:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode)}" sourceLinked="0"/>` : '';
|
|
6849
7472
|
return `<cx:dataLabels pos="${pos}">` + `<cx:visibility seriesName="0" categoryName="${showCategory ? 1 : 0}" value="${showValue ? 1 : 0}"/>` + numFmt + txPr + '</cx:dataLabels>';
|
|
@@ -6906,7 +7529,7 @@ function firstLabelLevel(data) {
|
|
|
6906
7529
|
}
|
|
6907
7530
|
function makeTitle(opts) {
|
|
6908
7531
|
if (!opts.showTitle) return '';
|
|
6909
|
-
const size =
|
|
7532
|
+
const size = fontSizeToSz(opts.titleFontSize || (/* inlined export .DEF_FONT_TITLE_SIZE */18));
|
|
6910
7533
|
const color = opts.titleColor ? `<a:solidFill>${createColorElement(opts.titleColor)}</a:solidFill>` : '';
|
|
6911
7534
|
const face = opts.titleFontFace ? `<a:latin typeface="${encodeXmlEntities(opts.titleFontFace)}"/>` : '';
|
|
6912
7535
|
return '<cx:title pos="t" align="ctr" overlay="0"><cx:tx><cx:rich><a:bodyPr/><a:lstStyle/><a:p><a:pPr algn="ctr"/><a:r>' + `<a:rPr lang="${opts.lang || 'en-US'}" sz="${size}" b="${opts.titleBold ? 1 : 0}">${color}${face}</a:rPr>` + `<a:t>${encodeXmlEntities(opts.title || 'Chart Title')}</a:t>` + '</a:r></a:p></cx:rich></cx:tx></cx:title>';
|
|
@@ -7025,7 +7648,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
|
|
|
7025
7648
|
const align = opts.titleAlign === 'left' || opts.titleAlign === 'right' ? `<a:pPr algn="${opts.titleAlign.substring(0, 1)}">` : '<a:pPr>';
|
|
7026
7649
|
const rotate = opts.titleRotate ? `<a:bodyPr rot="${convertRotationDegrees(opts.titleRotate)}"/>` : '<a:bodyPr/>' // don't specify rotation to get default (ex. vertical for cat axis)
|
|
7027
7650
|
;
|
|
7028
|
-
const sizeAttr = opts.fontSize ? `sz="${
|
|
7651
|
+
const sizeAttr = opts.fontSize ? `sz="${fontSizeToSz(opts.fontSize)}"` : '' // only set the font size if specified. Powerpoint will handle the default size
|
|
7029
7652
|
;
|
|
7030
7653
|
const titleBold = opts.titleBold ? 1 : 0;
|
|
7031
7654
|
const titleItalic = opts.titleItalic ? 1 : 0;
|
|
@@ -7132,7 +7755,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
|
|
|
7132
7755
|
strXml += ' <c:tickLblPos val="' + (opts.catAxisLabelPos || (opts.barDir === 'col' ? 'low' : 'nextTo')) + '"/>';
|
|
7133
7756
|
}
|
|
7134
7757
|
strXml += ' <c:spPr>';
|
|
7135
|
-
strXml += ` <a:ln w="${opts.catAxisLineSize ?
|
|
7758
|
+
strXml += ` <a:ln w="${opts.catAxisLineSize ? valToLineWidth(opts.catAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
|
|
7136
7759
|
strXml += !opts.catAxisLineShow ? '<a:noFill/>' : '<a:solidFill>' + createColorElement(opts.catAxisLineColor || DEF_CHART_GRIDLINE.color) + '</a:solidFill>';
|
|
7137
7760
|
strXml += ' <a:prstDash val="' + (opts.catAxisLineStyle || 'solid') + '"/>';
|
|
7138
7761
|
strXml += ' <a:round/>';
|
|
@@ -7148,7 +7771,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
|
|
|
7148
7771
|
strXml += ' <a:lstStyle/>';
|
|
7149
7772
|
strXml += ' <a:p>';
|
|
7150
7773
|
strXml += ' <a:pPr>';
|
|
7151
|
-
strXml += ` <a:defRPr sz="${
|
|
7774
|
+
strXml += ` <a:defRPr sz="${fontSizeToSz(opts.catAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.catAxisLabelFontBold ? 1 : 0}" i="${opts.catAxisLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">`;
|
|
7152
7775
|
strXml += ' <a:solidFill>' + createColorElement(opts.catAxisLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
|
|
7153
7776
|
strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.catAxisLabelFontFace) || 'Arial') + '"/>';
|
|
7154
7777
|
strXml += ' <a:ea typeface="' + (encodeXmlEntities(opts.catAxisLabelFontFace) || 'Arial') + '"/>';
|
|
@@ -7242,7 +7865,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
|
|
|
7242
7865
|
strXml += ' <c:tickLblPos val="' + (opts.valAxisLabelPos || (opts.barDir === 'col' ? 'nextTo' : 'low')) + '"/>';
|
|
7243
7866
|
}
|
|
7244
7867
|
strXml += ' <c:spPr>';
|
|
7245
|
-
strXml += ` <a:ln w="${opts.valAxisLineSize ?
|
|
7868
|
+
strXml += ` <a:ln w="${opts.valAxisLineSize ? valToLineWidth(opts.valAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
|
|
7246
7869
|
strXml += !opts.valAxisLineShow ? '<a:noFill/>' : '<a:solidFill>' + createColorElement(opts.valAxisLineColor || DEF_CHART_GRIDLINE.color) + '</a:solidFill>';
|
|
7247
7870
|
strXml += ' <a:prstDash val="' + (opts.valAxisLineStyle || 'solid') + '"/>';
|
|
7248
7871
|
strXml += ' <a:round/>';
|
|
@@ -7253,7 +7876,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
|
|
|
7253
7876
|
strXml += ' <a:lstStyle/>';
|
|
7254
7877
|
strXml += ' <a:p>';
|
|
7255
7878
|
strXml += ' <a:pPr>';
|
|
7256
|
-
strXml += ` <a:defRPr sz="${
|
|
7879
|
+
strXml += ` <a:defRPr sz="${fontSizeToSz(opts.valAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.valAxisLabelFontBold ? 1 : 0}" i="${opts.valAxisLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">`;
|
|
7257
7880
|
strXml += ' <a:solidFill>' + createColorElement(opts.valAxisLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
|
|
7258
7881
|
strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.valAxisLabelFontFace) || 'Arial') + '"/>';
|
|
7259
7882
|
strXml += ' <a:ea typeface="' + (encodeXmlEntities(opts.valAxisLabelFontFace) || 'Arial') + '"/>';
|
|
@@ -7325,7 +7948,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
|
|
|
7325
7948
|
strXml += ' <a:lstStyle/>';
|
|
7326
7949
|
strXml += ' <a:p>';
|
|
7327
7950
|
strXml += ' <a:pPr>';
|
|
7328
|
-
strXml += ` <a:defRPr sz="${
|
|
7951
|
+
strXml += ` <a:defRPr sz="${fontSizeToSz(opts.serAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.serAxisLabelFontBold ? '1' : '0'}" i="${opts.serAxisLabelFontItalic ? '1' : '0'}" u="none" strike="noStrike">`;
|
|
7329
7952
|
strXml += ` <a:solidFill>${createColorElement(opts.serAxisLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>`;
|
|
7330
7953
|
strXml += ` <a:latin typeface="${encodeXmlEntities(opts.serAxisLabelFontFace) || 'Arial'}"/>`;
|
|
7331
7954
|
strXml += ` <a:ea typeface="${encodeXmlEntities(opts.serAxisLabelFontFace) || 'Arial'}"/>`;
|
|
@@ -7427,6 +8050,7 @@ function xml_object_spread_props(target, source) {
|
|
|
7427
8050
|
* @param {ISlideRelChart} rel - chart object
|
|
7428
8051
|
* @return {string} XML
|
|
7429
8052
|
*/ function makeXmlCharts(rel) {
|
|
8053
|
+
var _ref;
|
|
7430
8054
|
var _rel_opts_chartArea, _rel_opts_chartArea1, _rel_opts_chartArea_border, _rel_opts_chartArea2, _rel_opts_chartArea_border1, _rel_opts_chartArea3;
|
|
7431
8055
|
let strXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
7432
8056
|
let usesSecondaryValAxis = false;
|
|
@@ -7459,7 +8083,8 @@ function xml_object_spread_props(target, source) {
|
|
|
7459
8083
|
/** Add 3D view tag
|
|
7460
8084
|
* @see: https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_perspective_topic_ID0E6BUQB.html
|
|
7461
8085
|
*/ if (rel.opts._type === core_enums_CHART_TYPE.BAR3D) {
|
|
7462
|
-
|
|
8086
|
+
var _rel_opts_v3DRotX, _rel_opts_v3DRotY, _rel_opts_v3DPerspective;
|
|
8087
|
+
strXml += `<c:view3D><c:rotX val="${clampInt((_rel_opts_v3DRotX = rel.opts.v3DRotX) !== null && _rel_opts_v3DRotX !== void 0 ? _rel_opts_v3DRotX : 30, -90, 90)}"/><c:rotY val="${clampInt((_rel_opts_v3DRotY = rel.opts.v3DRotY) !== null && _rel_opts_v3DRotY !== void 0 ? _rel_opts_v3DRotY : 30, 0, 360)}"/><c:rAngAx val="${!rel.opts.v3DRAngAx ? 0 : 1}"/><c:perspective val="${clampInt((_rel_opts_v3DPerspective = rel.opts.v3DPerspective) !== null && _rel_opts_v3DPerspective !== void 0 ? _rel_opts_v3DPerspective : 30, 0, 240)}"/></c:view3D>`;
|
|
7463
8088
|
}
|
|
7464
8089
|
strXml += '<c:plotArea>';
|
|
7465
8090
|
// IMPORTANT: Dont specify layout to enable auto-fit: PPT does a great job maximizing space with all 4 TRBL locations
|
|
@@ -7480,9 +8105,21 @@ function xml_object_spread_props(target, source) {
|
|
|
7480
8105
|
}
|
|
7481
8106
|
}
|
|
7482
8107
|
// A: Create Chart XML -----------------------------------------------------------
|
|
8108
|
+
const hiddenLegendIndices = [];
|
|
7483
8109
|
if (Array.isArray(rel.opts._type)) {
|
|
8110
|
+
let seriesIdx = 0;
|
|
7484
8111
|
rel.opts._type.forEach((type)=>{
|
|
7485
8112
|
var _options_secondaryValAxis;
|
|
8113
|
+
if (Array.isArray(type.data)) {
|
|
8114
|
+
var _type_options;
|
|
8115
|
+
const hideSubchartLegend = ((_type_options = type.options) === null || _type_options === void 0 ? void 0 : _type_options.showLegend) === false;
|
|
8116
|
+
type.data.forEach((obj)=>{
|
|
8117
|
+
var _obj__dataIndex;
|
|
8118
|
+
const idx = (_obj__dataIndex = obj._dataIndex) !== null && _obj__dataIndex !== void 0 ? _obj__dataIndex : seriesIdx;
|
|
8119
|
+
if (hideSubchartLegend) hiddenLegendIndices.push(idx);
|
|
8120
|
+
seriesIdx++;
|
|
8121
|
+
});
|
|
8122
|
+
}
|
|
7486
8123
|
const options = xml_object_spread({}, rel.opts, type.options);
|
|
7487
8124
|
if (options.dataLabelPosition) {
|
|
7488
8125
|
options.dataLabelPosition = resolveDataLabelPosition(options.dataLabelPosition, type.type, options.barGrouping);
|
|
@@ -7539,6 +8176,7 @@ function xml_object_spread_props(target, source) {
|
|
|
7539
8176
|
}
|
|
7540
8177
|
// C: Chart Properties and plotArea Options: Border, Data Table, Fill, Legend
|
|
7541
8178
|
{
|
|
8179
|
+
var _ref1;
|
|
7542
8180
|
var _rel_opts_plotArea, _rel_opts_plotArea1, _rel_opts_plotArea_border, _rel_opts_plotArea2, _rel_opts_plotArea_border1, _rel_opts_plotArea3;
|
|
7543
8181
|
// NOTE: DataTable goes between '</c:valAx>' and '<c:spPr>'
|
|
7544
8182
|
if (rel.opts.showDataTable) {
|
|
@@ -7557,7 +8195,7 @@ function xml_object_spread_props(target, source) {
|
|
|
7557
8195
|
strXml += ' <a:lstStyle/>';
|
|
7558
8196
|
strXml += ' <a:p>';
|
|
7559
8197
|
strXml += ' <a:pPr rtl="0">';
|
|
7560
|
-
strXml += ` <a:defRPr sz="${
|
|
8198
|
+
strXml += ` <a:defRPr sz="${fontSizeToSz(rel.opts.dataTableFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="0" i="0" u="none" strike="noStrike" kern="1200" baseline="0">`;
|
|
7561
8199
|
strXml += ' <a:solidFill><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></a:solidFill>';
|
|
7562
8200
|
strXml += ' <a:latin typeface="+mn-lt"/>';
|
|
7563
8201
|
strXml += ' <a:ea typeface="+mn-ea"/>';
|
|
@@ -7573,7 +8211,7 @@ function xml_object_spread_props(target, source) {
|
|
|
7573
8211
|
// OPTION: Fill
|
|
7574
8212
|
strXml += ((_rel_opts_plotArea = rel.opts.plotArea) === null || _rel_opts_plotArea === void 0 ? void 0 : _rel_opts_plotArea.fill) && (rel.opts.plotArea.fill.type === 'gradient' || rel.opts.plotArea.fill.type === 'linearGradient' || rel.opts.plotArea.fill.type === 'pattern' || rel.opts.plotArea.fill.color) ? genXmlColorSelection(rel.opts.plotArea.fill) : '<a:noFill/>';
|
|
7575
8213
|
// OPTION: Border
|
|
7576
|
-
strXml += ((_rel_opts_plotArea1 = rel.opts.plotArea) === null || _rel_opts_plotArea1 === void 0 ? void 0 : _rel_opts_plotArea1.border) ? `<a:ln w="${
|
|
8214
|
+
strXml += ((_rel_opts_plotArea1 = rel.opts.plotArea) === null || _rel_opts_plotArea1 === void 0 ? void 0 : _rel_opts_plotArea1.border) ? `<a:ln w="${valToLineWidth((_ref1 = (_rel_opts_plotArea2 = rel.opts.plotArea) === null || _rel_opts_plotArea2 === void 0 ? void 0 : (_rel_opts_plotArea_border = _rel_opts_plotArea2.border) === null || _rel_opts_plotArea_border === void 0 ? void 0 : _rel_opts_plotArea_border.pt) !== null && _ref1 !== void 0 ? _ref1 : 0)}" cap="flat">${genXmlColorSelection((_rel_opts_plotArea3 = rel.opts.plotArea) === null || _rel_opts_plotArea3 === void 0 ? void 0 : (_rel_opts_plotArea_border1 = _rel_opts_plotArea3.border) === null || _rel_opts_plotArea_border1 === void 0 ? void 0 : _rel_opts_plotArea_border1.color)}</a:ln>` : '<a:ln><a:noFill/></a:ln>';
|
|
7577
8215
|
// Close shapeProp/plotArea before Legend
|
|
7578
8216
|
strXml += ' <a:effectLst/>';
|
|
7579
8217
|
strXml += ' </c:spPr>';
|
|
@@ -7583,7 +8221,27 @@ function xml_object_spread_props(target, source) {
|
|
|
7583
8221
|
if (rel.opts.showLegend) {
|
|
7584
8222
|
strXml += '<c:legend>';
|
|
7585
8223
|
strXml += '<c:legendPos val="' + rel.opts.legendPos + '"/>';
|
|
7586
|
-
//
|
|
8224
|
+
// ECMA-376 CT_Legend sequence: legendPos -> legendEntry* -> layout -> overlay -> spPr -> txPr
|
|
8225
|
+
hiddenLegendIndices.forEach((idx)=>{
|
|
8226
|
+
strXml += `<c:legendEntry><c:idx val="${idx}"/><c:delete val="1"/></c:legendEntry>`;
|
|
8227
|
+
});
|
|
8228
|
+
if (rel.opts.legendLayout) {
|
|
8229
|
+
const { x, y, w, h } = rel.opts.legendLayout;
|
|
8230
|
+
const hasX = typeof x === 'number' && Number.isFinite(x);
|
|
8231
|
+
const hasY = typeof y === 'number' && Number.isFinite(y);
|
|
8232
|
+
const hasW = typeof w === 'number' && Number.isFinite(w);
|
|
8233
|
+
const hasH = typeof h === 'number' && Number.isFinite(h);
|
|
8234
|
+
if (hasX || hasY || hasW || hasH) {
|
|
8235
|
+
strXml += '<c:layout><c:manualLayout>';
|
|
8236
|
+
if (hasX) strXml += '<c:xMode val="edge"/>';
|
|
8237
|
+
if (hasY) strXml += '<c:yMode val="edge"/>';
|
|
8238
|
+
if (hasX) strXml += `<c:x val="${x}"/>`;
|
|
8239
|
+
if (hasY) strXml += `<c:y val="${y}"/>`;
|
|
8240
|
+
if (hasW) strXml += `<c:w val="${w}"/>`;
|
|
8241
|
+
if (hasH) strXml += `<c:h val="${h}"/>`;
|
|
8242
|
+
strXml += '</c:manualLayout></c:layout>';
|
|
8243
|
+
}
|
|
8244
|
+
}
|
|
7587
8245
|
strXml += '<c:overlay val="0"/>';
|
|
7588
8246
|
if (rel.opts.legendFontFace || rel.opts.legendFontSize || rel.opts.legendColor) {
|
|
7589
8247
|
strXml += '<c:txPr>';
|
|
@@ -7591,7 +8249,7 @@ function xml_object_spread_props(target, source) {
|
|
|
7591
8249
|
strXml += ' <a:lstStyle/>';
|
|
7592
8250
|
strXml += ' <a:p>';
|
|
7593
8251
|
strXml += ' <a:pPr>';
|
|
7594
|
-
strXml += rel.opts.legendFontSize ? `<a:defRPr sz="${
|
|
8252
|
+
strXml += rel.opts.legendFontSize ? `<a:defRPr sz="${fontSizeToSz(Number(rel.opts.legendFontSize))}">` : '<a:defRPr>';
|
|
7595
8253
|
if (rel.opts.legendColor) strXml += genXmlColorSelection(rel.opts.legendColor);
|
|
7596
8254
|
if (rel.opts.legendFontFace) strXml += '<a:latin typeface="' + encodeXmlEntities(rel.opts.legendFontFace) + '"/>';
|
|
7597
8255
|
if (rel.opts.legendFontFace) strXml += '<a:ea typeface="' + encodeXmlEntities(rel.opts.legendFontFace) + '"/>';
|
|
@@ -7612,7 +8270,7 @@ function xml_object_spread_props(target, source) {
|
|
|
7612
8270
|
// D: CHARTSPACE SHAPE PROPS
|
|
7613
8271
|
strXml += '<c:spPr>';
|
|
7614
8272
|
strXml += ((_rel_opts_chartArea = rel.opts.chartArea) === null || _rel_opts_chartArea === void 0 ? void 0 : _rel_opts_chartArea.fill) && (rel.opts.chartArea.fill.type === 'gradient' || rel.opts.chartArea.fill.type === 'linearGradient' || rel.opts.chartArea.fill.type === 'pattern' || rel.opts.chartArea.fill.color) ? genXmlColorSelection(rel.opts.chartArea.fill) : '<a:noFill/>';
|
|
7615
|
-
strXml += ((_rel_opts_chartArea1 = rel.opts.chartArea) === null || _rel_opts_chartArea1 === void 0 ? void 0 : _rel_opts_chartArea1.border) ? `<a:ln w="${
|
|
8273
|
+
strXml += ((_rel_opts_chartArea1 = rel.opts.chartArea) === null || _rel_opts_chartArea1 === void 0 ? void 0 : _rel_opts_chartArea1.border) ? `<a:ln w="${valToLineWidth((_ref = (_rel_opts_chartArea2 = rel.opts.chartArea) === null || _rel_opts_chartArea2 === void 0 ? void 0 : (_rel_opts_chartArea_border = _rel_opts_chartArea2.border) === null || _rel_opts_chartArea_border === void 0 ? void 0 : _rel_opts_chartArea_border.pt) !== null && _ref !== void 0 ? _ref : 0)}" cap="flat">${genXmlColorSelection((_rel_opts_chartArea3 = rel.opts.chartArea) === null || _rel_opts_chartArea3 === void 0 ? void 0 : (_rel_opts_chartArea_border1 = _rel_opts_chartArea3.border) === null || _rel_opts_chartArea_border1 === void 0 ? void 0 : _rel_opts_chartArea_border1.color)}</a:ln>` : '<a:ln><a:noFill/></a:ln>';
|
|
7616
8274
|
strXml += ' <a:effectLst/>';
|
|
7617
8275
|
strXml += '</c:spPr>';
|
|
7618
8276
|
// E: DATA (Add relID)
|
|
@@ -7638,13 +8296,13 @@ function xml_object_spread_props(target, source) {
|
|
|
7638
8296
|
* (`standards/ecma/part-23_drawingml-reference-material-drawingml-charts.txt`).
|
|
7639
8297
|
* An empty `<a:defRPr/>` drops dataLabelFont* on scatter labels (gitbrent #1348).
|
|
7640
8298
|
*/ function genXmlDataLabelDefRPr(opts) {
|
|
7641
|
-
return `<a:defRPr sz="${
|
|
8299
|
+
return `<a:defRPr sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">` + `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>` + `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>` + '</a:defRPr>';
|
|
7642
8300
|
}
|
|
7643
8301
|
/**
|
|
7644
8302
|
* Rich-text body for a custom chart data label (`c:tx` / `c:rich`).
|
|
7645
8303
|
* Escapes text and applies data-label font options.
|
|
7646
8304
|
*/ function genXmlDataLabelRichText(text, opts) {
|
|
7647
|
-
const sz =
|
|
8305
|
+
const sz = fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12));
|
|
7648
8306
|
const lang = opts.lang || 'en-US';
|
|
7649
8307
|
let xml = '<c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r>';
|
|
7650
8308
|
xml += `<a:rPr lang="${lang}" dirty="0" sz="${sz}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}">`;
|
|
@@ -7714,9 +8372,9 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
7714
8372
|
case core_enums_CHART_TYPE.RADAR:
|
|
7715
8373
|
// 1: Start Chart
|
|
7716
8374
|
strXml += `<c:${chartType}Chart>`;
|
|
7717
|
-
// Area charts: `c:grouping` / ST_Grouping (ECMA-376 §5.7.2.76 / §5.7.3.17).
|
|
8375
|
+
// Area and line charts: `c:grouping` / ST_Grouping (ECMA-376 §5.7.2.76 / §5.7.2.97 / §5.7.3.17).
|
|
7718
8376
|
// `barGrouping` is the public option name; the element is not `c:barGrouping` (that is ST_BarGrouping on bar charts).
|
|
7719
|
-
if (chartType === core_enums_CHART_TYPE.AREA) {
|
|
8377
|
+
if (chartType === core_enums_CHART_TYPE.AREA || chartType === core_enums_CHART_TYPE.LINE) {
|
|
7720
8378
|
strXml += '<c:grouping val="' + resolveAreaGrouping(opts.barGrouping) + '"/>';
|
|
7721
8379
|
}
|
|
7722
8380
|
if (chartType === core_enums_CHART_TYPE.BAR || chartType === core_enums_CHART_TYPE.BAR3D) {
|
|
@@ -7782,7 +8440,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
7782
8440
|
if (seriesColor === 'transparent') {
|
|
7783
8441
|
strXml += '<a:noFill/>';
|
|
7784
8442
|
} else if (opts.chartColorsOpacity) {
|
|
7785
|
-
strXml += '<a:solidFill>' + createColorElement(seriesColor, `<a:alpha val="${
|
|
8443
|
+
strXml += '<a:solidFill>' + createColorElement(seriesColor, `<a:alpha val="${clampAlphaPct(100 - opts.chartColorsOpacity)}"/>`) + '</a:solidFill>';
|
|
7786
8444
|
} else {
|
|
7787
8445
|
strXml += '<a:solidFill>' + createColorElement(seriesColor) + '</a:solidFill>';
|
|
7788
8446
|
}
|
|
@@ -7790,11 +8448,13 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
7790
8448
|
if (opts.lineSize === 0) {
|
|
7791
8449
|
strXml += '<a:ln><a:noFill/></a:ln>';
|
|
7792
8450
|
} else {
|
|
7793
|
-
|
|
8451
|
+
var _opts_lineSize;
|
|
8452
|
+
strXml += `<a:ln w="${valToLineWidth((_opts_lineSize = opts.lineSize) !== null && _opts_lineSize !== void 0 ? _opts_lineSize : 0)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(seriesColor)}</a:solidFill>`;
|
|
7794
8453
|
strXml += '<a:prstDash val="' + resolveSeriesLineDash(obj.lineDash, opts.lineDash) + '"/><a:round/></a:ln>';
|
|
7795
8454
|
}
|
|
7796
8455
|
} else if (opts.dataBorder) {
|
|
7797
|
-
|
|
8456
|
+
var _opts_dataBorder_pt;
|
|
8457
|
+
strXml += `<a:ln w="${valToLineWidth((_opts_dataBorder_pt = opts.dataBorder.pt) !== null && _opts_dataBorder_pt !== void 0 ? _opts_dataBorder_pt : 0)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
|
|
7798
8458
|
}
|
|
7799
8459
|
strXml += createShadowElement(resolveShadowOptions(opts.shadow));
|
|
7800
8460
|
strXml += ' </c:spPr>';
|
|
@@ -7810,7 +8470,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
7810
8470
|
strXml += `<c:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode) || 'General'}" sourceLinked="0"/>`;
|
|
7811
8471
|
if (opts.dataLabelBkgrdColors) strXml += `<c:spPr><a:solidFill>${createColorElement(seriesColor)}</a:solidFill></c:spPr>`;
|
|
7812
8472
|
strXml += '<c:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>';
|
|
7813
|
-
strXml += `<a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${
|
|
8473
|
+
strXml += `<a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" u="none">`;
|
|
7814
8474
|
strXml += `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>`;
|
|
7815
8475
|
strXml += `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>`;
|
|
7816
8476
|
strXml += '</a:defRPr></a:pPr></a:p></c:txPr>';
|
|
@@ -7825,9 +8485,10 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
7825
8485
|
}
|
|
7826
8486
|
// 'c:marker' tag: `lineDataSymbol`
|
|
7827
8487
|
if (chartType === core_enums_CHART_TYPE.LINE || chartType === core_enums_CHART_TYPE.RADAR) {
|
|
8488
|
+
var _opts_lineDataSymbolLineSize;
|
|
7828
8489
|
strXml += '<c:marker>';
|
|
7829
8490
|
strXml += ' <c:symbol val="' + opts.lineDataSymbol + '"/>';
|
|
7830
|
-
if (opts.lineDataSymbolSize) strXml += `<c:size val="${opts.lineDataSymbolSize}"/>`; // Defaults to "auto" otherwise (but this is usually too small, so there is a default)
|
|
8491
|
+
if (opts.lineDataSymbolSize) strXml += `<c:size val="${clampInt(opts.lineDataSymbolSize, 2, 72)}"/>`; // Defaults to "auto" otherwise (but this is usually too small, so there is a default)
|
|
7831
8492
|
strXml += ' <c:spPr>';
|
|
7832
8493
|
// NateRadebaugh/transparent-markers: `'transparent'` → noFill (same as series fill)
|
|
7833
8494
|
{
|
|
@@ -7835,7 +8496,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
7835
8496
|
const markerColor = (_obj_color1 = obj.color) !== null && _obj_color1 !== void 0 ? _obj_color1 : chartColors[dataIndex + 1 > chartColors.length ? Math.floor(Math.random() * chartColors.length) : dataIndex];
|
|
7836
8497
|
strXml += markerColor === 'transparent' ? ' <a:noFill/>' : ` <a:solidFill>${createColorElement(markerColor)}</a:solidFill>`;
|
|
7837
8498
|
}
|
|
7838
|
-
strXml += ` <a:ln w="${opts.lineDataSymbolLineSize}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || seriesColor)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
|
|
8499
|
+
strXml += ` <a:ln w="${clampLineWidth((_opts_lineDataSymbolLineSize = opts.lineDataSymbolLineSize) !== null && _opts_lineDataSymbolLineSize !== void 0 ? _opts_lineDataSymbolLineSize : 0)}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || seriesColor)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
|
|
7839
8500
|
strXml += ' <a:effectLst/>';
|
|
7840
8501
|
strXml += ' </c:spPr>';
|
|
7841
8502
|
strXml += '</c:marker>';
|
|
@@ -7946,7 +8607,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
7946
8607
|
strXml += ' <a:bodyPr/>';
|
|
7947
8608
|
strXml += ' <a:lstStyle/>';
|
|
7948
8609
|
strXml += ' <a:p><a:pPr>';
|
|
7949
|
-
strXml += ` <a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${
|
|
8610
|
+
strXml += ` <a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" u="none">`;
|
|
7950
8611
|
strXml += ' <a:solidFill>' + createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
|
|
7951
8612
|
strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.dataLabelFontFace) || 'Arial') + '"/>';
|
|
7952
8613
|
strXml += ' </a:defRPr>';
|
|
@@ -7964,16 +8625,18 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
7964
8625
|
}
|
|
7965
8626
|
// 4: Add more chart options (gapWidth, line Marker, etc.)
|
|
7966
8627
|
if (chartType === core_enums_CHART_TYPE.BAR) {
|
|
7967
|
-
|
|
8628
|
+
var _opts_barGapWidthPct;
|
|
8629
|
+
strXml += ` <c:gapWidth val="${clampInt((_opts_barGapWidthPct = opts.barGapWidthPct) !== null && _opts_barGapWidthPct !== void 0 ? _opts_barGapWidthPct : 150, 0, 500)}"/>`;
|
|
7968
8630
|
// istevkovski/prioritize-overlap: honor barOverlapPct even when grouping is stacked
|
|
7969
8631
|
// (also treat 0 as explicit — upstream used a truthy check that skipped 0)
|
|
7970
8632
|
{
|
|
7971
|
-
const overlap = typeof opts.barOverlapPct === 'number' ? opts.barOverlapPct : (opts.barGrouping || '').includes('tacked') ? 100 : 0;
|
|
8633
|
+
const overlap = typeof opts.barOverlapPct === 'number' ? clampInt(opts.barOverlapPct, -100, 100) : (opts.barGrouping || '').includes('tacked') ? 100 : 0;
|
|
7972
8634
|
strXml += ` <c:overlap val="${overlap}"/>`;
|
|
7973
8635
|
}
|
|
7974
8636
|
} else if (chartType === core_enums_CHART_TYPE.BAR3D) {
|
|
7975
|
-
|
|
7976
|
-
strXml += ` <c:
|
|
8637
|
+
var _opts_barGapWidthPct1, _opts_barGapDepthPct;
|
|
8638
|
+
strXml += ` <c:gapWidth val="${clampInt((_opts_barGapWidthPct1 = opts.barGapWidthPct) !== null && _opts_barGapWidthPct1 !== void 0 ? _opts_barGapWidthPct1 : 150, 0, 500)}"/>`;
|
|
8639
|
+
strXml += ` <c:gapDepth val="${clampInt((_opts_barGapDepthPct = opts.barGapDepthPct) !== null && _opts_barGapDepthPct !== void 0 ? _opts_barGapDepthPct : 150, 0, 500)}"/>`;
|
|
7977
8640
|
strXml += ' <c:shape val="' + opts.bar3DShape + '"/>';
|
|
7978
8641
|
} else if (chartType === core_enums_CHART_TYPE.LINE) {
|
|
7979
8642
|
strXml += ' <c:marker val="1"/>';
|
|
@@ -8019,14 +8682,15 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
8019
8682
|
if (tmpSerColor === 'transparent') {
|
|
8020
8683
|
strXml += '<a:noFill/>';
|
|
8021
8684
|
} else if (opts.chartColorsOpacity) {
|
|
8022
|
-
strXml += '<a:solidFill>' + createColorElement(tmpSerColor,
|
|
8685
|
+
strXml += '<a:solidFill>' + createColorElement(tmpSerColor, `<a:alpha val="${clampAlphaPct(100 - opts.chartColorsOpacity)}"/>`) + '</a:solidFill>';
|
|
8023
8686
|
} else {
|
|
8024
8687
|
strXml += '<a:solidFill>' + createColorElement(tmpSerColor) + '</a:solidFill>';
|
|
8025
8688
|
}
|
|
8026
8689
|
if (opts.lineSize === 0) {
|
|
8027
8690
|
strXml += '<a:ln><a:noFill/></a:ln>';
|
|
8028
8691
|
} else {
|
|
8029
|
-
|
|
8692
|
+
var _opts_lineSize;
|
|
8693
|
+
strXml += `<a:ln w="${valToLineWidth((_opts_lineSize = opts.lineSize) !== null && _opts_lineSize !== void 0 ? _opts_lineSize : 0)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(tmpSerColor)}</a:solidFill>`;
|
|
8030
8694
|
strXml += `<a:prstDash val="${resolveSeriesLineDash(obj.lineDash, opts.lineDash)}"/><a:round/></a:ln>`;
|
|
8031
8695
|
}
|
|
8032
8696
|
// Shadow
|
|
@@ -8035,11 +8699,12 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
8035
8699
|
strXml += ' </c:spPr>';
|
|
8036
8700
|
// 'c:marker' tag: `lineDataSymbol`
|
|
8037
8701
|
{
|
|
8702
|
+
var _opts_lineDataSymbolLineSize;
|
|
8038
8703
|
strXml += '<c:marker>';
|
|
8039
8704
|
strXml += ' <c:symbol val="' + opts.lineDataSymbol + '"/>';
|
|
8040
8705
|
if (opts.lineDataSymbolSize) {
|
|
8041
8706
|
// Defaults to "auto" otherwise (but this is usually too small, so there is a default)
|
|
8042
|
-
strXml += `<c:size val="${opts.lineDataSymbolSize}"/>`;
|
|
8707
|
+
strXml += `<c:size val="${clampInt(opts.lineDataSymbolSize, 2, 72)}"/>`;
|
|
8043
8708
|
}
|
|
8044
8709
|
strXml += '<c:spPr>';
|
|
8045
8710
|
// NateRadebaugh/transparent-markers: `'transparent'` → noFill (same as series fill)
|
|
@@ -8048,7 +8713,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
8048
8713
|
const markerColor = (_obj_color1 = obj.color) !== null && _obj_color1 !== void 0 ? _obj_color1 : chartColors[idx + 1 > chartColors.length ? Math.floor(Math.random() * chartColors.length) : idx];
|
|
8049
8714
|
strXml += markerColor === 'transparent' ? '<a:noFill/>' : `<a:solidFill>${createColorElement(markerColor)}</a:solidFill>`;
|
|
8050
8715
|
}
|
|
8051
|
-
strXml += `<a:ln w="${opts.lineDataSymbolLineSize}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || obj.color || chartColors[colorIndex % chartColors.length])}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
|
|
8716
|
+
strXml += `<a:ln w="${clampLineWidth((_opts_lineDataSymbolLineSize = opts.lineDataSymbolLineSize) !== null && _opts_lineDataSymbolLineSize !== void 0 ? _opts_lineDataSymbolLineSize : 0)}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || obj.color || chartColors[colorIndex % chartColors.length])}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
|
|
8052
8717
|
strXml += '<a:effectLst/>';
|
|
8053
8718
|
strXml += '</c:spPr>';
|
|
8054
8719
|
strXml += '</c:marker>';
|
|
@@ -8237,7 +8902,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
8237
8902
|
strXml += ' <a:bodyPr/>';
|
|
8238
8903
|
strXml += ' <a:lstStyle/>';
|
|
8239
8904
|
strXml += ' <a:p><a:pPr>';
|
|
8240
|
-
strXml += ` <a:defRPr b="${opts.dataLabelFontBold ? '1' : '0'}" i="${opts.dataLabelFontItalic ? '1' : '0'}" strike="noStrike" sz="${
|
|
8905
|
+
strXml += ` <a:defRPr b="${opts.dataLabelFontBold ? '1' : '0'}" i="${opts.dataLabelFontItalic ? '1' : '0'}" strike="noStrike" sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" u="none">`;
|
|
8241
8906
|
strXml += ' <a:solidFill>' + createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
|
|
8242
8907
|
strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.dataLabelFontFace) || 'Arial') + '"/>';
|
|
8243
8908
|
strXml += ' </a:defRPr>';
|
|
@@ -8293,16 +8958,18 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
8293
8958
|
if (tmpSerColor === 'transparent') {
|
|
8294
8959
|
strXml += '<a:noFill/>';
|
|
8295
8960
|
} else if (opts.chartColorsOpacity) {
|
|
8296
|
-
strXml += `<a:solidFill>${createColorElement(tmpSerColor,
|
|
8961
|
+
strXml += `<a:solidFill>${createColorElement(tmpSerColor, `<a:alpha val="${clampAlphaPct(100 - opts.chartColorsOpacity)}"/>`)}</a:solidFill>`;
|
|
8297
8962
|
} else {
|
|
8298
8963
|
strXml += '<a:solidFill>' + createColorElement(tmpSerColor) + '</a:solidFill>';
|
|
8299
8964
|
}
|
|
8300
8965
|
if (opts.lineSize === 0) {
|
|
8301
8966
|
strXml += '<a:ln><a:noFill/></a:ln>';
|
|
8302
8967
|
} else if (opts.dataBorder) {
|
|
8303
|
-
|
|
8968
|
+
var _opts_dataBorder_pt;
|
|
8969
|
+
strXml += `<a:ln w="${valToLineWidth((_opts_dataBorder_pt = opts.dataBorder.pt) !== null && _opts_dataBorder_pt !== void 0 ? _opts_dataBorder_pt : 0)}" cap="flat"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
|
|
8304
8970
|
} else {
|
|
8305
|
-
|
|
8971
|
+
var _opts_lineSize;
|
|
8972
|
+
strXml += `<a:ln w="${valToLineWidth((_opts_lineSize = opts.lineSize) !== null && _opts_lineSize !== void 0 ? _opts_lineSize : 0)}" cap="flat"><a:solidFill>${createColorElement(tmpSerColor)}</a:solidFill>`;
|
|
8306
8973
|
strXml += `<a:prstDash val="${resolveSeriesLineDash(obj.lineDash, opts.lineDash)}"/><a:round/></a:ln>`;
|
|
8307
8974
|
}
|
|
8308
8975
|
// Shadow
|
|
@@ -8365,7 +9032,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
8365
9032
|
strXml += '<c:dLbls>';
|
|
8366
9033
|
strXml += `<c:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode) || 'General'}" sourceLinked="0"/>`;
|
|
8367
9034
|
strXml += '<c:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>';
|
|
8368
|
-
strXml += `<a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${
|
|
9035
|
+
strXml += `<a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" u="none">`;
|
|
8369
9036
|
strXml += `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>`;
|
|
8370
9037
|
strXml += `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>`;
|
|
8371
9038
|
strXml += '</a:defRPr></a:pPr></a:p></c:txPr>';
|
|
@@ -8392,7 +9059,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
8392
9059
|
case core_enums_CHART_TYPE.DOUGHNUT:
|
|
8393
9060
|
case core_enums_CHART_TYPE.PIE:
|
|
8394
9061
|
{
|
|
8395
|
-
var _optsChartData_labels, _optsChartData_values, _opts_dataLabelPosition;
|
|
9062
|
+
var _optsChartData_labels, _optsChartData_values, _opts_dataLabelPosition, _opts_firstSliceAng;
|
|
8396
9063
|
const optsChartData = data[0];
|
|
8397
9064
|
// NOTE: chart data arrays are always populated at render time; guarded locals keep this null-safe without changing output
|
|
8398
9065
|
const chartDataLabels = (_optsChartData_labels = optsChartData.labels) !== null && _optsChartData_labels !== void 0 ? _optsChartData_labels : [];
|
|
@@ -8429,7 +9096,9 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
8429
9096
|
strXml += createShadowElement(resolveShadowOptions(opts.shadow));
|
|
8430
9097
|
}
|
|
8431
9098
|
strXml += ' </c:spPr>';
|
|
8432
|
-
|
|
9099
|
+
if (typeof opts.chartPieExplosion === 'number' && Number.isFinite(opts.chartPieExplosion) && opts.chartPieExplosion > 0) {
|
|
9100
|
+
strXml += `<c:explosion val="${clampInt(opts.chartPieExplosion, 0, 1000)}"/>`;
|
|
9101
|
+
}
|
|
8433
9102
|
// 2: "Data Point" block for every data row
|
|
8434
9103
|
chartDataLabels[0].forEach((_label, idx)=>{
|
|
8435
9104
|
strXml += '<c:dPt>';
|
|
@@ -8438,7 +9107,8 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
8438
9107
|
strXml += ' <c:spPr>';
|
|
8439
9108
|
strXml += `<a:solidFill>${createColorElement(chartColors[idx + 1 > chartColors.length ? Math.floor(Math.random() * chartColors.length) : idx])}</a:solidFill>`;
|
|
8440
9109
|
if (opts.dataBorder) {
|
|
8441
|
-
|
|
9110
|
+
var _opts_dataBorder_pt;
|
|
9111
|
+
strXml += `<a:ln w="${valToLineWidth((_opts_dataBorder_pt = opts.dataBorder.pt) !== null && _opts_dataBorder_pt !== void 0 ? _opts_dataBorder_pt : 0)}" cap="flat"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
|
|
8442
9112
|
}
|
|
8443
9113
|
strXml += createShadowElement(resolveShadowOptions(opts.shadow));
|
|
8444
9114
|
strXml += ' </c:spPr>';
|
|
@@ -8453,7 +9123,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
8453
9123
|
strXml += ' <a:lstStyle/>';
|
|
8454
9124
|
strXml += ' <a:p>';
|
|
8455
9125
|
strXml += ' <a:pPr>';
|
|
8456
|
-
strXml += ` <a:defRPr sz="${
|
|
9126
|
+
strXml += ` <a:defRPr sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.dataLabelFontBold ? '1' : '0'}" i="${opts.dataLabelFontItalic ? '1' : '0'}" u="none" strike="noStrike">`;
|
|
8457
9127
|
strXml += ` <a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill><a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>`;
|
|
8458
9128
|
strXml += ' </a:defRPr>';
|
|
8459
9129
|
strXml += ' </a:pPr>';
|
|
@@ -8495,8 +9165,8 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
8495
9165
|
strXml += ' </c:val>';
|
|
8496
9166
|
// 4: Close "SERIES"
|
|
8497
9167
|
strXml += ' </c:ser>';
|
|
8498
|
-
strXml += ` <c:firstSliceAng val="${
|
|
8499
|
-
if (chartType === core_enums_CHART_TYPE.DOUGHNUT) strXml += `<c:holeSize val="${typeof opts.holeSize === 'number' ? opts.holeSize :
|
|
9168
|
+
strXml += ` <c:firstSliceAng val="${clampInt((_opts_firstSliceAng = opts.firstSliceAng) !== null && _opts_firstSliceAng !== void 0 ? _opts_firstSliceAng : 0, 0, 360)}"/>`;
|
|
9169
|
+
if (chartType === core_enums_CHART_TYPE.DOUGHNUT) strXml += `<c:holeSize val="${clampInt(typeof opts.holeSize === 'number' ? opts.holeSize : 50, 1, 90)}"/>`;
|
|
8500
9170
|
strXml += '</c:' + chartType + 'Chart>';
|
|
8501
9171
|
break;
|
|
8502
9172
|
}
|
|
@@ -8507,7 +9177,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
|
|
|
8507
9177
|
return strXml;
|
|
8508
9178
|
}
|
|
8509
9179
|
|
|
8510
|
-
function
|
|
9180
|
+
function workbook_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
8511
9181
|
try {
|
|
8512
9182
|
var info = gen[key](arg);
|
|
8513
9183
|
var value = info.value;
|
|
@@ -8518,16 +9188,16 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
8518
9188
|
if (info.done) resolve(value);
|
|
8519
9189
|
else Promise.resolve(value).then(_next, _throw);
|
|
8520
9190
|
}
|
|
8521
|
-
function
|
|
9191
|
+
function workbook_async_to_generator(fn) {
|
|
8522
9192
|
return function() {
|
|
8523
9193
|
var self = this, args = arguments;
|
|
8524
9194
|
return new Promise(function(resolve, reject) {
|
|
8525
9195
|
var gen = fn.apply(self, args);
|
|
8526
9196
|
function _next(value) {
|
|
8527
|
-
|
|
9197
|
+
workbook_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
8528
9198
|
}
|
|
8529
9199
|
function _throw(err) {
|
|
8530
|
-
|
|
9200
|
+
workbook_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
8531
9201
|
}
|
|
8532
9202
|
_next(undefined);
|
|
8533
9203
|
});
|
|
@@ -8566,7 +9236,7 @@ function makeNumberStyles(formats) {
|
|
|
8566
9236
|
* @param {JSZip} zip - file that the resulting XLSX should be added to
|
|
8567
9237
|
* @return {Promise} promise of generating the XLSX file
|
|
8568
9238
|
*/ function createExcelWorksheet(chartObject, zip) {
|
|
8569
|
-
return
|
|
9239
|
+
return workbook_async_to_generator(function*() {
|
|
8570
9240
|
const zipExcel = new JSZip();
|
|
8571
9241
|
const dataTableStyles = getDataTableStyles(chartObject);
|
|
8572
9242
|
addCoreWorkbookFiles(zipExcel, dataTableStyles.customFormats);
|
|
@@ -16989,181 +17659,30 @@ function convert_to_eot_object_spread(target) {
|
|
|
16989
17659
|
ttfObject = otf2ttfobject(fontBuffer, opts);
|
|
16990
17660
|
} else if (type === 'woff') {
|
|
16991
17661
|
if (typeof opts.inflate !== 'function') {
|
|
16992
|
-
throw new Error('WOFF conversion requires options.inflate (pako)');
|
|
16993
|
-
}
|
|
16994
|
-
const ttfBuffer = woff2ttf(fontBuffer, opts);
|
|
16995
|
-
ttfObject = new TTFReader(opts).read(ttfBuffer);
|
|
16996
|
-
} else {
|
|
16997
|
-
throw new Error(`Unsupported font type for EOT conversion: ${String(type)}`);
|
|
16998
|
-
}
|
|
16999
|
-
const ttfBuffer = new TTFWriter(opts).write(ttfObject);
|
|
17000
|
-
return ttf2eot(ttfBuffer, opts);
|
|
17001
|
-
}
|
|
17002
|
-
|
|
17003
|
-
/**
|
|
17004
|
-
* PptxGenJS: Opt-in embedded TrueType fonts (OOXML `ppt/fonts/*.fntdata`)
|
|
17005
|
-
*
|
|
17006
|
-
* `embedFontsIntoZip` is a no-op when `fonts` is empty — default export never
|
|
17007
|
-
* writes Font parts, fntdata content types, or Presentation font relationships.
|
|
17008
|
-
* Callers supply their own font bytes via `addFont` and must have a license
|
|
17009
|
-
* that permits embedding those files. This library ships no font files.
|
|
17010
|
-
*
|
|
17011
|
-
* Font-embed orchestration absorbed from MIT `pptx-embed-fonts`
|
|
17012
|
-
* (https://github.com/liyao1520/pptx-embed-fonts). TTF/OTF/WOFF→EOT conversion is a
|
|
17013
|
-
* vendored subset of MIT `fonteditor-core` under `src/vendor/fonteditor-core`
|
|
17014
|
-
* (https://github.com/kekee000/fonteditor-core). WOFF inflate uses pako 3.
|
|
17015
|
-
*/ function gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17016
|
-
try {
|
|
17017
|
-
var info = gen[key](arg);
|
|
17018
|
-
var value = info.value;
|
|
17019
|
-
} catch (error) {
|
|
17020
|
-
reject(error);
|
|
17021
|
-
return;
|
|
17022
|
-
}
|
|
17023
|
-
if (info.done) resolve(value);
|
|
17024
|
-
else Promise.resolve(value).then(_next, _throw);
|
|
17025
|
-
}
|
|
17026
|
-
function gen_fonts_async_to_generator(fn) {
|
|
17027
|
-
return function() {
|
|
17028
|
-
var self = this, args = arguments;
|
|
17029
|
-
return new Promise(function(resolve, reject) {
|
|
17030
|
-
var gen = fn.apply(self, args);
|
|
17031
|
-
function _next(value) {
|
|
17032
|
-
gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
17033
|
-
}
|
|
17034
|
-
function _throw(err) {
|
|
17035
|
-
gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
17036
|
-
}
|
|
17037
|
-
_next(undefined);
|
|
17038
|
-
});
|
|
17039
|
-
};
|
|
17040
|
-
}
|
|
17041
|
-
|
|
17042
|
-
|
|
17043
|
-
/** High rId base so font relationships do not collide with slide/master rIds */ const FONT_RID_START = 201314;
|
|
17044
|
-
const FONT_REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/font';
|
|
17045
|
-
/**
|
|
17046
|
-
* Convert TTF / OTF / WOFF bytes to EOT (Office `fntdata` payload).
|
|
17047
|
-
* Lazy-loads pako only for WOFF.
|
|
17048
|
-
*/ function fontToEot(type, fontBuffer) {
|
|
17049
|
-
return gen_fonts_async_to_generator(function*() {
|
|
17050
|
-
const options = {
|
|
17051
|
-
hinting: true
|
|
17052
|
-
};
|
|
17053
|
-
if (type === 'woff') {
|
|
17054
|
-
// pako 3: named exports only; InflateInput is Uint8Array | ArrayBuffer (not number[])
|
|
17055
|
-
const { inflate } = yield import("pako");
|
|
17056
|
-
options.inflate = (deflatedData)=>Array.from(inflate(Uint8Array.from(deflatedData)));
|
|
17057
|
-
}
|
|
17058
|
-
return convertToEot(type, fontBuffer, options);
|
|
17059
|
-
})();
|
|
17060
|
-
}
|
|
17061
|
-
function toFntdata(fontType, fontFile) {
|
|
17062
|
-
return gen_fonts_async_to_generator(function*() {
|
|
17063
|
-
switch(fontType){
|
|
17064
|
-
case 'eot':
|
|
17065
|
-
// EOT bytes are stored as-is under ppt/fonts/*.fntdata
|
|
17066
|
-
return fontFile;
|
|
17067
|
-
case 'ttf':
|
|
17068
|
-
case 'otf':
|
|
17069
|
-
case 'woff':
|
|
17070
|
-
return yield fontToEot(fontType, fontFile);
|
|
17071
|
-
default:
|
|
17072
|
-
throw new Error(`Invalid font type "${String(fontType)}" - use ttf | otf | woff | eot`);
|
|
17073
|
-
}
|
|
17074
|
-
})();
|
|
17075
|
-
}
|
|
17076
|
-
function ensureFntdataContentType(contentTypesXml) {
|
|
17077
|
-
if (/Extension="fntdata"/i.test(contentTypesXml)) return contentTypesXml;
|
|
17078
|
-
const entry = '<Default Extension="fntdata" ContentType="application/x-fontdata"/>';
|
|
17079
|
-
// Prefer inserting among other Defaults near the top of <Types>
|
|
17080
|
-
if (/<Default\b/i.test(contentTypesXml)) {
|
|
17081
|
-
return contentTypesXml.replace(/<Default\b/i, `${entry}<Default`);
|
|
17082
|
-
}
|
|
17083
|
-
return contentTypesXml.replace(/<Types([^>]*)>/i, `<Types$1>${entry}`);
|
|
17084
|
-
}
|
|
17085
|
-
function ensurePresentationFontAttrs(presentationXml) {
|
|
17086
|
-
let xml = presentationXml;
|
|
17087
|
-
if (/embedTrueTypeFonts=/i.test(xml)) {
|
|
17088
|
-
xml = xml.replace(/embedTrueTypeFonts="[^"]*"/i, 'embedTrueTypeFonts="true"');
|
|
17089
|
-
} else {
|
|
17090
|
-
xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 embedTrueTypeFonts="true">');
|
|
17091
|
-
}
|
|
17092
|
-
if (/saveSubsetFonts=/i.test(xml)) {
|
|
17093
|
-
xml = xml.replace(/saveSubsetFonts="[^"]*"/i, 'saveSubsetFonts="true"');
|
|
17094
|
-
} else {
|
|
17095
|
-
xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 saveSubsetFonts="true">');
|
|
17096
|
-
}
|
|
17097
|
-
return xml;
|
|
17098
|
-
}
|
|
17099
|
-
function buildEmbeddedFontLst(fonts) {
|
|
17100
|
-
let lst = '<p:embeddedFontLst>';
|
|
17101
|
-
for (const font of fonts){
|
|
17102
|
-
lst += '<p:embeddedFont>' + `<p:font typeface="${escapeXmlAttr(font.name)}"/>` + `<p:regular r:id="rId${font.rid}"/>` + '</p:embeddedFont>';
|
|
17103
|
-
}
|
|
17104
|
-
lst += '</p:embeddedFontLst>';
|
|
17105
|
-
return lst;
|
|
17106
|
-
}
|
|
17107
|
-
function escapeXmlAttr(value) {
|
|
17108
|
-
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
17109
|
-
}
|
|
17110
|
-
function ensureEmbeddedFontLst(presentationXml, fonts) {
|
|
17111
|
-
const lst = buildEmbeddedFontLst(fonts);
|
|
17112
|
-
if (/<p:embeddedFontLst[\s>]/i.test(presentationXml)) {
|
|
17113
|
-
// Replace existing list wholesale (export always owns the registered set)
|
|
17114
|
-
return presentationXml.replace(/<p:embeddedFontLst[\s\S]*?<\/p:embeddedFontLst>/i, lst);
|
|
17115
|
-
}
|
|
17116
|
-
// ISO 29500: embeddedFontLst precedes defaultTextStyle.
|
|
17117
|
-
// Insert after the full opening tag (match consumes `>` or attrs so it's preserved).
|
|
17118
|
-
const dtsOpen = presentationXml.match(/<p:defaultTextStyle(?:\s[^>]*)?>/i);
|
|
17119
|
-
if (dtsOpen) {
|
|
17120
|
-
return presentationXml.replace(dtsOpen[0], `${lst}${dtsOpen[0]}`);
|
|
17121
|
-
}
|
|
17122
|
-
// Fallback: before closing presentation
|
|
17123
|
-
return presentationXml.replace(/<\/p:presentation>/i, `${lst}</p:presentation>`);
|
|
17124
|
-
}
|
|
17125
|
-
function appendFontRelationships(relsXml, fonts) {
|
|
17126
|
-
const nodes = fonts.map((font)=>`<Relationship Id="rId${font.rid}" ` + `Type="${FONT_REL_TYPE}" ` + `Target="fonts/${font.rid}.fntdata"/>`).join('');
|
|
17127
|
-
if (!nodes) return relsXml;
|
|
17128
|
-
return relsXml.replace(/<\/Relationships>/i, `${nodes}</Relationships>`);
|
|
17129
|
-
}
|
|
17130
|
-
/**
|
|
17131
|
-
* Convert registered fonts into OOXML `ppt/fonts/*.fntdata` + presentation.xml entries.
|
|
17132
|
-
* Mutates `zip` in place (before generateAsync).
|
|
17133
|
-
*/ function embedFontsIntoZip(zip, fonts) {
|
|
17134
|
-
return gen_fonts_async_to_generator(function*() {
|
|
17135
|
-
if (fonts.length === 0) return;
|
|
17136
|
-
const prepared = [];
|
|
17137
|
-
let nextRid = FONT_RID_START;
|
|
17138
|
-
for (const font of fonts){
|
|
17139
|
-
prepared.push({
|
|
17140
|
-
name: font.fontFace,
|
|
17141
|
-
data: yield toFntdata(font.fontType, font.fontFile),
|
|
17142
|
-
rid: nextRid++
|
|
17143
|
-
});
|
|
17144
|
-
}
|
|
17145
|
-
const contentTypesFile = zip.file('[Content_Types].xml');
|
|
17146
|
-
if (!contentTypesFile) throw new Error('[Content_Types].xml not found');
|
|
17147
|
-
addZipFile(zip, '[Content_Types].xml', ensureFntdataContentType((yield contentTypesFile.async('string'))));
|
|
17148
|
-
const presentationFile = zip.file('ppt/presentation.xml');
|
|
17149
|
-
if (!presentationFile) throw new Error('ppt/presentation.xml not found');
|
|
17150
|
-
let presentationXml = yield presentationFile.async('string');
|
|
17151
|
-
presentationXml = ensurePresentationFontAttrs(presentationXml);
|
|
17152
|
-
presentationXml = ensureEmbeddedFontLst(presentationXml, prepared);
|
|
17153
|
-
addZipFile(zip, 'ppt/presentation.xml', presentationXml);
|
|
17154
|
-
const relsFile = zip.file('ppt/_rels/presentation.xml.rels');
|
|
17155
|
-
if (!relsFile) throw new Error('ppt/_rels/presentation.xml.rels not found');
|
|
17156
|
-
addZipFile(zip, 'ppt/_rels/presentation.xml.rels', appendFontRelationships((yield relsFile.async('string')), prepared));
|
|
17157
|
-
for (const font of prepared){
|
|
17158
|
-
addZipFile(zip, `ppt/fonts/${font.rid}.fntdata`, font.data, {
|
|
17159
|
-
binary: true,
|
|
17160
|
-
compression: 'DEFLATE'
|
|
17161
|
-
});
|
|
17662
|
+
throw new Error('WOFF conversion requires options.inflate (pako)');
|
|
17162
17663
|
}
|
|
17163
|
-
|
|
17664
|
+
const ttfBuffer = woff2ttf(fontBuffer, opts);
|
|
17665
|
+
ttfObject = new TTFReader(opts).read(ttfBuffer);
|
|
17666
|
+
} else {
|
|
17667
|
+
throw new Error(`Unsupported font type for EOT conversion: ${String(type)}`);
|
|
17668
|
+
}
|
|
17669
|
+
const ttfBuffer = new TTFWriter(opts).write(ttfObject);
|
|
17670
|
+
return ttf2eot(ttfBuffer, opts);
|
|
17164
17671
|
}
|
|
17165
17672
|
|
|
17166
|
-
|
|
17673
|
+
/**
|
|
17674
|
+
* PptxGenJS: Opt-in embedded TrueType fonts (OOXML `ppt/fonts/*.fntdata`)
|
|
17675
|
+
*
|
|
17676
|
+
* `embedFontsIntoZip` is a no-op when `fonts` is empty — default export never
|
|
17677
|
+
* writes Font parts, fntdata content types, or Presentation font relationships.
|
|
17678
|
+
* Callers supply their own font bytes via `addFont` and must have a license
|
|
17679
|
+
* that permits embedding those files. This library ships no font files.
|
|
17680
|
+
*
|
|
17681
|
+
* Font-embed orchestration absorbed from MIT `pptx-embed-fonts`
|
|
17682
|
+
* (https://github.com/liyao1520/pptx-embed-fonts). TTF/OTF/WOFF→EOT conversion is a
|
|
17683
|
+
* vendored subset of MIT `fonteditor-core` under `src/vendor/fonteditor-core`
|
|
17684
|
+
* (https://github.com/kekee000/fonteditor-core). WOFF inflate uses pako 3.
|
|
17685
|
+
*/ function gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17167
17686
|
try {
|
|
17168
17687
|
var info = gen[key](arg);
|
|
17169
17688
|
var value = info.value;
|
|
@@ -17174,364 +17693,143 @@ function gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key,
|
|
|
17174
17693
|
if (info.done) resolve(value);
|
|
17175
17694
|
else Promise.resolve(value).then(_next, _throw);
|
|
17176
17695
|
}
|
|
17177
|
-
function
|
|
17696
|
+
function gen_fonts_async_to_generator(fn) {
|
|
17178
17697
|
return function() {
|
|
17179
|
-
var self = this, args = arguments;
|
|
17180
|
-
return new Promise(function(resolve, reject) {
|
|
17181
|
-
var gen = fn.apply(self, args);
|
|
17182
|
-
function _next(value) {
|
|
17183
|
-
|
|
17184
|
-
}
|
|
17185
|
-
function _throw(err) {
|
|
17186
|
-
gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
17187
|
-
}
|
|
17188
|
-
_next(undefined);
|
|
17189
|
-
});
|
|
17190
|
-
};
|
|
17191
|
-
}
|
|
17192
|
-
/**
|
|
17193
|
-
* PptxGenJS: Media Methods
|
|
17194
|
-
*/
|
|
17195
|
-
|
|
17196
|
-
/** Images are measured in pixels; PowerPoint slide dimensions are inches at 96 DPI */ const IMAGE_DPI = 96;
|
|
17197
|
-
/**
|
|
17198
|
-
* Read the natural pixel dimensions of a raster image from its header bytes.
|
|
17199
|
-
* Self-contained replacement for the `image-size` package (PNG/JPEG/GIF/BMP).
|
|
17200
|
-
* Format refs: PNG spec §11.2.2 (IHDR is always the first chunk, width/height big-endian at bytes 16-24);
|
|
17201
|
-
* JPEG (JFIF) SOF0-SOF15 markers carry height then width big-endian; GIF87a/89a logical-screen descriptor
|
|
17202
|
-
* little-endian at bytes 6-10; BMP DIB header little-endian at bytes 18-26. SVG is sized separately (gen-objects).
|
|
17203
|
-
*
|
|
17204
|
-
* Declared dims are header-only (we never decode pixels), so clamp to a sane ceiling: a maliciously crafted
|
|
17205
|
-
* header can claim 0xFFFFFFFF px and emit a ~44-million-inch slide (a corrupt pptx). PowerPoint's max slide is
|
|
17206
|
-
* 56 in (5376 px @ 96 DPI); 100 000 px is generous headroom for legit high-res sources while rejecting bombs.
|
|
17207
|
-
*/ const MAX_IMAGE_PX = 100000;
|
|
17208
|
-
function imageDimensions(bytes) {
|
|
17209
|
-
if (bytes.length < 10) return {} // every supported header's dims start at/after byte 6
|
|
17210
|
-
;
|
|
17211
|
-
const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
17212
|
-
const sane = (w, h)=>w > 0 && h > 0 && w <= MAX_IMAGE_PX && h <= MAX_IMAGE_PX ? {
|
|
17213
|
-
width: w,
|
|
17214
|
-
height: h
|
|
17215
|
-
} : {};
|
|
17216
|
-
// PNG: 8-byte signature 89 50 4E 47 0D 0A 1A 0A, then IHDR length(4)+type(4)+width(4)+height(4)
|
|
17217
|
-
if (bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) {
|
|
17218
|
-
if (bytes.length < 24) return {};
|
|
17219
|
-
return sane(dv.getUint32(16, false), dv.getUint32(20, false));
|
|
17220
|
-
}
|
|
17221
|
-
// GIF: 'GIF87a'/'GIF89a', logical screen width/height little-endian at bytes 6-10
|
|
17222
|
-
if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46) {
|
|
17223
|
-
return sane(dv.getUint16(6, true), dv.getUint16(8, true));
|
|
17224
|
-
}
|
|
17225
|
-
// BMP: 'BM', DIB width/height little-endian at bytes 18-26 (signed; height may be negative = top-down)
|
|
17226
|
-
if (bytes[0] === 0x42 && bytes[1] === 0x4d) {
|
|
17227
|
-
if (bytes.length < 26) return {};
|
|
17228
|
-
return sane(Math.abs(dv.getInt32(18, true)), Math.abs(dv.getInt32(22, true)));
|
|
17229
|
-
}
|
|
17230
|
-
// JPEG: FF D8, then walk marker segments until a Start-Of-Frame (C0-CF except C4/C8/CC) carries the dims
|
|
17231
|
-
if (bytes[0] === 0xff && bytes[1] === 0xd8) {
|
|
17232
|
-
let off = 2;
|
|
17233
|
-
while(off + 9 <= bytes.length){
|
|
17234
|
-
if (bytes[off] !== 0xff) {
|
|
17235
|
-
off++;
|
|
17236
|
-
continue;
|
|
17237
|
-
}
|
|
17238
|
-
const marker = bytes[off + 1];
|
|
17239
|
-
const isSOF = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
|
|
17240
|
-
if (isSOF) return sane(dv.getUint16(off + 7, false), dv.getUint16(off + 5, false));
|
|
17241
|
-
if (marker === 0xd8 || marker === 0xd9 || marker >= 0xd0 && marker <= 0xd7) {
|
|
17242
|
-
off += 2;
|
|
17243
|
-
continue;
|
|
17244
|
-
} // no length
|
|
17245
|
-
const segLen = dv.getUint16(off + 2, false);
|
|
17246
|
-
off += 2 + segLen;
|
|
17247
|
-
}
|
|
17248
|
-
}
|
|
17249
|
-
return {};
|
|
17250
|
-
}
|
|
17251
|
-
/**
|
|
17252
|
-
* Natural pixel size from encoded image bytes (PNG/JPEG/GIF/BMP headers).
|
|
17253
|
-
* Returns null when the payload is missing, not a supported raster, or claims 0×0
|
|
17254
|
-
* (`imageDimensions` already rejects zero and bomb-sized headers).
|
|
17255
|
-
*
|
|
17256
|
-
* contain/cover `a:srcRect` (ECMA-376 §5.1.10.55) needs the *blip* aspect, not the
|
|
17257
|
-
* placement box — using w/h as imgSize makes srcRect a no-op whenever they match the sizing box.
|
|
17258
|
-
*/ function getImagePixelSize(base64Data) {
|
|
17259
|
-
if (typeof base64Data !== 'string' || !base64Data || base64Data === IMG_BROKEN) return null;
|
|
17260
|
-
try {
|
|
17261
|
-
const dims = imageDimensions(base64ToBytes(base64Data));
|
|
17262
|
-
if (dims.width && dims.height) return {
|
|
17263
|
-
w: dims.width,
|
|
17264
|
-
h: dims.height
|
|
17265
|
-
};
|
|
17266
|
-
} catch (unused) {
|
|
17267
|
-
// unrecognized / truncated payload
|
|
17268
|
-
}
|
|
17269
|
-
return null;
|
|
17270
|
-
}
|
|
17271
|
-
/**
|
|
17272
|
-
* Size images added without `w`/`h` to their natural dimensions (issue #34)
|
|
17273
|
-
* @note must run after `encodeSlideMediaRels` has resolved - it reads the encoded image bytes
|
|
17274
|
-
* @param {PresSlide | SlideLayout} layout - slide layout
|
|
17275
|
-
*/ function applyNaturalImageSizes(layout) {
|
|
17276
|
-
layout._slideObjects.filter((obj)=>{
|
|
17277
|
-
var _obj_options;
|
|
17278
|
-
return obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.image */"image") && ((_obj_options = obj.options) === null || _obj_options === void 0 ? void 0 : _obj_options._sizeFromImage);
|
|
17279
|
-
}).forEach((obj)=>{
|
|
17280
|
-
var _layout__relsMedia_find;
|
|
17281
|
-
const strData = (_layout__relsMedia_find = layout._relsMedia.find((rel)=>rel.rId === obj.imageRid)) === null || _layout__relsMedia_find === void 0 ? void 0 : _layout__relsMedia_find.data;
|
|
17282
|
-
if (!obj.options || typeof strData !== 'string' || !strData || strData === IMG_BROKEN) return;
|
|
17283
|
-
// An image bound to a placeholder inherits the placeholder's w/h (slide XML resolves it); sizing it
|
|
17284
|
-
// to its natural pixel dims instead would collapse it to ~px/96 inches (issue #996).
|
|
17285
|
-
if (obj.options.placeholder) return;
|
|
17286
|
-
try {
|
|
17287
|
-
const dims = imageDimensions(base64ToBytes(strData));
|
|
17288
|
-
if (dims.width && dims.height) {
|
|
17289
|
-
obj.options.w = dims.width / IMAGE_DPI;
|
|
17290
|
-
obj.options.h = dims.height / IMAGE_DPI;
|
|
17291
|
-
}
|
|
17292
|
-
} catch (_ex) {
|
|
17293
|
-
// Unreadable/unsupported image: keep the 1x1 inch default
|
|
17294
|
-
}
|
|
17295
|
-
});
|
|
17296
|
-
}
|
|
17297
|
-
/** Select relations that still need their local or remote media encoded. */ function getMediaCandidates(layout) {
|
|
17298
|
-
return layout._relsMedia.filter((rel)=>!rel.isLinked && rel.type !== 'online' && !rel.data && (!rel.path || rel.path && !rel.path.includes('preencoded')));
|
|
17299
|
-
}
|
|
17300
|
-
/**
|
|
17301
|
-
* Mark repeated source paths so only the first relation performs I/O.
|
|
17302
|
-
*
|
|
17303
|
-
* Mutates `isDuplicate`; subsequent helpers copy the first result to every duplicate.
|
|
17304
|
-
*/ function markDuplicateMedia(candidates) {
|
|
17305
|
-
const paths = new Set();
|
|
17306
|
-
candidates.forEach((rel)=>{
|
|
17307
|
-
var _rel_path;
|
|
17308
|
-
const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
|
|
17309
|
-
rel.isDuplicate = paths.has(path);
|
|
17310
|
-
paths.add(path);
|
|
17311
|
-
});
|
|
17312
|
-
}
|
|
17313
|
-
/** Copy an encoded or broken source relation's data to every duplicate path. */ function copyMediaToDuplicates(candidates, rel) {
|
|
17314
|
-
candidates.filter((duplicate)=>duplicate.isDuplicate && duplicate.path === rel.path).forEach((duplicate)=>duplicate.data = rel.data);
|
|
17315
|
-
}
|
|
17316
|
-
/** Mark a failed source and all duplicates with the sentinel expected by package generation. */ function markMediaBroken(candidates, rel) {
|
|
17317
|
-
rel.data = IMG_BROKEN;
|
|
17318
|
-
copyMediaToDuplicates(candidates, rel);
|
|
17319
|
-
}
|
|
17320
|
-
function mediaLoadFailed(candidates, rel, message, onError) {
|
|
17321
|
-
markMediaBroken(candidates, rel);
|
|
17322
|
-
if (onError === 'placeholder') {
|
|
17323
|
-
console.warn(`WARN: Unable to load image, using placeholder: ${rel.path}${message ? ` (${message})` : ''}`);
|
|
17324
|
-
return 'done';
|
|
17325
|
-
}
|
|
17326
|
-
throw new Error(message);
|
|
17327
|
-
}
|
|
17328
|
-
/**
|
|
17329
|
-
* Read one Node-local media source and encode it as base64.
|
|
17330
|
-
*
|
|
17331
|
-
* A read failure is recorded before rejection so duplicate references remain consistent.
|
|
17332
|
-
*/ function readNodeMediaFile(rel, candidates, fs, onError) {
|
|
17333
|
-
return gen_media_async_to_generator(function*() {
|
|
17334
|
-
try {
|
|
17335
|
-
var _rel_path;
|
|
17336
|
-
var _rel_fill;
|
|
17337
|
-
const relPath = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
|
|
17338
|
-
const svgFill = typeof ((_rel_fill = rel.fill) === null || _rel_fill === void 0 ? void 0 : _rel_fill.color) === 'string' ? rel.fill.color : undefined;
|
|
17339
|
-
if (svgFill && (rel.type === 'image/svg+xml' || rel.extn === 'svg')) {
|
|
17340
|
-
const svgText = applySvgFillColor(fs.readFileSync(relPath, 'utf8'), svgFill);
|
|
17341
|
-
rel.data = utf8ToBase64(svgText);
|
|
17342
|
-
} else {
|
|
17343
|
-
const bitmap = fs.readFileSync(relPath);
|
|
17344
|
-
rel.data = bytesToBase64(new Uint8Array(bitmap));
|
|
17345
|
-
if (svgFill && typeof rel.data === 'string') {
|
|
17346
|
-
rel.data = applySvgFillToDataUrl(rel.data, svgFill);
|
|
17347
|
-
}
|
|
17348
|
-
}
|
|
17349
|
-
copyMediaToDuplicates(candidates, rel);
|
|
17350
|
-
return 'done';
|
|
17351
|
-
} catch (ex) {
|
|
17352
|
-
return mediaLoadFailed(candidates, rel, `ERROR: Unable to read media: "${rel.path}"\n${String(ex)}`, onError);
|
|
17353
|
-
}
|
|
17354
|
-
})();
|
|
17355
|
-
}
|
|
17356
|
-
/**
|
|
17357
|
-
* Load one HTTP(S) source in Node, draining error responses and handling both request and response errors.
|
|
17358
|
-
*/ function loadNodeMediaUrl(rel, candidates, https, http, onError) {
|
|
17359
|
-
var _rel_path;
|
|
17360
|
-
const httpMod = ((_rel_path = rel.path) === null || _rel_path === void 0 ? void 0 : _rel_path.startsWith('http://')) ? http : https;
|
|
17361
|
-
return new Promise((resolve, reject)=>{
|
|
17362
|
-
const fail = (message)=>{
|
|
17363
|
-
try {
|
|
17364
|
-
resolve(mediaLoadFailed(candidates, rel, message, onError));
|
|
17365
|
-
} catch (ex) {
|
|
17366
|
-
reject(ex);
|
|
17367
|
-
}
|
|
17368
|
-
};
|
|
17369
|
-
try {
|
|
17370
|
-
var _rel_path;
|
|
17371
|
-
const req = httpMod.get((_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '', (res)=>{
|
|
17372
|
-
var _res_statusCode;
|
|
17373
|
-
const status = (_res_statusCode = res.statusCode) !== null && _res_statusCode !== void 0 ? _res_statusCode : 0;
|
|
17374
|
-
if (status < 200 || status > 299) {
|
|
17375
|
-
res.resume(); // drain so the socket is freed
|
|
17376
|
-
fail(`ERROR! Unable to load image (HTTP ${status}): ${rel.path}`);
|
|
17377
|
-
return;
|
|
17378
|
-
}
|
|
17379
|
-
let raw = '';
|
|
17380
|
-
res.setEncoding('binary'); // IMPORTANT: Only binary encoding works
|
|
17381
|
-
res.on('data', (chunk)=>raw += chunk);
|
|
17382
|
-
res.on('end', ()=>{
|
|
17383
|
-
rel.data = binaryStringToBase64(raw);
|
|
17384
|
-
copyMediaToDuplicates(candidates, rel);
|
|
17385
|
-
resolve('done');
|
|
17386
|
-
});
|
|
17387
|
-
res.on('error', ()=>fail(`ERROR! Unable to load image (response): ${rel.path}`));
|
|
17388
|
-
});
|
|
17389
|
-
// NOTE: without this, a DNS/TLS/connection failure emits an unhandled 'error' and kills the process
|
|
17390
|
-
req.on('error', (ex)=>fail(`ERROR! Unable to load image (request): ${rel.path}\n${String(ex)}`));
|
|
17391
|
-
} catch (ex) {
|
|
17392
|
-
fail(`ERROR! Unable to load image (https.get): ${rel.path}\n${String(ex)}`);
|
|
17393
|
-
}
|
|
17394
|
-
});
|
|
17395
|
-
}
|
|
17396
|
-
/**
|
|
17397
|
-
* Fetch one browser media source and convert its Blob response to a data URL.
|
|
17398
|
-
* SVG previews are produced only after the source relation has been populated.
|
|
17399
|
-
*/ function loadBrowserMedia(rel, candidates, onError) {
|
|
17400
|
-
return new Promise((resolve, reject)=>{
|
|
17401
|
-
var _rel_path;
|
|
17402
|
-
const fail = (message)=>{
|
|
17403
|
-
try {
|
|
17404
|
-
resolve(mediaLoadFailed(candidates, rel, message, onError));
|
|
17405
|
-
} catch (ex) {
|
|
17406
|
-
reject(ex);
|
|
17407
|
-
}
|
|
17408
|
-
};
|
|
17409
|
-
const xhr = new XMLHttpRequest();
|
|
17410
|
-
xhr.onload = ()=>{
|
|
17411
|
-
// status 0 = non-HTTP schemes (file://); anything outside 2xx is an error page, not image bytes
|
|
17412
|
-
if (xhr.status !== 0 && (xhr.status < 200 || xhr.status > 299)) {
|
|
17413
|
-
fail(`ERROR! HTTP status ${xhr.status} loading image: ${rel.path}`);
|
|
17414
|
-
return;
|
|
17698
|
+
var self = this, args = arguments;
|
|
17699
|
+
return new Promise(function(resolve, reject) {
|
|
17700
|
+
var gen = fn.apply(self, args);
|
|
17701
|
+
function _next(value) {
|
|
17702
|
+
gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
17415
17703
|
}
|
|
17416
|
-
|
|
17417
|
-
|
|
17418
|
-
|
|
17419
|
-
|
|
17420
|
-
|
|
17421
|
-
|
|
17422
|
-
};
|
|
17423
|
-
reader.readAsDataURL(xhr.response);
|
|
17424
|
-
};
|
|
17425
|
-
xhr.onerror = ()=>{
|
|
17426
|
-
fail(`ERROR! Unable to load image (xhr.onerror): ${rel.path}`);
|
|
17427
|
-
};
|
|
17428
|
-
xhr.open('GET', (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '');
|
|
17429
|
-
xhr.responseType = 'blob';
|
|
17430
|
-
xhr.send();
|
|
17431
|
-
});
|
|
17704
|
+
function _throw(err) {
|
|
17705
|
+
gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
17706
|
+
}
|
|
17707
|
+
_next(undefined);
|
|
17708
|
+
});
|
|
17709
|
+
};
|
|
17432
17710
|
}
|
|
17433
|
-
|
|
17434
|
-
|
|
17435
|
-
|
|
17436
|
-
|
|
17437
|
-
|
|
17438
|
-
|
|
17439
|
-
|
|
17440
|
-
|
|
17711
|
+
|
|
17712
|
+
|
|
17713
|
+
/** High rId base so font relationships do not collide with slide/master rIds */ const FONT_RID_START = 201314;
|
|
17714
|
+
const FONT_REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/font';
|
|
17715
|
+
/**
|
|
17716
|
+
* Convert TTF / OTF / WOFF bytes to EOT (Office `fntdata` payload).
|
|
17717
|
+
* Lazy-loads pako only for WOFF.
|
|
17718
|
+
*/ function fontToEot(type, fontBuffer) {
|
|
17719
|
+
return gen_fonts_async_to_generator(function*() {
|
|
17720
|
+
const options = {
|
|
17721
|
+
hinting: true
|
|
17722
|
+
};
|
|
17723
|
+
if (type === 'woff') {
|
|
17724
|
+
// pako 3: named exports only; InflateInput is Uint8Array | ArrayBuffer (not number[])
|
|
17725
|
+
const { inflate } = yield import("pako");
|
|
17726
|
+
options.inflate = (deflatedData)=>Array.from(inflate(Uint8Array.from(deflatedData)));
|
|
17727
|
+
}
|
|
17728
|
+
return convertToEot(type, fontBuffer, options);
|
|
17441
17729
|
})();
|
|
17442
17730
|
}
|
|
17443
|
-
|
|
17444
|
-
*
|
|
17445
|
-
|
|
17446
|
-
|
|
17447
|
-
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
|
|
17453
|
-
|
|
17454
|
-
|
|
17731
|
+
function toFntdata(fontType, fontFile) {
|
|
17732
|
+
return gen_fonts_async_to_generator(function*() {
|
|
17733
|
+
switch(fontType){
|
|
17734
|
+
case 'eot':
|
|
17735
|
+
// EOT bytes are stored as-is under ppt/fonts/*.fntdata
|
|
17736
|
+
return fontFile;
|
|
17737
|
+
case 'ttf':
|
|
17738
|
+
case 'otf':
|
|
17739
|
+
case 'woff':
|
|
17740
|
+
return yield fontToEot(fontType, fontFile);
|
|
17741
|
+
default:
|
|
17742
|
+
throw new Error(`Invalid font type "${String(fontType)}" - use ttf | otf | woff | eot`);
|
|
17455
17743
|
}
|
|
17456
|
-
});
|
|
17744
|
+
})();
|
|
17457
17745
|
}
|
|
17458
|
-
|
|
17459
|
-
|
|
17460
|
-
|
|
17461
|
-
|
|
17462
|
-
|
|
17463
|
-
|
|
17464
|
-
|
|
17465
|
-
|
|
17466
|
-
|
|
17467
|
-
|
|
17468
|
-
|
|
17469
|
-
|
|
17470
|
-
|
|
17471
|
-
|
|
17472
|
-
|
|
17473
|
-
|
|
17474
|
-
|
|
17475
|
-
|
|
17476
|
-
|
|
17477
|
-
|
|
17478
|
-
|
|
17479
|
-
|
|
17480
|
-
|
|
17481
|
-
|
|
17482
|
-
|
|
17483
|
-
|
|
17484
|
-
|
|
17485
|
-
|
|
17486
|
-
|
|
17487
|
-
|
|
17488
|
-
|
|
17489
|
-
|
|
17490
|
-
return
|
|
17746
|
+
function ensureFntdataContentType(contentTypesXml) {
|
|
17747
|
+
if (/Extension="fntdata"/i.test(contentTypesXml)) return contentTypesXml;
|
|
17748
|
+
const entry = '<Default Extension="fntdata" ContentType="application/x-fontdata"/>';
|
|
17749
|
+
// Prefer inserting among other Defaults near the top of <Types>
|
|
17750
|
+
if (/<Default\b/i.test(contentTypesXml)) {
|
|
17751
|
+
return contentTypesXml.replace(/<Default\b/i, `${entry}<Default`);
|
|
17752
|
+
}
|
|
17753
|
+
return contentTypesXml.replace(/<Types([^>]*)>/i, `<Types$1>${entry}`);
|
|
17754
|
+
}
|
|
17755
|
+
function ensurePresentationFontAttrs(presentationXml) {
|
|
17756
|
+
let xml = presentationXml;
|
|
17757
|
+
if (/embedTrueTypeFonts=/i.test(xml)) {
|
|
17758
|
+
xml = xml.replace(/embedTrueTypeFonts="[^"]*"/i, 'embedTrueTypeFonts="true"');
|
|
17759
|
+
} else {
|
|
17760
|
+
xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 embedTrueTypeFonts="true">');
|
|
17761
|
+
}
|
|
17762
|
+
if (/saveSubsetFonts=/i.test(xml)) {
|
|
17763
|
+
xml = xml.replace(/saveSubsetFonts="[^"]*"/i, 'saveSubsetFonts="true"');
|
|
17764
|
+
} else {
|
|
17765
|
+
xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 saveSubsetFonts="true">');
|
|
17766
|
+
}
|
|
17767
|
+
return xml;
|
|
17768
|
+
}
|
|
17769
|
+
function buildEmbeddedFontLst(fonts) {
|
|
17770
|
+
let lst = '<p:embeddedFontLst>';
|
|
17771
|
+
for (const font of fonts){
|
|
17772
|
+
lst += '<p:embeddedFont>' + `<p:font typeface="${escapeXmlAttr(font.name)}"/>` + `<p:regular r:id="rId${font.rid}"/>` + '</p:embeddedFont>';
|
|
17773
|
+
}
|
|
17774
|
+
lst += '</p:embeddedFontLst>';
|
|
17775
|
+
return lst;
|
|
17776
|
+
}
|
|
17777
|
+
function escapeXmlAttr(value) {
|
|
17778
|
+
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
17779
|
+
}
|
|
17780
|
+
function ensureEmbeddedFontLst(presentationXml, fonts) {
|
|
17781
|
+
const lst = buildEmbeddedFontLst(fonts);
|
|
17782
|
+
if (/<p:embeddedFontLst[\s>]/i.test(presentationXml)) {
|
|
17783
|
+
// Replace existing list wholesale (export always owns the registered set)
|
|
17784
|
+
return presentationXml.replace(/<p:embeddedFontLst[\s\S]*?<\/p:embeddedFontLst>/i, lst);
|
|
17785
|
+
}
|
|
17786
|
+
// ISO 29500: embeddedFontLst precedes defaultTextStyle.
|
|
17787
|
+
// Insert after the full opening tag (match consumes `>` or attrs so it's preserved).
|
|
17788
|
+
const dtsOpen = presentationXml.match(/<p:defaultTextStyle(?:\s[^>]*)?>/i);
|
|
17789
|
+
if (dtsOpen) {
|
|
17790
|
+
return presentationXml.replace(dtsOpen[0], `${lst}${dtsOpen[0]}`);
|
|
17791
|
+
}
|
|
17792
|
+
// Fallback: before closing presentation
|
|
17793
|
+
return presentationXml.replace(/<\/p:presentation>/i, `${lst}</p:presentation>`);
|
|
17794
|
+
}
|
|
17795
|
+
function appendFontRelationships(relsXml, fonts) {
|
|
17796
|
+
const nodes = fonts.map((font)=>`<Relationship Id="rId${font.rid}" ` + `Type="${FONT_REL_TYPE}" ` + `Target="fonts/${font.rid}.fntdata"/>`).join('');
|
|
17797
|
+
if (!nodes) return relsXml;
|
|
17798
|
+
return relsXml.replace(/<\/Relationships>/i, `${nodes}</Relationships>`);
|
|
17491
17799
|
}
|
|
17492
17800
|
/**
|
|
17493
|
-
*
|
|
17494
|
-
*
|
|
17495
|
-
|
|
17496
|
-
|
|
17497
|
-
|
|
17498
|
-
|
|
17499
|
-
|
|
17500
|
-
|
|
17501
|
-
|
|
17502
|
-
|
|
17503
|
-
|
|
17504
|
-
|
|
17505
|
-
};
|
|
17506
|
-
|
|
17507
|
-
|
|
17508
|
-
|
|
17509
|
-
|
|
17510
|
-
|
|
17511
|
-
|
|
17512
|
-
|
|
17513
|
-
|
|
17514
|
-
|
|
17515
|
-
|
|
17516
|
-
|
|
17517
|
-
|
|
17518
|
-
|
|
17519
|
-
|
|
17520
|
-
|
|
17521
|
-
|
|
17522
|
-
|
|
17523
|
-
|
|
17524
|
-
|
|
17525
|
-
rel.data = canvas.toDataURL(rel.type);
|
|
17526
|
-
resolve('done');
|
|
17527
|
-
} catch (_ex) {
|
|
17528
|
-
handleError();
|
|
17529
|
-
}
|
|
17530
|
-
};
|
|
17531
|
-
image.onerror = handleError;
|
|
17532
|
-
// C: Load image
|
|
17533
|
-
image.src = typeof rel.data === 'string' ? rel.data : IMG_BROKEN;
|
|
17534
|
-
});
|
|
17801
|
+
* Convert registered fonts into OOXML `ppt/fonts/*.fntdata` + presentation.xml entries.
|
|
17802
|
+
* Mutates `zip` in place (before generateAsync).
|
|
17803
|
+
*/ function embedFontsIntoZip(zip, fonts) {
|
|
17804
|
+
return gen_fonts_async_to_generator(function*() {
|
|
17805
|
+
if (fonts.length === 0) return;
|
|
17806
|
+
const prepared = [];
|
|
17807
|
+
let nextRid = FONT_RID_START;
|
|
17808
|
+
for (const font of fonts){
|
|
17809
|
+
prepared.push({
|
|
17810
|
+
name: font.fontFace,
|
|
17811
|
+
data: yield toFntdata(font.fontType, font.fontFile),
|
|
17812
|
+
rid: nextRid++
|
|
17813
|
+
});
|
|
17814
|
+
}
|
|
17815
|
+
const contentTypesFile = zip.file('[Content_Types].xml');
|
|
17816
|
+
if (!contentTypesFile) throw new Error('[Content_Types].xml not found');
|
|
17817
|
+
addZipFile(zip, '[Content_Types].xml', ensureFntdataContentType((yield contentTypesFile.async('string'))));
|
|
17818
|
+
const presentationFile = zip.file('ppt/presentation.xml');
|
|
17819
|
+
if (!presentationFile) throw new Error('ppt/presentation.xml not found');
|
|
17820
|
+
let presentationXml = yield presentationFile.async('string');
|
|
17821
|
+
presentationXml = ensurePresentationFontAttrs(presentationXml);
|
|
17822
|
+
presentationXml = ensureEmbeddedFontLst(presentationXml, prepared);
|
|
17823
|
+
addZipFile(zip, 'ppt/presentation.xml', presentationXml);
|
|
17824
|
+
const relsFile = zip.file('ppt/_rels/presentation.xml.rels');
|
|
17825
|
+
if (!relsFile) throw new Error('ppt/_rels/presentation.xml.rels not found');
|
|
17826
|
+
addZipFile(zip, 'ppt/_rels/presentation.xml.rels', appendFontRelationships((yield relsFile.async('string')), prepared));
|
|
17827
|
+
for (const font of prepared){
|
|
17828
|
+
addZipFile(zip, `ppt/fonts/${font.rid}.fntdata`, font.data, {
|
|
17829
|
+
binary: true,
|
|
17830
|
+
compression: 'DEFLATE'
|
|
17831
|
+
});
|
|
17832
|
+
}
|
|
17535
17833
|
})();
|
|
17536
17834
|
}
|
|
17537
17835
|
|
|
@@ -21158,11 +21456,11 @@ const ImageSizingXml = {
|
|
|
21158
21456
|
* @returns {string} XML
|
|
21159
21457
|
*/ function genXmlCellBorder(name, border) {
|
|
21160
21458
|
var _ref, _border_width, _border_color;
|
|
21161
|
-
if (border.type === 'none') return `<a:${name}
|
|
21459
|
+
if (border.type === 'none') return `<a:${name}><a:noFill/></a:${name}>`;
|
|
21162
21460
|
const width = (_ref = (_border_width = border.width) !== null && _border_width !== void 0 ? _border_width : border.pt) !== null && _ref !== void 0 ? _ref : DEF_CELL_BORDER.pt;
|
|
21163
21461
|
const borderTransparency = border.transparency;
|
|
21164
|
-
const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${
|
|
21165
|
-
return `<a:${name} w="${
|
|
21462
|
+
const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${clampAlphaPct(borderTransparency)}"/>` : '';
|
|
21463
|
+
return `<a:${name} w="${valToLineWidth(width)}" cap="flat" cmpd="sng" algn="ctr">` + `<a:solidFill>${createColorElement((_border_color = border.color) !== null && _border_color !== void 0 ? _border_color : DEF_CELL_BORDER.color, borderAlpha)}</a:solidFill>` + `<a:prstDash val="${border.type === 'dash' ? 'sysDash' : 'solid'}"/><a:round/>` + '<a:headEnd type="none" w="med" len="med"/><a:tailEnd type="none" w="med" len="med"/>' + `</a:${name}>`;
|
|
21166
21464
|
}
|
|
21167
21465
|
/**
|
|
21168
21466
|
* One `a:audioCd` endpoint (`a:st` or `a:end`).
|
|
@@ -21302,7 +21600,7 @@ const ImageSizingXml = {
|
|
|
21302
21600
|
/**
|
|
21303
21601
|
* Alpha + recolor effects for an image's `a:blip`.
|
|
21304
21602
|
*/ function genXmlBlipEffects(transparency, alpha, recolor) {
|
|
21305
|
-
let xml = transparency ? `<a:alphaModFix amt="${
|
|
21603
|
+
let xml = transparency ? `<a:alphaModFix amt="${clampAlphaPct(transparency)}"/>` : '';
|
|
21306
21604
|
xml += genXmlBlipRecolor(recolor);
|
|
21307
21605
|
if (!alpha) return xml;
|
|
21308
21606
|
if (typeof alpha.replace === 'number' && isFinite(alpha.replace)) xml += `<a:alphaRepl a="${Math.round(Math.min(100, Math.max(0, alpha.replace)) * 1000)}"/>`;
|
|
@@ -21464,7 +21762,7 @@ function resolveShapeId(options, idx, usedIds) {
|
|
|
21464
21762
|
xml += '<a:rect l="l" t="t" r="r" b="b" />';
|
|
21465
21763
|
xml += '<a:pathLst>';
|
|
21466
21764
|
for (const points of pathArrays){
|
|
21467
|
-
xml += `<a:path w="${
|
|
21765
|
+
xml += `<a:path w="${positiveExtent(pathW)}" h="${positiveExtent(pathH)}">`;
|
|
21468
21766
|
points === null || points === void 0 ? void 0 : points.forEach((point, i)=>{
|
|
21469
21767
|
if ('curve' in point) {
|
|
21470
21768
|
switch(point.curve.type){
|
|
@@ -21633,6 +21931,14 @@ function slideObjectToXml(slide) {
|
|
|
21633
21931
|
flipH = line.flipH;
|
|
21634
21932
|
flipV = line.flipV;
|
|
21635
21933
|
}
|
|
21934
|
+
// Clamp extents to ST_PositiveCoordinate (>= 0) after line flip so lines keep negative endpoint deltas
|
|
21935
|
+
if (cx < 0 || cy < 0) {
|
|
21936
|
+
console.warn(`[pptxgenjs] negative size on ${slideItemObj._type}${slideItemObj.options.objectName ? ` "${slideItemObj.options.objectName}"` : ''} - w/h cannot be negative, clamped to 0`);
|
|
21937
|
+
}
|
|
21938
|
+
cx = positiveExtent(cx);
|
|
21939
|
+
cy = positiveExtent(cy);
|
|
21940
|
+
imgWidth = positiveExtent(imgWidth);
|
|
21941
|
+
imgHeight = positiveExtent(imgHeight);
|
|
21636
21942
|
if (flipH) locationAttr += ' flipH="1"';
|
|
21637
21943
|
if (flipV) locationAttr += ' flipV="1"';
|
|
21638
21944
|
if (slideItemObj.options.rotate) locationAttr += ` rot="${convertRotationDegrees(slideItemObj.options.rotate)}"`;
|
|
@@ -21677,7 +21983,7 @@ function slideObjectToXml(slide) {
|
|
|
21677
21983
|
if (w == null || isNaN(w)) {
|
|
21678
21984
|
w = (typeof slideItemObj.options.w === 'number' ? slideItemObj.options.w : 1) / intColCnt;
|
|
21679
21985
|
}
|
|
21680
|
-
strXml += `<a:gridCol w="${
|
|
21986
|
+
strXml += `<a:gridCol w="${positiveExtent(w)}"/>`;
|
|
21681
21987
|
}
|
|
21682
21988
|
strXml += '</a:tblGrid>';
|
|
21683
21989
|
} else {
|
|
@@ -21685,7 +21991,7 @@ function slideObjectToXml(slide) {
|
|
|
21685
21991
|
if (slideItemObj.options.w && !objTabOpts.colW) intColW = Math.round((typeof slideItemObj.options.w === 'number' ? slideItemObj.options.w : 1) / intColCnt);
|
|
21686
21992
|
strXml += '<a:tblGrid>';
|
|
21687
21993
|
for(let colw = 0; colw < intColCnt; colw++){
|
|
21688
|
-
strXml += `<a:gridCol w="${intColW}"/>`;
|
|
21994
|
+
strXml += `<a:gridCol w="${positiveExtent(intColW)}"/>`;
|
|
21689
21995
|
}
|
|
21690
21996
|
strXml += '</a:tblGrid>';
|
|
21691
21997
|
}
|
|
@@ -21763,7 +22069,7 @@ function slideObjectToXml(slide) {
|
|
|
21763
22069
|
intRowH = Math.round((itemOpts.h ? inch2Emu(itemOpts.h) : typeof itemOpts.cy === 'number' ? itemOpts.cy : 1) / arrTabRows.length);
|
|
21764
22070
|
}
|
|
21765
22071
|
// B: Start row
|
|
21766
|
-
strXml += `<a:tr h="${intRowH}">`;
|
|
22072
|
+
strXml += `<a:tr h="${positiveExtent(intRowH)}">`;
|
|
21767
22073
|
// C: Loop over each CELL
|
|
21768
22074
|
cells.forEach((cellObj)=>{
|
|
21769
22075
|
var _ref, _ref1;
|
|
@@ -21796,6 +22102,7 @@ function slideObjectToXml(slide) {
|
|
|
21796
22102
|
'fill',
|
|
21797
22103
|
'fontFace',
|
|
21798
22104
|
'fontSize',
|
|
22105
|
+
'lang',
|
|
21799
22106
|
'margin',
|
|
21800
22107
|
'textDirection',
|
|
21801
22108
|
'vert',
|
|
@@ -21804,7 +22111,7 @@ function slideObjectToXml(slide) {
|
|
|
21804
22111
|
].forEach((name)=>{
|
|
21805
22112
|
if (objTabOpts[name] && !cellOpts[name] && cellOpts[name] !== 0) cellOpts[name] = objTabOpts[name];
|
|
21806
22113
|
});
|
|
21807
|
-
const cellValign = cellOpts.valign ? ` anchor="${cellOpts.valign.replace(/^c$/i, 'ctr').replace(/^m
|
|
22114
|
+
const cellValign = cellOpts.valign ? ` anchor="${cellOpts.valign.replace(/^c$/i, 'ctr').replace(/^m(id(dle)?)?$/i, 'ctr').replace(/^center$/i, 'ctr').replace(/^top$/i, 't').replace(/^b(tm|ottom)$/i, 'b')}"` : '';
|
|
21808
22115
|
// `vert` = Martin-N alias of `textDirection`
|
|
21809
22116
|
const cellDir = cellOpts.textDirection || cellOpts.vert;
|
|
21810
22117
|
const cellTextDir = cellDir && cellDir !== 'horz' ? ` vert="${cellDir}"` : '';
|
|
@@ -21953,9 +22260,17 @@ function slideObjectToXml(slide) {
|
|
|
21953
22260
|
} else {
|
|
21954
22261
|
var _slideItemObj_options_line_curveadjust, _slideItemObj_options_line7;
|
|
21955
22262
|
strSlideXml += '<a:prstGeom prst="' + slideItemObj.shape + '"><a:avLst>';
|
|
21956
|
-
// `rectRadius
|
|
21957
|
-
|
|
21958
|
-
|
|
22263
|
+
// `rectRadius` adj is a 0..50000 fraction of the shorter side; clamp out-of-range / zero-extent results.
|
|
22264
|
+
// `round2SameRect` uses two handles (`adj1` top corners, `adj2` bottom corners) — single `adj` is ignored.
|
|
22265
|
+
if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius)) {
|
|
22266
|
+
const minDim = Math.min(cx, cy);
|
|
22267
|
+
const rawAdj = minDim > 0 ? slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / minDim : slideItemObj.options.rectRadius > 0 ? 50000 : 0;
|
|
22268
|
+
const adjVal = clampInt(rawAdj, 0, 50000);
|
|
22269
|
+
if (slideItemObj.shape === core_enums_SHAPE_TYPE.ROUND_2_SAME_RECTANGLE) {
|
|
22270
|
+
strSlideXml += `<a:gd name="adj1" fmla="val ${adjVal}"/><a:gd name="adj2" fmla="val 0"/>`;
|
|
22271
|
+
} else {
|
|
22272
|
+
strSlideXml += `<a:gd name="adj" fmla="val ${adjVal}"/>`;
|
|
22273
|
+
}
|
|
21959
22274
|
} else if (slideItemObj.options.angleRange) {
|
|
21960
22275
|
for(let i = 0; i < 2; i++){
|
|
21961
22276
|
const angle = slideItemObj.options.angleRange[i];
|
|
@@ -22068,8 +22383,8 @@ function slideObjectToXml(slide) {
|
|
|
22068
22383
|
// the frame must keep the user's w/h container - collapsing it to the crop box (or 0) breaks
|
|
22069
22384
|
// rendering (issue #1399).
|
|
22070
22385
|
if (sizing.type !== 'crop') {
|
|
22071
|
-
imgWidth = boxW;
|
|
22072
|
-
imgHeight = boxH;
|
|
22386
|
+
imgWidth = positiveExtent(boxW);
|
|
22387
|
+
imgHeight = positiveExtent(boxH);
|
|
22073
22388
|
}
|
|
22074
22389
|
} else {
|
|
22075
22390
|
strSlideXml += ' <a:stretch><a:fillRect/></a:stretch>';
|
|
@@ -22082,8 +22397,10 @@ function slideObjectToXml(slide) {
|
|
|
22082
22397
|
strSlideXml += ' </a:xfrm>';
|
|
22083
22398
|
// Geometry: rectRadius → roundRect; rounding (legacy) → ellipse; else rect
|
|
22084
22399
|
// Selective port of niranjan-uma-shankar/feature/html-to-pptx (keeps ellipse back-compat)
|
|
22085
|
-
if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius)
|
|
22086
|
-
const
|
|
22400
|
+
if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius)) {
|
|
22401
|
+
const minDim = Math.min(imgWidth, imgHeight);
|
|
22402
|
+
const rawAdj = minDim > 0 ? slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / minDim : slideItemObj.options.rectRadius > 0 ? 50000 : 0;
|
|
22403
|
+
const adjValue = clampInt(rawAdj, 0, 50000);
|
|
22087
22404
|
strSlideXml += ` <a:prstGeom prst="roundRect"><a:avLst><a:gd name="adj" fmla="val ${adjValue}"/></a:avLst></a:prstGeom>`;
|
|
22088
22405
|
} else {
|
|
22089
22406
|
strSlideXml += ` <a:prstGeom prst="${rounding ? 'ellipse' : 'rect'}"><a:avLst/></a:prstGeom>`;
|
|
@@ -22113,7 +22430,7 @@ function slideObjectToXml(slide) {
|
|
|
22113
22430
|
const coverRid = (_slideItemObj__coverRid = slideItemObj._coverRid) !== null && _slideItemObj__coverRid !== void 0 ? _slideItemObj__coverRid : 2;
|
|
22114
22431
|
strSlideXml += '<p:pic>';
|
|
22115
22432
|
strSlideXml += ' <p:nvPicPr>';
|
|
22116
|
-
strSlideXml += `<p:cNvPr id="${
|
|
22433
|
+
strSlideXml += `<p:cNvPr id="${shapeId}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
|
|
22117
22434
|
strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
|
|
22118
22435
|
if (slideItemObj.mtype === 'audioCd') {
|
|
22119
22436
|
const cd = slideItemObj.options.audioCd;
|
|
@@ -22129,34 +22446,32 @@ function slideObjectToXml(slide) {
|
|
|
22129
22446
|
strSlideXml += ' </p:spPr>';
|
|
22130
22447
|
strSlideXml += '</p:pic>';
|
|
22131
22448
|
} else if (slideItemObj.mtype === 'online') {
|
|
22132
|
-
var _slideItemObj_mediaRid
|
|
22449
|
+
var _slideItemObj_mediaRid;
|
|
22133
22450
|
const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
|
|
22134
22451
|
strSlideXml += '<p:pic>';
|
|
22135
22452
|
strSlideXml += ' <p:nvPicPr>';
|
|
22136
|
-
|
|
22137
|
-
strSlideXml += `<p:cNvPr id="${((_slideItemObj_mediaRid = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid !== void 0 ? _slideItemObj_mediaRid : 0) + 2}" name="${slideItemObj.options.objectName}"/>`;
|
|
22453
|
+
strSlideXml += `<p:cNvPr id="${shapeId}" name="${slideItemObj.options.objectName}"/>`;
|
|
22138
22454
|
strSlideXml += ' <p:cNvPicPr/>';
|
|
22139
22455
|
strSlideXml += genXmlNvPr(slideItemObj.options, `<a:videoFile r:link="rId${slideItemObj.mediaRid}"${contentType}/>`);
|
|
22140
22456
|
strSlideXml += ' </p:nvPicPr>';
|
|
22141
22457
|
// NOTE: `blip` is diferent than videos; also there's no preview "p:extLst" above but exists in videos
|
|
22142
|
-
strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((
|
|
22458
|
+
strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((_slideItemObj_mediaRid = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid !== void 0 ? _slideItemObj_mediaRid : 0) + 1}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`; // NOTE: Preview image is required!
|
|
22143
22459
|
strSlideXml += ' <p:spPr>';
|
|
22144
22460
|
strSlideXml += ` <a:xfrm${locationAttr}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm>`;
|
|
22145
22461
|
strSlideXml += ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>';
|
|
22146
22462
|
strSlideXml += ' </p:spPr>';
|
|
22147
22463
|
strSlideXml += '</p:pic>';
|
|
22148
22464
|
} else {
|
|
22149
|
-
var _slideItemObj_mediaRid2, _slideItemObj_mediaRid3
|
|
22465
|
+
var _slideItemObj_mediaRid1, _slideItemObj_mediaRid2, _slideItemObj_mediaRid3;
|
|
22150
22466
|
// ECMA-376: audio uses `<a:audioFile>`, video uses `<a:videoFile>` under nvPr.
|
|
22151
22467
|
const mediaFileTag = slideItemObj.mtype === 'audio' ? 'a:audioFile' : 'a:videoFile';
|
|
22152
22468
|
const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
|
|
22153
22469
|
strSlideXml += '<p:pic>';
|
|
22154
22470
|
strSlideXml += ' <p:nvPicPr>';
|
|
22155
|
-
|
|
22156
|
-
strSlideXml += `<p:cNvPr id="${((_slideItemObj_mediaRid2 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid2 !== void 0 ? _slideItemObj_mediaRid2 : 0) + 2}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
|
|
22471
|
+
strSlideXml += `<p:cNvPr id="${shapeId}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
|
|
22157
22472
|
strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
|
|
22158
22473
|
const mediaExtras = genXmlMediaExtras(slideItemObj.options);
|
|
22159
|
-
const mediaExt = '<p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}">' + (mediaExtras ? ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((
|
|
22474
|
+
const mediaExt = '<p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}">' + (mediaExtras ? ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((_slideItemObj_mediaRid1 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid1 !== void 0 ? _slideItemObj_mediaRid1 : 0) + 1}">${mediaExtras} </p14:media>` : ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((_slideItemObj_mediaRid2 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid2 !== void 0 ? _slideItemObj_mediaRid2 : 0) + 1}"/>`) + '</p:ext>';
|
|
22160
22475
|
const narrationExt = slideItemObj.options.isNarration ? '<p:ext uri="{42D2F446-02D8-4167-A562-619A0277C38B}"><p15:isNarration xmlns:p15="http://schemas.microsoft.com/office/powerpoint/2012/main" val="1"/></p:ext>' : '';
|
|
22161
22476
|
strSlideXml += genXmlNvPr(slideItemObj.options, `<${mediaFileTag} r:link="rId${slideItemObj.mediaRid}"${contentType}/>`, narrationExt ? [
|
|
22162
22477
|
mediaExt,
|
|
@@ -22165,7 +22480,7 @@ function slideObjectToXml(slide) {
|
|
|
22165
22480
|
mediaExt
|
|
22166
22481
|
]);
|
|
22167
22482
|
strSlideXml += ' </p:nvPicPr>';
|
|
22168
|
-
strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((
|
|
22483
|
+
strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((_slideItemObj_mediaRid3 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid3 !== void 0 ? _slideItemObj_mediaRid3 : 0) + 2}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`; // NOTE: Preview image is required!
|
|
22169
22484
|
strSlideXml += ' <p:spPr>';
|
|
22170
22485
|
strSlideXml += ` <a:xfrm${locationAttr}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm>`;
|
|
22171
22486
|
strSlideXml += ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>';
|
|
@@ -22348,7 +22663,7 @@ function slideObjectToXml(slide) {
|
|
|
22348
22663
|
strSlideXml += ' <p:nvPr><p:ph type="sldNum" sz="quarter" idx="4294967295"/></p:nvPr>';
|
|
22349
22664
|
strSlideXml += ' </p:nvSpPr>';
|
|
22350
22665
|
strSlideXml += ' <p:spPr>';
|
|
22351
|
-
strSlideXml += '<a:xfrm>' + `<a:off x="${getSmartParseNumber(slide._slideNumberProps.x, 'X', slide._presLayout)}" y="${getSmartParseNumber(slide._slideNumberProps.y, 'Y', slide._presLayout)}"/>` + `<a:ext cx="${slide._slideNumberProps.w ? getSmartParseNumber(slide._slideNumberProps.w, 'X', slide._presLayout) : '800000'}" cy="${slide._slideNumberProps.h ? getSmartParseNumber(slide._slideNumberProps.h, 'Y', slide._presLayout) : '300000'}"/>` + '</a:xfrm>' + ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>' + ' <a:extLst><a:ext uri="{C572A759-6A51-4108-AA02-DFA0A04FC94B}"><ma14:wrappingTextBoxFlag val="0" xmlns:ma14="http://schemas.microsoft.com/office/mac/drawingml/2011/main"/></a:ext></a:extLst>' + '</p:spPr>';
|
|
22666
|
+
strSlideXml += '<a:xfrm>' + `<a:off x="${getSmartParseNumber(slide._slideNumberProps.x, 'X', slide._presLayout)}" y="${getSmartParseNumber(slide._slideNumberProps.y, 'Y', slide._presLayout)}"/>` + `<a:ext cx="${slide._slideNumberProps.w ? positiveExtent(getSmartParseNumber(slide._slideNumberProps.w, 'X', slide._presLayout)) : '800000'}" cy="${slide._slideNumberProps.h ? positiveExtent(getSmartParseNumber(slide._slideNumberProps.h, 'Y', slide._presLayout)) : '300000'}"/>` + '</a:xfrm>' + ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>' + ' <a:extLst><a:ext uri="{C572A759-6A51-4108-AA02-DFA0A04FC94B}"><ma14:wrappingTextBoxFlag val="0" xmlns:ma14="http://schemas.microsoft.com/office/mac/drawingml/2011/main"/></a:ext></a:extLst>' + '</p:spPr>';
|
|
22352
22667
|
strSlideXml += '<p:txBody>';
|
|
22353
22668
|
strSlideXml += '<a:bodyPr';
|
|
22354
22669
|
if (slide._slideNumberProps.margin && Array.isArray(slide._slideNumberProps.margin)) {
|
|
@@ -22368,7 +22683,7 @@ function slideObjectToXml(slide) {
|
|
|
22368
22683
|
strSlideXml += '/>';
|
|
22369
22684
|
strSlideXml += ' <a:lstStyle><a:lvl1pPr>';
|
|
22370
22685
|
if (slide._slideNumberProps.fontFace || slide._slideNumberProps.fontSize || slide._slideNumberProps.color) {
|
|
22371
|
-
strSlideXml += `<a:defRPr sz="${
|
|
22686
|
+
strSlideXml += `<a:defRPr sz="${fontSizeToSz(slide._slideNumberProps.fontSize || 12)}">`;
|
|
22372
22687
|
if (slide._slideNumberProps.color) strSlideXml += genXmlColorSelection(slide._slideNumberProps.color);
|
|
22373
22688
|
if (slide._slideNumberProps.fontFace) {
|
|
22374
22689
|
strSlideXml += `<a:latin typeface="${slide._slideNumberProps.fontFace}"/><a:ea typeface="${slide._slideNumberProps.fontFace}"/><a:cs typeface="${slide._slideNumberProps.fontFace}"/>`;
|
|
@@ -22729,20 +23044,21 @@ function slideShowExtLst(slide) {
|
|
|
22729
23044
|
* @returns {SlideObjectAnimation[]} array of object animations with their indices
|
|
22730
23045
|
*/ /**
|
|
22731
23046
|
* Collect media shapes that need a playback entry in the slide timing tree.
|
|
22732
|
-
* The shape id targeted by `<p:spTgt spid>` is the
|
|
22733
|
-
*
|
|
23047
|
+
* The shape id targeted by `<p:spTgt spid>` is the allocated `<p:cNvPr id>` stamped onto
|
|
23048
|
+
* `obj.options.sId` by `slideObjectToXml`. Online (linked) videos are excluded —
|
|
22734
23049
|
* they don't support the embedded playback timing tree.
|
|
22735
23050
|
*/ function collectMediaPlayback(slide) {
|
|
22736
23051
|
var _slide__slideObjects;
|
|
22737
23052
|
const entries = [];
|
|
22738
|
-
((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).
|
|
22739
|
-
|
|
23053
|
+
const renderable = ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).filter((obj)=>obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.notes */"notes"));
|
|
23054
|
+
renderable.forEach((obj, idx)=>{
|
|
23055
|
+
var _o_sId;
|
|
22740
23056
|
if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.media */"media") || obj.mtype !== 'audio' && obj.mtype !== 'video') return;
|
|
22741
23057
|
const o = obj.options;
|
|
22742
23058
|
// Defaults are all false: no timing node unless at least one playback flag is set.
|
|
22743
23059
|
if (!o || !(o.autoplay || o.loop || o.fullScreen || o.mute)) return;
|
|
22744
23060
|
entries.push({
|
|
22745
|
-
spid: (
|
|
23061
|
+
spid: (_o_sId = o.sId) !== null && _o_sId !== void 0 ? _o_sId : idx + 2,
|
|
22746
23062
|
kind: obj.mtype === 'video' ? 'video' : 'audio',
|
|
22747
23063
|
autoplay: o.autoplay,
|
|
22748
23064
|
loop: o.loop,
|
|
@@ -22756,7 +23072,8 @@ function slideShowExtLst(slide) {
|
|
|
22756
23072
|
function collectSlideAnimations(slide) {
|
|
22757
23073
|
const animations = [];
|
|
22758
23074
|
if (!slide._slideObjects) return animations;
|
|
22759
|
-
slide._slideObjects.
|
|
23075
|
+
const renderable = slide._slideObjects.filter((obj)=>obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.notes */"notes"));
|
|
23076
|
+
renderable.forEach((slideObj, index)=>{
|
|
22760
23077
|
var _ref;
|
|
22761
23078
|
var _slideObj_options, _slideObj_options1, _slideObj_options2;
|
|
22762
23079
|
// Warn when animations are incorrectly attached to individual text runs
|
|
@@ -22795,8 +23112,8 @@ function collectSlideAnimations(slide) {
|
|
|
22795
23112
|
delay: 0
|
|
22796
23113
|
}, animConfig);
|
|
22797
23114
|
}
|
|
22798
|
-
//
|
|
22799
|
-
const shapeId =
|
|
23115
|
+
// `slideObjectToXml` runs first and stamps every object's allocated `p:cNvPr/@id` onto `options.sId`
|
|
23116
|
+
const shapeId = (_ref = (_slideObj_options2 = slideObj.options) === null || _slideObj_options2 === void 0 ? void 0 : _slideObj_options2.sId) !== null && _ref !== void 0 ? _ref : index + 2;
|
|
22800
23117
|
animations.push({
|
|
22801
23118
|
objectIndex: index,
|
|
22802
23119
|
shapeId,
|
|
@@ -22818,6 +23135,9 @@ function collectSlideAnimations(slide) {
|
|
|
22818
23135
|
if (!s._id) s._id = getUuid('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
|
|
22819
23136
|
});
|
|
22820
23137
|
resolveZoomSections(slide, sections);
|
|
23138
|
+
// Render `p:cSld` first so `resolveShapeId` allocates unique `p:cNvPr/@id` values (including media)
|
|
23139
|
+
// and stamps `options.sId` before animations & media playback timing target `<p:spTgt spid="..."/>`.
|
|
23140
|
+
const cSldXml = slideObjectToXml(slide);
|
|
22821
23141
|
const animations = collectSlideAnimations(slide);
|
|
22822
23142
|
const mediaPlayback = collectMediaPlayback(slide);
|
|
22823
23143
|
const timingXml = animations.length > 0 || mediaPlayback.length > 0 ? createTimingXml(animations, mediaPlayback) : '';
|
|
@@ -22832,7 +23152,7 @@ function collectSlideAnimations(slide) {
|
|
|
22832
23152
|
commentRelExt
|
|
22833
23153
|
].filter(Boolean);
|
|
22834
23154
|
const sldExtXml = sldExtLst.length > 0 ? `<p:extLst>${sldExtLst.join('')}</p:extLst>` : '';
|
|
22835
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}` + '<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" ' + 'xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" ' + `xmlns:m="${MATH_NS}" ` + `xmlns:a14="${A14_NS}" ` + (hasP14 ? `xmlns:p14="${P14_NS}" ` : '') + `xmlns:mc="${MC_NS}" mc:Ignorable="a14${hasP14 ? ' p14' : ''}"` + `${(slide === null || slide === void 0 ? void 0 : slide.hidden) ? ' show="0"' : ''}>` + `${
|
|
23155
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}` + '<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" ' + 'xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" ' + `xmlns:m="${MATH_NS}" ` + `xmlns:a14="${A14_NS}" ` + (hasP14 ? `xmlns:p14="${P14_NS}" ` : '') + `xmlns:mc="${MC_NS}" mc:Ignorable="a14${hasP14 ? ' p14' : ''}"` + `${(slide === null || slide === void 0 ? void 0 : slide.hidden) ? ' show="0"' : ''}>` + `${cSldXml}` + '<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>' + `${transitionXml}` + `${timingXml}` + `${sldExtXml}` + '</p:sld>';
|
|
22836
23156
|
}
|
|
22837
23157
|
/**
|
|
22838
23158
|
* Get text content of Notes from Slide
|
|
@@ -22926,21 +23246,54 @@ function collectSlideAnimations(slide) {
|
|
|
22926
23246
|
* Distinct `thm15:themeFamily` ids keep the notes theme from being a byte-identical twin
|
|
22927
23247
|
* (Office repair creates theme2 when notesMaster shares theme1; Juliussssssss 9bdfe09 / SCV-Soft 1a1998e).
|
|
22928
23248
|
* @return {string} XML
|
|
22929
|
-
*/
|
|
22930
|
-
|
|
22931
|
-
|
|
22932
|
-
|
|
22933
|
-
|
|
22934
|
-
|
|
22935
|
-
|
|
23249
|
+
*/ const THEME_COLOR_SLOT_ORDER = [
|
|
23250
|
+
'dk1',
|
|
23251
|
+
'lt1',
|
|
23252
|
+
'dk2',
|
|
23253
|
+
'lt2',
|
|
23254
|
+
'accent1',
|
|
23255
|
+
'accent2',
|
|
23256
|
+
'accent3',
|
|
23257
|
+
'accent4',
|
|
23258
|
+
'accent5',
|
|
23259
|
+
'accent6',
|
|
23260
|
+
'hlink',
|
|
23261
|
+
'folHlink'
|
|
23262
|
+
];
|
|
23263
|
+
function makeXmlTheme(pres, variant = 'slide') {
|
|
23264
|
+
var _pres_theme, _pres_theme1, _pres_theme2, _pres_theme3, _pres_theme4, _pres_theme5, _pres_theme6, _pres_theme7;
|
|
23265
|
+
const headFace = ((_pres_theme = pres.theme) === null || _pres_theme === void 0 ? void 0 : _pres_theme.headFontFace) ? encodeXmlEntities(pres.theme.headFontFace) : '';
|
|
23266
|
+
const bodyFace = ((_pres_theme1 = pres.theme) === null || _pres_theme1 === void 0 ? void 0 : _pres_theme1.bodyFontFace) ? encodeXmlEntities(pres.theme.bodyFontFace) : '';
|
|
23267
|
+
const explicitEa = ((_pres_theme2 = pres.theme) === null || _pres_theme2 === void 0 ? void 0 : _pres_theme2.eaFontFace) !== undefined ? encodeXmlEntities(pres.theme.eaFontFace) : undefined;
|
|
23268
|
+
const explicitCs = ((_pres_theme3 = pres.theme) === null || _pres_theme3 === void 0 ? void 0 : _pres_theme3.csFontFace) !== undefined ? encodeXmlEntities(pres.theme.csFontFace) : undefined;
|
|
23269
|
+
// Without ea/cs faces, East Asian and complex-script runs inheriting the theme font fall back to app defaults.
|
|
23270
|
+
// When `eaFontFace`/`csFontFace` are unset, mirror `headFontFace`/`bodyFontFace` (pitch-io 3049ea49).
|
|
23271
|
+
const majorFont = headFace ? `<a:latin typeface="${headFace}"/><a:ea typeface="${explicitEa !== null && explicitEa !== void 0 ? explicitEa : headFace}"/><a:cs typeface="${explicitCs !== null && explicitCs !== void 0 ? explicitCs : headFace}"/>` : `<a:latin typeface="Calibri Light" panose="020F0302020204030204"/><a:ea typeface="${explicitEa !== null && explicitEa !== void 0 ? explicitEa : ''}"/><a:cs typeface="${explicitCs !== null && explicitCs !== void 0 ? explicitCs : ''}"/>`;
|
|
23272
|
+
const minorFont = bodyFace ? `<a:latin typeface="${bodyFace}"/><a:ea typeface="${explicitEa !== null && explicitEa !== void 0 ? explicitEa : bodyFace}"/><a:cs typeface="${explicitCs !== null && explicitCs !== void 0 ? explicitCs : bodyFace}"/>` : `<a:latin typeface="Calibri" panose="020F0502020204030204"/><a:ea typeface="${explicitEa !== null && explicitEa !== void 0 ? explicitEa : ''}"/><a:cs typeface="${explicitCs !== null && explicitCs !== void 0 ? explicitCs : ''}"/>`;
|
|
22936
23273
|
const themeFamilyId = variant === 'notes' ? '{2E142A2C-CD16-42D6-873A-C26D2A0506FA}' : '{62F939B6-93AF-4DB8-9C6B-D6C7DFDC589F}';
|
|
22937
23274
|
const themeFamilyVid = variant === 'notes' ? '{1BDDFF52-6CD6-40A5-AB3C-68EB2F1E4D0A}' : '{4A3C46E8-61CC-4603-A589-7422A47A8E4A}';
|
|
22938
23275
|
// Exactly 12 hex colors required (upstream only checked truthy `.length`, which allowed short arrays → undefined attrs)
|
|
22939
|
-
const isCustomColors = Array.isArray((_pres_theme6 = pres.theme) === null || _pres_theme6 === void 0 ? void 0 : _pres_theme6.themeColors) && pres.theme.themeColors.length === 12;
|
|
22940
23276
|
const c = resolveThemeColors(pres.theme);
|
|
22941
|
-
|
|
22942
|
-
|
|
22943
|
-
|
|
23277
|
+
let hasNamedColorOverrides = false;
|
|
23278
|
+
if (((_pres_theme4 = pres.theme) === null || _pres_theme4 === void 0 ? void 0 : _pres_theme4.colors) && typeof pres.theme.colors === 'object') {
|
|
23279
|
+
for (const [slot, raw] of Object.entries(pres.theme.colors)){
|
|
23280
|
+
const idx = THEME_COLOR_SLOT_ORDER.indexOf(slot);
|
|
23281
|
+
if (idx < 0 || typeof raw !== 'string') continue;
|
|
23282
|
+
const hex = raw.replace(/^#/, '').toUpperCase();
|
|
23283
|
+
if (/^[0-9A-F]{6}$/.test(hex)) {
|
|
23284
|
+
c[idx] = hex;
|
|
23285
|
+
hasNamedColorOverrides = true;
|
|
23286
|
+
} else {
|
|
23287
|
+
console.warn(`[pptxgenjs] theme.colors.${slot}="${raw}" is not a valid 6-digit hex; using ${c[idx]}`);
|
|
23288
|
+
}
|
|
23289
|
+
}
|
|
23290
|
+
}
|
|
23291
|
+
const isCustomColors = Array.isArray((_pres_theme5 = pres.theme) === null || _pres_theme5 === void 0 ? void 0 : _pres_theme5.themeColors) && pres.theme.themeColors.length === 12 || hasNamedColorOverrides;
|
|
23292
|
+
const customName = ((_pres_theme6 = pres.theme) === null || _pres_theme6 === void 0 ? void 0 : _pres_theme6.name) ? encodeXmlEntities(pres.theme.name) : '';
|
|
23293
|
+
const themeName = customName || (isCustomColors ? 'Custom Theme' : 'Office Theme');
|
|
23294
|
+
const schemeName = customName || (isCustomColors ? 'Custom' : 'Office');
|
|
23295
|
+
const fontSchemeName = ((_pres_theme7 = pres.theme) === null || _pres_theme7 === void 0 ? void 0 : _pres_theme7.fontSchemeName) ? encodeXmlEntities(pres.theme.fontSchemeName) : customName || 'Office';
|
|
23296
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="${themeName}"><a:themeElements><a:clrScheme name="${schemeName}"><a:dk1><a:sysClr val="windowText" lastClr="${c[0]}"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="${c[1]}"/></a:lt1><a:dk2><a:srgbClr val="${c[2]}"/></a:dk2><a:lt2><a:srgbClr val="${c[3]}"/></a:lt2><a:accent1><a:srgbClr val="${c[4]}"/></a:accent1><a:accent2><a:srgbClr val="${c[5]}"/></a:accent2><a:accent3><a:srgbClr val="${c[6]}"/></a:accent3><a:accent4><a:srgbClr val="${c[7]}"/></a:accent4><a:accent5><a:srgbClr val="${c[8]}"/></a:accent5><a:accent6><a:srgbClr val="${c[9]}"/></a:accent6><a:hlink><a:srgbClr val="${c[10]}"/></a:hlink><a:folHlink><a:srgbClr val="${c[11]}"/></a:folHlink></a:clrScheme><a:fontScheme name="${fontSchemeName}"><a:majorFont>${majorFont}<a:font script="Jpan" typeface="游ゴシック Light"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="等线 Light"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Angsana New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/><a:font script="Armn" typeface="Arial"/><a:font script="Bugi" typeface="Leelawadee UI"/><a:font script="Bopo" typeface="Microsoft JhengHei"/><a:font script="Java" typeface="Javanese Text"/><a:font script="Lisu" typeface="Segoe UI"/><a:font script="Mymr" typeface="Myanmar Text"/><a:font script="Nkoo" typeface="Ebrima"/><a:font script="Olck" typeface="Nirmala UI"/><a:font script="Osma" typeface="Ebrima"/><a:font script="Phag" typeface="Phagspa"/><a:font script="Syrn" typeface="Estrangelo Edessa"/><a:font script="Syrj" typeface="Estrangelo Edessa"/><a:font script="Syre" typeface="Estrangelo Edessa"/><a:font script="Sora" typeface="Nirmala UI"/><a:font script="Tale" typeface="Microsoft Tai Le"/><a:font script="Talu" typeface="Microsoft New Tai Lue"/><a:font script="Tfng" typeface="Ebrima"/></a:majorFont><a:minorFont>${minorFont}<a:font script="Jpan" typeface="游ゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="等线"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Cordia New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/><a:font script="Armn" typeface="Arial"/><a:font script="Bugi" typeface="Leelawadee UI"/><a:font script="Bopo" typeface="Microsoft JhengHei"/><a:font script="Java" typeface="Javanese Text"/><a:font script="Lisu" typeface="Segoe UI"/><a:font script="Mymr" typeface="Myanmar Text"/><a:font script="Nkoo" typeface="Ebrima"/><a:font script="Olck" typeface="Nirmala UI"/><a:font script="Osma" typeface="Ebrima"/><a:font script="Phag" typeface="Phagspa"/><a:font script="Syrn" typeface="Estrangelo Edessa"/><a:font script="Syrj" typeface="Estrangelo Edessa"/><a:font script="Syre" typeface="Estrangelo Edessa"/><a:font script="Sora" typeface="Nirmala UI"/><a:font script="Tale" typeface="Microsoft Tai Le"/><a:font script="Talu" typeface="Microsoft New Tai Lue"/><a:font script="Tfng" typeface="Ebrima"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:lumMod val="110000"/><a:satMod val="105000"/><a:tint val="67000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="103000"/><a:tint val="73000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="109000"/><a:tint val="81000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:satMod val="103000"/><a:lumMod val="102000"/><a:tint val="94000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:satMod val="110000"/><a:lumMod val="100000"/><a:shade val="100000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="99000"/><a:satMod val="120000"/><a:shade val="78000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="6350" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="12700" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="19050" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="63000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"><a:tint val="95000"/><a:satMod val="170000"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="93000"/><a:satMod val="150000"/><a:shade val="98000"/><a:lumMod val="102000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:tint val="98000"/><a:satMod val="130000"/><a:shade val="90000"/><a:lumMod val="103000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="63000"/><a:satMod val="120000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/><a:extLst><a:ext uri="{05A4C25C-085E-4340-85A3-A5531E510DB2}"><thm15:themeFamily xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main" name="Office Theme" id="${themeFamilyId}" vid="${themeFamilyVid}"/></a:ext></a:extLst></a:theme>`;
|
|
22944
23297
|
}
|
|
22945
23298
|
const package_P15_NS = 'http://schemas.microsoft.com/office/powerpoint/2012/main';
|
|
22946
23299
|
const SLD_GUIDE_URI = '{EFAFB233-063F-42B5-8137-9DF3F51BA10A}';
|
|
@@ -22994,7 +23347,8 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
|
|
|
22994
23347
|
// STEP 4: Add sizes
|
|
22995
23348
|
// `@type` records which preset the dimensions match; omitted when the caller does not say
|
|
22996
23349
|
strXml += `<p:sldSz cx="${pres.presLayout.width}" cy="${pres.presLayout.height}"${pres.slideSizeType ? ` type="${pres.slideSizeType}"` : ''}/>`;
|
|
22997
|
-
|
|
23350
|
+
// Diffit-Inc 15c5bade: fixed 7.5×10in portrait notes page matching standard notesMaster placeholders
|
|
23351
|
+
strXml += '<p:notesSz cx="6858000" cy="9144000"/>';
|
|
22998
23352
|
// CT_Presentation sequence puts these between `notesSz` and `defaultTextStyle` (photoAlbum, kinsoku)
|
|
22999
23353
|
if (pres.photoAlbum) {
|
|
23000
23354
|
const album = pres.photoAlbum;
|
|
@@ -23797,7 +24151,7 @@ class PptxGenJS {
|
|
|
23797
24151
|
*/ pptxgen_define_property(this, "_layout", void 0);
|
|
23798
24152
|
/**
|
|
23799
24153
|
* PptxGenJS Library Version
|
|
23800
|
-
*/ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.
|
|
24154
|
+
*/ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.4.0"));
|
|
23801
24155
|
/**
|
|
23802
24156
|
* @type {string}
|
|
23803
24157
|
*/ pptxgen_define_property(this, "_author", void 0);
|