slidecanvas 1.0.8 → 1.1.0

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/README.md CHANGED
@@ -151,10 +151,10 @@ export default function MyEditor() {
151
151
 
152
152
  ### 1. 7-Second S3 Auto-Save (Real-Time Persistence)
153
153
 
154
- To save changes back to S3 after a modifications stop for 7 seconds, use the `PptxExporter` combined with a debounce pattern:
154
+ To save changes back to S3 after a modifications stop for 7 seconds, use the **`PptxBlobExporter`** combined with a debounce pattern. Unlike the regular exporter, this utility returns a `Blob` directly without triggering a browser download.
155
155
 
156
156
  ```tsx
157
- import { PptEditor, PptxExporter } from 'slidecanvas';
157
+ import { PptEditor, PptxBlobExporter } from 'slidecanvas';
158
158
  import { useRef } from 'react';
159
159
 
160
160
  export function S3Editor({ s3Key }: { s3Key: string }) {
@@ -166,11 +166,11 @@ export function S3Editor({ s3Key }: { s3Key: string }) {
166
166
 
167
167
  // 2. Start a new 7-second countdown
168
168
  timerRef.current = setTimeout(async () => {
169
- console.log('User stopped editing. Exporting and saving to S3...');
169
+ console.log('User stopped editing. Generating Blob and saving to S3...');
170
170
 
171
- // 3. Generate the .pptx file binary
172
- const exporter = new PptxExporter();
173
- const blob = await exporter.export(presentation);
171
+ // 3. Generate the .pptx file binary as a Blob
172
+ const exporter = new PptxBlobExporter();
173
+ const blob = await exporter.exportToBlob(presentation);
174
174
 
175
175
  // 4. Upload to your backend API which talks to S3
176
176
  const formData = new FormData();
@@ -180,7 +180,7 @@ export function S3Editor({ s3Key }: { s3Key: string }) {
180
180
  await fetch('/api/save-to-s3', {
181
181
  method: 'POST',
182
182
  body: formData
183
- });
183
+ });
184
184
 
185
185
  console.log('Saved successfully!');
186
186
  }, 7000); // 7 seconds
@@ -355,20 +355,24 @@ SlideCanvas features a sophisticated 120px high ribbon layout divided into logic
355
355
  #### Intelligent Routing
356
356
  Use the `onSourceChange` callback to synchronize the editor state with your application's routing. This allows for deep-linking to specific presentations or maintaining "Upload" vs "New" states in the address bar.
357
357
 
358
- ### `PptxParser` & `PptxExporter`
358
+ ### `PptxParser`, `PptxExporter` & `PptxBlobExporter`
359
359
 
360
360
  For headless workflows, you can use the internal engine directly:
361
361
 
362
362
  ```typescript
363
- import { PptxParser, PptxExporter } from 'slidecanvas';
363
+ import { PptxParser, PptxExporter, PptxBlobExporter } from 'slidecanvas';
364
364
 
365
- // Load
365
+ // 1. Load: Parse a .pptx file into JSON
366
366
  const parser = new PptxParser();
367
- const presentation = await parser.parse(myBlob);
367
+ const presentation = await parser.parse(myArrayBuffer);
368
368
 
369
- // Export
369
+ // 2. Export: Trigger a browser file download
370
370
  const exporter = new PptxExporter();
371
371
  await exporter.export(presentation);
372
+
373
+ // 3. Blob Export: Get file data as a Blob (useful for S3/API uploads)
374
+ const blobExporter = new PptxBlobExporter();
375
+ const blob = await blobExporter.exportToBlob(presentation);
372
376
  ```
373
377
 
374
378
  ---
package/dist/index.d.mts CHANGED
@@ -85,4 +85,20 @@ declare class PptxExporter {
85
85
  export(presentation: Presentation): Promise<void>;
86
86
  }
87
87
 
88
- export { type BaseElement, type ElementType, type ImageElement, PptEditor, PptxExporter, PptxParser, type Presentation, type PresentationSource, type ShapeElement, type ShapeType, type Slide, type SlideElement, type TextElement };
88
+ /**
89
+ * A standalone service to convert a Presentation object into a .pptx Blob.
90
+ * Use this for background processing, S3 uploads, or other non-UI tasks.
91
+ *
92
+ * This replicates the logic from PptxExporter but returns a Blob instead of
93
+ * triggering a browser download.
94
+ */
95
+ declare class PptxBlobExporter {
96
+ /**
97
+ * Converts a Presentation object into a .pptx Blob.
98
+ * @param presentation The presentation data to export.
99
+ * @returns A Promise that resolves to a Blob containing the .pptx file.
100
+ */
101
+ exportToBlob(presentation: Presentation): Promise<Blob>;
102
+ }
103
+
104
+ export { type BaseElement, type ElementType, type ImageElement, PptEditor, PptxBlobExporter, PptxExporter, PptxParser, type Presentation, type PresentationSource, type ShapeElement, type ShapeType, type Slide, type SlideElement, type TextElement };
package/dist/index.d.ts CHANGED
@@ -85,4 +85,20 @@ declare class PptxExporter {
85
85
  export(presentation: Presentation): Promise<void>;
86
86
  }
87
87
 
88
- export { type BaseElement, type ElementType, type ImageElement, PptEditor, PptxExporter, PptxParser, type Presentation, type PresentationSource, type ShapeElement, type ShapeType, type Slide, type SlideElement, type TextElement };
88
+ /**
89
+ * A standalone service to convert a Presentation object into a .pptx Blob.
90
+ * Use this for background processing, S3 uploads, or other non-UI tasks.
91
+ *
92
+ * This replicates the logic from PptxExporter but returns a Blob instead of
93
+ * triggering a browser download.
94
+ */
95
+ declare class PptxBlobExporter {
96
+ /**
97
+ * Converts a Presentation object into a .pptx Blob.
98
+ * @param presentation The presentation data to export.
99
+ * @returns A Promise that resolves to a Blob containing the .pptx file.
100
+ */
101
+ exportToBlob(presentation: Presentation): Promise<Blob>;
102
+ }
103
+
104
+ export { type BaseElement, type ElementType, type ImageElement, PptEditor, PptxBlobExporter, PptxExporter, PptxParser, type Presentation, type PresentationSource, type ShapeElement, type ShapeType, type Slide, type SlideElement, type TextElement };