@picsart/react-photo-editor 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 +58 -0
- package/dist/index.d.mts +180 -0
- package/dist/index.d.ts +180 -0
- package/dist/index.js +1850 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1843 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @picsart/react-photo-editor
|
|
2
|
+
|
|
3
|
+
React component for embedding the Picsart Photo & Video Editor (Create) SDK in web apps.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @picsart/react-photo-editor
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires **React 17+** as a peer dependency.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { PhotoEditor } from '@picsart/react-photo-editor';
|
|
17
|
+
|
|
18
|
+
export function Editor() {
|
|
19
|
+
return (
|
|
20
|
+
<PhotoEditor
|
|
21
|
+
apiKey={process.env.NEXT_PUBLIC_PICSART_API_KEY!}
|
|
22
|
+
customerId={process.env.NEXT_PUBLIC_PICSART_CUSTOMER_ID!}
|
|
23
|
+
propertyId={process.env.NEXT_PUBLIC_PICSART_PROPERTY_ID}
|
|
24
|
+
editorDomain={process.env.NEXT_PUBLIC_PICSART_EDITOR_DOMAIN!}
|
|
25
|
+
parentDomain={process.env.NEXT_PUBLIC_PICSART_PARENT_DOMAIN}
|
|
26
|
+
imageUrl="https://example.com/image.png"
|
|
27
|
+
onExport={(result) => console.log(result)}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
For local dev over `http://localhost`, set **`parentDomain`** (or `NEXT_PUBLIC_PICSART_PARENT_DOMAIN` / `VITE_PICSART_PARENT_DOMAIN`) to an **HTTPS** tunnel origin so the SDK can validate the parent window.
|
|
34
|
+
|
|
35
|
+
## Publish to npm (Picsart org members)
|
|
36
|
+
|
|
37
|
+
1. Use an npm account that is a **member of the `@picsart` organization** with publish permission.
|
|
38
|
+
2. From this repository root:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm login
|
|
42
|
+
npm run build
|
|
43
|
+
npm run publish:npm
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This project includes a root **`.npmrc`** so installs and publishes target **`https://registry.npmjs.org/`** for the `@picsart` scope (and avoids accidental publishes to other registries).
|
|
47
|
+
|
|
48
|
+
3. Scoped packages must be **public** (already set via `publishConfig.access`).
|
|
49
|
+
|
|
50
|
+
If `npm publish` fails with **403**, your user is not on the `@picsart` org or lacks publish rights—ask your org admin on npmjs.com.
|
|
51
|
+
|
|
52
|
+
## Local example
|
|
53
|
+
|
|
54
|
+
See the `example/` app: copy `example/.env.example` to `example/.env`, then from repo root:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm run dev:example
|
|
58
|
+
```
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
|
|
4
|
+
declare class Picsart {
|
|
5
|
+
constructor(settings: any);
|
|
6
|
+
settings: any;
|
|
7
|
+
provideShapesData: {
|
|
8
|
+
data: ({
|
|
9
|
+
id: number;
|
|
10
|
+
shapeURL: string;
|
|
11
|
+
previewURL: string;
|
|
12
|
+
shapeData: {};
|
|
13
|
+
height: number;
|
|
14
|
+
width: number;
|
|
15
|
+
meta_data?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
id: number;
|
|
18
|
+
shapeURL: string;
|
|
19
|
+
previewURL: string;
|
|
20
|
+
meta_data: {};
|
|
21
|
+
height: number;
|
|
22
|
+
width: number;
|
|
23
|
+
shapeData?: undefined;
|
|
24
|
+
})[];
|
|
25
|
+
};
|
|
26
|
+
isEditorReady: boolean;
|
|
27
|
+
onExportCb: () => void;
|
|
28
|
+
messageListener: ({ data, origin }: {
|
|
29
|
+
data: any;
|
|
30
|
+
origin: any;
|
|
31
|
+
}) => void;
|
|
32
|
+
isMessageListenerAttached: boolean;
|
|
33
|
+
log(...args: any[]): void;
|
|
34
|
+
onOpen(callback: any): this;
|
|
35
|
+
openCallBack: any;
|
|
36
|
+
renderNew(src: any): void;
|
|
37
|
+
iframe: HTMLIFrameElement | null | undefined;
|
|
38
|
+
render(src: any): void;
|
|
39
|
+
close(): this;
|
|
40
|
+
hide(): void;
|
|
41
|
+
callCloseHandlers(): void;
|
|
42
|
+
resetTempData(): void;
|
|
43
|
+
tempOnClose: any;
|
|
44
|
+
tempOnExport: any;
|
|
45
|
+
tempExportType: any;
|
|
46
|
+
tempExportSettings: any;
|
|
47
|
+
onClose(cb?: () => void): this;
|
|
48
|
+
cbClose: (() => void) | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* @param {(payload: any) => void} [cb]
|
|
51
|
+
*/
|
|
52
|
+
onError(cb?: (payload: any) => void): this;
|
|
53
|
+
cbError: ((payload: any) => void) | undefined;
|
|
54
|
+
clear(): this;
|
|
55
|
+
applySettings(settings: any): void;
|
|
56
|
+
isIframeLoaded(): boolean | null | undefined;
|
|
57
|
+
onReady(cb?: () => void): this;
|
|
58
|
+
exportData(payload: any, cb: any): Promise<void>;
|
|
59
|
+
handleUpload(data: any): void;
|
|
60
|
+
onUpload(handler: any): void;
|
|
61
|
+
/**
|
|
62
|
+
* @param {(result: any) => void} [cb]
|
|
63
|
+
*/
|
|
64
|
+
onExport(cb?: (result: any) => void): this;
|
|
65
|
+
export(): void;
|
|
66
|
+
getEditorSettings(params: any): any;
|
|
67
|
+
open(params?: {}): this;
|
|
68
|
+
openOld(params?: {}): this;
|
|
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;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
type PhotoEditorOpenParams = Record<string, unknown>;
|
|
141
|
+
type PhotoEditorProps = {
|
|
142
|
+
apiKey: string;
|
|
143
|
+
customerId: string;
|
|
144
|
+
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;
|
|
157
|
+
className?: string;
|
|
158
|
+
style?: CSSProperties;
|
|
159
|
+
title?: string;
|
|
160
|
+
imageUrl?: string;
|
|
161
|
+
/** When true (default), merges the bundled CMS-style defaults from `cmsSettings`. */
|
|
162
|
+
cms?: boolean;
|
|
163
|
+
debug?: boolean;
|
|
164
|
+
onExport?: (result: unknown) => void;
|
|
165
|
+
onError?: (payload: unknown) => void;
|
|
166
|
+
onClose?: () => void;
|
|
167
|
+
onOpen?: () => void;
|
|
168
|
+
/** Merged into the Picsart constructor (advanced). */
|
|
169
|
+
picsartSettings?: Record<string, unknown>;
|
|
170
|
+
/** Merged into the `.open()` call after mount. */
|
|
171
|
+
openParams?: PhotoEditorOpenParams;
|
|
172
|
+
};
|
|
173
|
+
type PhotoEditorHandle = {
|
|
174
|
+
picsart: InstanceType<typeof Picsart> | null;
|
|
175
|
+
open: (params?: PhotoEditorOpenParams) => InstanceType<typeof Picsart>;
|
|
176
|
+
close: () => InstanceType<typeof Picsart>;
|
|
177
|
+
};
|
|
178
|
+
declare const PhotoEditor: react.ForwardRefExoticComponent<PhotoEditorProps & react.RefAttributes<PhotoEditorHandle>>;
|
|
179
|
+
|
|
180
|
+
export { PhotoEditor, type PhotoEditorHandle, type PhotoEditorOpenParams, type PhotoEditorProps, Picsart };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
|
|
4
|
+
declare class Picsart {
|
|
5
|
+
constructor(settings: any);
|
|
6
|
+
settings: any;
|
|
7
|
+
provideShapesData: {
|
|
8
|
+
data: ({
|
|
9
|
+
id: number;
|
|
10
|
+
shapeURL: string;
|
|
11
|
+
previewURL: string;
|
|
12
|
+
shapeData: {};
|
|
13
|
+
height: number;
|
|
14
|
+
width: number;
|
|
15
|
+
meta_data?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
id: number;
|
|
18
|
+
shapeURL: string;
|
|
19
|
+
previewURL: string;
|
|
20
|
+
meta_data: {};
|
|
21
|
+
height: number;
|
|
22
|
+
width: number;
|
|
23
|
+
shapeData?: undefined;
|
|
24
|
+
})[];
|
|
25
|
+
};
|
|
26
|
+
isEditorReady: boolean;
|
|
27
|
+
onExportCb: () => void;
|
|
28
|
+
messageListener: ({ data, origin }: {
|
|
29
|
+
data: any;
|
|
30
|
+
origin: any;
|
|
31
|
+
}) => void;
|
|
32
|
+
isMessageListenerAttached: boolean;
|
|
33
|
+
log(...args: any[]): void;
|
|
34
|
+
onOpen(callback: any): this;
|
|
35
|
+
openCallBack: any;
|
|
36
|
+
renderNew(src: any): void;
|
|
37
|
+
iframe: HTMLIFrameElement | null | undefined;
|
|
38
|
+
render(src: any): void;
|
|
39
|
+
close(): this;
|
|
40
|
+
hide(): void;
|
|
41
|
+
callCloseHandlers(): void;
|
|
42
|
+
resetTempData(): void;
|
|
43
|
+
tempOnClose: any;
|
|
44
|
+
tempOnExport: any;
|
|
45
|
+
tempExportType: any;
|
|
46
|
+
tempExportSettings: any;
|
|
47
|
+
onClose(cb?: () => void): this;
|
|
48
|
+
cbClose: (() => void) | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* @param {(payload: any) => void} [cb]
|
|
51
|
+
*/
|
|
52
|
+
onError(cb?: (payload: any) => void): this;
|
|
53
|
+
cbError: ((payload: any) => void) | undefined;
|
|
54
|
+
clear(): this;
|
|
55
|
+
applySettings(settings: any): void;
|
|
56
|
+
isIframeLoaded(): boolean | null | undefined;
|
|
57
|
+
onReady(cb?: () => void): this;
|
|
58
|
+
exportData(payload: any, cb: any): Promise<void>;
|
|
59
|
+
handleUpload(data: any): void;
|
|
60
|
+
onUpload(handler: any): void;
|
|
61
|
+
/**
|
|
62
|
+
* @param {(result: any) => void} [cb]
|
|
63
|
+
*/
|
|
64
|
+
onExport(cb?: (result: any) => void): this;
|
|
65
|
+
export(): void;
|
|
66
|
+
getEditorSettings(params: any): any;
|
|
67
|
+
open(params?: {}): this;
|
|
68
|
+
openOld(params?: {}): this;
|
|
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;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
type PhotoEditorOpenParams = Record<string, unknown>;
|
|
141
|
+
type PhotoEditorProps = {
|
|
142
|
+
apiKey: string;
|
|
143
|
+
customerId: string;
|
|
144
|
+
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;
|
|
157
|
+
className?: string;
|
|
158
|
+
style?: CSSProperties;
|
|
159
|
+
title?: string;
|
|
160
|
+
imageUrl?: string;
|
|
161
|
+
/** When true (default), merges the bundled CMS-style defaults from `cmsSettings`. */
|
|
162
|
+
cms?: boolean;
|
|
163
|
+
debug?: boolean;
|
|
164
|
+
onExport?: (result: unknown) => void;
|
|
165
|
+
onError?: (payload: unknown) => void;
|
|
166
|
+
onClose?: () => void;
|
|
167
|
+
onOpen?: () => void;
|
|
168
|
+
/** Merged into the Picsart constructor (advanced). */
|
|
169
|
+
picsartSettings?: Record<string, unknown>;
|
|
170
|
+
/** Merged into the `.open()` call after mount. */
|
|
171
|
+
openParams?: PhotoEditorOpenParams;
|
|
172
|
+
};
|
|
173
|
+
type PhotoEditorHandle = {
|
|
174
|
+
picsart: InstanceType<typeof Picsart> | null;
|
|
175
|
+
open: (params?: PhotoEditorOpenParams) => InstanceType<typeof Picsart>;
|
|
176
|
+
close: () => InstanceType<typeof Picsart>;
|
|
177
|
+
};
|
|
178
|
+
declare const PhotoEditor: react.ForwardRefExoticComponent<PhotoEditorProps & react.RefAttributes<PhotoEditorHandle>>;
|
|
179
|
+
|
|
180
|
+
export { PhotoEditor, type PhotoEditorHandle, type PhotoEditorOpenParams, type PhotoEditorProps, Picsart };
|