slidecanvas 1.1.0 → 1.1.1

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
@@ -12,6 +12,7 @@
12
12
  - **Professional Ribbon UI**: A high-density, Microsoft Office-style toolbar layout (120px height) with optimized visibility for all controls.
13
13
  - **Slash Commands (`/`)**: A fast, context-aware command menu triggered by typing `/` anywhere on the canvas or in a text box.
14
14
  - **AI-Powered Image Generation**: Integrated flow for generating design assets via optional `onGenerateImage` hook, with built-in preview and replacement logic.
15
+ - **Two-Step Infographic Generation**: Advanced workflow to refine selected slide text into visual prompts before generating infographics (via `onRefineInfographicPrompt` and `onGenerateInfographic`).
15
16
  - **AI Suggestion Box**: A side-by-side text refinement UI for reviewing Shorten/Reframe/Lengthen suggestions before applying them.
16
17
  - **Smart Actions Group**: Prominent buttons for Present, Export (PPTX), and Delete, with a subtle "Saved" status indicator.
17
18
  - **Professional Export**: High-quality `.pptx` generation with support for transparency and layout mapping.
@@ -129,7 +130,27 @@ You can integrate your own AI image provider (e.g., DALL-E, Midjourney, or a cus
129
130
  > [!TIP]
130
131
  > When an image is generated, SlideCanvas provides a professional **Preview Modal** allowing users to **Insert** as new, **Replace** a selected image (preserving dimensions), or **Discard**.
131
132
 
132
- ### 6. Enabling AI Text Refinement
133
+ ### 6. Infographic Generation (Two-Step Flow)
134
+ SlideCanvas supports a sophisticated two-step workflow for creating infographics from slide content. This is enabled via the `isTwoStepInfographicGeneration` prop.
135
+
136
+ 1. **Step 1: Refinement**: The selected text is sent to `onRefineInfographicPrompt`. The user previews and edits the AI-generated visual prompt.
137
+ 2. **Step 2: Generation**: The refined prompt is then sent to `onGenerateInfographic` to create the final asset.
138
+
139
+ ```tsx
140
+ <PptEditor
141
+ isTwoStepInfographicGeneration={true}
142
+ onRefineInfographicPrompt={async (text) => {
143
+ // Use LLM to turn slide text into a visualization prompt
144
+ return await myAiRefine(text);
145
+ }}
146
+ onGenerateInfographic={async (prompt) => {
147
+ // Generate the actual chart/infographic image
148
+ return await myImageGen(prompt);
149
+ }}
150
+ />
151
+ ```
152
+
153
+ ### 7. Enabling AI Text Refinement
133
154
  SlideCanvas comes battery-included with Gemini AI support for text.
134
155
 
135
156
  ```tsx
@@ -147,6 +168,28 @@ export default function MyEditor() {
147
168
  }
148
169
  ```
149
170
 
171
+ ### 8. Custom AI Text Refinement Hooks
172
+ While SlideCanvas includes built-in Gemini support, you can override the logic with your own AI providers (OpenAI, Anthropic, or custom internal LLMs) using the following hooks:
173
+
174
+ ```tsx
175
+ <PptEditor
176
+ onAiRewrite={async (text) => {
177
+ const res = await myAiService.call('rewrite', text);
178
+ return res.output;
179
+ }}
180
+ onAiGrammar={async (text) => {
181
+ return await myAiService.call('fix-grammar', text);
182
+ }}
183
+ onAiShorten={async (text) => {
184
+ return await myAiService.call('summarize', text);
185
+ }}
186
+ // Also supports onAiLengthen and onAiContinue
187
+ />
188
+ ```
189
+
190
+ > [!NOTE]
191
+ > When these hooks are provided, the editor will favor them over the default Gemini integration.
192
+
150
193
  ## Advanced Usage Examples
151
194
 
152
195
  ### 1. 7-Second S3 Auto-Save (Real-Time Persistence)
@@ -282,10 +325,18 @@ async function extractCaptions(fileBuffer: ArrayBuffer) {
282
325
  | `appBgColor` | `string` | `"#B7472A"` | Primary brand color for the UI. |
283
326
  | `geminiApiKey` | `string` | `undefined` | API key for built-in AI text actions. |
284
327
  | `onGenerateImage` | `(prompt: string) => Promise<string>` | `undefined` | Custom hook to handle AI image generation. |
328
+ | `isTwoStepInfographicGeneration` | `boolean` | `false` | Enables Step 1: Prompt Refinement modal for infographics. |
329
+ | `onRefineInfographicPrompt` | `(text: string) => Promise<string>` | `undefined` | Hook to transform text into a visual prompt (Step 1). |
330
+ | `onGenerateInfographic` | `(prompt: string) => Promise<string>` | `undefined` | Hook to generate the infographic image (Step 2). |
285
331
  | `proxyUrl` | `string` | `undefined` | Base path for the proxy API (used for PPTX loading and image previews). |
286
332
  | `showHomeOnEmpty` | `boolean` | `false` | Shows a "New / Upload" splash if no data provided. |
287
333
  | `onChange` | `(pres: Presentation) => void` | `undefined` | Fired on any change to the deck. |
288
334
  | `onSourceChange` | `(src, url?) => void` | `undefined` | Fired when the deck origin changes (useful for routing). |
335
+ | `onAiRewrite` | `(text: string) => Promise<string>` | `undefined` | Optional hook to override default Gemini rewrite logic. |
336
+ | `onAiGrammar` | `(text: string) => Promise<string>` | `undefined` | Optional hook to override default Gemini grammar logic. |
337
+ | `onAiShorten` | `(text: string) => Promise<string>` | `undefined` | Optional hook to override default Gemini shorten logic. |
338
+ | `onAiLengthen` | `(text: string) => Promise<string>` | `undefined` | Optional hook to override default Gemini lengthen logic. |
339
+ | `onAiContinue` | `(text: string) => Promise<string>` | `undefined` | Optional hook to override default Gemini continue-writing logic. |
289
340
 
290
341
  ### Usage Examples
291
342
 
package/dist/index.d.mts CHANGED
@@ -19,10 +19,17 @@ interface TextElement extends BaseElement {
19
19
  fontSize: number;
20
20
  fontFamily: string;
21
21
  color: string;
22
+ highlightColor?: string;
22
23
  isBold?: boolean;
23
24
  isItalic?: boolean;
24
- textAlign?: 'left' | 'center' | 'right';
25
+ isUnderline?: boolean;
26
+ isStrikethrough?: boolean;
27
+ hasShadow?: boolean;
28
+ charSpacing?: number;
29
+ listType?: string;
30
+ textAlign?: 'left' | 'center' | 'right' | 'justify';
25
31
  isBulleted?: boolean;
32
+ isNumbered?: boolean;
26
33
  }
27
34
  interface ImageElement extends BaseElement {
28
35
  type: 'image';
@@ -62,6 +69,14 @@ interface PptEditorProps {
62
69
  onSourceChange?: (source: PresentationSource, url?: string) => void;
63
70
  proxyUrl?: string;
64
71
  onGenerateImage?: (prompt: string) => Promise<string>;
72
+ onGenerateInfographic?: (prompt: string) => Promise<string>;
73
+ onAiRewrite?: (text: string) => Promise<string>;
74
+ onAiGrammar?: (text: string) => Promise<string>;
75
+ onAiShorten?: (text: string) => Promise<string>;
76
+ onAiLengthen?: (text: string) => Promise<string>;
77
+ onAiContinue?: (text: string) => Promise<string>;
78
+ isTwoStepInfographicGeneration?: boolean;
79
+ onRefineInfographicPrompt?: (text: string) => Promise<string>;
65
80
  }
66
81
  declare const PptEditor: React.FC<PptEditorProps>;
67
82
 
package/dist/index.d.ts CHANGED
@@ -19,10 +19,17 @@ interface TextElement extends BaseElement {
19
19
  fontSize: number;
20
20
  fontFamily: string;
21
21
  color: string;
22
+ highlightColor?: string;
22
23
  isBold?: boolean;
23
24
  isItalic?: boolean;
24
- textAlign?: 'left' | 'center' | 'right';
25
+ isUnderline?: boolean;
26
+ isStrikethrough?: boolean;
27
+ hasShadow?: boolean;
28
+ charSpacing?: number;
29
+ listType?: string;
30
+ textAlign?: 'left' | 'center' | 'right' | 'justify';
25
31
  isBulleted?: boolean;
32
+ isNumbered?: boolean;
26
33
  }
27
34
  interface ImageElement extends BaseElement {
28
35
  type: 'image';
@@ -62,6 +69,14 @@ interface PptEditorProps {
62
69
  onSourceChange?: (source: PresentationSource, url?: string) => void;
63
70
  proxyUrl?: string;
64
71
  onGenerateImage?: (prompt: string) => Promise<string>;
72
+ onGenerateInfographic?: (prompt: string) => Promise<string>;
73
+ onAiRewrite?: (text: string) => Promise<string>;
74
+ onAiGrammar?: (text: string) => Promise<string>;
75
+ onAiShorten?: (text: string) => Promise<string>;
76
+ onAiLengthen?: (text: string) => Promise<string>;
77
+ onAiContinue?: (text: string) => Promise<string>;
78
+ isTwoStepInfographicGeneration?: boolean;
79
+ onRefineInfographicPrompt?: (text: string) => Promise<string>;
65
80
  }
66
81
  declare const PptEditor: React.FC<PptEditorProps>;
67
82