@microlee666/dom-to-pptx 1.1.4 → 1.1.6
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/.claude/settings.local.json +12 -0
- package/Readme.md +28 -0
- package/SUPPORTED.md +5 -0
- package/USAGE_CN.md +26 -0
- package/cli/dom-to-pptx.bundle.js +977 -36
- package/cli/html2pptx.js +19 -6
- package/cli/presentation.pptx +0 -0
- package/dist/dom-to-pptx.bundle.js +769 -14
- package/dist/dom-to-pptx.cjs +767 -13
- package/dist/dom-to-pptx.cjs.map +1 -1
- package/dist/dom-to-pptx.mjs +767 -13
- package/dist/dom-to-pptx.mjs.map +1 -1
- package/package.json +2 -2
- package/scripts/patch-bundle.js +66 -0
- package/src/index.js +530 -10
- package/src/utils.js +240 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microlee666/dom-to-pptx",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "A client-side library that converts any HTML element into a fully editable PowerPoint slide. **dom-to-pptx** transforms DOM structures into pixel-accurate `.pptx` content, preserving gradients, shadows, rounded images, and responsive layouts. It translates CSS Flexbox/Grid, linear-gradients, box-shadows, and typography into native PowerPoint shapes, enabling precise, design-faithful slide generation directly from the browser.",
|
|
5
5
|
"main": "dist/dom-to-pptx.cjs",
|
|
6
6
|
"module": "dist/dom-to-pptx.mjs",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
17
|
-
"build": "npx rollup -c",
|
|
17
|
+
"build": "npx rollup -c && node scripts/patch-bundle.js",
|
|
18
18
|
"lint": "eslint .",
|
|
19
19
|
"format": "prettier --write ."
|
|
20
20
|
},
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Post-build patch script for dom-to-pptx bundle
|
|
4
|
+
* Adds anchorCtr="1" attribute when anchor="ctr" is set in bodyPr
|
|
5
|
+
* This ensures text is truly centered in PowerPoint
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
const bundlePath = path.join(__dirname, '..', 'dist', 'dom-to-pptx.bundle.js');
|
|
12
|
+
const cliBundlePath = path.join(__dirname, '..', 'cli', 'dom-to-pptx.bundle.js');
|
|
13
|
+
|
|
14
|
+
function patchBundle(filePath) {
|
|
15
|
+
if (!fs.existsSync(filePath)) {
|
|
16
|
+
console.log('Bundle not found: ' + filePath);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
21
|
+
|
|
22
|
+
// Pattern to match the anchor setting line
|
|
23
|
+
const pattern = /bodyProperties\s*\+=\s*' anchor="'\s*\+\s*slideObject\.options\._bodyProp\.anchor\s*\+\s*'"';\s*\/\/\s*VALS:\s*\[t,ctr,b\]/;
|
|
24
|
+
|
|
25
|
+
// Check if already patched
|
|
26
|
+
if (content.includes("anchorCtr=\\\"1\\\"'")) {
|
|
27
|
+
console.log('Already patched: ' + path.basename(filePath));
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Apply patch
|
|
32
|
+
const patchedContent = content.replace(
|
|
33
|
+
pattern,
|
|
34
|
+
"bodyProperties += ' anchor=\"' + slideObject.options._bodyProp.anchor + '\"'; // VALS: [t,ctr,b]\n if (slideObject.options._bodyProp.anchor === 'ctr') bodyProperties += ' anchorCtr=\\\"1\\\"';"
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
if (patchedContent !== content) {
|
|
38
|
+
fs.writeFileSync(filePath, patchedContent, 'utf8');
|
|
39
|
+
console.log('Patched: ' + path.basename(filePath));
|
|
40
|
+
return true;
|
|
41
|
+
} else {
|
|
42
|
+
console.log('Pattern not found in: ' + path.basename(filePath));
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Patch both bundle files
|
|
48
|
+
const results = [];
|
|
49
|
+
results.push(patchBundle(bundlePath));
|
|
50
|
+
|
|
51
|
+
// Copy patched bundle to cli directory
|
|
52
|
+
if (fs.existsSync(bundlePath)) {
|
|
53
|
+
fs.copyFileSync(bundlePath, cliBundlePath);
|
|
54
|
+
console.log('Copied bundle to cli directory');
|
|
55
|
+
results.push(true);
|
|
56
|
+
} else {
|
|
57
|
+
results.push(patchBundle(cliBundlePath));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (results.some(r => r)) {
|
|
61
|
+
console.log('Bundle patching completed successfully!');
|
|
62
|
+
process.exit(0);
|
|
63
|
+
} else {
|
|
64
|
+
console.log('No bundles were patched.');
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|