@microlee666/dom-to-pptx 1.1.4

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/.prettierrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "es5",
4
+ "singleQuote": true,
5
+ "printWidth": 100
6
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,96 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ ## [1.1.4] - 2026-01-19
5
+
6
+ ### Added
7
+ - **Tailwind CSS v4 Support**: Added robust color parsing for modern CSS color formats (e.g., `oklch`, `lab`, `display-p3`) used by Tailwind v4. The library now uses canvas-based normalization to support any valid CSS color.
8
+ - **Text Gradient Fallback**: Text with CSS gradients (e.g., `background-clip: text`) now gracefully falls back to the *first color* of the gradient string instead of rendering as invisible or black.
9
+ - **List Marker Customization**: Support for `::marker` pseudo-element styles. Custom bullet colors and font sizes are now preserved in the generated PowerPoint.
10
+
11
+ ### Fixed
12
+ - **Text Alignment**: Fixed an issue where text containers were slightly shorter than browser rendering, causing overlap with subsequent elements. Added a precision buffer to account for font metric differences.
13
+ - **Line Breaks**: Fixed an issue where `<br>` tags with surrounding whitespace caused double line breaks in the output.
14
+ - **Missing Elements (Cone Fix)**: Fixed a bug where empty elements with solid backgrounds and partial border radii (e.g., decorative shapes) were skipped during rasterization. We now generate a high-fidelity Vector SVG for these shapes.
15
+ - **Inline Badges**: Improved flow for inline elements with backgrounds (badges), ensuring they align correctly with surrounding text.
16
+
17
+ ## [1.1.3] - 2026-01-12
18
+
19
+ ### Added
20
+ - **Table Supprt**: Added support for table elements like `<table>`, `<th>` `<td>`, `<tr>` with basic css formatting.
21
+
22
+ ## [1.1.2] - 2026-01-08
23
+
24
+ ### Added
25
+ - **Canvas Support**: Added support for `<canvas>` elements. Libraries like **ECharts** and **Chart.js** now render correctly as images instead of blank spaces.
26
+ - **Backend Upload Support**: Added `skipDownload` option to `exportToPptx`. The function now returns a `Promise<Blob>`, allowing developers to upload the generated file to a server instead of triggering a browser download.
27
+ - **List Configuration**: Added `listConfig` option to manually override bullet colors and spacing (before/after) globally.
28
+ - **Icon Support in Lists**: Added logic to capture pseudo-element content (`::before`), ensuring icons (e.g., FontAwesome) inside list items are rendered correctly.
29
+
30
+ ### Fixed
31
+ - **Native Lists**: HTML `<ul>` and `<ol>` lists are now rendered as a single native PowerPoint text box with real bullets, rather than disconnected text shapes.
32
+ - **Line Height Calculation**: Fixed an issue where pixel-based CSS `line-height` was interpreted as a multiplier in PowerPoint, causing text to overlap or crush.
33
+ - **Paragraph Spacing**: CSS `margin-top` and `margin-bottom` are now correctly converted to PowerPoint points (`paraSpaceBefore` / `paraSpaceAfter`).
34
+ - **List Item Spacing**: Fixed a bug where list items had double line breaks, causing excessive spacing between bullets.
35
+
36
+ ## [1.1.1] - 2026-01-02
37
+
38
+ ### Fixed
39
+
40
+ - Resolved an issue where ordered (`<ol>`) and unordered (`<ul>`) lists were not rendered correctly in exported PPTX files. (Fixes #8)
41
+ - Corrected geometric shape rendering issues related to absolute positioning and percentage-based sizing to ensure accurate layout in PPTX exports. (Fixes #6)
42
+ - Fixed text box width calculation discrepancies that caused incorrect line breaks and text wrapping in PPTX output. (Fixes #5)
43
+
44
+ ## [1.1.0] - 2025-12-29
45
+
46
+ ### Added
47
+
48
+ - **Automatic Font Discovery:** The library now automatically scans the DOM for used font families, extracts their `@font-face` URLs from the document stylesheets, and embeds them into the PPTX file; Addresses Feature Request [#4].
49
+ - **Custom Font Embedding:** Added support for manually embedding web fonts (TTF, WOFF, OTF).
50
+ - **Font Configuration:** Added `fonts` option for manual font URLs and `autoEmbedFonts` (default: `true`) to toggle automatic detection.
51
+
52
+ ### Changed
53
+
54
+ - **Build Configuration:** Updated Rollup build to include necessary Node.js polyfills (Buffer, Stream) for the browser bundle to support binary font manipulation.
55
+ - **Text Detection:** Improved `isTextContainer` logic to better distinguish between pure text nodes and structural inline elements (like icons or styled spans).
56
+
57
+ ## [1.0.9] - 2025-12-28
58
+
59
+ ### Fixed
60
+
61
+ - **Complex Gradients:** Fixed `linear-gradient` parsing to correctly support degree-based angles (e.g., `45deg`) and complex directional keywords (e.g., `to top right`), ensuring background gradients match the CSS exactly.
62
+ - **Icon Visibility:** Fixed an issue where icons (Font Awesome, Material Icons, etc.) nested within list items or text containers were being treated as empty text and failing to render, fixes [#3].
63
+
64
+ ## [1.0.8] - 2025-12-12 (Hot-Patch)
65
+
66
+ ### Fixed
67
+
68
+ - **Fixed SVGs not getting converted**: Seperated the logic to handle SVGs and Web Components/Icons.
69
+
70
+ ## [1.0.7] - 2025-12-12
71
+
72
+ ### Fixed
73
+
74
+ - **Fix Stacking Context/Z-Index**: Implemented logic to traverse and inherit Z-index from parents. Render queue is now sorted by Z-index then DOM order, preventing text from being hidden behind background cards.
75
+ - **Support Web Components/Icons**: Updated `createRenderItem` and `isTextContainer` to recognize `ion-icon` and custom tags. These are now rasterized via canvas rather than ignored.
76
+ - **Fix Mixed Content (Icons + Text)**: Switched main traversal loop to use `childNodes` instead of `children`. Added specific handler for `nodeType === 3` (Text Nodes) to render orphan text residing next to icons/shapes.
77
+ - **Fix Styled Inline Spans (Badges)**: Updated `isTextContainer` to return `false` if children have visible backgrounds or borders. This ensures elements like "Pune/Vashi" badges render as individual styled shapes instead of flattening into unstyled text runs.
78
+
79
+ ## [1.0.6] - 2025-12-06
80
+
81
+ ### Added
82
+
83
+ - Standalone UMD bundle `dist/dom-to-pptx.bundle.js` which includes runtime dependencies for single-script usage.
84
+ - `SUPPORTED.md` listing common supported HTML elements and CSS features.
85
+
86
+ ### Fixed
87
+
88
+ - Rounded corner math: decreased false-positive circle detection and capped `rectRadius` to avoid pill-shaped elements becoming full circles.
89
+ - Partial border-radius clipping: elements inside `overflow:hidden` are now correctly rendered with clipping preserved.
90
+ - Very small elements (sub-pixel) rendering: lowered threshold to include tiny decorative elements (e.g., 2x2 dots).
91
+ - Backdrop blur support: simulated `backdrop-filter: blur()` using html2canvas snapshotting.
92
+ - CORS canvas errors: replaced fragile foreignObject rendering with safer SVG + canvas or html2canvas-based capture where appropriate.
93
+
94
+ ## [1.0.3] - Previous
95
+
96
+ - Minor fixes and optimizations.
@@ -0,0 +1,72 @@
1
+ # Contributing to dom-to-pptx
2
+
3
+ We welcome contributions to `dom-to-pptx`! To ensure a smooth and effective collaboration, please follow these guidelines.
4
+
5
+ ## How to Contribute
6
+
7
+ 1. **Fork the Repository:** Start by forking the `dom-to-pptx` repository to your GitHub account.
8
+ 2. **Clone Your Fork:** Clone the forked repository to your local machine:
9
+
10
+ ```bash
11
+ git clone https://github.com/atharva9167j/dom-to-pptx.git
12
+ cd dom-to-pptx
13
+ ```
14
+
15
+ 3. **Create a New Branch:** Create a new branch for your feature or bug fix:
16
+
17
+ ```bash
18
+ git checkout -b feature/your-feature-name
19
+ # or
20
+ git checkout -b bugfix/issue-description
21
+ ```
22
+
23
+ 4. **Install Dependencies:** Install the project dependencies:
24
+
25
+ ```bash
26
+ npm install
27
+ ```
28
+
29
+ 5. **Make Your Changes:** Implement your feature or bug fix. Ensure your code adheres to the project's coding style and passes all tests.
30
+
31
+ 6. **Run Tests:** Before submitting, run the tests to ensure everything is working correctly:
32
+
33
+ ```bash
34
+ npm test
35
+ ```
36
+
37
+ 7. **Lint and Format:** Ensure your code is properly linted and formatted:
38
+
39
+ ```bash
40
+ npm run lint
41
+ npm run format
42
+ ```
43
+
44
+ 8. **Commit Your Changes:** Commit your changes with a clear and concise commit message. We follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
45
+
46
+ ```bash
47
+ git commit -m "feat: Add new feature"
48
+ # or
49
+ git commit -m "fix: Fix a bug"
50
+ ```
51
+
52
+ 9. **Push to Your Fork:** Push your changes to your forked repository:
53
+
54
+ ```bash
55
+ git push origin feature/your-feature-name
56
+ ```
57
+
58
+ 10. **Create a Pull Request:** Open a pull request from your fork to the `master` branch of the `dom-to-pptx` repository. Provide a detailed description of your changes.
59
+
60
+ ## Code Style
61
+
62
+ We use ESLint for linting and Prettier for code formatting. Please ensure your code passes linting and formatting checks before submitting a pull request.
63
+
64
+ ## Reporting Bugs
65
+
66
+ If you find a bug, please open an issue on the [GitHub Issues](https://github.com/atharva9167j/dom-to-pptx/issues) page. Provide as much detail as possible, including steps to reproduce the bug, expected behavior, and actual behavior.
67
+
68
+ ## Feature Requests
69
+
70
+ If you have a feature request, please open an issue on the [GitHub Issues](https://github.com/atharva9167j/dom-to-pptx/issues) page. Describe your idea clearly and explain why it would be beneficial to the project.
71
+
72
+ Thank you for contributing!
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Atharva Dharmendra Jagtap and dom-to-pptx contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/Readme.md ADDED
@@ -0,0 +1,310 @@
1
+ # dom-to-pptx
2
+
3
+ **The High-Fidelity HTML to PowerPoint Converter (v1.1.4)**
4
+
5
+ Most HTML-to-PPTX libraries fail when faced with modern web design. They break on gradients, misalign text, ignore rounded corners, or simply take a screenshot (which isn't editable).
6
+
7
+ **dom-to-pptx** is different. It is a **Coordinate Scraper & Style Engine** that traverses your DOM, calculates the exact computed styles of every element (Flexbox/Grid positions, complex gradients, shadows), and mathematically maps them to native PowerPoint shapes and text boxes. The result is a fully editable, vector-sharp presentation that looks exactly like your web view.
8
+
9
+ ### 🛠️ Updates in v1.1.4
10
+ - **Tailwind CSS v4 Support** (oklch colors)
11
+ - **Text Gradient Fallback**
12
+ - **List Customization & Layout fixes**
13
+
14
+ ## Features
15
+
16
+ ### 🚀 New in v1.1.0
17
+
18
+ - **Smart Font Embedding:** The library **automatically detects** the fonts used in your HTML, finds their URLs in your CSS, and embeds them into the PPTX. Your slides will look identical on any computer, even if the user doesn't have the fonts installed.
19
+ - **Enhanced Icon Support:** Flawless rendering of FontAwesome, Material Icons, and SVG-based icon libraries (including gradient text icons).
20
+
21
+ ### 🎨 Advanced Visual Fidelity
22
+
23
+ - **Complex Gradients:** Includes a built-in CSS Gradient Parser that converts `linear-gradient` strings (with multiple stops, specific angles like `45deg`, and transparency) into vector SVGs.
24
+ - **Mathematically Accurate Shadows:** Converts CSS Cartesian shadows (`x`, `y`, `blur`) into PowerPoint's Polar coordinate system (`angle`, `distance`) for 1:1 depth matching.
25
+ - **Anti-Halo Image Processing:** Uses off-screen HTML5 Canvas with `source-in` composite masking to render rounded images without the ugly white "halo" artifacts found in other libraries.
26
+ - **Soft Edges/Blurs:** Accurately translates CSS `filter: blur()` into PowerPoint's soft-edge effects, preserving visual depth.
27
+
28
+ ### 📐 Smart Layout & Typography
29
+
30
+ - **Auto-Scaling Engine:** Build your slide in HTML at **1920x1080** (or any aspect ratio). The library automatically calculates the scaling factor to fit it perfectly into a standard 16:9 PowerPoint slide.
31
+ - **Rich Text Blocks:** Handles mixed-style text (e.g., **bold** spans inside a normal paragraph).
32
+ - **Text Transformations:** Supports CSS `text-transform: uppercase/lowercase` and `letter-spacing`.
33
+
34
+ ### ⚡ Technical Capabilities
35
+
36
+ - **Z-Index Handling:** Respects DOM order for correct layering of elements.
37
+ - **Border Radius Math:** Calculates perfect corner rounding percentages based on element dimensions.
38
+ - **Client-Side:** Runs entirely in the browser. No server required.
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ npm install dom-to-pptx
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ This library is intended for use in the browser (React, Vue, Svelte, Vanilla JS, etc.).
49
+
50
+ ### 1. Basic Example (Auto-Font Embedding)
51
+
52
+ By default, `dom-to-pptx` attempts to automatically find and embed your web fonts.
53
+
54
+ ```javascript
55
+ import { exportToPptx } from 'dom-to-pptx';
56
+
57
+ document.getElementById('export-btn').addEventListener('click', async () => {
58
+ // Pass the CSS selector of the container
59
+ await exportToPptx('#slide-container', {
60
+ fileName: 'slide-presentation.pptx',
61
+ });
62
+ });
63
+ ```
64
+
65
+ ### 2. Manual Font Configuration (Optional)
66
+
67
+ If you are using external fonts (like Google Fonts) that are hosted on a server without CORS headers, automatic detection might fail. In that case, you can explicitly pass the font URLs:
68
+
69
+ ```javascript
70
+ import { exportToPptx } from 'dom-to-pptx';
71
+
72
+ await exportToPptx('#slide-container', {
73
+ fileName: 'report.pptx',
74
+ // Optional: Only needed if auto-detection fails due to CORS
75
+ fonts: [
76
+ {
77
+ name: 'Roboto',
78
+ url: 'https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxK.woff2',
79
+ },
80
+ ],
81
+ });
82
+ ```
83
+
84
+ ### 3. Multi-Slide Example
85
+
86
+ To export multiple HTML elements as separate slides, pass an array of elements or selectors:
87
+
88
+ ```javascript
89
+ import { exportToPptx } from 'dom-to-pptx';
90
+
91
+ document.getElementById('export-btn').addEventListener('click', async () => {
92
+ const slideElements = document.querySelectorAll('.slide');
93
+ await exportToPptx(Array.from(slideElements), {
94
+ fileName: 'multi-slide-presentation.pptx',
95
+ });
96
+ });
97
+ ```
98
+
99
+ ### 4. Browser Usage (Script Tags)
100
+
101
+ You can use `dom-to-pptx` directly via CDN. The bundle includes all dependencies.
102
+
103
+ ```html
104
+ <script src="https://cdn.jsdelivr.net/npm/dom-to-pptx@latest/dist/dom-to-pptx.bundle.js"></script>
105
+
106
+ <script>
107
+ document.getElementById('export-btn').addEventListener('click', async () => {
108
+ // The library is available globally as `domToPptx`
109
+ await domToPptx.exportToPptx('#slide-container', {
110
+ fileName: 'slide.pptx',
111
+ });
112
+ });
113
+ </script>
114
+ ```
115
+
116
+ ## Recommended HTML Structure
117
+
118
+ We recommend building your slide container at **1920x1080px**. The library will handle the downscaling to fit the PowerPoint slide (16:9).
119
+
120
+ ```html
121
+ <!-- Container (16:9 Aspect Ratio) -->
122
+ <!-- The library will capture this background color/gradient automatically -->
123
+ <div
124
+ id="slide-container"
125
+ class="slide w-[1000px] h-[562px] bg-white rounded-xl overflow-hidden relative shadow-2xl shadow-black/50 flex"
126
+ >
127
+ <!-- Left Sidebar -->
128
+ <div class="w-1/3 bg-slate-900 relative overflow-hidden flex flex-col p-10 justify-between">
129
+ <!-- Decorative gradients -->
130
+ <div class="absolute top-0 left-0 w-full h-full opacity-30 pointer-events-none">
131
+ <div
132
+ class="absolute -top-20 -left-20 w-64 h-64 bg-purple-600 rounded-full blur-3xl mix-blend-screen"
133
+ ></div>
134
+ <div
135
+ class="absolute bottom-0 right-0 w-80 h-80 bg-indigo-600 rounded-full blur-3xl mix-blend-screen"
136
+ ></div>
137
+ </div>
138
+ <div class="relative z-10">
139
+ <div
140
+ class="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-white/10 border border-white/10 backdrop-blur-md mb-6"
141
+ >
142
+ <span class="w-2 h-2 rounded-full bg-green-400 animate-pulse"></span>
143
+ <span class="text-xs font-medium text-slate-300 tracking-wider">LIVE DATA</span>
144
+ </div>
145
+ <h2 class="text-4xl font-bold text-white leading-tight mb-4">
146
+ Quarterly <br />
147
+ <span class="text-transparent bg-clip-text bg-gradient-to-r from-indigo-400 to-cyan-400"
148
+ >Performance</span
149
+ >
150
+ </h2>
151
+ <p class="text-slate-400 leading-relaxed">
152
+ Visualizing the impact of high-fidelity DOM conversion on presentation workflows.
153
+ </p>
154
+ </div>
155
+ <!-- Feature List (Flexbox/Grid test) -->
156
+ <div class="relative z-10 space-y-4">
157
+ <div class="flex items-center gap-3 p-3 rounded-lg bg-white/5 border border-white/5">
158
+ <div
159
+ class="w-8 h-8 rounded-full bg-indigo-500/20 flex items-center justify-center text-indigo-400 font-bold"
160
+ >
161
+ 1
162
+ </div>
163
+ <div class="text-sm text-slate-300">Pixel-perfect Shadows</div>
164
+ </div>
165
+ <div class="flex items-center gap-3 p-3 rounded-lg bg-white/5 border border-white/5">
166
+ <div
167
+ class="w-8 h-8 rounded-full bg-purple-500/20 flex items-center justify-center text-purple-400 font-bold"
168
+ >
169
+ 2
170
+ </div>
171
+ <div class="text-sm text-slate-300">Complex Gradients</div>
172
+ </div>
173
+ </div>
174
+ </div>
175
+ <!-- Right Content -->
176
+ <div class="w-2/3 bg-slate-50 p-10 relative">
177
+ <!-- Header -->
178
+ <div class="flex justify-between items-start mb-10">
179
+ <div>
180
+ <h3 class="text-slate-800 font-bold text-xl">Revenue Breakdown</h3>
181
+ <p class="text-slate-500 text-sm">Fiscal Year 2024</p>
182
+ </div>
183
+ <div class="flex -space-x-2">
184
+ <!-- Rounded Images Test (CORS friendly) -->
185
+ <img
186
+ class="w-10 h-10 rounded-full border-2 border-white object-cover shadow-md"
187
+ src="https://images.unsplash.com/photo-1534528741775-53994a69daeb?auto=format&amp;fit=crop&amp;w=64&amp;h=64"
188
+ alt="User 1"
189
+ />
190
+ <img
191
+ class="w-10 h-10 rounded-full border-2 border-white object-cover shadow-md"
192
+ src="https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?auto=format&amp;fit=crop&amp;w=64&amp;h=64"
193
+ alt="User 2"
194
+ />
195
+ <div
196
+ class="w-10 h-10 rounded-full border-2 border-white bg-slate-200 flex items-center justify-center text-xs font-bold text-slate-500 shadow-md"
197
+ >
198
+ +5
199
+ </div>
200
+ </div>
201
+ </div>
202
+ <!-- Grid Layout Test -->
203
+ <div class="grid grid-cols-2 gap-6 mb-8">
204
+ <!-- Card 1: Gradient & Shadow -->
205
+ <div
206
+ class="bg-white p-5 rounded-xl complex-shadow border border-slate-100 relative overflow-hidden group"
207
+ >
208
+ <div class="relative z-10">
209
+ <p class="text-xs font-bold text-indigo-500 uppercase tracking-wider mb-1">Total Sales</p>
210
+ <h4 class="text-3xl font-bold text-slate-800">$124,500</h4>
211
+ <div class="mt-3 flex items-center text-xs font-semibold text-green-600">
212
+ <svg class="w-3 h-3 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
213
+ <path
214
+ stroke-linecap="round"
215
+ stroke-linejoin="round"
216
+ stroke-width="2"
217
+ d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"
218
+ ></path>
219
+ </svg>
220
+ <span>+14.5%</span>
221
+ </div>
222
+ </div>
223
+ </div>
224
+ <!-- Card 2: Gradient Border/Background -->
225
+ <div
226
+ class="p-5 rounded-xl shadow-lg text-white relative overflow-hidden"
227
+ style="
228
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
229
+ "
230
+ >
231
+ <p class="text-xs font-bold text-white/80 uppercase tracking-wider mb-1">Active Users</p>
232
+ <h4 class="text-3xl font-bold text-white">45.2k</h4>
233
+ <div class="mt-3 w-full bg-black/20 rounded-full h-1.5">
234
+ <div class="bg-white/90 h-1.5 rounded-full" style="width: 70%"></div>
235
+ </div>
236
+ </div>
237
+ </div>
238
+ <!-- Complex Typography & Layout -->
239
+ <div class="bg-indigo-50/50 rounded-xl p-6 border border-indigo-100">
240
+ <h5 class="font-bold text-indigo-900 mb-3">Analysis Summary</h5>
241
+ <p class="text-indigo-800/80 text-sm leading-relaxed">
242
+ The
243
+ <span class="font-bold text-indigo-600">Q3 projection</span>
244
+ exceeds expectations due to the new
245
+ <span class="italic">optimization algorithm</span>. We observed a
246
+ <strong class="text-indigo-700">240% increase</strong>
247
+ in processing speed across all nodes.
248
+ </p>
249
+ </div>
250
+ <!-- Floating Badge (Absolute positioning test) -->
251
+ <div
252
+ class="absolute bottom-6 right-6 bg-white/90 backdrop-blur px-4 py-2 rounded-lg shadow-lg border border-slate-200 flex items-center gap-2"
253
+ >
254
+ <div class="w-2 h-2 rounded-full bg-red-500"></div>
255
+ <span class="text-xs font-bold text-slate-600 uppercase">Confidential</span>
256
+ </div>
257
+ </div>
258
+ </div>
259
+ ```
260
+
261
+ ## API
262
+
263
+ ### `exportToPptx(elementOrSelector, options)`
264
+
265
+ Returns: `Promise<Blob>` - Resolves with the generated PPTX file data (Blob).
266
+
267
+ | Parameter | Type | Description |
268
+ | :------------------ | :---------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------- |
269
+ | `elementOrSelector` | `string` \| `HTMLElement` \| `Array<string \| HTMLElement>` | The DOM node(s) or ID selector(s) to convert. Can be a single element/selector or an array for multi-slide export. |
270
+ | `options` | `object` | Configuration object. |
271
+
272
+ **Options Object:**
273
+
274
+ | Key | Type | Default | Description |
275
+ | :--------------- | :-------- | :-------------- | :------------------------------------------------------------------------------------------------------- |
276
+ | `fileName` | `string` | `"export.pptx"` | The name of the downloaded file. |
277
+ | `autoEmbedFonts` | `boolean` | `true` | Automatically detect and embed used fonts. |
278
+ | `fonts` | `Array` | `[]` | Manual array of font objects: `{ name, url }`. |
279
+ | `skipDownload` | `boolean` | `false` | If `true`, the file is not downloaded automatically. Use the returned `Blob` for custom handling (upload). |
280
+ | `listConfig` | `object` | `undefined` | Global overrides for list styles. Structure: `{ color: string, spacing: { before: number, after: number } }`. |
281
+
282
+ **List Configuration Example:**
283
+ ```javascript
284
+ listConfig: {
285
+ spacing: {
286
+ before: 10, // Space before bullet (pt)
287
+ after: 5 // Space after bullet (pt)
288
+ }
289
+ }
290
+ ```
291
+
292
+ ## Important Notes
293
+
294
+ 1. **Fonts & CORS:**
295
+ - **Automatic Embedding:** Works perfectly for local fonts and external fonts served with correct CORS headers.
296
+ - **Google Fonts:** For auto-detection to work with Google Fonts, you must add `crossorigin="anonymous"` to your link tag:
297
+ `<link href="https://fonts.googleapis.com/..." rel="stylesheet" crossorigin="anonymous">`
298
+ - If a font cannot be accessed due to CORS, the library will log a warning and proceed without embedding it (PowerPoint will fallback to Arial).
299
+
300
+ 2. **Layout System:** The library does not "read" Flexbox or Grid definitions directly. It measures the final `x, y, width, height` of every element relative to the slide root and places them absolutely. This ensures 100% visual accuracy regardless of the CSS layout method used.
301
+
302
+ 3. **CORS Images:** External images (`<img>` tags) must also be served with `Access-Control-Allow-Origin: *` headers to be processed by the rounding/masking engine.
303
+
304
+ ## License
305
+
306
+ MIT © [Atharva Dharmendra Jagtap](https://github.com/atharva9167j) and `dom-to-pptx` contributors.
307
+
308
+ ## Acknowledgements
309
+
310
+ This project is built on top of [PptxGenJS](https://github.com/gitbrent/PptxGenJS). Huge thanks to the PptxGenJS maintainers and all contributors — dom-to-pptx leverages and extends their excellent work on PPTX generation.
package/SUPPORTED.md ADDED
@@ -0,0 +1,50 @@
1
+ # Supported CSS & HTML
2
+
3
+ This document lists the common CSS features, Tailwind-like utility classes, and HTML elements that dom-to-pptx understands and maps to PowerPoint shapes/text.
4
+
5
+ Note: The library measures computed layout from the browser (getBoundingClientRect) and maps positions/sizes precisely to PPTX inches. If a CSS feature is not listed below it may still work because the browser computes layout and visual styles — the mapping focuses on visual fidelity.
6
+
7
+ ## Supported HTML elements
8
+
9
+ - div, span, p, h1-h6
10
+ - img, svg
11
+ - ul, ol, li
12
+ - a
13
+ - button
14
+ - section, article, header, footer
15
+ - input (text), textarea (simple text extraction)
16
+ - figure, figcaption
17
+
18
+ ## Supported CSS properties (rendered visually)
19
+
20
+ - background-color, background-image (linear-gradient)
21
+ - background-position, background-size (basic handling in gradients)
22
+ - color, opacity
23
+ - border, border-_-color, border-_-width, border-radius (per-corner)
24
+ - box-shadow (outer shadows mapped to PPTX outer shadows)
25
+ - filter: blur() (soft-edge rendering via SVG)
26
+ - backdrop-filter: blur() (simulated via html2canvas snapshot)
27
+ - transform: rotate() (extraction of rotation angle)
28
+ - display, position, width, height, padding, margin
29
+ - text-align, vertical-align, white-space, text-transform
30
+ - font-family, font-size, font-weight, font-style, line-height
31
+
32
+ ## Common utility/Tailwind-like classes (recognized by visual result)
33
+
34
+ These classes are examples; dom-to-pptx reads computed styles, so any combination that results in the same computed value will be supported.
35
+
36
+ - `rounded`, `rounded-sm`, `rounded-md`, `rounded-lg`, `rounded-xl`, `rounded-full`, `rounded-tr-*`, `rounded-bl-full`, etc.
37
+ - `bg-white`, `bg-slate-50`, `bg-indigo-50`, `bg-gradient-to-r`, `from-indigo-400`, `to-cyan-400`, etc. (linear-gradients are parsed)
38
+ - `shadow`, `shadow-md`, `shadow-lg`, `shadow-2xl` (box-shadow)
39
+ - `flex`, `grid`, `items-center`, `justify-center`, `gap-*`
40
+ - `p-4`, `px-6`, `py-2`, `m-4`
41
+ - `w-*`, `h-*` (fixed pixel/percentage/wrappers — computed width/height are used)
42
+ - `text-xs`, `text-sm`, `text-lg`, `font-bold`, `uppercase`, `italic`, `tracking-wide`
43
+
44
+ ## Limitations
45
+
46
+ - Complex CSS animations/transitions are not exported — only the current computed visual state is captured.
47
+ - Some advanced CSS features (CSS variables used as colors, filters beyond blur) may not map 1:1.
48
+ - For images to be processed via canvas (rounded images), the source must be CORS-accessible (`Access-Control-Allow-Origin` header) or the image will be skipped or rendered as-is.
49
+
50
+ If a style or element is critical and you find it not behaving as expected, open an issue with a minimal repro and I'll add support or provide a workaround.