@file-viewer/pptx 2.2.1 → 2.2.3
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/styles.d.ts +7 -1
- package/dist/styles.js +14 -1
- package/dist/viewer.js +2 -2
- package/dist/worker.js +24 -6
- package/package.json +4 -4
package/dist/styles.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The legacy engine emits class-only selector lists. Prefix each top-level
|
|
3
|
+
* class rule so light-DOM consumers do not inherit generic `.slide` or
|
|
4
|
+
* generated `._css_*` rules from a renderer-local style element.
|
|
5
|
+
*/
|
|
6
|
+
export declare const scopePptxContentStyleText: (cssText: string) => string;
|
|
7
|
+
export declare const pptxViewerCss: string;
|
|
2
8
|
export declare const ensurePptxViewerStyles: (documentRef: Document, root?: Document | ShadowRoot) => void;
|
package/dist/styles.js
CHANGED
|
@@ -31,6 +31,19 @@ const legacyPptxCss = `
|
|
|
31
31
|
.slide table{position:absolute}
|
|
32
32
|
.slide svg.drawing{position:absolute;overflow:visible}
|
|
33
33
|
`;
|
|
34
|
+
const PPTX_CONTENT_STYLE_SCOPE = '.flyfish-pptx-content';
|
|
35
|
+
/**
|
|
36
|
+
* The legacy engine emits class-only selector lists. Prefix each top-level
|
|
37
|
+
* class rule so light-DOM consumers do not inherit generic `.slide` or
|
|
38
|
+
* generated `._css_*` rules from a renderer-local style element.
|
|
39
|
+
*/
|
|
40
|
+
export const scopePptxContentStyleText = (cssText) => cssText.replace(/(^|})\s*(\.[^{}]+)\{/g, (_match, boundary, selectorList) => {
|
|
41
|
+
const scopedSelectors = selectorList
|
|
42
|
+
.split(',')
|
|
43
|
+
.map(selector => `${PPTX_CONTENT_STYLE_SCOPE} ${selector.trim()}`)
|
|
44
|
+
.join(',');
|
|
45
|
+
return `${boundary}${scopedSelectors}{`;
|
|
46
|
+
});
|
|
34
47
|
export const pptxViewerCss = `
|
|
35
48
|
.flyfish-pptx-scale-box{position:relative;box-sizing:border-box;max-width:100%;margin:0 auto;min-width:0}
|
|
36
49
|
.flyfish-pptx-content{position:absolute;top:0;left:0;box-sizing:border-box;max-width:none;min-width:0;transform-origin:top left;will-change:transform}
|
|
@@ -41,7 +54,7 @@ export const pptxViewerCss = `
|
|
|
41
54
|
.flyfish-pptx-slide-error-card strong{font-size:18px}
|
|
42
55
|
.flyfish-pptx-content .slide{background:#fff;box-shadow:0 18px 36px rgba(18,35,52,.12)}
|
|
43
56
|
.flyfish-pptx-thumbnail{display:block;box-sizing:border-box;width:min(960px,100%);height:auto;margin:0 auto 28px;border-radius:12px;background:#fff;box-shadow:0 18px 36px rgba(18,35,52,.14)}
|
|
44
|
-
${legacyPptxCss}
|
|
57
|
+
${scopePptxContentStyleText(legacyPptxCss)}
|
|
45
58
|
.flyfish-pptx-content > .slide:last-of-type{margin-bottom:0}
|
|
46
59
|
.flyfish-pptx-slide-slot:last-of-type > .slide{margin-bottom:0}
|
|
47
60
|
`;
|
package/dist/viewer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderPptxPostProcessing } from './chart.js';
|
|
2
2
|
import { resolvePptxEngineOptions, RECOMMENDED_ZIP_LIMITS } from './options.js';
|
|
3
|
-
import { ensurePptxViewerStyles } from './styles.js';
|
|
3
|
+
import { ensurePptxViewerStyles, scopePptxContentStyleText } from './styles.js';
|
|
4
4
|
import { createPptxWorker } from './worker.js';
|
|
5
5
|
const clamp = (value, min, max) => {
|
|
6
6
|
return Math.min(max, Math.max(min, value));
|
|
@@ -251,7 +251,7 @@ export class PptxViewer {
|
|
|
251
251
|
return;
|
|
252
252
|
}
|
|
253
253
|
const style = this.target.ownerDocument.createElement('style');
|
|
254
|
-
style.textContent = css;
|
|
254
|
+
style.textContent = scopePptxContentStyleText(css);
|
|
255
255
|
this.content.append(style);
|
|
256
256
|
}
|
|
257
257
|
showThumbnail(base64Jpeg) {
|
package/dist/worker.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
const
|
|
1
|
+
const viteOptimizedWorkerPathPattern = /\/\.?vite\/deps\/worker\/pptx\.worker\.js$/;
|
|
2
|
+
const angularCachePath = '/.angular/cache/';
|
|
2
3
|
const viteOptimizedPptxSourcePattern = /\/\/\s+(node_modules\/(?:\.pnpm\/[^\n]+?\/node_modules\/)?@file-viewer\/pptx\/dist\/worker\.js)\b/;
|
|
3
4
|
const resolveBundledPptxWorkerUrl = () => new URL('./worker/pptx.worker.js', import.meta.url);
|
|
4
5
|
const canResolveAbsolutePathFrom = (url) => url.protocol !== 'data:' && url.protocol !== 'blob:';
|
|
5
6
|
const resolveViteDevPptxWorkerUrl = (baseUrl) => new URL('/node_modules/@file-viewer/pptx/dist/worker/pptx.worker.js', canResolveAbsolutePathFrom(baseUrl)
|
|
6
7
|
? baseUrl
|
|
7
8
|
: new URL(typeof location !== 'undefined' ? location.href : 'file:///'));
|
|
8
|
-
const
|
|
9
|
+
const resolveAngularVitePptxWorkerUrl = (baseUrl, workerPath) => {
|
|
10
|
+
const cacheIndex = baseUrl.pathname.indexOf(angularCachePath);
|
|
11
|
+
if (cacheIndex < 0) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const workerUrl = new URL(baseUrl.href);
|
|
15
|
+
workerUrl.pathname = `${workerUrl.pathname.slice(0, cacheIndex)}/${workerPath}`;
|
|
16
|
+
workerUrl.search = '';
|
|
17
|
+
workerUrl.hash = '';
|
|
18
|
+
return workerUrl;
|
|
19
|
+
};
|
|
20
|
+
const resolveViteOptimizedPptxWorkerUrl = (defaultPptxWorkerUrl) => {
|
|
9
21
|
if (typeof XMLHttpRequest === 'undefined') {
|
|
10
22
|
return null;
|
|
11
23
|
}
|
|
@@ -23,7 +35,10 @@ const resolveViteOptimizedPptxWorkerUrl = () => {
|
|
|
23
35
|
return null;
|
|
24
36
|
}
|
|
25
37
|
const workerPath = match[1].replace(/dist\/worker\.js$/, 'dist/worker/pptx.worker.js');
|
|
26
|
-
const
|
|
38
|
+
const angularWorkerUrl = resolveAngularVitePptxWorkerUrl(defaultPptxWorkerUrl, workerPath);
|
|
39
|
+
if (angularWorkerUrl) {
|
|
40
|
+
return angularWorkerUrl;
|
|
41
|
+
}
|
|
27
42
|
const origin = typeof location !== 'undefined' && location.origin
|
|
28
43
|
? location.origin
|
|
29
44
|
: defaultPptxWorkerUrl.origin;
|
|
@@ -38,9 +53,12 @@ const resolveDefaultPptxWorkerUrl = () => {
|
|
|
38
53
|
if (!canResolveAbsolutePathFrom(defaultPptxWorkerUrl)) {
|
|
39
54
|
return defaultPptxWorkerUrl;
|
|
40
55
|
}
|
|
41
|
-
// Vite dep optimization rewrites import.meta.url into
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
// Vite dep optimization rewrites import.meta.url into vite/deps, away from
|
|
57
|
+
// this package's worker file. Angular's application builder uses the same
|
|
58
|
+
// optimizer under .angular/cache and prefixes its @fs URL with baseHref.
|
|
59
|
+
if (viteOptimizedWorkerPathPattern.test(defaultPptxWorkerUrl.pathname)) {
|
|
60
|
+
return resolveViteOptimizedPptxWorkerUrl(defaultPptxWorkerUrl)
|
|
61
|
+
|| resolveViteDevPptxWorkerUrl(defaultPptxWorkerUrl);
|
|
44
62
|
}
|
|
45
63
|
return defaultPptxWorkerUrl;
|
|
46
64
|
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/pptx",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "Native PPTX renderer extracted from
|
|
6
|
+
"description": "Native PPTX renderer extracted from File Viewer",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"pptx",
|
|
9
9
|
"powerpoint",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"registry": "https://registry.npmjs.org/"
|
|
20
20
|
},
|
|
21
21
|
"author": {
|
|
22
|
-
"name": "
|
|
23
|
-
"email": "
|
|
22
|
+
"name": "Yu Wang",
|
|
23
|
+
"email": "admin@flyfish.dev"
|
|
24
24
|
},
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|