pptx-templates 0.0.0-stage → 0.1.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/AI-INSTRUCTOR.md +2253 -0
- package/CHANGELOG.md +49 -0
- package/LICENSE +23 -0
- package/README.md +86 -2
- package/dist/automizer.d.ts +224 -0
- package/dist/automizer.js +704 -0
- package/dist/automizer.js.map +1 -0
- package/dist/classes/content-type-registry.d.ts +46 -0
- package/dist/classes/content-type-registry.js +170 -0
- package/dist/classes/content-type-registry.js.map +1 -0
- package/dist/classes/element-importer.d.ts +49 -0
- package/dist/classes/element-importer.js +254 -0
- package/dist/classes/element-importer.js.map +1 -0
- package/dist/classes/has-shapes.d.ts +286 -0
- package/dist/classes/has-shapes.js +385 -0
- package/dist/classes/has-shapes.js.map +1 -0
- package/dist/classes/layout.d.ts +42 -0
- package/dist/classes/layout.js +113 -0
- package/dist/classes/layout.js.map +1 -0
- package/dist/classes/master.d.ts +45 -0
- package/dist/classes/master.js +146 -0
- package/dist/classes/master.js.map +1 -0
- package/dist/classes/placeholder-normalizer.d.ts +42 -0
- package/dist/classes/placeholder-normalizer.js +136 -0
- package/dist/classes/placeholder-normalizer.js.map +1 -0
- package/dist/classes/related-content-copier.d.ts +18 -0
- package/dist/classes/related-content-copier.js +114 -0
- package/dist/classes/related-content-copier.js.map +1 -0
- package/dist/classes/shape.d.ts +62 -0
- package/dist/classes/shape.js +194 -0
- package/dist/classes/shape.js.map +1 -0
- package/dist/classes/slide-master-remover.d.ts +44 -0
- package/dist/classes/slide-master-remover.js +201 -0
- package/dist/classes/slide-master-remover.js.map +1 -0
- package/dist/classes/slide-notes-copier.d.ts +26 -0
- package/dist/classes/slide-notes-copier.js +76 -0
- package/dist/classes/slide-notes-copier.js.map +1 -0
- package/dist/classes/slide.d.ts +91 -0
- package/dist/classes/slide.js +286 -0
- package/dist/classes/slide.js.map +1 -0
- package/dist/classes/template.d.ts +137 -0
- package/dist/classes/template.js +311 -0
- package/dist/classes/template.js.map +1 -0
- package/dist/constants/constants.d.ts +11 -0
- package/dist/constants/constants.js +182 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/enums/chart-type.d.ts +11 -0
- package/dist/enums/chart-type.js +16 -0
- package/dist/enums/chart-type.js.map +1 -0
- package/dist/enums/content-type-map.d.ts +16 -0
- package/dist/enums/content-type-map.js +23 -0
- package/dist/enums/content-type-map.js.map +1 -0
- package/dist/enums/element-type.d.ts +14 -0
- package/dist/enums/element-type.js +20 -0
- package/dist/enums/element-type.js.map +1 -0
- package/dist/errors.d.ts +81 -0
- package/dist/errors.js +100 -0
- package/dist/errors.js.map +1 -0
- package/dist/extensions/index.d.ts +5 -0
- package/dist/extensions/index.js +31 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/pptxgenjs-compat/img-broken-png.d.ts +5 -0
- package/dist/extensions/pptxgenjs-compat/img-broken-png.js +9 -0
- package/dist/extensions/pptxgenjs-compat/img-broken-png.js.map +1 -0
- package/dist/extensions/pptxgenjs-compat/index.d.ts +5 -0
- package/dist/extensions/pptxgenjs-compat/index.js +10 -0
- package/dist/extensions/pptxgenjs-compat/index.js.map +1 -0
- package/dist/extensions/pptxgenjs-compat/svg-fallback.d.ts +14 -0
- package/dist/extensions/pptxgenjs-compat/svg-fallback.js +139 -0
- package/dist/extensions/pptxgenjs-compat/svg-fallback.js.map +1 -0
- package/dist/extensions/template-logic/commands.d.ts +22 -0
- package/dist/extensions/template-logic/commands.js +83 -0
- package/dist/extensions/template-logic/commands.js.map +1 -0
- package/dist/extensions/template-logic/expression.d.ts +61 -0
- package/dist/extensions/template-logic/expression.js +499 -0
- package/dist/extensions/template-logic/expression.js.map +1 -0
- package/dist/extensions/template-logic/images.d.ts +26 -0
- package/dist/extensions/template-logic/images.js +183 -0
- package/dist/extensions/template-logic/images.js.map +1 -0
- package/dist/extensions/template-logic/index.d.ts +14 -0
- package/dist/extensions/template-logic/index.js +64 -0
- package/dist/extensions/template-logic/index.js.map +1 -0
- package/dist/extensions/template-logic/list-commands.d.ts +9 -0
- package/dist/extensions/template-logic/list-commands.js +72 -0
- package/dist/extensions/template-logic/list-commands.js.map +1 -0
- package/dist/extensions/template-logic/renderer.d.ts +85 -0
- package/dist/extensions/template-logic/renderer.js +867 -0
- package/dist/extensions/template-logic/renderer.js.map +1 -0
- package/dist/extensions/template-logic/types.d.ts +62 -0
- package/dist/extensions/template-logic/types.js +3 -0
- package/dist/extensions/template-logic/types.js.map +1 -0
- package/dist/helper/archive/archive-fs.d.ts +45 -0
- package/dist/helper/archive/archive-fs.js +206 -0
- package/dist/helper/archive/archive-fs.js.map +1 -0
- package/dist/helper/archive/archive-jszip.d.ts +31 -0
- package/dist/helper/archive/archive-jszip.js +173 -0
- package/dist/helper/archive/archive-jszip.js.map +1 -0
- package/dist/helper/archive/archive.d.ts +27 -0
- package/dist/helper/archive/archive.js +78 -0
- package/dist/helper/archive/archive.js.map +1 -0
- package/dist/helper/cell-id-helper.d.ts +25 -0
- package/dist/helper/cell-id-helper.js +95 -0
- package/dist/helper/cell-id-helper.js.map +1 -0
- package/dist/helper/compute-src-rect.d.ts +9 -0
- package/dist/helper/compute-src-rect.js +52 -0
- package/dist/helper/compute-src-rect.js.map +1 -0
- package/dist/helper/content-tracker.d.ts +31 -0
- package/dist/helper/content-tracker.js +227 -0
- package/dist/helper/content-tracker.js.map +1 -0
- package/dist/helper/count-helper.d.ts +33 -0
- package/dist/helper/count-helper.js +140 -0
- package/dist/helper/count-helper.js.map +1 -0
- package/dist/helper/css-style-parser.d.ts +52 -0
- package/dist/helper/css-style-parser.js +246 -0
- package/dist/helper/css-style-parser.js.map +1 -0
- package/dist/helper/file-helper.d.ts +36 -0
- package/dist/helper/file-helper.js +150 -0
- package/dist/helper/file-helper.js.map +1 -0
- package/dist/helper/general-helper.d.ts +6 -0
- package/dist/helper/general-helper.js +34 -0
- package/dist/helper/general-helper.js.map +1 -0
- package/dist/helper/generate/generate-pptxgenjs.d.ts +37 -0
- package/dist/helper/generate/generate-pptxgenjs.js +134 -0
- package/dist/helper/generate/generate-pptxgenjs.js.map +1 -0
- package/dist/helper/html-to-multitext-helper.d.ts +84 -0
- package/dist/helper/html-to-multitext-helper.js +490 -0
- package/dist/helper/html-to-multitext-helper.js.map +1 -0
- package/dist/helper/hyperlink-processor.d.ts +54 -0
- package/dist/helper/hyperlink-processor.js +289 -0
- package/dist/helper/hyperlink-processor.js.map +1 -0
- package/dist/helper/image-dimensions.d.ts +21 -0
- package/dist/helper/image-dimensions.js +202 -0
- package/dist/helper/image-dimensions.js.map +1 -0
- package/dist/helper/jszip-helper.d.ts +21 -0
- package/dist/helper/jszip-helper.js +162 -0
- package/dist/helper/jszip-helper.js.map +1 -0
- package/dist/helper/layout-index.d.ts +55 -0
- package/dist/helper/layout-index.js +155 -0
- package/dist/helper/layout-index.js.map +1 -0
- package/dist/helper/logger.d.ts +53 -0
- package/dist/helper/logger.js +73 -0
- package/dist/helper/logger.js.map +1 -0
- package/dist/helper/media-deduplicator.d.ts +42 -0
- package/dist/helper/media-deduplicator.js +88 -0
- package/dist/helper/media-deduplicator.js.map +1 -0
- package/dist/helper/modify-background-helper.d.ts +19 -0
- package/dist/helper/modify-background-helper.js +59 -0
- package/dist/helper/modify-background-helper.js.map +1 -0
- package/dist/helper/modify-chart-helper.d.ts +159 -0
- package/dist/helper/modify-chart-helper.js +642 -0
- package/dist/helper/modify-chart-helper.js.map +1 -0
- package/dist/helper/modify-cleanup-helper.d.ts +69 -0
- package/dist/helper/modify-cleanup-helper.js +343 -0
- package/dist/helper/modify-cleanup-helper.js.map +1 -0
- package/dist/helper/modify-color-helper.d.ts +35 -0
- package/dist/helper/modify-color-helper.js +211 -0
- package/dist/helper/modify-color-helper.js.map +1 -0
- package/dist/helper/modify-helper.d.ts +23 -0
- package/dist/helper/modify-helper.js +61 -0
- package/dist/helper/modify-helper.js.map +1 -0
- package/dist/helper/modify-hyperlink-element.d.ts +9 -0
- package/dist/helper/modify-hyperlink-element.js +34 -0
- package/dist/helper/modify-hyperlink-element.js.map +1 -0
- package/dist/helper/modify-hyperlink-helper.d.ts +42 -0
- package/dist/helper/modify-hyperlink-helper.js +258 -0
- package/dist/helper/modify-hyperlink-helper.js.map +1 -0
- package/dist/helper/modify-image-helper.d.ts +23 -0
- package/dist/helper/modify-image-helper.js +157 -0
- package/dist/helper/modify-image-helper.js.map +1 -0
- package/dist/helper/modify-presentation-helper.d.ts +55 -0
- package/dist/helper/modify-presentation-helper.js +177 -0
- package/dist/helper/modify-presentation-helper.js.map +1 -0
- package/dist/helper/modify-shape-helper.d.ts +111 -0
- package/dist/helper/modify-shape-helper.js +340 -0
- package/dist/helper/modify-shape-helper.js.map +1 -0
- package/dist/helper/modify-table-helper.d.ts +11 -0
- package/dist/helper/modify-table-helper.js +100 -0
- package/dist/helper/modify-table-helper.js.map +1 -0
- package/dist/helper/modify-text-helper.d.ts +62 -0
- package/dist/helper/modify-text-helper.js +244 -0
- package/dist/helper/modify-text-helper.js.map +1 -0
- package/dist/helper/modify-xml-helper.d.ts +52 -0
- package/dist/helper/modify-xml-helper.js +305 -0
- package/dist/helper/modify-xml-helper.js.map +1 -0
- package/dist/helper/multitext-helper.d.ts +116 -0
- package/dist/helper/multitext-helper.js +462 -0
- package/dist/helper/multitext-helper.js.map +1 -0
- package/dist/helper/ppt-paths.d.ts +76 -0
- package/dist/helper/ppt-paths.js +116 -0
- package/dist/helper/ppt-paths.js.map +1 -0
- package/dist/helper/shape-type-detector.d.ts +34 -0
- package/dist/helper/shape-type-detector.js +99 -0
- package/dist/helper/shape-type-detector.js.map +1 -0
- package/dist/helper/text-replace-helper.d.ts +30 -0
- package/dist/helper/text-replace-helper.js +147 -0
- package/dist/helper/text-replace-helper.js.map +1 -0
- package/dist/helper/xml/lnLRTB.d.ts +1 -0
- package/dist/helper/xml/lnLRTB.js +62 -0
- package/dist/helper/xml/lnLRTB.js.map +1 -0
- package/dist/helper/xml/prstGeom.d.ts +1 -0
- package/dist/helper/xml/prstGeom.js +11 -0
- package/dist/helper/xml/prstGeom.js.map +1 -0
- package/dist/helper/xml-elements.d.ts +134 -0
- package/dist/helper/xml-elements.js +538 -0
- package/dist/helper/xml-elements.js.map +1 -0
- package/dist/helper/xml-helper.d.ts +120 -0
- package/dist/helper/xml-helper.js +495 -0
- package/dist/helper/xml-helper.js.map +1 -0
- package/dist/helper/xml-placeholder-helper.d.ts +92 -0
- package/dist/helper/xml-placeholder-helper.js +454 -0
- package/dist/helper/xml-placeholder-helper.js.map +1 -0
- package/dist/helper/xml-pretty-print.d.ts +17 -0
- package/dist/helper/xml-pretty-print.js +88 -0
- package/dist/helper/xml-pretty-print.js.map +1 -0
- package/dist/helper/xml-relationship-helper.d.ts +103 -0
- package/dist/helper/xml-relationship-helper.js +397 -0
- package/dist/helper/xml-relationship-helper.js.map +1 -0
- package/dist/helper/xml-slide-helper.d.ts +107 -0
- package/dist/helper/xml-slide-helper.js +676 -0
- package/dist/helper/xml-slide-helper.js.map +1 -0
- package/dist/helper/xml-template-helper.d.ts +42 -0
- package/dist/helper/xml-template-helper.js +252 -0
- package/dist/helper/xml-template-helper.js.map +1 -0
- package/dist/helper/xmldom-sax-patch.d.ts +18 -0
- package/dist/helper/xmldom-sax-patch.js +58 -0
- package/dist/helper/xmldom-sax-patch.js.map +1 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +177 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/iarchive.d.ts +43 -0
- package/dist/interfaces/iarchive.js +3 -0
- package/dist/interfaces/iarchive.js.map +1 -0
- package/dist/interfaces/ichart.d.ts +7 -0
- package/dist/interfaces/ichart.js +3 -0
- package/dist/interfaces/ichart.js.map +1 -0
- package/dist/interfaces/icounter.d.ts +7 -0
- package/dist/interfaces/icounter.js +3 -0
- package/dist/interfaces/icounter.js.map +1 -0
- package/dist/interfaces/igenerator.d.ts +4 -0
- package/dist/interfaces/igenerator.js +3 -0
- package/dist/interfaces/igenerator.js.map +1 -0
- package/dist/interfaces/iimage.d.ts +7 -0
- package/dist/interfaces/iimage.js +3 -0
- package/dist/interfaces/iimage.js.map +1 -0
- package/dist/interfaces/ilayout.d.ts +14 -0
- package/dist/interfaces/ilayout.js +3 -0
- package/dist/interfaces/ilayout.js.map +1 -0
- package/dist/interfaces/imaster.d.ts +15 -0
- package/dist/interfaces/imaster.js +3 -0
- package/dist/interfaces/imaster.js.map +1 -0
- package/dist/interfaces/imulti-text.d.ts +50 -0
- package/dist/interfaces/imulti-text.js +3 -0
- package/dist/interfaces/imulti-text.js.map +1 -0
- package/dist/interfaces/ipptxgenjs-slide.d.ts +40 -0
- package/dist/interfaces/ipptxgenjs-slide.js +3 -0
- package/dist/interfaces/ipptxgenjs-slide.js.map +1 -0
- package/dist/interfaces/ipresentation-props.d.ts +16 -0
- package/dist/interfaces/ipresentation-props.js +3 -0
- package/dist/interfaces/ipresentation-props.js.map +1 -0
- package/dist/interfaces/ishape-action.d.ts +18 -0
- package/dist/interfaces/ishape-action.js +3 -0
- package/dist/interfaces/ishape-action.js.map +1 -0
- package/dist/interfaces/ishape.d.ts +5 -0
- package/dist/interfaces/ishape.js +3 -0
- package/dist/interfaces/ishape.js.map +1 -0
- package/dist/interfaces/islide.d.ts +71 -0
- package/dist/interfaces/islide.js +3 -0
- package/dist/interfaces/islide.js.map +1 -0
- package/dist/interfaces/itemplate.d.ts +9 -0
- package/dist/interfaces/itemplate.js +3 -0
- package/dist/interfaces/itemplate.js.map +1 -0
- package/dist/interfaces/pres-template.d.ts +9 -0
- package/dist/interfaces/pres-template.js +3 -0
- package/dist/interfaces/pres-template.js.map +1 -0
- package/dist/interfaces/root-pres-template.d.ts +38 -0
- package/dist/interfaces/root-pres-template.js +3 -0
- package/dist/interfaces/root-pres-template.js.map +1 -0
- package/dist/modify/modify-chart.d.ts +74 -0
- package/dist/modify/modify-chart.js +753 -0
- package/dist/modify/modify-chart.js.map +1 -0
- package/dist/modify/modify-table.d.ts +64 -0
- package/dist/modify/modify-table.js +435 -0
- package/dist/modify/modify-table.js.map +1 -0
- package/dist/shapes/chart.d.ts +91 -0
- package/dist/shapes/chart.js +437 -0
- package/dist/shapes/chart.js.map +1 -0
- package/dist/shapes/diagram.d.ts +33 -0
- package/dist/shapes/diagram.js +167 -0
- package/dist/shapes/diagram.js.map +1 -0
- package/dist/shapes/generic.d.ts +27 -0
- package/dist/shapes/generic.js +118 -0
- package/dist/shapes/generic.js.map +1 -0
- package/dist/shapes/hyperlink.d.ts +27 -0
- package/dist/shapes/hyperlink.js +193 -0
- package/dist/shapes/hyperlink.js.map +1 -0
- package/dist/shapes/image.d.ts +47 -0
- package/dist/shapes/image.js +244 -0
- package/dist/shapes/image.js.map +1 -0
- package/dist/shapes/ole.d.ts +30 -0
- package/dist/shapes/ole.js +237 -0
- package/dist/shapes/ole.js.map +1 -0
- package/dist/types/chart-types.d.ts +115 -0
- package/dist/types/chart-types.js +3 -0
- package/dist/types/chart-types.js.map +1 -0
- package/dist/types/modify-types.d.ts +128 -0
- package/dist/types/modify-types.js +3 -0
- package/dist/types/modify-types.js.map +1 -0
- package/dist/types/shape-types.d.ts +40 -0
- package/dist/types/shape-types.js +3 -0
- package/dist/types/shape-types.js.map +1 -0
- package/dist/types/table-types.d.ts +38 -0
- package/dist/types/table-types.js +3 -0
- package/dist/types/table-types.js.map +1 -0
- package/dist/types/types.d.ts +317 -0
- package/dist/types/types.js +16 -0
- package/dist/types/types.js.map +1 -0
- package/dist/types/xml-types.d.ts +168 -0
- package/dist/types/xml-types.js +3 -0
- package/dist/types/xml-types.js.map +1 -0
- package/package.json +92 -4
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.XmlSlideHelper = exports.mapUriType = exports.nsMain = void 0;
|
|
16
|
+
const logger_1 = require("./logger");
|
|
17
|
+
const xml_helper_1 = require("./xml-helper");
|
|
18
|
+
const xml_template_helper_1 = require("./xml-template-helper");
|
|
19
|
+
const xml_placeholder_helper_1 = __importDefault(require("./xml-placeholder-helper"));
|
|
20
|
+
exports.nsMain = 'http://schemas.openxmlformats.org/presentationml/2006/main';
|
|
21
|
+
exports.mapUriType = {
|
|
22
|
+
'http://schemas.openxmlformats.org/drawingml/2006/table': 'table',
|
|
23
|
+
'http://schemas.openxmlformats.org/drawingml/2006/chart': 'chart',
|
|
24
|
+
'http://schemas.microsoft.com/office/drawing/2014/chartex': 'chartEx',
|
|
25
|
+
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject': 'oleObject',
|
|
26
|
+
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink': 'hyperlink',
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Class that represents an XML slide helper
|
|
30
|
+
*/
|
|
31
|
+
class XmlSlideHelper {
|
|
32
|
+
/**
|
|
33
|
+
* Constructor for the XmlSlideHelper class.
|
|
34
|
+
* @param {XmlDocument} slideXml - The slide XML document to be used by the helper.
|
|
35
|
+
* @param params
|
|
36
|
+
*/
|
|
37
|
+
constructor(slideXml, params) {
|
|
38
|
+
/**
|
|
39
|
+
* Fetches an XML file from the given path and extracts the dimensions.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} path - The path of the XML file.
|
|
42
|
+
* @returns {Promise<{ width: number; height: number } | null>} - A promise that resolves with an object containing the width and height, or `null` if there was an error.
|
|
43
|
+
*/
|
|
44
|
+
this.getAndExtractDimensions = (path) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
try {
|
|
46
|
+
const xml = yield xml_helper_1.XmlHelper.getXmlFromArchive(this.sourceArchive, path);
|
|
47
|
+
if (!xml)
|
|
48
|
+
return null;
|
|
49
|
+
const sldSz = xml.getElementsByTagName('p:sldSz')[0];
|
|
50
|
+
if (sldSz) {
|
|
51
|
+
const width = XmlSlideHelper.parseCoordinate(sldSz, 'cx');
|
|
52
|
+
const height = XmlSlideHelper.parseCoordinate(sldSz, 'cy');
|
|
53
|
+
return { width, height };
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
logger_1.log.warn(`Error while fetching XML from path ${path}: ${error}`);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
if (!slideXml) {
|
|
63
|
+
throw Error('Slide XML is not defined');
|
|
64
|
+
}
|
|
65
|
+
this.slideXml = slideXml;
|
|
66
|
+
this.sourceArchive = params.sourceArchive;
|
|
67
|
+
this.slideNumber = params.slideNumber;
|
|
68
|
+
this.sourceLayoutId = params.sourceLayoutId;
|
|
69
|
+
}
|
|
70
|
+
getSlideCreationId() {
|
|
71
|
+
const creationIdItem = this.slideXml
|
|
72
|
+
.getElementsByTagName('p14:creationId')
|
|
73
|
+
.item(0);
|
|
74
|
+
if (!creationIdItem) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const creationIdSlide = creationIdItem.getAttribute('val');
|
|
78
|
+
if (!creationIdSlide) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
return Number(creationIdSlide);
|
|
82
|
+
}
|
|
83
|
+
getSlideLayout() {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const xml = yield this.getSlideLayoutXml(this.sourceLayoutId);
|
|
86
|
+
return xml_template_helper_1.XmlTemplateHelper.getLayoutInfo(xml);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get an ElementInfo object for the target element on the slide.
|
|
91
|
+
* @param selector
|
|
92
|
+
*/
|
|
93
|
+
getElement(selector) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const shapeNode = xml_helper_1.XmlHelper.isElementCreationId(selector)
|
|
96
|
+
? xml_helper_1.XmlHelper.findByCreationId(this.slideXml, selector)
|
|
97
|
+
: xml_helper_1.XmlHelper.findByName(this.slideXml, selector);
|
|
98
|
+
return XmlSlideHelper.getElementInfo(shapeNode);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get an array of ElementInfo objects for all named elements on a slide.
|
|
103
|
+
* @param filterTags Use an array of strings to filter the output array
|
|
104
|
+
* @param layoutPlaceholders
|
|
105
|
+
*/
|
|
106
|
+
getAllElements(filterTags, layoutPlaceholders) {
|
|
107
|
+
const elementInfo = [];
|
|
108
|
+
try {
|
|
109
|
+
const shapeNodes = this.getNamedElements(filterTags);
|
|
110
|
+
shapeNodes.forEach((shapeNode) => {
|
|
111
|
+
elementInfo.push(XmlSlideHelper.getElementInfo(shapeNode, layoutPlaceholders));
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
logger_1.log.error(error);
|
|
116
|
+
throw new Error(`Failed to retrieve elements: ${error.message}`, {
|
|
117
|
+
cause: error,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return elementInfo;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get all text element IDs from the slide.
|
|
124
|
+
* @return {string[]} An array of text element IDs.
|
|
125
|
+
*/
|
|
126
|
+
getAllTextElementIds(useCreationIds) {
|
|
127
|
+
const elementIds = [];
|
|
128
|
+
try {
|
|
129
|
+
elementIds.push(...this.getAllElements(['sp'])
|
|
130
|
+
.filter((element) => element.hasTextBody)
|
|
131
|
+
.map((element) => (useCreationIds ? element.id : element.name)));
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
logger_1.log.error(error);
|
|
135
|
+
throw new Error(`Failed to retrieve text element IDs: ${error.message}`, {
|
|
136
|
+
cause: error,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return elementIds;
|
|
140
|
+
}
|
|
141
|
+
static getElementInfo(slideElement, layoutPlaceholders) {
|
|
142
|
+
const selector = this.getSelector(slideElement);
|
|
143
|
+
const position = XmlSlideHelper.parseShapeCoordinates(slideElement);
|
|
144
|
+
const type = XmlSlideHelper.getElementType(slideElement);
|
|
145
|
+
const visualType = XmlSlideHelper.getElementVisualType(slideElement);
|
|
146
|
+
return {
|
|
147
|
+
name: selector.name,
|
|
148
|
+
id: selector.creationId,
|
|
149
|
+
creationId: selector.creationId,
|
|
150
|
+
nameIdx: selector.nameIdx,
|
|
151
|
+
type,
|
|
152
|
+
visualType,
|
|
153
|
+
position,
|
|
154
|
+
getPlaceholderInfo: () => {
|
|
155
|
+
return xml_placeholder_helper_1.default.getPlaceholderInfo(slideElement, layoutPlaceholders);
|
|
156
|
+
},
|
|
157
|
+
hasTextBody: !!XmlSlideHelper.getTextBody(slideElement),
|
|
158
|
+
getXmlElement: () => slideElement,
|
|
159
|
+
getText: () => XmlSlideHelper.parseTextFragments(slideElement),
|
|
160
|
+
getParagraphs: () => XmlSlideHelper.parseTextParagraphs(slideElement),
|
|
161
|
+
getParagraphGroups: () => XmlSlideHelper.parseParagraphGroups(slideElement),
|
|
162
|
+
getTableInfo: () => XmlSlideHelper.readTableInfo(slideElement),
|
|
163
|
+
getAltText: () => XmlSlideHelper.getImageAltText(slideElement),
|
|
164
|
+
getGroupInfo: () => XmlSlideHelper.parseGroupInfo(slideElement),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Retrieves a list of all named elements on a slide. Automation requires at least a name.
|
|
169
|
+
* @param filterTags Use an array of strings to filter the output array
|
|
170
|
+
*/
|
|
171
|
+
getNamedElements(filterTags) {
|
|
172
|
+
const skipTags = ['spTree'];
|
|
173
|
+
const nvPrs = this.slideXml.getElementsByTagNameNS(exports.nsMain, 'cNvPr');
|
|
174
|
+
const namedElements = [];
|
|
175
|
+
xml_helper_1.XmlHelper.modifyCollection(nvPrs, (nvPr) => {
|
|
176
|
+
var _a;
|
|
177
|
+
const parentNode = (_a = nvPr === null || nvPr === void 0 ? void 0 : nvPr.parentNode) === null || _a === void 0 ? void 0 : _a.parentNode;
|
|
178
|
+
const parentTag = parentNode === null || parentNode === void 0 ? void 0 : parentNode.localName;
|
|
179
|
+
if (!skipTags.includes(parentTag) &&
|
|
180
|
+
(!(filterTags === null || filterTags === void 0 ? void 0 : filterTags.length) || filterTags.includes(parentTag))) {
|
|
181
|
+
namedElements.push(parentNode);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
return namedElements;
|
|
185
|
+
}
|
|
186
|
+
static getTextBody(shapeNode) {
|
|
187
|
+
return shapeNode.getElementsByTagNameNS(exports.nsMain, 'txBody').item(0);
|
|
188
|
+
}
|
|
189
|
+
static parseTextFragments(shapeNode) {
|
|
190
|
+
const txBody = XmlSlideHelper.getTextBody(shapeNode);
|
|
191
|
+
const textFragments = [];
|
|
192
|
+
if (!txBody) {
|
|
193
|
+
return textFragments;
|
|
194
|
+
}
|
|
195
|
+
const texts = txBody.getElementsByTagName('a:t');
|
|
196
|
+
for (let t = 0; t < texts.length; t++) {
|
|
197
|
+
const text = texts.item(t);
|
|
198
|
+
textFragments.push(text.textContent);
|
|
199
|
+
}
|
|
200
|
+
return textFragments;
|
|
201
|
+
}
|
|
202
|
+
static parseParagraphGroups(shapeNode) {
|
|
203
|
+
const rawParagraphs = XmlSlideHelper.parseTextParagraphs(shapeNode);
|
|
204
|
+
return XmlSlideHelper.groupSimilarParagraphs(rawParagraphs);
|
|
205
|
+
}
|
|
206
|
+
static parseTextParagraphs(shapeNode) {
|
|
207
|
+
const textParagraphs = [];
|
|
208
|
+
// Find txBody element first
|
|
209
|
+
const txBody = shapeNode.getElementsByTagName('p:txBody')[0] ||
|
|
210
|
+
shapeNode.getElementsByTagName('a:txBody')[0];
|
|
211
|
+
if (!txBody)
|
|
212
|
+
return textParagraphs;
|
|
213
|
+
// Get all paragraph elements
|
|
214
|
+
const paragraphs = txBody.getElementsByTagName('a:p');
|
|
215
|
+
for (const p of Array.from(paragraphs)) {
|
|
216
|
+
const paragraph = { texts: [] };
|
|
217
|
+
// Check for paragraph properties (indent and bullet)
|
|
218
|
+
const pPr = p.getElementsByTagName('a:pPr')[0];
|
|
219
|
+
if (pPr) {
|
|
220
|
+
XmlSlideHelper.setParagraphProperties(pPr, paragraph);
|
|
221
|
+
}
|
|
222
|
+
// Get all text runs in the paragraph
|
|
223
|
+
const runs = p.getElementsByTagName('a:r');
|
|
224
|
+
const texts = [];
|
|
225
|
+
for (const run of Array.from(runs)) {
|
|
226
|
+
XmlSlideHelper.setTextProperties(run, paragraph);
|
|
227
|
+
// Get text content
|
|
228
|
+
const textElements = run.getElementsByTagName('a:t');
|
|
229
|
+
for (const textElement of Array.from(textElements)) {
|
|
230
|
+
texts.push(textElement.textContent || '');
|
|
231
|
+
}
|
|
232
|
+
// Check if the next sibling after rPr is a line break
|
|
233
|
+
const nextSibling = run.nextSibling;
|
|
234
|
+
if (nextSibling && nextSibling.nodeName === 'a:br') {
|
|
235
|
+
texts.push(`\n`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// Only add paragraphs that have text content
|
|
239
|
+
if (texts.length > 0) {
|
|
240
|
+
paragraph.texts = texts;
|
|
241
|
+
textParagraphs.push(paragraph);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return textParagraphs;
|
|
245
|
+
}
|
|
246
|
+
static setTextProperties(run, paragraph) {
|
|
247
|
+
const rPr = run.getElementsByTagName('a:rPr')[0];
|
|
248
|
+
if (rPr) {
|
|
249
|
+
const isBold = rPr.getAttribute('b') === '1';
|
|
250
|
+
const isUnderlined = rPr.getAttribute('u');
|
|
251
|
+
const isItalic = rPr.getAttribute('i') === '1';
|
|
252
|
+
const fontSize = parseInt(rPr.getAttribute('sz') || '0') / 100; // Convert to points
|
|
253
|
+
if (isBold)
|
|
254
|
+
paragraph.isBold = true;
|
|
255
|
+
if (isItalic)
|
|
256
|
+
paragraph.isItalic = true;
|
|
257
|
+
if (isUnderlined)
|
|
258
|
+
paragraph.isUnderlined = true;
|
|
259
|
+
if (fontSize)
|
|
260
|
+
paragraph.fontSize = fontSize;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
static setParagraphProperties(pPr, paragraph) {
|
|
264
|
+
const marL = pPr.getAttribute('marL');
|
|
265
|
+
if (marL) {
|
|
266
|
+
paragraph.indent = parseInt(marL);
|
|
267
|
+
}
|
|
268
|
+
const buChar = pPr.getElementsByTagName('a:buChar')[0];
|
|
269
|
+
if (buChar) {
|
|
270
|
+
paragraph.bullet = buChar.getAttribute('char');
|
|
271
|
+
}
|
|
272
|
+
// Check for numbered list
|
|
273
|
+
const buAutoNum = pPr.getElementsByTagName('a:buAutoNum')[0];
|
|
274
|
+
if (buAutoNum) {
|
|
275
|
+
paragraph.isNumbered = true;
|
|
276
|
+
paragraph.numberingType = buAutoNum.getAttribute('type') || undefined;
|
|
277
|
+
paragraph.startAt = buAutoNum.getAttribute('startAt') || undefined;
|
|
278
|
+
}
|
|
279
|
+
// Check for alignment
|
|
280
|
+
const algn = pPr.getAttribute('algn');
|
|
281
|
+
if (algn) {
|
|
282
|
+
paragraph.align = algn;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
static groupSimilarParagraphs(paragraphs) {
|
|
286
|
+
const groups = [];
|
|
287
|
+
let currentGroup = null;
|
|
288
|
+
const getDefinedProperties = (paragraph) => {
|
|
289
|
+
const properties = {};
|
|
290
|
+
const propertyKeys = [
|
|
291
|
+
'fontSize',
|
|
292
|
+
'isBold',
|
|
293
|
+
'isItalic',
|
|
294
|
+
'isUnderlined',
|
|
295
|
+
// 'indent',
|
|
296
|
+
'align',
|
|
297
|
+
'isNumbered',
|
|
298
|
+
'numberingType',
|
|
299
|
+
'bullet',
|
|
300
|
+
'startAt',
|
|
301
|
+
];
|
|
302
|
+
for (const key of propertyKeys) {
|
|
303
|
+
if (paragraph[key] !== undefined) {
|
|
304
|
+
properties[key] = paragraph[key];
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return properties;
|
|
308
|
+
};
|
|
309
|
+
for (const paragraph of paragraphs) {
|
|
310
|
+
const properties = getDefinedProperties(paragraph);
|
|
311
|
+
// Helper function to check if properties match
|
|
312
|
+
const propertiesMatch = (a, b) => {
|
|
313
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
314
|
+
};
|
|
315
|
+
// If we have no current group or properties don't match, create new group
|
|
316
|
+
if (!currentGroup ||
|
|
317
|
+
!propertiesMatch(currentGroup.properties, properties)) {
|
|
318
|
+
currentGroup = {
|
|
319
|
+
properties,
|
|
320
|
+
texts: [],
|
|
321
|
+
};
|
|
322
|
+
groups.push(currentGroup);
|
|
323
|
+
}
|
|
324
|
+
// Add text to current group
|
|
325
|
+
currentGroup.texts.push(paragraph.texts.join(''));
|
|
326
|
+
}
|
|
327
|
+
return groups;
|
|
328
|
+
}
|
|
329
|
+
static getNonVisibleProperties(shapeNode) {
|
|
330
|
+
return shapeNode.getElementsByTagNameNS(exports.nsMain, 'cNvPr').item(0);
|
|
331
|
+
}
|
|
332
|
+
static getImageAltText(slideElement) {
|
|
333
|
+
const cNvPr = XmlSlideHelper.getNonVisibleProperties(slideElement);
|
|
334
|
+
if (cNvPr) {
|
|
335
|
+
return cNvPr.getAttribute('descr');
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
static getElementName(slideElement) {
|
|
339
|
+
const cNvPr = XmlSlideHelper.getNonVisibleProperties(slideElement);
|
|
340
|
+
if (cNvPr) {
|
|
341
|
+
return cNvPr.getAttribute('name');
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
static getElementCreationId(slideElement, stripBrackets) {
|
|
345
|
+
const cNvPr = XmlSlideHelper.getNonVisibleProperties(slideElement);
|
|
346
|
+
if (cNvPr) {
|
|
347
|
+
const creationIdElement = cNvPr
|
|
348
|
+
.getElementsByTagName('a16:creationId')
|
|
349
|
+
.item(0);
|
|
350
|
+
if (creationIdElement) {
|
|
351
|
+
const id = creationIdElement.getAttribute('id');
|
|
352
|
+
if (stripBrackets)
|
|
353
|
+
return id.replace('{', '').replace('}', '');
|
|
354
|
+
return id;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
static getElementNameIdx(slideElement) {
|
|
359
|
+
const elementName = XmlSlideHelper.getElementName(slideElement);
|
|
360
|
+
if (!elementName) {
|
|
361
|
+
return 0;
|
|
362
|
+
}
|
|
363
|
+
// Find the parent slide element (spTree) to search all elements on the slide
|
|
364
|
+
const currentNode = xml_helper_1.XmlHelper.getClosestParent('p:spTree', slideElement);
|
|
365
|
+
if (!currentNode) {
|
|
366
|
+
return 0; // Unable to find slide parent
|
|
367
|
+
}
|
|
368
|
+
const spTree = currentNode;
|
|
369
|
+
// Get all named elements from the slide
|
|
370
|
+
const namedElements = [];
|
|
371
|
+
const nvPrs = spTree.getElementsByTagNameNS(exports.nsMain, 'cNvPr');
|
|
372
|
+
xml_helper_1.XmlHelper.modifyCollection(nvPrs, (nvPr) => {
|
|
373
|
+
const parentNode = nvPr.parentNode.parentNode;
|
|
374
|
+
const name = nvPr.getAttribute('name');
|
|
375
|
+
if (name === elementName) {
|
|
376
|
+
namedElements.push(parentNode);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
// Find the index of the current element in the array of elements with the same name
|
|
380
|
+
for (let i = 0; i < namedElements.length; i++) {
|
|
381
|
+
if (namedElements[i] === slideElement) {
|
|
382
|
+
return i;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return 0;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Parses local tag name to specify element type in case it is a 'graphicFrame'.
|
|
389
|
+
* @param slideElementParent
|
|
390
|
+
*/
|
|
391
|
+
static getElementType(slideElementParent) {
|
|
392
|
+
let type = slideElementParent === null || slideElementParent === void 0 ? void 0 : slideElementParent.localName;
|
|
393
|
+
const getUri = () => {
|
|
394
|
+
const graphicData = slideElementParent.getElementsByTagName('a:graphicData')[0];
|
|
395
|
+
return graphicData.getAttribute('uri');
|
|
396
|
+
};
|
|
397
|
+
switch (type) {
|
|
398
|
+
case 'graphicFrame':
|
|
399
|
+
type = exports.mapUriType[getUri()] || type;
|
|
400
|
+
break;
|
|
401
|
+
case 'oleObj':
|
|
402
|
+
type = 'OLEObject';
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
// Check for hyperlinks
|
|
406
|
+
const hasHyperlink = slideElementParent.getElementsByTagName('a:hlinkClick');
|
|
407
|
+
if (hasHyperlink.length > 0) {
|
|
408
|
+
type = 'Hyperlink';
|
|
409
|
+
}
|
|
410
|
+
return type;
|
|
411
|
+
}
|
|
412
|
+
static parseShapeCoordinates(slideElementParent, returnDefaults) {
|
|
413
|
+
const xFrmsA = slideElementParent.getElementsByTagName('a:xfrm');
|
|
414
|
+
const xFrmsP = slideElementParent.getElementsByTagName('p:xfrm');
|
|
415
|
+
const xFrms = xFrmsP.item(0) ? xFrmsP : xFrmsA;
|
|
416
|
+
const position = {
|
|
417
|
+
x: 0,
|
|
418
|
+
y: 0,
|
|
419
|
+
cx: 0,
|
|
420
|
+
cy: 0,
|
|
421
|
+
rot: 0,
|
|
422
|
+
};
|
|
423
|
+
if (!xFrms.item(0)) {
|
|
424
|
+
if (returnDefaults === false) {
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
return position;
|
|
428
|
+
}
|
|
429
|
+
const xFrm = xFrms.item(0);
|
|
430
|
+
const Off = xFrm.getElementsByTagName('a:off').item(0);
|
|
431
|
+
const Ext = xFrm.getElementsByTagName('a:ext').item(0);
|
|
432
|
+
position.x = XmlSlideHelper.parseCoordinate(Off, 'x');
|
|
433
|
+
position.y = XmlSlideHelper.parseCoordinate(Off, 'y');
|
|
434
|
+
position.cx = XmlSlideHelper.parseCoordinate(Ext, 'cx');
|
|
435
|
+
position.cy = XmlSlideHelper.parseCoordinate(Ext, 'cy');
|
|
436
|
+
if (xFrm.getAttribute('rot')) {
|
|
437
|
+
position.rot = parseInt(xFrm.getAttribute('rot'));
|
|
438
|
+
}
|
|
439
|
+
return position;
|
|
440
|
+
}
|
|
441
|
+
getSlideLayoutXml(layoutId) {
|
|
442
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
443
|
+
return XmlSlideHelper.getSlideLayoutXml(this.sourceArchive, layoutId);
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
static getSlideLayoutXml(sourceArchive, layoutId) {
|
|
447
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
448
|
+
const layoutPath = 'ppt/slideLayouts/slideLayout' + layoutId + '.xml';
|
|
449
|
+
const layoutXml = yield xml_helper_1.XmlHelper.getXmlFromArchive(sourceArchive, layoutPath);
|
|
450
|
+
if (layoutXml) {
|
|
451
|
+
return layoutXml;
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Asynchronously retrieves the dimensions of a slide.
|
|
457
|
+
* Tries to find the dimensions from the slide XML, then from the layout, master, and presentation XMLs in order.
|
|
458
|
+
*
|
|
459
|
+
* @returns {Promise<{ width: number, height: number }>} The dimensions of the slide.
|
|
460
|
+
* @throws Error if unable to determine dimensions.
|
|
461
|
+
*/
|
|
462
|
+
getDimensions() {
|
|
463
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
464
|
+
try {
|
|
465
|
+
const dimensions = yield this.getAndExtractDimensions('ppt/presentation.xml');
|
|
466
|
+
if (dimensions)
|
|
467
|
+
return dimensions;
|
|
468
|
+
}
|
|
469
|
+
catch (error) {
|
|
470
|
+
logger_1.log.error(`Error while fetching slide dimensions: ${error}`);
|
|
471
|
+
throw error;
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Reconstruct the complete selector for a given xmlElement, including the
|
|
477
|
+
* n-th occurance of the shape name on the current slide
|
|
478
|
+
* @param slideElement
|
|
479
|
+
*/
|
|
480
|
+
static getSelector(slideElement) {
|
|
481
|
+
const creationId = XmlSlideHelper.getElementCreationId(slideElement, true);
|
|
482
|
+
const nameIdx = !creationId
|
|
483
|
+
? XmlSlideHelper.getElementNameIdx(slideElement)
|
|
484
|
+
: 0;
|
|
485
|
+
return {
|
|
486
|
+
name: XmlSlideHelper.getElementName(slideElement),
|
|
487
|
+
creationId,
|
|
488
|
+
nameIdx,
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Determines the type of visual element in PowerPoint
|
|
493
|
+
* @param element The XML element to check
|
|
494
|
+
* @returns A string identifying the element type
|
|
495
|
+
*/
|
|
496
|
+
static getElementVisualType(element) {
|
|
497
|
+
if (XmlSlideHelper.getElementType(element) === 'grpSp') {
|
|
498
|
+
return 'group';
|
|
499
|
+
}
|
|
500
|
+
// Check for graphicFrame elements (charts, SmartArt, tables, etc.)
|
|
501
|
+
if (element.tagName === 'p:graphicFrame') {
|
|
502
|
+
const graphicData = xml_helper_1.XmlHelper.findElement(element, 'a:graphicData');
|
|
503
|
+
if (graphicData) {
|
|
504
|
+
const uri = graphicData.getAttribute('uri').toLowerCase();
|
|
505
|
+
// Check for specific URIs that identify element types
|
|
506
|
+
if (uri && uri.includes('chart')) {
|
|
507
|
+
return 'chart';
|
|
508
|
+
}
|
|
509
|
+
else if (uri &&
|
|
510
|
+
(uri.includes('smartart') || uri.includes('diagram'))) {
|
|
511
|
+
return 'smartArt';
|
|
512
|
+
}
|
|
513
|
+
else if (uri && uri.includes('table')) {
|
|
514
|
+
return 'table';
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return 'graphicFrame';
|
|
518
|
+
}
|
|
519
|
+
// Check for tables - also check direct table elements
|
|
520
|
+
if (xml_helper_1.XmlHelper.findElement(element, 'a:tbl') ||
|
|
521
|
+
element.getElementsByTagName('a:tbl')[0]) {
|
|
522
|
+
return 'table';
|
|
523
|
+
}
|
|
524
|
+
// Check for SVG Images
|
|
525
|
+
if (xml_helper_1.XmlHelper.findElement(element, 'a:svgBlip') ||
|
|
526
|
+
xml_helper_1.XmlHelper.findElement(element, 'asvg:svgBlip')) {
|
|
527
|
+
return 'svgImage';
|
|
528
|
+
}
|
|
529
|
+
// Check for pictures/photos
|
|
530
|
+
const hasPicPr = !!element.getElementsByTagName('p:nvPicPr')[0];
|
|
531
|
+
if (hasPicPr) {
|
|
532
|
+
return 'picture';
|
|
533
|
+
}
|
|
534
|
+
// Check for image fills
|
|
535
|
+
const hasBlipFill = !!xml_helper_1.XmlHelper.findElement(element, 'a:blipFill');
|
|
536
|
+
if (hasBlipFill) {
|
|
537
|
+
return 'imageFilledShape';
|
|
538
|
+
}
|
|
539
|
+
const hasGeometry = !!xml_helper_1.XmlHelper.findElement(element, 'a:prstGeom') ||
|
|
540
|
+
!!xml_helper_1.XmlHelper.findElement(element, 'a:custGeom');
|
|
541
|
+
if (hasGeometry) {
|
|
542
|
+
// Check if it's a line shape specifically
|
|
543
|
+
const prstGeomElement = xml_helper_1.XmlHelper.findElement(element, 'a:prstGeom');
|
|
544
|
+
if (prstGeomElement) {
|
|
545
|
+
const prst = prstGeomElement.getAttribute('prst');
|
|
546
|
+
// Common line presets in PowerPoint
|
|
547
|
+
const linePresets = [
|
|
548
|
+
'line',
|
|
549
|
+
'lineInv',
|
|
550
|
+
'straightConnector1',
|
|
551
|
+
'bentConnector2',
|
|
552
|
+
'bentConnector3',
|
|
553
|
+
'bentConnector4',
|
|
554
|
+
'bentConnector5',
|
|
555
|
+
'curvedConnector2',
|
|
556
|
+
'curvedConnector3',
|
|
557
|
+
'curvedConnector4',
|
|
558
|
+
'curvedConnector5',
|
|
559
|
+
'callout1',
|
|
560
|
+
'callout2',
|
|
561
|
+
'callout3',
|
|
562
|
+
'accentCallout1',
|
|
563
|
+
'accentCallout2',
|
|
564
|
+
'accentCallout3',
|
|
565
|
+
'borderCallout1',
|
|
566
|
+
'borderCallout2',
|
|
567
|
+
'borderCallout3',
|
|
568
|
+
'accentBorderCallout1',
|
|
569
|
+
'accentBorderCallout2',
|
|
570
|
+
'accentBorderCallout3',
|
|
571
|
+
];
|
|
572
|
+
if (prst && linePresets.includes(prst)) {
|
|
573
|
+
return 'vectorLine';
|
|
574
|
+
}
|
|
575
|
+
if (prst && prst === 'rect') {
|
|
576
|
+
const cNvSpPr = xml_helper_1.XmlHelper.findElement(element, 'p:cNvSpPr');
|
|
577
|
+
if (cNvSpPr && cNvSpPr.getAttribute('txBox') === '1') {
|
|
578
|
+
return 'textBox';
|
|
579
|
+
}
|
|
580
|
+
return 'rectangle';
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return 'vectorShape';
|
|
584
|
+
}
|
|
585
|
+
if (element.tagName === 'p:sp') {
|
|
586
|
+
const txBody = xml_helper_1.XmlHelper.findElement(element, 'p:txBody');
|
|
587
|
+
if (txBody) {
|
|
588
|
+
return 'textBox';
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
// Check for 3D models
|
|
592
|
+
if (xml_helper_1.XmlHelper.findElement(element, 'a:scene3d')) {
|
|
593
|
+
return '3dModel';
|
|
594
|
+
}
|
|
595
|
+
// Default case
|
|
596
|
+
return 'unknown';
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
exports.XmlSlideHelper = XmlSlideHelper;
|
|
600
|
+
XmlSlideHelper.parseCoordinate = (element, attributeName) => {
|
|
601
|
+
return parseInt(element.getAttribute(attributeName), 10);
|
|
602
|
+
};
|
|
603
|
+
XmlSlideHelper.parseGroupInfo = (element) => {
|
|
604
|
+
if (!(element === null || element === void 0 ? void 0 : element.parentNode)) {
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
// Check if element is a child of a group
|
|
608
|
+
// Look for a parent node that is a group (grpSp)
|
|
609
|
+
const isChild = element.parentNode &&
|
|
610
|
+
(element.parentNode.nodeName === 'grpSp' ||
|
|
611
|
+
element.parentNode.nodeName.includes('grpSp'));
|
|
612
|
+
// Check if element is a group parent itself
|
|
613
|
+
const isParent = element.localName === 'grpSp' || element.nodeName.includes('grpSp');
|
|
614
|
+
// Function to get the parent group if element is a child
|
|
615
|
+
const getParent = () => {
|
|
616
|
+
if (isChild && element.parentNode) {
|
|
617
|
+
return element.parentNode;
|
|
618
|
+
}
|
|
619
|
+
return null;
|
|
620
|
+
};
|
|
621
|
+
// Function to get children if element is a group parent
|
|
622
|
+
const getChildren = () => {
|
|
623
|
+
if (isParent) {
|
|
624
|
+
// Get all children that are not group properties or group metadata
|
|
625
|
+
const children = Array.from(element.childNodes).filter((node) => {
|
|
626
|
+
if (node.nodeType !== 1)
|
|
627
|
+
return false; // Skip non-element nodes
|
|
628
|
+
const nodeName = node.localName || node.nodeName;
|
|
629
|
+
// Skip group property elements
|
|
630
|
+
return (!nodeName.includes('nvGrpSpPr') && !nodeName.includes('grpSpPr'));
|
|
631
|
+
});
|
|
632
|
+
return children;
|
|
633
|
+
}
|
|
634
|
+
return [];
|
|
635
|
+
};
|
|
636
|
+
return {
|
|
637
|
+
isChild,
|
|
638
|
+
isParent,
|
|
639
|
+
getParent,
|
|
640
|
+
getChildren,
|
|
641
|
+
};
|
|
642
|
+
};
|
|
643
|
+
XmlSlideHelper.readTableInfo = (element) => {
|
|
644
|
+
const info = [];
|
|
645
|
+
const rows = element.getElementsByTagName('a:tr');
|
|
646
|
+
if (!rows) {
|
|
647
|
+
logger_1.log.error("Can't find a table row.");
|
|
648
|
+
return info;
|
|
649
|
+
}
|
|
650
|
+
for (let r = 0; r < rows.length; r++) {
|
|
651
|
+
const row = rows.item(r);
|
|
652
|
+
const columns = row.getElementsByTagName('a:tc');
|
|
653
|
+
for (let c = 0; c < columns.length; c++) {
|
|
654
|
+
const cell = columns.item(c);
|
|
655
|
+
const gridSpan = cell.getAttribute('gridSpan');
|
|
656
|
+
const hMerge = cell.getAttribute('hMerge');
|
|
657
|
+
const texts = cell.getElementsByTagName('a:t');
|
|
658
|
+
const text = [];
|
|
659
|
+
for (let t = 0; t < texts.length; t++) {
|
|
660
|
+
text.push(texts.item(t).textContent);
|
|
661
|
+
}
|
|
662
|
+
info.push({
|
|
663
|
+
row: r,
|
|
664
|
+
column: c,
|
|
665
|
+
rowXml: row,
|
|
666
|
+
columnXml: cell,
|
|
667
|
+
text: text,
|
|
668
|
+
textContent: text.join(''),
|
|
669
|
+
gridSpan: Number(gridSpan),
|
|
670
|
+
hMerge: Number(hMerge),
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return info;
|
|
675
|
+
};
|
|
676
|
+
//# sourceMappingURL=xml-slide-helper.js.map
|