1- /* PptxGenJS 4.0.0 @ 2025-05-04T15:19:14.634Z */
1+ /* PptxGenJS 4.0.1-beta. 0 @ 2025-05-29T03:10:57.448Z */
22import JSZip from 'jszip';
33
44/******************************************************************************
@@ -1315,7 +1315,7 @@ function getSlidesForTableRows(tableRows = [], tableProps = {}, presLayout, mast
13151315 emuTabCurrH += emuLineMaxH;
13161316 // 6: advance column/cell index (or circle back to first one to continue adding lines)
13171317 currCellIdx = currCellIdx < rowCellLines.length - 1 ? currCellIdx + 1 : 0;
1318- // 7: done?
1318+ // 7: WIP: done?
13191319 const brent = rowCellLines.map(cell => cell._lines.length).reduce((prev, next) => prev + next);
13201320 if (brent === 0)
13211321 isDone = true;
@@ -2486,7 +2486,7 @@ function addTableDefinition(target, tableRows, options, slideLayout, presLayout,
24862486 // Create hyperlink rels (IMPORTANT: Wait until table has been shredded across Slides or all rels will end-up on Slide 1!)
24872487 createHyperlinkRels(newSlide, slide.rows);
24882488 // Add rows to new slide
2489- newSlide.addTable(slide.rows, Object.assign({}, opt ));
2489+ newSlide.addTable(slide.rows, JSON.parse(JSON.stringify(opt || {}) ));
24902490 // Add reference to the new slide so it can be returned, but don't add the first one because the user already has a reference to that one.
24912491 if (idx > 0)
24922492 newAutoPagedSlides.push(newSlide);
@@ -2682,7 +2682,7 @@ function addBackgroundDefinition(props, target) {
26822682 * @param {PresSlide} target - slide object that any hyperlinks will be be added to
26832683 * @param {number | string | TextProps | TextProps[] | ITableCell[][]} text - text to parse
26842684 */
2685- function createHyperlinkRels(target, text) {
2685+ function createHyperlinkRels(target, text, options ) {
26862686 let textObjs = [];
26872687 // Only text objects can have hyperlinks, bail when text param is plain text
26882688 if (typeof text === 'string' || typeof text === 'number')
@@ -2692,20 +2692,30 @@ function createHyperlinkRels(target, text) {
26922692 textObjs = text;
26932693 else if (typeof text === 'object')
26942694 textObjs = [text];
2695- textObjs.forEach((text) => {
2696- // `text` can be an array of other `text` objects (table cell word-level formatting), continue parsing using recursion
2695+ textObjs.forEach((text, idx) => {
2696+ // IMPORTANT: `options` are lost due to recursion/copy!
2697+ if (options && options[idx])
2698+ text.options = options[idx];
2699+ // NOTE: `text` can be an array of other `text` objects (table cell word-level formatting), continue parsing using recursion
26972700 if (Array.isArray(text)) {
2698- createHyperlinkRels(target, text);
2701+ const cellOpts = [];
2702+ text.forEach((tablecell) => {
2703+ if (tablecell.options && !tablecell.text.options) {
2704+ cellOpts.push(tablecell.options);
2705+ }
2706+ });
2707+ createHyperlinkRels(target, text, cellOpts);
26992708 }
27002709 else if (Array.isArray(text.text)) {
2701- // this handles TableCells with hyperlinks
2702- createHyperlinkRels(target, text.text);
2710+ createHyperlinkRels(target, text.text, options && options[idx] ? [options[idx]] : undefined);
27032711 }
27042712 else if (text && typeof text === 'object' && text.options && text.options.hyperlink && !text.options.hyperlink._rId) {
2705- if (typeof text.options.hyperlink !== 'object')
2713+ if (typeof text.options.hyperlink !== 'object') {
27062714 console.log('ERROR: text `hyperlink` option should be an object. Ex: `hyperlink: {url:\'https://github.com\'}` ');
2707- else if (!text.options.hyperlink.url && !text.options.hyperlink.slide)
2715+ }
2716+ else if (!text.options.hyperlink.url && !text.options.hyperlink.slide) {
27082717 console.log('ERROR: \'hyperlink requires either: `url` or `slide`\'');
2718+ }
27092719 else {
27102720 const relId = getNewRelId(target);
27112721 target._rels.push({
@@ -2717,6 +2727,17 @@ function createHyperlinkRels(target, text) {
27172727 text.options.hyperlink._rId = relId;
27182728 }
27192729 }
2730+ else if (text && typeof text === 'object' && text.options && text.options.hyperlink && text.options.hyperlink._rId) {
2731+ // NOTE: auto-paging will create new slides, but skip above as _rId exists, BUT this is a new slide, so add rels!
2732+ if (target._rels.filter(rel => rel.rId === text.options.hyperlink._rId).length === 0) {
2733+ target._rels.push({
2734+ type: SLIDE_OBJECT_TYPES.hyperlink,
2735+ data: text.options.hyperlink.slide ? 'slide' : 'dummy',
2736+ rId: text.options.hyperlink._rId,
2737+ Target: encodeXmlEntities(text.options.hyperlink.url) || text.options.hyperlink.slide.toString(),
2738+ });
2739+ }
2740+ }
27202741 });
27212742}
27222743
@@ -6759,7 +6780,7 @@ function makeXmlViewProps() {
67596780 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
67606781 * SOFTWARE.
67616782 */
6762- const VERSION = '4.0.0';
6783+ const VERSION = '4.0.1-beta. 0';
67636784class PptxGenJS {
67646785 set layout(value) {
67656786 const newLayout = this.LAYOUTS[value];
@@ -7174,7 +7195,8 @@ class PptxGenJS {
71747195 // STEP 4: Write the file out
71757196 if (isNode) {
71767197 // Dynamically import to avoid bundling fs in the browser build
7177- const { writeFile } = yield import('node:fs/promises');
7198+ const { promises: fs } = yield import('node:fs');
7199+ const { writeFile } = fs;
71787200 yield writeFile(fileName, data);
71797201 return fileName;
71807202 }
0 commit comments