dom-to-pptx 1.0.0 → 1.0.2

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.
@@ -0,0 +1,17 @@
1
+ import globals from 'globals';
2
+ import pluginJs from '@eslint/js';
3
+ import pluginPrettier from 'eslint-config-prettier';
4
+
5
+ export default [
6
+ { ignores: ['dist/**'] },
7
+ { files: ['**/*.js'], languageOptions: { sourceType: 'module', globals: globals.browser } },
8
+ pluginJs.configs.recommended,
9
+ pluginPrettier,
10
+ {
11
+ rules: {
12
+ // Custom rules or overrides
13
+ 'no-unused-vars': 'warn',
14
+ 'no-undef': 'warn',
15
+ },
16
+ },
17
+ ];
package/package.json CHANGED
@@ -1,53 +1,64 @@
1
- {
2
- "name": "dom-to-pptx",
3
- "version": "1.0.0",
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
- "main": "src/index.js",
6
- "type": "module",
7
- "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/atharva9167j/dom-to-pptx.git"
13
- },
14
- "keywords": [
15
- "pptx",
16
- "html-to-pptx",
17
- "powerpoint",
18
- "pptx-generator",
19
- "slide-generator",
20
- "presentation-generator",
21
- "dom",
22
- "dom-to-pptx",
23
- "export",
24
- "browser-export",
25
- "client-side-pptx",
26
- "html-to-powerpoint",
27
- "convert-html",
28
- "css-to-pptx",
29
- "css-to-powerpoint",
30
- "pptx-creator",
31
- "presentation-tools",
32
- "slides",
33
- "slide-creation",
34
- "web-to-pptx",
35
- "web-to-powerpoint",
36
- "frontend-pptx",
37
- "html-rendering",
38
- "layout-engine",
39
- "gradient-support",
40
- "flexbox",
41
- "css-grid",
42
- "typography"
43
- ],
44
- "author": "Atharva Dharmendra Jagtap <atharvaj321@gmail.com>",
45
- "license": "MIT",
46
- "bugs": {
47
- "url": "https://github.com/atharva9167j/dom-to-pptx/issues"
48
- },
49
- "homepage": "https://github.com/atharva9167j/dom-to-pptx#readme",
50
- "dependencies": {
51
- "pptxgenjs": "^3.12.0"
52
- }
53
- }
1
+ {
2
+ "name": "dom-to-pptx",
3
+ "version": "1.0.2",
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
+ "main": "dist/dom-to-pptx.min.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "build": "npx rollup -c",
10
+ "lint": "eslint .",
11
+ "format": "prettier --write ."
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/atharva9167j/dom-to-pptx.git"
16
+ },
17
+ "keywords": [
18
+ "pptx",
19
+ "html-to-pptx",
20
+ "powerpoint",
21
+ "pptx-generator",
22
+ "slide-generator",
23
+ "presentation-generator",
24
+ "dom",
25
+ "dom-to-pptx",
26
+ "export",
27
+ "browser-export",
28
+ "client-side-pptx",
29
+ "html-to-powerpoint",
30
+ "convert-html",
31
+ "css-to-pptx",
32
+ "css-to-powerpoint",
33
+ "pptx-creator",
34
+ "presentation-tools",
35
+ "slides",
36
+ "slide-creation",
37
+ "web-to-pptx",
38
+ "web-to-powerpoint",
39
+ "frontend-pptx",
40
+ "html-rendering",
41
+ "layout-engine",
42
+ "gradient-support",
43
+ "flexbox",
44
+ "css-grid",
45
+ "typography"
46
+ ],
47
+ "author": "Atharva Dharmendra Jagtap <atharvaj321@gmail.com>",
48
+ "license": "MIT",
49
+ "bugs": {
50
+ "url": "https://github.com/atharva9167j/dom-to-pptx/issues"
51
+ },
52
+ "homepage": "https://github.com/atharva9167j/dom-to-pptx#readme",
53
+ "dependencies": {
54
+ "pptxgenjs": "^3.12.0"
55
+ },
56
+ "devDependencies": {
57
+ "@rollup/plugin-commonjs": "^29.0.0",
58
+ "@rollup/plugin-node-resolve": "^16.0.3",
59
+ "eslint": "^9.39.1",
60
+ "eslint-config-prettier": "^10.1.8",
61
+ "eslint-plugin-prettier": "^5.5.4",
62
+ "prettier": "^3.7.3"
63
+ }
64
+ }
@@ -0,0 +1,17 @@
1
+ import resolve from '@rollup/plugin-node-resolve';
2
+ import commonjs from '@rollup/plugin-commonjs';
3
+
4
+ export default {
5
+ input: 'src/index.js',
6
+ output: {
7
+ file: 'dist/dom-to-pptx.min.js',
8
+ format: 'umd',
9
+ name: 'domToPptx',
10
+ esModule: false,
11
+ globals: {
12
+ pptxgenjs: 'PptxGenJS',
13
+ },
14
+ },
15
+ plugins: [resolve(), commonjs()],
16
+ external: ['pptxgenjs'],
17
+ };
@@ -1,48 +1,48 @@
1
- // src/image-processor.js
2
-
3
- export async function getProcessedImage(src, targetW, targetH, radius) {
4
- return new Promise((resolve) => {
5
- const img = new Image();
6
- img.crossOrigin = "Anonymous"; // Critical for canvas manipulation
7
-
8
- img.onload = () => {
9
- const canvas = document.createElement('canvas');
10
- // Double resolution for better quality
11
- const scale = 2;
12
- canvas.width = targetW * scale;
13
- canvas.height = targetH * scale;
14
- const ctx = canvas.getContext('2d');
15
- ctx.scale(scale, scale);
16
-
17
- // 1. Draw the Mask (Rounded Rect)
18
- ctx.beginPath();
19
- if (ctx.roundRect) {
20
- ctx.roundRect(0, 0, targetW, targetH, radius);
21
- } else {
22
- // Fallback for older browsers if needed
23
- ctx.rect(0, 0, targetW, targetH);
24
- }
25
- ctx.fillStyle = '#000';
26
- ctx.fill();
27
-
28
- // 2. Composite Source-In
29
- ctx.globalCompositeOperation = 'source-in';
30
-
31
- // 3. Draw Image (Object Cover Logic)
32
- const wRatio = targetW / img.width;
33
- const hRatio = targetH / img.height;
34
- const maxRatio = Math.max(wRatio, hRatio);
35
- const renderW = img.width * maxRatio;
36
- const renderH = img.height * maxRatio;
37
- const renderX = (targetW - renderW) / 2;
38
- const renderY = (targetH - renderH) / 2;
39
-
40
- ctx.drawImage(img, renderX, renderY, renderW, renderH);
41
-
42
- resolve(canvas.toDataURL('image/png'));
43
- };
44
-
45
- img.onerror = () => resolve(null);
46
- img.src = src;
47
- });
48
- }
1
+ // src/image-processor.js
2
+
3
+ export async function getProcessedImage(src, targetW, targetH, radius) {
4
+ return new Promise((resolve) => {
5
+ const img = new Image();
6
+ img.crossOrigin = 'Anonymous'; // Critical for canvas manipulation
7
+
8
+ img.onload = () => {
9
+ const canvas = document.createElement('canvas');
10
+ // Double resolution for better quality
11
+ const scale = 2;
12
+ canvas.width = targetW * scale;
13
+ canvas.height = targetH * scale;
14
+ const ctx = canvas.getContext('2d');
15
+ ctx.scale(scale, scale);
16
+
17
+ // 1. Draw the Mask (Rounded Rect)
18
+ ctx.beginPath();
19
+ if (ctx.roundRect) {
20
+ ctx.roundRect(0, 0, targetW, targetH, radius);
21
+ } else {
22
+ // Fallback for older browsers if needed
23
+ ctx.rect(0, 0, targetW, targetH);
24
+ }
25
+ ctx.fillStyle = '#000';
26
+ ctx.fill();
27
+
28
+ // 2. Composite Source-In
29
+ ctx.globalCompositeOperation = 'source-in';
30
+
31
+ // 3. Draw Image (Object Cover Logic)
32
+ const wRatio = targetW / img.width;
33
+ const hRatio = targetH / img.height;
34
+ const maxRatio = Math.max(wRatio, hRatio);
35
+ const renderW = img.width * maxRatio;
36
+ const renderH = img.height * maxRatio;
37
+ const renderX = (targetW - renderW) / 2;
38
+ const renderY = (targetH - renderH) / 2;
39
+
40
+ ctx.drawImage(img, renderX, renderY, renderW, renderH);
41
+
42
+ resolve(canvas.toDataURL('image/png'));
43
+ };
44
+
45
+ img.onerror = () => resolve(null);
46
+ img.src = src;
47
+ });
48
+ }