pptx-viewer-core 1.1.38 → 1.1.39
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/cli/index.js +0 -0
- package/dist/cli/index.mjs +0 -0
- package/dist/index.js +44 -9
- package/dist/index.mjs +44 -9
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
Binary file
|
package/dist/cli/index.mjs
CHANGED
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -2074,7 +2074,7 @@ var MediaGraphicFrameXmlFactory = class {
|
|
|
2074
2074
|
const mediaType = element.mediaType === "audio" ? "audio" : "video";
|
|
2075
2075
|
const mediaName = mediaType === "audio" ? "Audio" : "Video";
|
|
2076
2076
|
const mediaTag = mediaType === "audio" ? "a:audioFile" : "a:videoFile";
|
|
2077
|
-
const linkAttr =
|
|
2077
|
+
const linkAttr = "@_r:link";
|
|
2078
2078
|
return {
|
|
2079
2079
|
"p:nvGraphicFramePr": {
|
|
2080
2080
|
"p:cNvPr": {
|
|
@@ -32046,12 +32046,43 @@ function ensureA16NamespaceOnSlideRoot(slideRoot) {
|
|
|
32046
32046
|
slideRoot["@_mc:Ignorable"] = "a16";
|
|
32047
32047
|
return;
|
|
32048
32048
|
}
|
|
32049
|
-
const tokens = existingIgnorable.split(/\s+/).filter((token) => token.length > 0);
|
|
32049
|
+
const tokens = existingIgnorable.split(/\s+/u).filter((token) => token.length > 0);
|
|
32050
32050
|
if (!tokens.includes("a16")) {
|
|
32051
32051
|
tokens.push("a16");
|
|
32052
32052
|
slideRoot["@_mc:Ignorable"] = tokens.join(" ");
|
|
32053
32053
|
}
|
|
32054
32054
|
}
|
|
32055
|
+
var MATH_NAMESPACE = "http://schemas.openxmlformats.org/officeDocument/2006/math";
|
|
32056
|
+
function ensureMathNamespaceOnSlideRoot(slideRoot) {
|
|
32057
|
+
if (!slideRoot["@_xmlns:m"]) {
|
|
32058
|
+
slideRoot["@_xmlns:m"] = MATH_NAMESPACE;
|
|
32059
|
+
}
|
|
32060
|
+
}
|
|
32061
|
+
function slideContainsMathElement(node) {
|
|
32062
|
+
if (node === null || node === void 0) {
|
|
32063
|
+
return false;
|
|
32064
|
+
}
|
|
32065
|
+
if (Array.isArray(node)) {
|
|
32066
|
+
for (const entry of node) {
|
|
32067
|
+
if (slideContainsMathElement(entry)) {
|
|
32068
|
+
return true;
|
|
32069
|
+
}
|
|
32070
|
+
}
|
|
32071
|
+
return false;
|
|
32072
|
+
}
|
|
32073
|
+
if (typeof node !== "object") {
|
|
32074
|
+
return false;
|
|
32075
|
+
}
|
|
32076
|
+
for (const [key, value] of Object.entries(node)) {
|
|
32077
|
+
if (key.startsWith("m:")) {
|
|
32078
|
+
return true;
|
|
32079
|
+
}
|
|
32080
|
+
if (slideContainsMathElement(value)) {
|
|
32081
|
+
return true;
|
|
32082
|
+
}
|
|
32083
|
+
}
|
|
32084
|
+
return false;
|
|
32085
|
+
}
|
|
32055
32086
|
function slideContainsA16Element(node) {
|
|
32056
32087
|
if (node === null || node === void 0) {
|
|
32057
32088
|
return false;
|
|
@@ -35660,7 +35691,7 @@ var PptxHandlerRuntime31 = class extends PptxHandlerRuntime30 {
|
|
|
35660
35691
|
if (!targetImagePath) {
|
|
35661
35692
|
targetImagePath = ctx.saveSession.nextMediaPath(parsedImage.extension);
|
|
35662
35693
|
const relationshipId = ctx.slideRelationshipRegistry.nextRelationshipId();
|
|
35663
|
-
const relativeMediaPath = targetImagePath.replace(/^ppt
|
|
35694
|
+
const relativeMediaPath = targetImagePath.replace(/^ppt\//u, "../");
|
|
35664
35695
|
ctx.slideRelationships.push({
|
|
35665
35696
|
"@_Id": relationshipId,
|
|
35666
35697
|
"@_Type": ctx.slideImageRelationshipType,
|
|
@@ -35669,7 +35700,7 @@ var PptxHandlerRuntime31 = class extends PptxHandlerRuntime30 {
|
|
|
35669
35700
|
shape = this.createPictureXml(el, relationshipId);
|
|
35670
35701
|
}
|
|
35671
35702
|
if (targetImagePath) {
|
|
35672
|
-
const targetExt = targetImagePath.toLowerCase().match(/\.([^./\\]+)$/)?.[
|
|
35703
|
+
const targetExt = targetImagePath.toLowerCase().match(/\.(?<ext>[^./\\]+)$/u)?.groups?.["ext"];
|
|
35673
35704
|
const parsedExt = parsedImage.extension.toLowerCase();
|
|
35674
35705
|
const extensionMismatch = targetExt !== void 0 && targetExt !== parsedExt && !(targetExt === "jpg" && parsedExt === "jpeg") && !(targetExt === "jpeg" && parsedExt === "jpg");
|
|
35675
35706
|
if (!extensionMismatch) {
|
|
@@ -35704,13 +35735,13 @@ var PptxHandlerRuntime31 = class extends PptxHandlerRuntime30 {
|
|
|
35704
35735
|
targetMediaPath = ctx.saveSession.nextMediaPath(parsedMedia.extension, mediaType);
|
|
35705
35736
|
}
|
|
35706
35737
|
this.zip.file(targetMediaPath, parsedMedia.bytes);
|
|
35707
|
-
const relationshipTarget = targetMediaPath.replace(/^ppt
|
|
35738
|
+
const relationshipTarget = targetMediaPath.replace(/^ppt\//u, "../");
|
|
35708
35739
|
if (!mediaRelationshipId) {
|
|
35709
35740
|
mediaRelationshipId = ctx.slideRelationshipRegistry.nextRelationshipId();
|
|
35710
35741
|
}
|
|
35711
35742
|
ctx.slideRelationshipRegistry.upsertRelationship(
|
|
35712
35743
|
mediaRelationshipId,
|
|
35713
|
-
|
|
35744
|
+
relTypes.media,
|
|
35714
35745
|
relationshipTarget
|
|
35715
35746
|
);
|
|
35716
35747
|
if (!shape) {
|
|
@@ -35734,11 +35765,12 @@ var PptxHandlerRuntime31 = class extends PptxHandlerRuntime30 {
|
|
|
35734
35765
|
});
|
|
35735
35766
|
}
|
|
35736
35767
|
} else if (!shape && typeof mediaElement.mediaPath === "string" && mediaElement.mediaPath.length > 0) {
|
|
35737
|
-
const relationshipTarget = mediaElement.mediaPath.replace(/^ppt
|
|
35738
|
-
mediaRelationshipId
|
|
35768
|
+
const relationshipTarget = mediaElement.mediaPath.replace(/^ppt\//u, "../");
|
|
35769
|
+
mediaRelationshipId ||= ctx.slideRelationshipRegistry.nextRelationshipId();
|
|
35770
|
+
const pathRelType = mediaElement.isLinked ? this.slideMediaRelationshipBuilder.resolveMediaRelationshipType(mediaType, relTypes) : relTypes.media;
|
|
35739
35771
|
ctx.slideRelationshipRegistry.upsertRelationship(
|
|
35740
35772
|
mediaRelationshipId,
|
|
35741
|
-
|
|
35773
|
+
pathRelType,
|
|
35742
35774
|
relationshipTarget
|
|
35743
35775
|
);
|
|
35744
35776
|
shape = this.createMediaGraphicFrameXml(mediaElement, mediaRelationshipId);
|
|
@@ -36167,6 +36199,9 @@ var PptxHandlerRuntime33 = class extends PptxHandlerRuntime32 {
|
|
|
36167
36199
|
if (slideContainsA16Element(slideNode)) {
|
|
36168
36200
|
ensureA16NamespaceOnSlideRoot(slideNode);
|
|
36169
36201
|
}
|
|
36202
|
+
if (slideContainsMathElement(slideNode)) {
|
|
36203
|
+
ensureMathNamespaceOnSlideRoot(slideNode);
|
|
36204
|
+
}
|
|
36170
36205
|
this.zip.file(slide.id, this.builder.build(xmlObj));
|
|
36171
36206
|
}
|
|
36172
36207
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -2069,7 +2069,7 @@ var MediaGraphicFrameXmlFactory = class {
|
|
|
2069
2069
|
const mediaType = element.mediaType === "audio" ? "audio" : "video";
|
|
2070
2070
|
const mediaName = mediaType === "audio" ? "Audio" : "Video";
|
|
2071
2071
|
const mediaTag = mediaType === "audio" ? "a:audioFile" : "a:videoFile";
|
|
2072
|
-
const linkAttr =
|
|
2072
|
+
const linkAttr = "@_r:link";
|
|
2073
2073
|
return {
|
|
2074
2074
|
"p:nvGraphicFramePr": {
|
|
2075
2075
|
"p:cNvPr": {
|
|
@@ -32041,12 +32041,43 @@ function ensureA16NamespaceOnSlideRoot(slideRoot) {
|
|
|
32041
32041
|
slideRoot["@_mc:Ignorable"] = "a16";
|
|
32042
32042
|
return;
|
|
32043
32043
|
}
|
|
32044
|
-
const tokens = existingIgnorable.split(/\s+/).filter((token) => token.length > 0);
|
|
32044
|
+
const tokens = existingIgnorable.split(/\s+/u).filter((token) => token.length > 0);
|
|
32045
32045
|
if (!tokens.includes("a16")) {
|
|
32046
32046
|
tokens.push("a16");
|
|
32047
32047
|
slideRoot["@_mc:Ignorable"] = tokens.join(" ");
|
|
32048
32048
|
}
|
|
32049
32049
|
}
|
|
32050
|
+
var MATH_NAMESPACE = "http://schemas.openxmlformats.org/officeDocument/2006/math";
|
|
32051
|
+
function ensureMathNamespaceOnSlideRoot(slideRoot) {
|
|
32052
|
+
if (!slideRoot["@_xmlns:m"]) {
|
|
32053
|
+
slideRoot["@_xmlns:m"] = MATH_NAMESPACE;
|
|
32054
|
+
}
|
|
32055
|
+
}
|
|
32056
|
+
function slideContainsMathElement(node) {
|
|
32057
|
+
if (node === null || node === void 0) {
|
|
32058
|
+
return false;
|
|
32059
|
+
}
|
|
32060
|
+
if (Array.isArray(node)) {
|
|
32061
|
+
for (const entry of node) {
|
|
32062
|
+
if (slideContainsMathElement(entry)) {
|
|
32063
|
+
return true;
|
|
32064
|
+
}
|
|
32065
|
+
}
|
|
32066
|
+
return false;
|
|
32067
|
+
}
|
|
32068
|
+
if (typeof node !== "object") {
|
|
32069
|
+
return false;
|
|
32070
|
+
}
|
|
32071
|
+
for (const [key, value] of Object.entries(node)) {
|
|
32072
|
+
if (key.startsWith("m:")) {
|
|
32073
|
+
return true;
|
|
32074
|
+
}
|
|
32075
|
+
if (slideContainsMathElement(value)) {
|
|
32076
|
+
return true;
|
|
32077
|
+
}
|
|
32078
|
+
}
|
|
32079
|
+
return false;
|
|
32080
|
+
}
|
|
32050
32081
|
function slideContainsA16Element(node) {
|
|
32051
32082
|
if (node === null || node === void 0) {
|
|
32052
32083
|
return false;
|
|
@@ -35655,7 +35686,7 @@ var PptxHandlerRuntime31 = class extends PptxHandlerRuntime30 {
|
|
|
35655
35686
|
if (!targetImagePath) {
|
|
35656
35687
|
targetImagePath = ctx.saveSession.nextMediaPath(parsedImage.extension);
|
|
35657
35688
|
const relationshipId = ctx.slideRelationshipRegistry.nextRelationshipId();
|
|
35658
|
-
const relativeMediaPath = targetImagePath.replace(/^ppt
|
|
35689
|
+
const relativeMediaPath = targetImagePath.replace(/^ppt\//u, "../");
|
|
35659
35690
|
ctx.slideRelationships.push({
|
|
35660
35691
|
"@_Id": relationshipId,
|
|
35661
35692
|
"@_Type": ctx.slideImageRelationshipType,
|
|
@@ -35664,7 +35695,7 @@ var PptxHandlerRuntime31 = class extends PptxHandlerRuntime30 {
|
|
|
35664
35695
|
shape = this.createPictureXml(el, relationshipId);
|
|
35665
35696
|
}
|
|
35666
35697
|
if (targetImagePath) {
|
|
35667
|
-
const targetExt = targetImagePath.toLowerCase().match(/\.([^./\\]+)$/)?.[
|
|
35698
|
+
const targetExt = targetImagePath.toLowerCase().match(/\.(?<ext>[^./\\]+)$/u)?.groups?.["ext"];
|
|
35668
35699
|
const parsedExt = parsedImage.extension.toLowerCase();
|
|
35669
35700
|
const extensionMismatch = targetExt !== void 0 && targetExt !== parsedExt && !(targetExt === "jpg" && parsedExt === "jpeg") && !(targetExt === "jpeg" && parsedExt === "jpg");
|
|
35670
35701
|
if (!extensionMismatch) {
|
|
@@ -35699,13 +35730,13 @@ var PptxHandlerRuntime31 = class extends PptxHandlerRuntime30 {
|
|
|
35699
35730
|
targetMediaPath = ctx.saveSession.nextMediaPath(parsedMedia.extension, mediaType);
|
|
35700
35731
|
}
|
|
35701
35732
|
this.zip.file(targetMediaPath, parsedMedia.bytes);
|
|
35702
|
-
const relationshipTarget = targetMediaPath.replace(/^ppt
|
|
35733
|
+
const relationshipTarget = targetMediaPath.replace(/^ppt\//u, "../");
|
|
35703
35734
|
if (!mediaRelationshipId) {
|
|
35704
35735
|
mediaRelationshipId = ctx.slideRelationshipRegistry.nextRelationshipId();
|
|
35705
35736
|
}
|
|
35706
35737
|
ctx.slideRelationshipRegistry.upsertRelationship(
|
|
35707
35738
|
mediaRelationshipId,
|
|
35708
|
-
|
|
35739
|
+
relTypes.media,
|
|
35709
35740
|
relationshipTarget
|
|
35710
35741
|
);
|
|
35711
35742
|
if (!shape) {
|
|
@@ -35729,11 +35760,12 @@ var PptxHandlerRuntime31 = class extends PptxHandlerRuntime30 {
|
|
|
35729
35760
|
});
|
|
35730
35761
|
}
|
|
35731
35762
|
} else if (!shape && typeof mediaElement.mediaPath === "string" && mediaElement.mediaPath.length > 0) {
|
|
35732
|
-
const relationshipTarget = mediaElement.mediaPath.replace(/^ppt
|
|
35733
|
-
mediaRelationshipId
|
|
35763
|
+
const relationshipTarget = mediaElement.mediaPath.replace(/^ppt\//u, "../");
|
|
35764
|
+
mediaRelationshipId ||= ctx.slideRelationshipRegistry.nextRelationshipId();
|
|
35765
|
+
const pathRelType = mediaElement.isLinked ? this.slideMediaRelationshipBuilder.resolveMediaRelationshipType(mediaType, relTypes) : relTypes.media;
|
|
35734
35766
|
ctx.slideRelationshipRegistry.upsertRelationship(
|
|
35735
35767
|
mediaRelationshipId,
|
|
35736
|
-
|
|
35768
|
+
pathRelType,
|
|
35737
35769
|
relationshipTarget
|
|
35738
35770
|
);
|
|
35739
35771
|
shape = this.createMediaGraphicFrameXml(mediaElement, mediaRelationshipId);
|
|
@@ -36162,6 +36194,9 @@ var PptxHandlerRuntime33 = class extends PptxHandlerRuntime32 {
|
|
|
36162
36194
|
if (slideContainsA16Element(slideNode)) {
|
|
36163
36195
|
ensureA16NamespaceOnSlideRoot(slideNode);
|
|
36164
36196
|
}
|
|
36197
|
+
if (slideContainsMathElement(slideNode)) {
|
|
36198
|
+
ensureMathNamespaceOnSlideRoot(slideNode);
|
|
36199
|
+
}
|
|
36165
36200
|
this.zip.file(slide.id, this.builder.build(xmlObj));
|
|
36166
36201
|
}
|
|
36167
36202
|
/**
|