slidecanvas 1.0.8 → 1.0.9
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 +16 -12
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
|
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,
|
|
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.
|
|
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
|
|
173
|
-
const blob = await exporter.
|
|
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` & `
|
|
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(
|
|
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
|
---
|