@picsart/react-photo-editor 1.0.0 → 1.0.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 +33 -23
- package/dist/index.d.mts +96 -167
- package/dist/index.d.ts +96 -167
- package/dist/index.js +202 -1820
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +202 -1817
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @picsart/react-photo-editor
|
|
2
2
|
|
|
3
|
-
React component
|
|
3
|
+
React component that loads the **official Picsart Create SDK** from `sdk.picsart.io` (script tag) and mounts the editor into your page. No bundled copy of the editor runtime is shipped in this package—only a thin React wrapper.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -8,51 +8,61 @@ React component for embedding the Picsart Photo & Video Editor (Create) SDK in w
|
|
|
8
8
|
npm install @picsart/react-photo-editor
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Peer dependencies: **React 17+** and **react-dom**.
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```tsx
|
|
16
|
-
import {
|
|
16
|
+
import { PicsartEditor } from '@picsart/react-photo-editor';
|
|
17
17
|
|
|
18
|
-
export function
|
|
18
|
+
export function Page() {
|
|
19
19
|
return (
|
|
20
|
-
<
|
|
20
|
+
<PicsartEditor
|
|
21
21
|
apiKey={process.env.NEXT_PUBLIC_PICSART_API_KEY!}
|
|
22
22
|
customerId={process.env.NEXT_PUBLIC_PICSART_CUSTOMER_ID!}
|
|
23
23
|
propertyId={process.env.NEXT_PUBLIC_PICSART_PROPERTY_ID}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
onExport={(
|
|
24
|
+
title="My editor"
|
|
25
|
+
imageURL="https://example.com/photo.png"
|
|
26
|
+
theme="dark"
|
|
27
|
+
onExport={(data) => console.log(data)}
|
|
28
|
+
onError={(err) => console.error(err)}
|
|
28
29
|
/>
|
|
29
30
|
);
|
|
30
31
|
}
|
|
31
32
|
```
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
### SDK script URL
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
By default the component loads `https://sdk.picsart.io/cdn.min.js`. If that URL does not match your SDK version, pass **`sdkScriptUrl`** (see [Picsart docs](https://docs.picsart.io/) for the correct `cdn?...` URL).
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
2. From this repository root:
|
|
38
|
+
### Ref (imperative API)
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
```tsx
|
|
41
|
+
const ref = useRef<PicsartEditorRef>(null);
|
|
42
|
+
<PicsartEditor ref={ref} ... />
|
|
43
|
+
ref.current?.export();
|
|
44
|
+
ref.current?.getInstance();
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Publish to npm (`@picsart` org)
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm whoami
|
|
51
|
+
npm login
|
|
52
|
+
npm run publish:npm
|
|
53
|
+
```
|
|
45
54
|
|
|
46
|
-
|
|
55
|
+
- Your npm user must be a **member of the `@picsart` organization** with permission to **publish** scoped packages.
|
|
56
|
+
- This repo’s **`.npmrc`** and **`publishConfig.registry`** target **`https://registry.npmjs.org/`** (not GitLab).
|
|
47
57
|
|
|
48
|
-
|
|
58
|
+
If **`npm publish`** returns **404** on `PUT …/@picsart%2freact-photo-editor`, npm is almost always telling you the current login **cannot publish that scope** (or you are not logged in). Fix org membership / use `npm login`, then retry.
|
|
49
59
|
|
|
50
|
-
|
|
60
|
+
To ship a **new** version after changes, bump **`version`** in `package.json`, then run `npm run publish:npm` again.
|
|
51
61
|
|
|
52
62
|
## Local example
|
|
53
63
|
|
|
54
|
-
See the `example/` app: copy `example/.env.example` to `example/.env`, then from repo root:
|
|
55
|
-
|
|
56
64
|
```bash
|
|
57
65
|
npm run dev:example
|
|
58
66
|
```
|
|
67
|
+
|
|
68
|
+
Configure `example/.env` from `example/.env.example`.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,180 +1,109 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { CSSProperties } from 'react';
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})[];
|
|
4
|
+
type PicsartTheme = 'dark' | 'light';
|
|
5
|
+
type PicsartExportType = 'base64' | 'blob' | 'buffer';
|
|
6
|
+
interface PicsartOpenOptions {
|
|
7
|
+
replayUrl?: string;
|
|
8
|
+
templateId?: string;
|
|
9
|
+
imageUrl?: string;
|
|
10
|
+
videoUrl?: string;
|
|
11
|
+
subtitleUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
interface PicsartExportOutput {
|
|
14
|
+
templateId?: string;
|
|
15
|
+
data: {
|
|
16
|
+
replayData?: Blob | ArrayBuffer | string;
|
|
17
|
+
imageData?: string | Blob;
|
|
18
|
+
printData?: string | Blob;
|
|
19
|
+
previewPdfData?: string | Blob;
|
|
20
|
+
pdfData?: string | Blob;
|
|
21
|
+
previewsData?: Array<string | Blob>;
|
|
22
|
+
videoData?: unknown;
|
|
23
|
+
videoUrl?: string;
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
onUpload
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
sendMessage(type: any, data: any): void;
|
|
70
|
-
attachMessageListener(): void;
|
|
71
|
-
detachMessageListener(): void;
|
|
72
|
-
handleMessage({ data, origin }: {
|
|
73
|
-
data: any;
|
|
74
|
-
origin: any;
|
|
75
|
-
}): void;
|
|
76
|
-
handleEditorReady(): void;
|
|
77
|
-
flushPendingData(): void;
|
|
78
|
-
getFetch(url: any): Promise<any>;
|
|
79
|
-
getCategoriesData(data: any): Promise<any[]>;
|
|
80
|
-
provideTemplates({ data, dataURL }: {
|
|
81
|
-
data: any;
|
|
82
|
-
dataURL: any;
|
|
83
|
-
}): Promise<this | undefined>;
|
|
84
|
-
provideTemplatesData: {
|
|
85
|
-
data: any;
|
|
86
|
-
dataURL: any;
|
|
87
|
-
} | undefined;
|
|
88
|
-
provideShapes({ data, dataURL }: {
|
|
89
|
-
data: any;
|
|
90
|
-
dataURL: any;
|
|
91
|
-
}): Promise<this | undefined>;
|
|
92
|
-
provideStickerShapes(): Promise<this>;
|
|
93
|
-
provideTexts({ data, dataURL }: {
|
|
94
|
-
data: any;
|
|
95
|
-
dataURL: any;
|
|
96
|
-
}): Promise<this | undefined>;
|
|
97
|
-
provideTextsData: {
|
|
98
|
-
data: any;
|
|
99
|
-
dataURL: any;
|
|
100
|
-
} | undefined;
|
|
101
|
-
provideColors(data: any): this | undefined;
|
|
102
|
-
provideColorsData: any;
|
|
103
|
-
providePhotos({ data, dataURL }: {
|
|
104
|
-
data: any;
|
|
105
|
-
dataURL: any;
|
|
106
|
-
}): Promise<this | undefined>;
|
|
107
|
-
providePhotosData: {
|
|
108
|
-
data: any;
|
|
109
|
-
dataURL: any;
|
|
110
|
-
} | undefined;
|
|
111
|
-
provideStickers({ data, dataURL }: {
|
|
112
|
-
data: any;
|
|
113
|
-
dataURL: any;
|
|
114
|
-
}): Promise<this | undefined>;
|
|
115
|
-
provideStickersData: {
|
|
116
|
-
data: any;
|
|
117
|
-
dataURL: any;
|
|
118
|
-
} | undefined;
|
|
119
|
-
provideFonts({ data, dataURL }: {
|
|
120
|
-
data: any;
|
|
121
|
-
dataURL: any;
|
|
122
|
-
}): Promise<this | undefined>;
|
|
123
|
-
provideFontsData: {
|
|
124
|
-
data: any;
|
|
125
|
-
dataURL: any;
|
|
126
|
-
} | undefined;
|
|
127
|
-
provideCanvasSizes({ data, dataURL }: {
|
|
128
|
-
data: any;
|
|
129
|
-
dataURL: any;
|
|
130
|
-
}): Promise<this | undefined>;
|
|
131
|
-
provideCanvasSizesData: {
|
|
132
|
-
data: any;
|
|
133
|
-
dataURL: any;
|
|
134
|
-
} | undefined;
|
|
135
|
-
provideLabels(data: any): this | undefined;
|
|
136
|
-
provideLabelsData: any;
|
|
137
|
-
provideExportSettings(): void;
|
|
25
|
+
}
|
|
26
|
+
type PicsartUploadHandler = (file: Blob | ArrayBuffer | Uint8Array, mimeType: string) => Promise<{
|
|
27
|
+
url: string;
|
|
28
|
+
status: string;
|
|
29
|
+
progress: number;
|
|
30
|
+
error: unknown;
|
|
31
|
+
}>;
|
|
32
|
+
interface PicsartInstance {
|
|
33
|
+
onError(cb: (error: unknown) => void): PicsartInstance;
|
|
34
|
+
onExport(cb: (output: PicsartExportOutput) => void): PicsartInstance;
|
|
35
|
+
onClose(cb?: () => void): PicsartInstance;
|
|
36
|
+
open(options?: PicsartOpenOptions): PicsartInstance;
|
|
37
|
+
close(): PicsartInstance;
|
|
38
|
+
}
|
|
39
|
+
interface PicsartConstructorOptions {
|
|
40
|
+
apiKey: string;
|
|
41
|
+
customerId?: string;
|
|
42
|
+
propertyId?: string;
|
|
43
|
+
containerId: string;
|
|
44
|
+
exportType?: PicsartExportType;
|
|
45
|
+
theme?: PicsartTheme;
|
|
46
|
+
title?: string;
|
|
47
|
+
selectedCategory?: string;
|
|
48
|
+
canvasSize?: string;
|
|
49
|
+
templatesTitleText?: string;
|
|
50
|
+
templatesSubTitle?: string;
|
|
51
|
+
replayUrl?: string;
|
|
52
|
+
videoUrl?: string;
|
|
53
|
+
imageUrl?: string;
|
|
54
|
+
subtitleUrl?: string;
|
|
55
|
+
templateId?: string;
|
|
56
|
+
stickerText?: string;
|
|
57
|
+
stickerImageUrl?: string;
|
|
58
|
+
templatesFilters?: Record<string, unknown>;
|
|
59
|
+
onUpload?: PicsartUploadHandler;
|
|
60
|
+
}
|
|
61
|
+
interface PicsartConstructor {
|
|
62
|
+
new (options: PicsartConstructorOptions): PicsartInstance;
|
|
63
|
+
}
|
|
64
|
+
declare global {
|
|
65
|
+
interface Window {
|
|
66
|
+
Picsart?: PicsartConstructor;
|
|
67
|
+
}
|
|
138
68
|
}
|
|
139
69
|
|
|
140
|
-
|
|
141
|
-
type PhotoEditorProps = {
|
|
70
|
+
interface PicsartEditorProps {
|
|
142
71
|
apiKey: string;
|
|
143
72
|
customerId: string;
|
|
73
|
+
/** Omitted when your Picsart setup does not use a property id. */
|
|
144
74
|
propertyId?: string;
|
|
145
|
-
|
|
146
|
-
* Full editor entry URL used as the iframe `src` origin (before `?query`).
|
|
147
|
-
* Use the value from your Picsart onboarding / docs for your SDK version.
|
|
148
|
-
*/
|
|
149
|
-
editorDomain?: string;
|
|
150
|
-
/**
|
|
151
|
-
* Origin the editor uses as the embedding parent (query `parentDomain`).
|
|
152
|
-
* **Important:** `http://localhost` often fails SDK origin / postMessage checks.
|
|
153
|
-
* For local dev use an HTTPS tunnel (ngrok, etc.) and set this to that `https://…` origin,
|
|
154
|
-
* or set env `NEXT_PUBLIC_PICSART_PARENT_DOMAIN` / `VITE_PICSART_PARENT_DOMAIN`.
|
|
155
|
-
*/
|
|
156
|
-
parentDomain?: string;
|
|
75
|
+
sdkScriptUrl?: string;
|
|
157
76
|
className?: string;
|
|
158
77
|
style?: CSSProperties;
|
|
78
|
+
children?: ReactNode;
|
|
79
|
+
exportType?: PicsartExportType;
|
|
80
|
+
theme?: PicsartTheme;
|
|
159
81
|
title?: string;
|
|
82
|
+
selectedCategory?: string;
|
|
83
|
+
canvasSize?: string;
|
|
84
|
+
templatesTitleText?: string;
|
|
85
|
+
templatesSubTitle?: string;
|
|
86
|
+
templatesFilters?: Record<string, unknown>;
|
|
87
|
+
replayUrl?: string;
|
|
88
|
+
videoUrl?: string;
|
|
160
89
|
imageUrl?: string;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
90
|
+
subtitleUrl?: string;
|
|
91
|
+
templateId?: string;
|
|
92
|
+
stickerText?: string;
|
|
93
|
+
stickerImageUrl?: string;
|
|
94
|
+
onUpload?: PicsartUploadHandler;
|
|
95
|
+
onExport?: (output: PicsartExportOutput) => void;
|
|
96
|
+
onError?: (error: unknown) => void;
|
|
166
97
|
onClose?: () => void;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
};
|
|
178
|
-
declare const PhotoEditor: react.ForwardRefExoticComponent<PhotoEditorProps & react.RefAttributes<PhotoEditorHandle>>;
|
|
98
|
+
/** When false, `open()` is called with no asset (blank editor). Default true. */
|
|
99
|
+
autoOpen?: boolean;
|
|
100
|
+
/** Override initial `open()` payload when autoOpen is true. */
|
|
101
|
+
openOptions?: PicsartOpenOptions;
|
|
102
|
+
}
|
|
103
|
+
declare function PicsartEditor({ apiKey, customerId, propertyId, sdkScriptUrl, className, style, children, exportType, theme, title, selectedCategory, canvasSize, templatesTitleText, templatesSubTitle, templatesFilters, replayUrl, videoUrl, imageUrl, subtitleUrl, templateId, stickerText, stickerImageUrl, onUpload, onExport, onError, onClose, autoOpen, openOptions, }: PicsartEditorProps): react_jsx_runtime.JSX.Element;
|
|
104
|
+
|
|
105
|
+
declare function loadPicsartSdk(scriptUrl?: string): Promise<void>;
|
|
106
|
+
|
|
107
|
+
declare function createDefaultVideoUpload(apiKey: string): PicsartUploadHandler;
|
|
179
108
|
|
|
180
|
-
export {
|
|
109
|
+
export { type PicsartConstructorOptions, PicsartEditor, type PicsartEditorProps, type PicsartExportOutput, type PicsartExportType, type PicsartInstance, type PicsartOpenOptions, type PicsartTheme, type PicsartUploadHandler, createDefaultVideoUpload, loadPicsartSdk };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,180 +1,109 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { CSSProperties } from 'react';
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})[];
|
|
4
|
+
type PicsartTheme = 'dark' | 'light';
|
|
5
|
+
type PicsartExportType = 'base64' | 'blob' | 'buffer';
|
|
6
|
+
interface PicsartOpenOptions {
|
|
7
|
+
replayUrl?: string;
|
|
8
|
+
templateId?: string;
|
|
9
|
+
imageUrl?: string;
|
|
10
|
+
videoUrl?: string;
|
|
11
|
+
subtitleUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
interface PicsartExportOutput {
|
|
14
|
+
templateId?: string;
|
|
15
|
+
data: {
|
|
16
|
+
replayData?: Blob | ArrayBuffer | string;
|
|
17
|
+
imageData?: string | Blob;
|
|
18
|
+
printData?: string | Blob;
|
|
19
|
+
previewPdfData?: string | Blob;
|
|
20
|
+
pdfData?: string | Blob;
|
|
21
|
+
previewsData?: Array<string | Blob>;
|
|
22
|
+
videoData?: unknown;
|
|
23
|
+
videoUrl?: string;
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
onUpload
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
sendMessage(type: any, data: any): void;
|
|
70
|
-
attachMessageListener(): void;
|
|
71
|
-
detachMessageListener(): void;
|
|
72
|
-
handleMessage({ data, origin }: {
|
|
73
|
-
data: any;
|
|
74
|
-
origin: any;
|
|
75
|
-
}): void;
|
|
76
|
-
handleEditorReady(): void;
|
|
77
|
-
flushPendingData(): void;
|
|
78
|
-
getFetch(url: any): Promise<any>;
|
|
79
|
-
getCategoriesData(data: any): Promise<any[]>;
|
|
80
|
-
provideTemplates({ data, dataURL }: {
|
|
81
|
-
data: any;
|
|
82
|
-
dataURL: any;
|
|
83
|
-
}): Promise<this | undefined>;
|
|
84
|
-
provideTemplatesData: {
|
|
85
|
-
data: any;
|
|
86
|
-
dataURL: any;
|
|
87
|
-
} | undefined;
|
|
88
|
-
provideShapes({ data, dataURL }: {
|
|
89
|
-
data: any;
|
|
90
|
-
dataURL: any;
|
|
91
|
-
}): Promise<this | undefined>;
|
|
92
|
-
provideStickerShapes(): Promise<this>;
|
|
93
|
-
provideTexts({ data, dataURL }: {
|
|
94
|
-
data: any;
|
|
95
|
-
dataURL: any;
|
|
96
|
-
}): Promise<this | undefined>;
|
|
97
|
-
provideTextsData: {
|
|
98
|
-
data: any;
|
|
99
|
-
dataURL: any;
|
|
100
|
-
} | undefined;
|
|
101
|
-
provideColors(data: any): this | undefined;
|
|
102
|
-
provideColorsData: any;
|
|
103
|
-
providePhotos({ data, dataURL }: {
|
|
104
|
-
data: any;
|
|
105
|
-
dataURL: any;
|
|
106
|
-
}): Promise<this | undefined>;
|
|
107
|
-
providePhotosData: {
|
|
108
|
-
data: any;
|
|
109
|
-
dataURL: any;
|
|
110
|
-
} | undefined;
|
|
111
|
-
provideStickers({ data, dataURL }: {
|
|
112
|
-
data: any;
|
|
113
|
-
dataURL: any;
|
|
114
|
-
}): Promise<this | undefined>;
|
|
115
|
-
provideStickersData: {
|
|
116
|
-
data: any;
|
|
117
|
-
dataURL: any;
|
|
118
|
-
} | undefined;
|
|
119
|
-
provideFonts({ data, dataURL }: {
|
|
120
|
-
data: any;
|
|
121
|
-
dataURL: any;
|
|
122
|
-
}): Promise<this | undefined>;
|
|
123
|
-
provideFontsData: {
|
|
124
|
-
data: any;
|
|
125
|
-
dataURL: any;
|
|
126
|
-
} | undefined;
|
|
127
|
-
provideCanvasSizes({ data, dataURL }: {
|
|
128
|
-
data: any;
|
|
129
|
-
dataURL: any;
|
|
130
|
-
}): Promise<this | undefined>;
|
|
131
|
-
provideCanvasSizesData: {
|
|
132
|
-
data: any;
|
|
133
|
-
dataURL: any;
|
|
134
|
-
} | undefined;
|
|
135
|
-
provideLabels(data: any): this | undefined;
|
|
136
|
-
provideLabelsData: any;
|
|
137
|
-
provideExportSettings(): void;
|
|
25
|
+
}
|
|
26
|
+
type PicsartUploadHandler = (file: Blob | ArrayBuffer | Uint8Array, mimeType: string) => Promise<{
|
|
27
|
+
url: string;
|
|
28
|
+
status: string;
|
|
29
|
+
progress: number;
|
|
30
|
+
error: unknown;
|
|
31
|
+
}>;
|
|
32
|
+
interface PicsartInstance {
|
|
33
|
+
onError(cb: (error: unknown) => void): PicsartInstance;
|
|
34
|
+
onExport(cb: (output: PicsartExportOutput) => void): PicsartInstance;
|
|
35
|
+
onClose(cb?: () => void): PicsartInstance;
|
|
36
|
+
open(options?: PicsartOpenOptions): PicsartInstance;
|
|
37
|
+
close(): PicsartInstance;
|
|
38
|
+
}
|
|
39
|
+
interface PicsartConstructorOptions {
|
|
40
|
+
apiKey: string;
|
|
41
|
+
customerId?: string;
|
|
42
|
+
propertyId?: string;
|
|
43
|
+
containerId: string;
|
|
44
|
+
exportType?: PicsartExportType;
|
|
45
|
+
theme?: PicsartTheme;
|
|
46
|
+
title?: string;
|
|
47
|
+
selectedCategory?: string;
|
|
48
|
+
canvasSize?: string;
|
|
49
|
+
templatesTitleText?: string;
|
|
50
|
+
templatesSubTitle?: string;
|
|
51
|
+
replayUrl?: string;
|
|
52
|
+
videoUrl?: string;
|
|
53
|
+
imageUrl?: string;
|
|
54
|
+
subtitleUrl?: string;
|
|
55
|
+
templateId?: string;
|
|
56
|
+
stickerText?: string;
|
|
57
|
+
stickerImageUrl?: string;
|
|
58
|
+
templatesFilters?: Record<string, unknown>;
|
|
59
|
+
onUpload?: PicsartUploadHandler;
|
|
60
|
+
}
|
|
61
|
+
interface PicsartConstructor {
|
|
62
|
+
new (options: PicsartConstructorOptions): PicsartInstance;
|
|
63
|
+
}
|
|
64
|
+
declare global {
|
|
65
|
+
interface Window {
|
|
66
|
+
Picsart?: PicsartConstructor;
|
|
67
|
+
}
|
|
138
68
|
}
|
|
139
69
|
|
|
140
|
-
|
|
141
|
-
type PhotoEditorProps = {
|
|
70
|
+
interface PicsartEditorProps {
|
|
142
71
|
apiKey: string;
|
|
143
72
|
customerId: string;
|
|
73
|
+
/** Omitted when your Picsart setup does not use a property id. */
|
|
144
74
|
propertyId?: string;
|
|
145
|
-
|
|
146
|
-
* Full editor entry URL used as the iframe `src` origin (before `?query`).
|
|
147
|
-
* Use the value from your Picsart onboarding / docs for your SDK version.
|
|
148
|
-
*/
|
|
149
|
-
editorDomain?: string;
|
|
150
|
-
/**
|
|
151
|
-
* Origin the editor uses as the embedding parent (query `parentDomain`).
|
|
152
|
-
* **Important:** `http://localhost` often fails SDK origin / postMessage checks.
|
|
153
|
-
* For local dev use an HTTPS tunnel (ngrok, etc.) and set this to that `https://…` origin,
|
|
154
|
-
* or set env `NEXT_PUBLIC_PICSART_PARENT_DOMAIN` / `VITE_PICSART_PARENT_DOMAIN`.
|
|
155
|
-
*/
|
|
156
|
-
parentDomain?: string;
|
|
75
|
+
sdkScriptUrl?: string;
|
|
157
76
|
className?: string;
|
|
158
77
|
style?: CSSProperties;
|
|
78
|
+
children?: ReactNode;
|
|
79
|
+
exportType?: PicsartExportType;
|
|
80
|
+
theme?: PicsartTheme;
|
|
159
81
|
title?: string;
|
|
82
|
+
selectedCategory?: string;
|
|
83
|
+
canvasSize?: string;
|
|
84
|
+
templatesTitleText?: string;
|
|
85
|
+
templatesSubTitle?: string;
|
|
86
|
+
templatesFilters?: Record<string, unknown>;
|
|
87
|
+
replayUrl?: string;
|
|
88
|
+
videoUrl?: string;
|
|
160
89
|
imageUrl?: string;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
90
|
+
subtitleUrl?: string;
|
|
91
|
+
templateId?: string;
|
|
92
|
+
stickerText?: string;
|
|
93
|
+
stickerImageUrl?: string;
|
|
94
|
+
onUpload?: PicsartUploadHandler;
|
|
95
|
+
onExport?: (output: PicsartExportOutput) => void;
|
|
96
|
+
onError?: (error: unknown) => void;
|
|
166
97
|
onClose?: () => void;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
};
|
|
178
|
-
declare const PhotoEditor: react.ForwardRefExoticComponent<PhotoEditorProps & react.RefAttributes<PhotoEditorHandle>>;
|
|
98
|
+
/** When false, `open()` is called with no asset (blank editor). Default true. */
|
|
99
|
+
autoOpen?: boolean;
|
|
100
|
+
/** Override initial `open()` payload when autoOpen is true. */
|
|
101
|
+
openOptions?: PicsartOpenOptions;
|
|
102
|
+
}
|
|
103
|
+
declare function PicsartEditor({ apiKey, customerId, propertyId, sdkScriptUrl, className, style, children, exportType, theme, title, selectedCategory, canvasSize, templatesTitleText, templatesSubTitle, templatesFilters, replayUrl, videoUrl, imageUrl, subtitleUrl, templateId, stickerText, stickerImageUrl, onUpload, onExport, onError, onClose, autoOpen, openOptions, }: PicsartEditorProps): react_jsx_runtime.JSX.Element;
|
|
104
|
+
|
|
105
|
+
declare function loadPicsartSdk(scriptUrl?: string): Promise<void>;
|
|
106
|
+
|
|
107
|
+
declare function createDefaultVideoUpload(apiKey: string): PicsartUploadHandler;
|
|
179
108
|
|
|
180
|
-
export {
|
|
109
|
+
export { type PicsartConstructorOptions, PicsartEditor, type PicsartEditorProps, type PicsartExportOutput, type PicsartExportType, type PicsartInstance, type PicsartOpenOptions, type PicsartTheme, type PicsartUploadHandler, createDefaultVideoUpload, loadPicsartSdk };
|