@imagecanvaskit/embed 1.0.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 +229 -0
- package/dist/index.cjs +338 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +333 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +186 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +31 -0
- package/dist/react.d.ts +31 -0
- package/dist/react.js +184 -0
- package/dist/react.js.map +1 -0
- package/dist/types-C7ZIsAaA.d.cts +215 -0
- package/dist/types-C7ZIsAaA.d.ts +215 -0
- package/dist/vanilla.cjs +155 -0
- package/dist/vanilla.cjs.map +1 -0
- package/dist/vanilla.d.cts +54 -0
- package/dist/vanilla.d.ts +54 -0
- package/dist/vanilla.js +151 -0
- package/dist/vanilla.js.map +1 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# @imagecanvaskit/embed
|
|
2
|
+
|
|
3
|
+
Embed the ImageCanvasKit image editor in your application with ease.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# npm
|
|
9
|
+
npm install @imagecanvaskit/embed
|
|
10
|
+
|
|
11
|
+
# yarn
|
|
12
|
+
yarn add @imagecanvaskit/embed
|
|
13
|
+
|
|
14
|
+
# pnpm
|
|
15
|
+
pnpm add @imagecanvaskit/embed
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## CDN Usage
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<script type="module">
|
|
22
|
+
import { createEditor } from 'https://unpkg.com/@imagecanvaskit/embed@latest';
|
|
23
|
+
|
|
24
|
+
const editor = createEditor({
|
|
25
|
+
container: '#editor',
|
|
26
|
+
apiKey: 'your-api-key',
|
|
27
|
+
});
|
|
28
|
+
</script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## React Usage
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { useRef } from 'react';
|
|
35
|
+
import { ImageCanvasKit, ImageCanvasKitInstance } from '@imagecanvaskit/embed';
|
|
36
|
+
|
|
37
|
+
function App() {
|
|
38
|
+
const editorRef = useRef<ImageCanvasKitInstance>(null);
|
|
39
|
+
|
|
40
|
+
const handleExport = () => {
|
|
41
|
+
editorRef.current?.export({ format: 'png' });
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div>
|
|
46
|
+
<button onClick={handleExport}>Export</button>
|
|
47
|
+
<ImageCanvasKit
|
|
48
|
+
ref={editorRef}
|
|
49
|
+
apiKey="your-api-key"
|
|
50
|
+
width={1200}
|
|
51
|
+
height={800}
|
|
52
|
+
theme="dark"
|
|
53
|
+
onExport={(e) => {
|
|
54
|
+
console.log('Exported image:', e.data);
|
|
55
|
+
// e.data.imageData contains base64 image
|
|
56
|
+
}}
|
|
57
|
+
onReady={() => console.log('Editor is ready!')}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Next.js App Router
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
'use client';
|
|
68
|
+
|
|
69
|
+
import dynamic from 'next/dynamic';
|
|
70
|
+
|
|
71
|
+
const ImageCanvasKit = dynamic(
|
|
72
|
+
() => import('@imagecanvaskit/embed').then((mod) => mod.ImageCanvasKit),
|
|
73
|
+
{ ssr: false }
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
export default function EditorPage() {
|
|
77
|
+
return (
|
|
78
|
+
<ImageCanvasKit
|
|
79
|
+
apiKey="your-api-key"
|
|
80
|
+
onExport={(e) => console.log(e.data)}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Vanilla JavaScript
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
import { createEditor, downloadImage } from '@imagecanvaskit/embed';
|
|
90
|
+
|
|
91
|
+
const editor = createEditor({
|
|
92
|
+
container: '#editor-container',
|
|
93
|
+
apiKey: 'your-api-key',
|
|
94
|
+
width: '100%',
|
|
95
|
+
height: '600px',
|
|
96
|
+
theme: 'light',
|
|
97
|
+
onExport: (e) => {
|
|
98
|
+
// Download the image
|
|
99
|
+
downloadImage(e.data.imageData, 'design.png', 'image/png');
|
|
100
|
+
},
|
|
101
|
+
onReady: () => {
|
|
102
|
+
console.log('Editor ready!');
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Programmatic control
|
|
107
|
+
document.getElementById('export-btn').addEventListener('click', () => {
|
|
108
|
+
editor.export({ format: 'png', quality: 0.9 });
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Add text programmatically
|
|
112
|
+
editor.addText({
|
|
113
|
+
text: 'Hello World',
|
|
114
|
+
fontSize: 48,
|
|
115
|
+
color: '#000000',
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Cleanup when done
|
|
119
|
+
editor.destroy();
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Vue.js
|
|
123
|
+
|
|
124
|
+
```vue
|
|
125
|
+
<template>
|
|
126
|
+
<div ref="editorContainer"></div>
|
|
127
|
+
</template>
|
|
128
|
+
|
|
129
|
+
<script setup>
|
|
130
|
+
import { ref, onMounted, onUnmounted } from 'vue';
|
|
131
|
+
import { createEditor } from '@imagecanvaskit/embed';
|
|
132
|
+
|
|
133
|
+
const editorContainer = ref(null);
|
|
134
|
+
let editor = null;
|
|
135
|
+
|
|
136
|
+
onMounted(() => {
|
|
137
|
+
editor = createEditor({
|
|
138
|
+
container: editorContainer.value,
|
|
139
|
+
apiKey: 'your-api-key',
|
|
140
|
+
onExport: (e) => console.log(e.data),
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
onUnmounted(() => {
|
|
145
|
+
editor?.destroy();
|
|
146
|
+
});
|
|
147
|
+
</script>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Configuration Options
|
|
151
|
+
|
|
152
|
+
| Option | Type | Description |
|
|
153
|
+
| ---------------- | ----------------------------- | ---------------------------------------- |
|
|
154
|
+
| `apiKey` | `string` | Your API key from the dashboard |
|
|
155
|
+
| `baseUrl` | `string` | Custom editor URL (for self-hosted) |
|
|
156
|
+
| `width` | `number` | Canvas width in pixels |
|
|
157
|
+
| `height` | `number` | Canvas height in pixels |
|
|
158
|
+
| `backgroundColor`| `string` | Background color (hex) or 'transparent' |
|
|
159
|
+
| `theme` | `'light' \| 'dark' \| 'system'` | Editor theme |
|
|
160
|
+
| `hideToolbar` | `boolean` | Hide the toolbar |
|
|
161
|
+
| `hideSidebar` | `boolean` | Hide the sidebar |
|
|
162
|
+
| `hideExport` | `boolean` | Hide export button |
|
|
163
|
+
| `templateId` | `string` | Template ID to load |
|
|
164
|
+
| `projectData` | `string` | Project JSON to load |
|
|
165
|
+
| `endUserId` | `string` | End user ID for multi-tenant tracking |
|
|
166
|
+
| `exportFormats` | `string[]` | Allowed export formats |
|
|
167
|
+
| `whiteLabel` | `object` | White-label configuration |
|
|
168
|
+
|
|
169
|
+
## Event Callbacks
|
|
170
|
+
|
|
171
|
+
| Callback | Data | Description |
|
|
172
|
+
| ------------------ | ----------------------------- | ---------------------------------------- |
|
|
173
|
+
| `onReady` | `{ version, canvasWidth, canvasHeight }` | Editor is loaded and ready |
|
|
174
|
+
| `onExport` | `{ imageData, format, width, height }` | Image export completed |
|
|
175
|
+
| `onSave` | `{ projectData, projectId }` | Project saved |
|
|
176
|
+
| `onLoad` | `{ success, projectId }` | Project/template loaded |
|
|
177
|
+
| `onError` | `{ code, message }` | Error occurred |
|
|
178
|
+
| `onObjectSelected` | `{ objectId, objectType }` | Object selected on canvas |
|
|
179
|
+
| `onCanvasModified` | `{ action, objectId }` | Canvas was modified |
|
|
180
|
+
|
|
181
|
+
## Instance Methods
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
interface ImageCanvasKitInstance {
|
|
185
|
+
export(options?: { format?: string; quality?: number }): void;
|
|
186
|
+
save(): void;
|
|
187
|
+
load(options: { projectData?: string; templateId?: string }): void;
|
|
188
|
+
clear(): void;
|
|
189
|
+
undo(): void;
|
|
190
|
+
redo(): void;
|
|
191
|
+
addText(options: { text: string; fontSize?: number; color?: string }): void;
|
|
192
|
+
addImage(options: { url: string; width?: number; height?: number }): void;
|
|
193
|
+
addShape(options: { shape: string; fill?: string }): void;
|
|
194
|
+
setBackground(options: { color?: string; imageUrl?: string }): void;
|
|
195
|
+
resize(width: number, height: number): void;
|
|
196
|
+
destroy(): void;
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## White-Label Configuration
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
<ImageCanvasKit
|
|
204
|
+
apiKey="your-api-key"
|
|
205
|
+
whiteLabel={{
|
|
206
|
+
logo: 'https://yoursite.com/logo.png',
|
|
207
|
+
primaryColor: '#FF5733',
|
|
208
|
+
companyName: 'Your Company',
|
|
209
|
+
hideBranding: true,
|
|
210
|
+
}}
|
|
211
|
+
/>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## TypeScript Support
|
|
215
|
+
|
|
216
|
+
Full TypeScript support with exported types:
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
import type {
|
|
220
|
+
ImageCanvasKitConfig,
|
|
221
|
+
ImageCanvasKitInstance,
|
|
222
|
+
ExportEventData,
|
|
223
|
+
SaveEventData,
|
|
224
|
+
} from '@imagecanvaskit/embed';
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## License
|
|
228
|
+
|
|
229
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
// src/react.tsx
|
|
7
|
+
var DEFAULT_BASE_URL = "https://imagecanvaskit.com";
|
|
8
|
+
function buildEditorUrl(config) {
|
|
9
|
+
const baseUrl = config.baseUrl || DEFAULT_BASE_URL;
|
|
10
|
+
const params = new URLSearchParams();
|
|
11
|
+
params.set("embed", "true");
|
|
12
|
+
if (config.apiKey) params.set("apiKey", config.apiKey);
|
|
13
|
+
if (config.width) params.set("width", String(config.width));
|
|
14
|
+
if (config.height) params.set("height", String(config.height));
|
|
15
|
+
if (config.backgroundColor) params.set("bg", config.backgroundColor);
|
|
16
|
+
if (config.theme) params.set("theme", config.theme);
|
|
17
|
+
if (config.hideToolbar) params.set("hideToolbar", "true");
|
|
18
|
+
if (config.hideSidebar) params.set("hideSidebar", "true");
|
|
19
|
+
if (config.hideExport) params.set("hideExport", "true");
|
|
20
|
+
if (config.templateId) params.set("templateId", config.templateId);
|
|
21
|
+
if (config.endUserId) params.set("endUserId", config.endUserId);
|
|
22
|
+
if (config.exportFormats) params.set("formats", config.exportFormats.join(","));
|
|
23
|
+
if (config.whiteLabel) {
|
|
24
|
+
if (config.whiteLabel.logo) params.set("logo", config.whiteLabel.logo);
|
|
25
|
+
if (config.whiteLabel.primaryColor) params.set("primaryColor", config.whiteLabel.primaryColor);
|
|
26
|
+
if (config.whiteLabel.companyName) params.set("companyName", config.whiteLabel.companyName);
|
|
27
|
+
if (config.whiteLabel.hideBranding) params.set("hideBranding", "true");
|
|
28
|
+
}
|
|
29
|
+
return `${baseUrl}/editor?${params.toString()}`;
|
|
30
|
+
}
|
|
31
|
+
var ImageCanvasKit = react.forwardRef(
|
|
32
|
+
function ImageCanvasKit2(props, ref) {
|
|
33
|
+
const {
|
|
34
|
+
// Config
|
|
35
|
+
apiKey,
|
|
36
|
+
baseUrl,
|
|
37
|
+
width,
|
|
38
|
+
height,
|
|
39
|
+
backgroundColor,
|
|
40
|
+
theme,
|
|
41
|
+
hideToolbar,
|
|
42
|
+
hideSidebar,
|
|
43
|
+
hideExport,
|
|
44
|
+
templateId,
|
|
45
|
+
projectData,
|
|
46
|
+
endUserId,
|
|
47
|
+
exportFormats,
|
|
48
|
+
fonts,
|
|
49
|
+
whiteLabel,
|
|
50
|
+
// Callbacks
|
|
51
|
+
onReady,
|
|
52
|
+
onExport,
|
|
53
|
+
onSave,
|
|
54
|
+
onLoad,
|
|
55
|
+
onError,
|
|
56
|
+
onResize,
|
|
57
|
+
onObjectSelected,
|
|
58
|
+
onObjectDeselected,
|
|
59
|
+
onCanvasModified,
|
|
60
|
+
// Container props
|
|
61
|
+
className,
|
|
62
|
+
style,
|
|
63
|
+
iframeWidth = "100%",
|
|
64
|
+
iframeHeight = "600px"
|
|
65
|
+
} = props;
|
|
66
|
+
const iframeRef = react.useRef(null);
|
|
67
|
+
const config = {
|
|
68
|
+
apiKey,
|
|
69
|
+
baseUrl,
|
|
70
|
+
width,
|
|
71
|
+
height,
|
|
72
|
+
backgroundColor,
|
|
73
|
+
theme,
|
|
74
|
+
hideToolbar,
|
|
75
|
+
hideSidebar,
|
|
76
|
+
hideExport,
|
|
77
|
+
templateId,
|
|
78
|
+
endUserId,
|
|
79
|
+
exportFormats,
|
|
80
|
+
whiteLabel
|
|
81
|
+
};
|
|
82
|
+
const editorUrl = buildEditorUrl(config);
|
|
83
|
+
const sendCommand = react.useCallback((payload) => {
|
|
84
|
+
if (iframeRef.current?.contentWindow) {
|
|
85
|
+
iframeRef.current.contentWindow.postMessage(
|
|
86
|
+
{ source: "imagecanvaskit-embed", ...payload },
|
|
87
|
+
"*"
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}, []);
|
|
91
|
+
react.useEffect(() => {
|
|
92
|
+
const handleMessage = (event) => {
|
|
93
|
+
if (baseUrl && !event.origin.includes(new URL(baseUrl).hostname)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const data = event.data;
|
|
97
|
+
if (!data || typeof data !== "object" || !data.type) return;
|
|
98
|
+
switch (data.type) {
|
|
99
|
+
case "ready":
|
|
100
|
+
onReady?.(data);
|
|
101
|
+
if (projectData) {
|
|
102
|
+
sendCommand({ command: "load", projectData });
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
case "export":
|
|
106
|
+
onExport?.(data);
|
|
107
|
+
break;
|
|
108
|
+
case "save":
|
|
109
|
+
onSave?.(data);
|
|
110
|
+
break;
|
|
111
|
+
case "load":
|
|
112
|
+
onLoad?.(data);
|
|
113
|
+
break;
|
|
114
|
+
case "error":
|
|
115
|
+
onError?.(data);
|
|
116
|
+
break;
|
|
117
|
+
case "resize":
|
|
118
|
+
onResize?.(data);
|
|
119
|
+
break;
|
|
120
|
+
case "objectSelected":
|
|
121
|
+
onObjectSelected?.(data);
|
|
122
|
+
break;
|
|
123
|
+
case "objectDeselected":
|
|
124
|
+
onObjectDeselected?.(data);
|
|
125
|
+
break;
|
|
126
|
+
case "canvasModified":
|
|
127
|
+
onCanvasModified?.(data);
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
window.addEventListener("message", handleMessage);
|
|
132
|
+
return () => window.removeEventListener("message", handleMessage);
|
|
133
|
+
}, [
|
|
134
|
+
baseUrl,
|
|
135
|
+
projectData,
|
|
136
|
+
onReady,
|
|
137
|
+
onExport,
|
|
138
|
+
onSave,
|
|
139
|
+
onLoad,
|
|
140
|
+
onError,
|
|
141
|
+
onResize,
|
|
142
|
+
onObjectSelected,
|
|
143
|
+
onObjectDeselected,
|
|
144
|
+
onCanvasModified,
|
|
145
|
+
sendCommand
|
|
146
|
+
]);
|
|
147
|
+
react.useImperativeHandle(
|
|
148
|
+
ref,
|
|
149
|
+
() => ({
|
|
150
|
+
sendCommand,
|
|
151
|
+
export: (options) => sendCommand({ command: "export", ...options }),
|
|
152
|
+
save: () => sendCommand({ command: "save" }),
|
|
153
|
+
load: (options) => sendCommand({ command: "load", ...options }),
|
|
154
|
+
clear: () => sendCommand({ command: "clear" }),
|
|
155
|
+
undo: () => sendCommand({ command: "undo" }),
|
|
156
|
+
redo: () => sendCommand({ command: "redo" }),
|
|
157
|
+
addText: (options) => sendCommand({ command: "addText", ...options }),
|
|
158
|
+
addImage: (options) => sendCommand({ command: "addImage", ...options }),
|
|
159
|
+
addShape: (options) => sendCommand({ command: "addShape", ...options }),
|
|
160
|
+
setBackground: (options) => sendCommand({ command: "setBackground", ...options }),
|
|
161
|
+
resize: (w, h) => sendCommand({ command: "resize", width: w, height: h }),
|
|
162
|
+
destroy: () => {
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
[sendCommand]
|
|
166
|
+
);
|
|
167
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
168
|
+
"iframe",
|
|
169
|
+
{
|
|
170
|
+
ref: iframeRef,
|
|
171
|
+
src: editorUrl,
|
|
172
|
+
width: iframeWidth,
|
|
173
|
+
height: iframeHeight,
|
|
174
|
+
style: {
|
|
175
|
+
border: "none",
|
|
176
|
+
display: "block"
|
|
177
|
+
},
|
|
178
|
+
allow: "clipboard-read; clipboard-write",
|
|
179
|
+
title: "ImageCanvasKit Editor"
|
|
180
|
+
}
|
|
181
|
+
) });
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
// src/vanilla.ts
|
|
186
|
+
var DEFAULT_BASE_URL2 = "https://imagecanvaskit.com";
|
|
187
|
+
function buildEditorUrl2(config) {
|
|
188
|
+
const baseUrl = config.baseUrl || DEFAULT_BASE_URL2;
|
|
189
|
+
const params = new URLSearchParams();
|
|
190
|
+
params.set("embed", "true");
|
|
191
|
+
if (config.apiKey) params.set("apiKey", config.apiKey);
|
|
192
|
+
if (config.width) params.set("width", String(config.width));
|
|
193
|
+
if (config.height) params.set("height", String(config.height));
|
|
194
|
+
if (config.backgroundColor) params.set("bg", config.backgroundColor);
|
|
195
|
+
if (config.theme) params.set("theme", config.theme);
|
|
196
|
+
if (config.hideToolbar) params.set("hideToolbar", "true");
|
|
197
|
+
if (config.hideSidebar) params.set("hideSidebar", "true");
|
|
198
|
+
if (config.hideExport) params.set("hideExport", "true");
|
|
199
|
+
if (config.templateId) params.set("templateId", config.templateId);
|
|
200
|
+
if (config.endUserId) params.set("endUserId", config.endUserId);
|
|
201
|
+
if (config.exportFormats) params.set("formats", config.exportFormats.join(","));
|
|
202
|
+
if (config.whiteLabel) {
|
|
203
|
+
if (config.whiteLabel.logo) params.set("logo", config.whiteLabel.logo);
|
|
204
|
+
if (config.whiteLabel.primaryColor) params.set("primaryColor", config.whiteLabel.primaryColor);
|
|
205
|
+
if (config.whiteLabel.companyName) params.set("companyName", config.whiteLabel.companyName);
|
|
206
|
+
if (config.whiteLabel.hideBranding) params.set("hideBranding", "true");
|
|
207
|
+
}
|
|
208
|
+
return `${baseUrl}/editor?${params.toString()}`;
|
|
209
|
+
}
|
|
210
|
+
function createEditor(options) {
|
|
211
|
+
const {
|
|
212
|
+
container,
|
|
213
|
+
width = "100%",
|
|
214
|
+
height = "600px",
|
|
215
|
+
canvasWidth,
|
|
216
|
+
canvasHeight,
|
|
217
|
+
onReady,
|
|
218
|
+
onExport,
|
|
219
|
+
onSave,
|
|
220
|
+
onLoad,
|
|
221
|
+
onError,
|
|
222
|
+
onResize,
|
|
223
|
+
onObjectSelected,
|
|
224
|
+
onObjectDeselected,
|
|
225
|
+
onCanvasModified,
|
|
226
|
+
projectData,
|
|
227
|
+
...config
|
|
228
|
+
} = options;
|
|
229
|
+
const editorConfig = {
|
|
230
|
+
...config,
|
|
231
|
+
width: canvasWidth,
|
|
232
|
+
height: canvasHeight
|
|
233
|
+
};
|
|
234
|
+
const containerEl = typeof container === "string" ? document.querySelector(container) : container;
|
|
235
|
+
if (!containerEl) {
|
|
236
|
+
throw new Error(`ImageCanvasKit: Container element not found: ${container}`);
|
|
237
|
+
}
|
|
238
|
+
const iframe = document.createElement("iframe");
|
|
239
|
+
iframe.src = buildEditorUrl2(editorConfig);
|
|
240
|
+
iframe.style.border = "none";
|
|
241
|
+
iframe.style.display = "block";
|
|
242
|
+
iframe.style.width = typeof width === "number" ? `${width}px` : width;
|
|
243
|
+
iframe.style.height = typeof height === "number" ? `${height}px` : height;
|
|
244
|
+
iframe.allow = "clipboard-read; clipboard-write";
|
|
245
|
+
iframe.title = "ImageCanvasKit Editor";
|
|
246
|
+
const sendCommand = (payload) => {
|
|
247
|
+
if (iframe.contentWindow) {
|
|
248
|
+
iframe.contentWindow.postMessage({ source: "imagecanvaskit-embed", ...payload }, "*");
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const handleMessage = (event) => {
|
|
252
|
+
if (config.baseUrl && !event.origin.includes(new URL(config.baseUrl).hostname)) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const data = event.data;
|
|
256
|
+
if (!data || typeof data !== "object" || !data.type) return;
|
|
257
|
+
switch (data.type) {
|
|
258
|
+
case "ready":
|
|
259
|
+
onReady?.(data);
|
|
260
|
+
if (projectData) {
|
|
261
|
+
sendCommand({ command: "load", projectData });
|
|
262
|
+
}
|
|
263
|
+
break;
|
|
264
|
+
case "export":
|
|
265
|
+
onExport?.(data);
|
|
266
|
+
break;
|
|
267
|
+
case "save":
|
|
268
|
+
onSave?.(data);
|
|
269
|
+
break;
|
|
270
|
+
case "load":
|
|
271
|
+
onLoad?.(data);
|
|
272
|
+
break;
|
|
273
|
+
case "error":
|
|
274
|
+
onError?.(data);
|
|
275
|
+
break;
|
|
276
|
+
case "resize":
|
|
277
|
+
onResize?.(data);
|
|
278
|
+
break;
|
|
279
|
+
case "objectSelected":
|
|
280
|
+
onObjectSelected?.(data);
|
|
281
|
+
break;
|
|
282
|
+
case "objectDeselected":
|
|
283
|
+
onObjectDeselected?.(data);
|
|
284
|
+
break;
|
|
285
|
+
case "canvasModified":
|
|
286
|
+
onCanvasModified?.(data);
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
window.addEventListener("message", handleMessage);
|
|
291
|
+
containerEl.appendChild(iframe);
|
|
292
|
+
const instance = {
|
|
293
|
+
sendCommand,
|
|
294
|
+
export: (opts) => sendCommand({ command: "export", ...opts }),
|
|
295
|
+
save: () => sendCommand({ command: "save" }),
|
|
296
|
+
load: (opts) => sendCommand({ command: "load", ...opts }),
|
|
297
|
+
clear: () => sendCommand({ command: "clear" }),
|
|
298
|
+
undo: () => sendCommand({ command: "undo" }),
|
|
299
|
+
redo: () => sendCommand({ command: "redo" }),
|
|
300
|
+
addText: (opts) => sendCommand({ command: "addText", ...opts }),
|
|
301
|
+
addImage: (opts) => sendCommand({ command: "addImage", ...opts }),
|
|
302
|
+
addShape: (opts) => sendCommand({ command: "addShape", ...opts }),
|
|
303
|
+
setBackground: (opts) => sendCommand({ command: "setBackground", ...opts }),
|
|
304
|
+
resize: (w, h) => sendCommand({ command: "resize", width: w, height: h }),
|
|
305
|
+
destroy: () => {
|
|
306
|
+
window.removeEventListener("message", handleMessage);
|
|
307
|
+
iframe.remove();
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
return instance;
|
|
311
|
+
}
|
|
312
|
+
function base64ToBlob(base64, mimeType) {
|
|
313
|
+
const byteCharacters = atob(base64.split(",")[1] || base64);
|
|
314
|
+
const byteNumbers = new Array(byteCharacters.length);
|
|
315
|
+
for (let i = 0; i < byteCharacters.length; i++) {
|
|
316
|
+
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
317
|
+
}
|
|
318
|
+
const byteArray = new Uint8Array(byteNumbers);
|
|
319
|
+
return new Blob([byteArray], { type: mimeType });
|
|
320
|
+
}
|
|
321
|
+
function downloadImage(imageData, filename, mimeType) {
|
|
322
|
+
const blob = base64ToBlob(imageData, mimeType);
|
|
323
|
+
const url = URL.createObjectURL(blob);
|
|
324
|
+
const a = document.createElement("a");
|
|
325
|
+
a.href = url;
|
|
326
|
+
a.download = filename;
|
|
327
|
+
document.body.appendChild(a);
|
|
328
|
+
a.click();
|
|
329
|
+
document.body.removeChild(a);
|
|
330
|
+
URL.revokeObjectURL(url);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
exports.ImageCanvasKit = ImageCanvasKit;
|
|
334
|
+
exports.base64ToBlob = base64ToBlob;
|
|
335
|
+
exports.createEditor = createEditor;
|
|
336
|
+
exports.downloadImage = downloadImage;
|
|
337
|
+
//# sourceMappingURL=index.cjs.map
|
|
338
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.tsx","../src/vanilla.ts"],"names":["forwardRef","ImageCanvasKit","useRef","useCallback","useEffect","useImperativeHandle","jsx","DEFAULT_BASE_URL","buildEditorUrl"],"mappings":";;;;;;AAyBA,IAAM,gBAAA,GAAmB,4BAAA;AAKzB,SAAS,eAAe,MAAA,EAAsC;AAC5D,EAAA,MAAM,OAAA,GAAU,OAAO,OAAA,IAAW,gBAAA;AAClC,EAAA,MAAM,MAAA,GAAS,IAAI,eAAA,EAAgB;AAEnC,EAAA,MAAA,CAAO,GAAA,CAAI,SAAS,MAAM,CAAA;AAE1B,EAAA,IAAI,OAAO,MAAA,EAAQ,MAAA,CAAO,GAAA,CAAI,QAAA,EAAU,OAAO,MAAM,CAAA;AACrD,EAAA,IAAI,MAAA,CAAO,OAAO,MAAA,CAAO,GAAA,CAAI,SAAS,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA;AAC1D,EAAA,IAAI,MAAA,CAAO,QAAQ,MAAA,CAAO,GAAA,CAAI,UAAU,MAAA,CAAO,MAAA,CAAO,MAAM,CAAC,CAAA;AAC7D,EAAA,IAAI,OAAO,eAAA,EAAiB,MAAA,CAAO,GAAA,CAAI,IAAA,EAAM,OAAO,eAAe,CAAA;AACnE,EAAA,IAAI,OAAO,KAAA,EAAO,MAAA,CAAO,GAAA,CAAI,OAAA,EAAS,OAAO,KAAK,CAAA;AAClD,EAAA,IAAI,MAAA,C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CAAc,GAAG,CAAA;AACpC,EAAA,CAAA,CAAE,IAAA,GAAO,GAAA;AACT,EAAA,CAAA,CAAE,QAAA,GAAW,QAAA;AACb,EAAA,QAAA,CAAS,IAAA,CAAK,YAAY,CAAC,CAAA;AAC3B,EAAA,CAAA,CAAE,KAAA,EAAM;AACR,EAAA,QAAA,CAAS,IAAA,CAAK,YAAY,CAAC,CAAA;AAC3B,EAAA,GAAA,CAAI,gBAAgB,GAAG,CAAA;AACzB","file":"index.cjs","sourcesContent":["'use client';\n\nimport {\n useRef,\n useEffect,\n useImperativeHandle,\n forwardRef,\n useCallback,\n} from 'react';\nimport type {\n ImageCanvasKitProps,\n ImageCanvasKitInstance,\n ImageCanvasKitConfig,\n CommandPayload,\n ImageCanvasKitEvent,\n ExportEventData,\n SaveEventData,\n LoadEventData,\n ErrorEventData,\n ReadyEventData,\n ResizeEventData,\n ObjectSelectedEventData,\n CanvasModifiedEventData,\n} from './types';\n\nconst DEFAULT_BASE_URL = 'https://imagecanvaskit.com';\n\n/**\n * Build the editor URL with configuration parameters\n */\nfunction buildEditorUrl(config: ImageCanvasKitConfig): string {\n const baseUrl = config.baseUrl || DEFAULT_BASE_URL;\n const params = new URLSearchParams();\n\n params.set('embed', 'true');\n\n if (config.apiKey) params.set('apiKey', config.apiKey);\n if (config.width) params.set('width', String(config.width));\n if (config.height) params.set('height', String(config.height));\n if (config.backgroundColor) params.set('bg', config.backgroundColor);\n if (config.theme) params.set('theme', config.theme);\n if (config.hideToolbar) params.set('hideToolbar', 'true');\n if (config.hideSidebar) params.set('hideSidebar', 'true');\n if (config.hideExport) params.set('hideExport', 'true');\n if (config.templateId) params.set('templateId', config.templateId);\n if (config.endUserId) params.set('endUserId', config.endUserId);\n if (config.exportFormats) params.set('formats', config.exportFormats.join(','));\n\n // White-label settings\n if (config.whiteLabel) {\n if (config.whiteLabel.logo) params.set('logo', config.whiteLabel.logo);\n if (config.whiteLabel.primaryColor) params.set('primaryColor', config.whiteLabel.primaryColor);\n if (config.whiteLabel.companyName) params.set('companyName', config.whiteLabel.companyName);\n if (config.whiteLabel.hideBranding) params.set('hideBranding', 'true');\n }\n\n return `${baseUrl}/editor?${params.toString()}`;\n}\n\n/**\n * ImageCanvasKit React Component\n *\n * Embeds the ImageCanvasKit editor in your React application.\n *\n * @example\n * ```tsx\n * import { ImageCanvasKit } from '@imagecanvaskit/embed';\n *\n * function App() {\n * const editorRef = useRef<ImageCanvasKitInstance>(null);\n *\n * return (\n * <ImageCanvasKit\n * ref={editorRef}\n * apiKey=\"your-api-key\"\n * width={1200}\n * height={800}\n * onExport={(e) => console.log('Exported:', e.data)}\n * onReady={() => console.log('Editor ready!')}\n * />\n * );\n * }\n * ```\n */\nexport const ImageCanvasKit = forwardRef<ImageCanvasKitInstance, ImageCanvasKitProps>(\n function ImageCanvasKit(props, ref) {\n const {\n // Config\n apiKey,\n baseUrl,\n width,\n height,\n backgroundColor,\n theme,\n hideToolbar,\n hideSidebar,\n hideExport,\n templateId,\n projectData,\n endUserId,\n exportFormats,\n fonts,\n whiteLabel,\n // Callbacks\n onReady,\n onExport,\n onSave,\n onLoad,\n onError,\n onResize,\n onObjectSelected,\n onObjectDeselected,\n onCanvasModified,\n // Container props\n className,\n style,\n iframeWidth = '100%',\n iframeHeight = '600px',\n } = props;\n\n const iframeRef = useRef<HTMLIFrameElement>(null);\n\n // Build config object\n const config: ImageCanvasKitConfig = {\n apiKey,\n baseUrl,\n width,\n height,\n backgroundColor,\n theme,\n hideToolbar,\n hideSidebar,\n hideExport,\n templateId,\n projectData,\n endUserId,\n exportFormats,\n fonts,\n whiteLabel,\n };\n\n const editorUrl = buildEditorUrl(config);\n\n // Send command to iframe\n const sendCommand = useCallback((payload: CommandPayload) => {\n if (iframeRef.current?.contentWindow) {\n iframeRef.current.contentWindow.postMessage(\n { source: 'imagecanvaskit-embed', ...payload },\n '*'\n );\n }\n }, []);\n\n // Handle incoming messages from iframe\n useEffect(() => {\n const handleMessage = (event: MessageEvent) => {\n // Verify origin in production\n if (baseUrl && !event.origin.includes(new URL(baseUrl).hostname)) {\n return;\n }\n\n const data = event.data as ImageCanvasKitEvent;\n if (!data || typeof data !== 'object' || !data.type) return;\n\n switch (data.type) {\n case 'ready':\n onReady?.(data as ImageCanvasKitEvent<ReadyEventData>);\n // Load project data if provided\n if (projectData) {\n sendCommand({ command: 'load', projectData });\n }\n break;\n case 'export':\n onExport?.(data as ImageCanvasKitEvent<ExportEventData>);\n break;\n case 'save':\n onSave?.(data as ImageCanvasKitEvent<SaveEventData>);\n break;\n case 'load':\n onLoad?.(data as ImageCanvasKitEvent<LoadEventData>);\n break;\n case 'error':\n onError?.(data as ImageCanvasKitEvent<ErrorEventData>);\n break;\n case 'resize':\n onResize?.(data as ImageCanvasKitEvent<ResizeEventData>);\n break;\n case 'objectSelected':\n onObjectSelected?.(data as ImageCanvasKitEvent<ObjectSelectedEventData>);\n break;\n case 'objectDeselected':\n onObjectDeselected?.(data as ImageCanvasKitEvent<void>);\n break;\n case 'canvasModified':\n onCanvasModified?.(data as ImageCanvasKitEvent<CanvasModifiedEventData>);\n break;\n }\n };\n\n window.addEventListener('message', handleMessage);\n return () => window.removeEventListener('message', handleMessage);\n }, [\n baseUrl,\n projectData,\n onReady,\n onExport,\n onSave,\n onLoad,\n onError,\n onResize,\n onObjectSelected,\n onObjectDeselected,\n onCanvasModified,\n sendCommand,\n ]);\n\n // Expose instance methods via ref\n useImperativeHandle(\n ref,\n () => ({\n sendCommand,\n export: (options) => sendCommand({ command: 'export', ...options }),\n save: () => sendCommand({ command: 'save' }),\n load: (options) => sendCommand({ command: 'load', ...options }),\n clear: () => sendCommand({ command: 'clear' }),\n undo: () => sendCommand({ command: 'undo' }),\n redo: () => sendCommand({ command: 'redo' }),\n addText: (options) => sendCommand({ command: 'addText', ...options }),\n addImage: (options) => sendCommand({ command: 'addImage', ...options }),\n addShape: (options) => sendCommand({ command: 'addShape', ...options }),\n setBackground: (options) => sendCommand({ command: 'setBackground', ...options }),\n resize: (w, h) => sendCommand({ command: 'resize', width: w, height: h }),\n destroy: () => {\n // Cleanup if needed\n },\n }),\n [sendCommand]\n );\n\n return (\n <div className={className} style={style}>\n <iframe\n ref={iframeRef}\n src={editorUrl}\n width={iframeWidth}\n height={iframeHeight}\n style={{\n border: 'none',\n display: 'block',\n }}\n allow=\"clipboard-read; clipboard-write\"\n title=\"ImageCanvasKit Editor\"\n />\n </div>\n );\n }\n);\n\n","/**\n * ImageCanvasKit Vanilla JS Embed\n *\n * For use in vanilla JavaScript, Vue, Angular, or any framework.\n */\n\nimport type {\n ImageCanvasKitConfig,\n ImageCanvasKitInstance,\n CommandPayload,\n EventCallbacks,\n ImageCanvasKitEvent,\n ExportEventData,\n SaveEventData,\n LoadEventData,\n ErrorEventData,\n ReadyEventData,\n ResizeEventData,\n ObjectSelectedEventData,\n CanvasModifiedEventData,\n} from './types';\n\nconst DEFAULT_BASE_URL = 'https://imagecanvaskit.com';\n\nexport interface CreateEditorOptions extends Omit<ImageCanvasKitConfig, 'width' | 'height'>, EventCallbacks {\n /** Container element or selector */\n container: HTMLElement | string;\n /** Canvas width in pixels (passed to editor) */\n canvasWidth?: number;\n /** Canvas height in pixels (passed to editor) */\n canvasHeight?: number;\n /** iframe width (CSS value) */\n width?: string | number;\n /** iframe height (CSS value) */\n height?: string | number;\n}\n\n/**\n * Build the editor URL with configuration parameters\n */\nfunction buildEditorUrl(config: ImageCanvasKitConfig): string {\n const baseUrl = config.baseUrl || DEFAULT_BASE_URL;\n const params = new URLSearchParams();\n\n params.set('embed', 'true');\n\n if (config.apiKey) params.set('apiKey', config.apiKey);\n if (config.width) params.set('width', String(config.width));\n if (config.height) params.set('height', String(config.height));\n if (config.backgroundColor) params.set('bg', config.backgroundColor);\n if (config.theme) params.set('theme', config.theme);\n if (config.hideToolbar) params.set('hideToolbar', 'true');\n if (config.hideSidebar) params.set('hideSidebar', 'true');\n if (config.hideExport) params.set('hideExport', 'true');\n if (config.templateId) params.set('templateId', config.templateId);\n if (config.endUserId) params.set('endUserId', config.endUserId);\n if (config.exportFormats) params.set('formats', config.exportFormats.join(','));\n\n // White-label settings\n if (config.whiteLabel) {\n if (config.whiteLabel.logo) params.set('logo', config.whiteLabel.logo);\n if (config.whiteLabel.primaryColor) params.set('primaryColor', config.whiteLabel.primaryColor);\n if (config.whiteLabel.companyName) params.set('companyName', config.whiteLabel.companyName);\n if (config.whiteLabel.hideBranding) params.set('hideBranding', 'true');\n }\n\n return `${baseUrl}/editor?${params.toString()}`;\n}\n\n/**\n * Create an ImageCanvasKit editor instance\n *\n * @example\n * ```js\n * import { createEditor } from '@imagecanvaskit/embed';\n *\n * const editor = createEditor({\n * container: '#editor-container',\n * apiKey: 'your-api-key',\n * width: '100%',\n * height: '600px',\n * onExport: (e) => console.log('Exported:', e.data),\n * onReady: () => console.log('Editor ready!'),\n * });\n *\n * // Later: trigger export\n * editor.export({ format: 'png' });\n *\n * // Cleanup\n * editor.destroy();\n * ```\n */\nexport function createEditor(options: CreateEditorOptions): ImageCanvasKitInstance {\n const {\n container,\n width = '100%',\n height = '600px',\n canvasWidth,\n canvasHeight,\n onReady,\n onExport,\n onSave,\n onLoad,\n onError,\n onResize,\n onObjectSelected,\n onObjectDeselected,\n onCanvasModified,\n projectData,\n ...config\n } = options;\n\n // Build config with canvas dimensions\n const editorConfig = {\n ...config,\n width: canvasWidth,\n height: canvasHeight,\n };\n\n // Get container element\n const containerEl =\n typeof container === 'string' ? document.querySelector<HTMLElement>(container) : container;\n\n if (!containerEl) {\n throw new Error(`ImageCanvasKit: Container element not found: ${container}`);\n }\n\n // Create iframe\n const iframe = document.createElement('iframe');\n iframe.src = buildEditorUrl(editorConfig);\n iframe.style.border = 'none';\n iframe.style.display = 'block';\n iframe.style.width = typeof width === 'number' ? `${width}px` : width;\n iframe.style.height = typeof height === 'number' ? `${height}px` : height;\n iframe.allow = 'clipboard-read; clipboard-write';\n iframe.title = 'ImageCanvasKit Editor';\n\n // Track ready state (for future use)\n let _isReady = false;\n\n // Send command to iframe\n const sendCommand = (payload: CommandPayload) => {\n if (iframe.contentWindow) {\n iframe.contentWindow.postMessage({ source: 'imagecanvaskit-embed', ...payload }, '*');\n }\n };\n\n // Handle incoming messages\n const handleMessage = (event: MessageEvent) => {\n // Verify origin in production\n if (config.baseUrl && !event.origin.includes(new URL(config.baseUrl).hostname)) {\n return;\n }\n\n const data = event.data as ImageCanvasKitEvent;\n if (!data || typeof data !== 'object' || !data.type) return;\n\n switch (data.type) {\n case 'ready':\n _isReady = true;\n onReady?.(data as ImageCanvasKitEvent<ReadyEventData>);\n // Load project data if provided\n if (projectData) {\n sendCommand({ command: 'load', projectData });\n }\n break;\n case 'export':\n onExport?.(data as ImageCanvasKitEvent<ExportEventData>);\n break;\n case 'save':\n onSave?.(data as ImageCanvasKitEvent<SaveEventData>);\n break;\n case 'load':\n onLoad?.(data as ImageCanvasKitEvent<LoadEventData>);\n break;\n case 'error':\n onError?.(data as ImageCanvasKitEvent<ErrorEventData>);\n break;\n case 'resize':\n onResize?.(data as ImageCanvasKitEvent<ResizeEventData>);\n break;\n case 'objectSelected':\n onObjectSelected?.(data as ImageCanvasKitEvent<ObjectSelectedEventData>);\n break;\n case 'objectDeselected':\n onObjectDeselected?.(data as ImageCanvasKitEvent<void>);\n break;\n case 'canvasModified':\n onCanvasModified?.(data as ImageCanvasKitEvent<CanvasModifiedEventData>);\n break;\n }\n };\n\n window.addEventListener('message', handleMessage);\n\n // Append iframe to container\n containerEl.appendChild(iframe);\n\n // Return instance API\n const instance: ImageCanvasKitInstance = {\n sendCommand,\n export: (opts) => sendCommand({ command: 'export', ...opts }),\n save: () => sendCommand({ command: 'save' }),\n load: (opts) => sendCommand({ command: 'load', ...opts }),\n clear: () => sendCommand({ command: 'clear' }),\n undo: () => sendCommand({ command: 'undo' }),\n redo: () => sendCommand({ command: 'redo' }),\n addText: (opts) => sendCommand({ command: 'addText', ...opts }),\n addImage: (opts) => sendCommand({ command: 'addImage', ...opts }),\n addShape: (opts) => sendCommand({ command: 'addShape', ...opts }),\n setBackground: (opts) => sendCommand({ command: 'setBackground', ...opts }),\n resize: (w, h) => sendCommand({ command: 'resize', width: w, height: h }),\n destroy: () => {\n window.removeEventListener('message', handleMessage);\n iframe.remove();\n },\n };\n\n return instance;\n}\n\n/**\n * Helper to convert base64 image data to Blob\n */\nexport function base64ToBlob(base64: string, mimeType: string): Blob {\n const byteCharacters = atob(base64.split(',')[1] || base64);\n const byteNumbers = new Array(byteCharacters.length);\n for (let i = 0; i < byteCharacters.length; i++) {\n byteNumbers[i] = byteCharacters.charCodeAt(i);\n }\n const byteArray = new Uint8Array(byteNumbers);\n return new Blob([byteArray], { type: mimeType });\n}\n\n/**\n * Helper to download exported image\n */\nexport function downloadImage(imageData: string, filename: string, mimeType: string): void {\n const blob = base64ToBlob(imageData, mimeType);\n const url = URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = url;\n a.download = filename;\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n URL.revokeObjectURL(url);\n}\n\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { A as AddImageCommand, a as AddShapeCommand, b as AddTextCommand, C as CanvasModifiedEventData, c as CommandPayload, d as CustomFont, E as ErrorEventData, e as EventCallback, f as EventCallbacks, g as ExportCommand, h as ExportEventData, I as ImageCanvasKitCommand, i as ImageCanvasKitConfig, j as ImageCanvasKitEvent, k as ImageCanvasKitEventType, l as ImageCanvasKitInstance, m as ImageCanvasKitProps, L as LoadCommand, n as LoadEventData, O as ObjectSelectedEventData, R as ReadyEventData, o as ResizeCommand, p as ResizeEventData, S as SaveEventData, q as SetBackgroundCommand, W as WhiteLabelConfig } from './types-C7ZIsAaA.cjs';
|
|
2
|
+
export { ImageCanvasKit } from './react.cjs';
|
|
3
|
+
export { base64ToBlob, createEditor, downloadImage } from './vanilla.cjs';
|
|
4
|
+
import 'react';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { A as AddImageCommand, a as AddShapeCommand, b as AddTextCommand, C as CanvasModifiedEventData, c as CommandPayload, d as CustomFont, E as ErrorEventData, e as EventCallback, f as EventCallbacks, g as ExportCommand, h as ExportEventData, I as ImageCanvasKitCommand, i as ImageCanvasKitConfig, j as ImageCanvasKitEvent, k as ImageCanvasKitEventType, l as ImageCanvasKitInstance, m as ImageCanvasKitProps, L as LoadCommand, n as LoadEventData, O as ObjectSelectedEventData, R as ReadyEventData, o as ResizeCommand, p as ResizeEventData, S as SaveEventData, q as SetBackgroundCommand, W as WhiteLabelConfig } from './types-C7ZIsAaA.js';
|
|
2
|
+
export { ImageCanvasKit } from './react.js';
|
|
3
|
+
export { base64ToBlob, createEditor, downloadImage } from './vanilla.js';
|
|
4
|
+
import 'react';
|