@arbisoft/react-design-tool 1.0.22 → 1.0.24
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 +139 -62
- package/dist/cjs/index.js +359 -559
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +359 -559
- package/dist/esm/index.js.map +1 -1
- package/package.json +78 -78
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
# 🎨 React Design Tool (by @arbisoft)
|
|
3
2
|
|
|
4
3
|
A React component for creating and editing designs with templates, images, and customizable elements.
|
|
@@ -12,37 +11,45 @@ With this tool, you can:
|
|
|
12
11
|
- **Save** the final design data and image output
|
|
13
12
|
|
|
14
13
|
Perfect for integrating into applications that require user-driven visual content creation.
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
## 🎬 Studio Preview
|
|
16
16
|
|
|
17
17
|
**Live Walkthrough (GIF)**
|
|
18
18
|
|
|
19
19
|

|
|
20
|
+
|
|
20
21
|
## 🖥️ Demo
|
|
21
22
|
|
|
22
23
|
Check out the live demo here:
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
[](https://codesandbox.io/p/sandbox/fdftlr)
|
|
25
26
|
|
|
26
27
|
## 📦 Installation( react >= 19 )
|
|
27
28
|
|
|
28
29
|
```bash
|
|
29
30
|
npm install @arbisoft/react-design-tool
|
|
30
31
|
```
|
|
32
|
+
|
|
31
33
|
OR
|
|
34
|
+
|
|
32
35
|
```bash
|
|
33
36
|
yarn add @arbisoft/react-design-tool
|
|
34
37
|
|
|
35
38
|
```
|
|
39
|
+
|
|
36
40
|
#### ⚠️ Important: Installation Guide for React 18 and Below
|
|
37
41
|
|
|
38
42
|
```bash
|
|
39
|
-
npm install @arbisoft/react-design-tool@1.0.
|
|
43
|
+
npm install @arbisoft/react-design-tool@1.0.23
|
|
40
44
|
```
|
|
45
|
+
|
|
41
46
|
OR
|
|
47
|
+
|
|
42
48
|
```bash
|
|
43
|
-
yarn add @arbisoft/react-design-tool@1.0.
|
|
49
|
+
yarn add @arbisoft/react-design-tool@1.0.23
|
|
44
50
|
|
|
45
51
|
```
|
|
52
|
+
|
|
46
53
|
## 🚀 Quick Start
|
|
47
54
|
|
|
48
55
|
```jsx
|
|
@@ -50,197 +57,267 @@ import React, { useRef } from 'react';
|
|
|
50
57
|
import { Studio } from '@arbisoft/react-design-tool';
|
|
51
58
|
|
|
52
59
|
function MyComponent() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
60
|
+
const studioRef = useRef(null);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<Studio
|
|
64
|
+
ref={studioRef}
|
|
65
|
+
defaultTemplatesList={[]}
|
|
66
|
+
customTemplatesList={[]}
|
|
67
|
+
defaultImages={[]}
|
|
68
|
+
customImages={[]}
|
|
69
|
+
uploadImageCallBack={async file => {
|
|
70
|
+
// Upload logic here
|
|
71
|
+
return 'url_of_uploaded_image';
|
|
72
|
+
}}
|
|
73
|
+
elementsList={[]}
|
|
74
|
+
qrLink={'http://example.com'}
|
|
75
|
+
disableWhiteLabel={true}
|
|
76
|
+
title={'New Title'}
|
|
77
|
+
styleProps={{
|
|
78
|
+
primaryColor: 'red',
|
|
79
|
+
}}
|
|
80
|
+
defaultText={'Your Default Text'}
|
|
81
|
+
onSave={async data => {
|
|
82
|
+
console.log('Saved data:', data);
|
|
83
|
+
}}
|
|
84
|
+
saveButtonText={'Save Progress'}
|
|
85
|
+
locale={'en'}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
export default MyComponent;
|
|
84
91
|
```
|
|
92
|
+
|
|
85
93
|
## Props Configuration
|
|
86
94
|
|
|
87
95
|
#### 1. `defaultTemplatesList` (Array of templates)
|
|
96
|
+
|
|
88
97
|
Pre-loaded default templates provided by the system.
|
|
89
98
|
**Format:** Array of template objects
|
|
90
99
|
**Example:**
|
|
100
|
+
|
|
91
101
|
```js
|
|
92
102
|
defaultTemplatesList={[
|
|
93
|
-
{
|
|
94
|
-
title: 'Business Card',
|
|
95
|
-
image: 'url',
|
|
96
|
-
elements: [...]
|
|
103
|
+
{
|
|
104
|
+
title: 'Business Card',
|
|
105
|
+
image: 'url',
|
|
106
|
+
elements: [...]
|
|
97
107
|
}
|
|
98
108
|
]}
|
|
99
109
|
```
|
|
100
|
-
|
|
110
|
+
|
|
111
|
+
#### 2. `customTemplatesList` (Array of templates)
|
|
112
|
+
|
|
101
113
|
**Format:** Array of template objects
|
|
102
114
|
**Example:**
|
|
115
|
+
|
|
103
116
|
```js
|
|
104
117
|
customTemplatesList={[
|
|
105
|
-
{
|
|
106
|
-
title: 'Custom template',
|
|
107
|
-
image: 'url',
|
|
108
|
-
elements: [...]
|
|
118
|
+
{
|
|
119
|
+
title: 'Custom template',
|
|
120
|
+
image: 'url',
|
|
121
|
+
elements: [...]
|
|
109
122
|
}
|
|
110
123
|
]}
|
|
111
124
|
```
|
|
112
|
-
|
|
125
|
+
|
|
126
|
+
#### 3. `defaultImages` (Array of URLs)
|
|
127
|
+
|
|
113
128
|
System-provided stock images.
|
|
114
129
|
|
|
115
130
|
**Format:** Array of image urls
|
|
116
131
|
**Example:**
|
|
132
|
+
|
|
117
133
|
```js
|
|
118
134
|
defaultImages={[
|
|
119
135
|
"https://example.com/stock1.jpg",
|
|
120
136
|
"https://example.com/stock2.png"
|
|
121
137
|
]}
|
|
122
138
|
```
|
|
123
|
-
|
|
139
|
+
|
|
140
|
+
#### 4. `customImages` (Array of URLs)
|
|
141
|
+
|
|
124
142
|
User-uploaded or organization-specific images.
|
|
125
143
|
|
|
126
144
|
**Format:** Array of image urls
|
|
127
145
|
**Example:**
|
|
146
|
+
|
|
128
147
|
```js
|
|
129
148
|
customImages={[
|
|
130
149
|
"https://example.com/stock1.jpg",
|
|
131
150
|
"https://example.com/stock2.png"
|
|
132
151
|
]}
|
|
133
152
|
```
|
|
134
|
-
|
|
153
|
+
|
|
154
|
+
#### 5. `uploadImageCallBack` (Async function)
|
|
155
|
+
|
|
135
156
|
User-defined function to handle file uploads and return a hosted URL.
|
|
136
157
|
By default, the component handles images as base64, which may not be ideal for storage.
|
|
137
158
|
To avoid large payloads and for better performance, it's recommended to upload the file and return the hosted URL.
|
|
138
159
|
|
|
139
160
|
**Example:**
|
|
161
|
+
|
|
140
162
|
```js
|
|
141
163
|
uploadImageCallBack={async (file) => {
|
|
142
164
|
// Upload logic here
|
|
143
165
|
return 'https://yourcdn.com/uploaded-image.png';
|
|
144
166
|
}}
|
|
145
167
|
```
|
|
146
|
-
|
|
168
|
+
|
|
169
|
+
#### 6. `elementsList` (Array of elements)
|
|
170
|
+
|
|
147
171
|
An array of design elements to be rendered on the canvas by default.
|
|
148
172
|
If you pass an `elementsList`, the Studio will initialize with these elements already placed on the canvas.
|
|
149
173
|
|
|
150
174
|
**Example:**
|
|
175
|
+
|
|
151
176
|
```js
|
|
152
177
|
elementsList={[
|
|
153
178
|
{...},{...},{...}
|
|
154
179
|
]}
|
|
155
180
|
```
|
|
156
|
-
|
|
181
|
+
|
|
182
|
+
#### 7. `qrLink` (URL String)
|
|
183
|
+
|
|
157
184
|
A URL string used to generate a QR code element on the canvas.
|
|
158
185
|
When scanned, the QR will redirect to this link.
|
|
159
186
|
|
|
160
187
|
**Example:**
|
|
188
|
+
|
|
161
189
|
```js
|
|
162
190
|
qrLink={'https://somelink.com'}
|
|
163
191
|
```
|
|
164
|
-
|
|
192
|
+
|
|
193
|
+
#### 8. `disableWhiteLabel` (Boolean)
|
|
194
|
+
|
|
165
195
|
Boolean flag to hide the white-label (branding) section from the sidebar.
|
|
166
196
|
Set to `true` if you want to remove branding options from the sidebar.
|
|
167
197
|
|
|
168
198
|
**Example:**
|
|
199
|
+
|
|
169
200
|
```js
|
|
170
201
|
disableWhiteLabel={true}
|
|
171
202
|
```
|
|
172
|
-
|
|
203
|
+
|
|
204
|
+
#### 9. `title` (String)
|
|
205
|
+
|
|
173
206
|
Sets the title for the current template being edited in the Studio.
|
|
174
207
|
|
|
175
208
|
**Example:**
|
|
209
|
+
|
|
176
210
|
```js
|
|
177
211
|
title={'New Title'}
|
|
178
212
|
```
|
|
179
|
-
|
|
213
|
+
|
|
214
|
+
#### 10. `styleProps` (Object)
|
|
215
|
+
|
|
180
216
|
Use this to customize the styling of the Studio, including elements like the sidebar pills.
|
|
181
217
|
For example, by providing a `primaryColor`, you can change the color of the sidebar pills to match your branding color.
|
|
182
218
|
|
|
183
219
|
**Example:**
|
|
220
|
+
|
|
184
221
|
```js
|
|
185
222
|
styleProps={{
|
|
186
223
|
primaryColor: 'red',
|
|
187
224
|
}}
|
|
188
225
|
```
|
|
189
|
-
|
|
226
|
+
|
|
227
|
+
#### 11. `defaultText` (String)
|
|
228
|
+
|
|
190
229
|
Overrides the predefined text content in the text section of the Studio.
|
|
191
230
|
There is a list of predefined texts that can be added to the canvas by clicking on them, each with predefined fonts and styles.
|
|
192
231
|
By providing this prop, you can change the default content for these texts.
|
|
193
232
|
|
|
194
233
|
**Example:**
|
|
234
|
+
|
|
195
235
|
```js
|
|
196
236
|
defaultText={'Your Default Text'}
|
|
197
237
|
```
|
|
198
|
-
|
|
238
|
+
|
|
239
|
+
#### 12. `defaultQrLogo` (String)
|
|
240
|
+
|
|
241
|
+
Sets a default logo image to appear inside the QR code when the Studio loads.
|
|
242
|
+
|
|
243
|
+
**Example:**
|
|
244
|
+
|
|
245
|
+
```js
|
|
246
|
+
defaultQrLogo={'https://yourcdn.com/qr-logo.png'}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### 13. `onSave` (Async function)
|
|
250
|
+
|
|
199
251
|
By providing this function, a "Save" Call-to-Action (CTA) button will appear in the Studio.
|
|
200
252
|
When the user clicks on this button, the function will be executed, and you will receive the current design data.
|
|
201
253
|
This data includes an array of elements and the image of the canvas. You can then use this data as needed, such as storing the elements and image.
|
|
202
254
|
|
|
203
255
|
**Example:**
|
|
256
|
+
|
|
204
257
|
```js
|
|
205
258
|
onSave={async (data) => {
|
|
206
|
-
console.log('Saved data:', data);
|
|
259
|
+
console.log('Saved data:', data);
|
|
207
260
|
// { elements: [array of elements],image:canvas image }
|
|
208
261
|
// You can store this data or perform any actions you'd like
|
|
209
262
|
}}
|
|
210
263
|
```
|
|
211
|
-
|
|
264
|
+
|
|
265
|
+
#### 14. `saveButtonText` (String)
|
|
266
|
+
|
|
212
267
|
Overrides the text for the Call-to-Action (CTA) button that appears in the Studio.
|
|
213
268
|
|
|
214
269
|
**Example:**
|
|
270
|
+
|
|
215
271
|
```js
|
|
216
272
|
saveButtonText={'Save Progress'}
|
|
217
273
|
```
|
|
218
|
-
|
|
274
|
+
|
|
275
|
+
#### 15. `locale` (String)
|
|
276
|
+
|
|
219
277
|
Sets the locale for the Studio to provide multilingual support.
|
|
220
278
|
You can set the `locale` prop to one of the supported languages: `"fr"`, `"en"`, `"ru"`, `"pl"`, `"de"`, `"es"`, or `"it"`.
|
|
221
279
|
The default locale is `"en"`.
|
|
222
280
|
|
|
223
281
|
**Example:**
|
|
282
|
+
|
|
224
283
|
```js
|
|
225
284
|
locale={'fr'}
|
|
226
285
|
```
|
|
227
|
-
|
|
228
|
-
|
|
286
|
+
|
|
287
|
+
#### 16. `ref` (reference)
|
|
288
|
+
|
|
289
|
+
A reference to the `Studio` component.
|
|
290
|
+
|
|
229
291
|
```js
|
|
230
292
|
const studioRef = useRef();
|
|
231
293
|
|
|
232
294
|
<Studio
|
|
233
295
|
ref={studioRef}
|
|
234
296
|
...
|
|
235
|
-
/>
|
|
297
|
+
/>
|
|
236
298
|
```
|
|
237
|
-
|
|
299
|
+
|
|
300
|
+
You can access the following properties via `studioRef.current`:
|
|
301
|
+
|
|
302
|
+
- `onSave()` – Manually trigger the save operation and retrieve the updated elements and image of the canvas, along with any other data.
|
|
303
|
+
- `loading` – Get the current loading state (`boolean`).
|
|
304
|
+
- `setLoading(true | false)` – Programmatically set the loading state of Studio.
|
|
238
305
|
|
|
239
306
|
**Example:**
|
|
307
|
+
|
|
240
308
|
```js
|
|
309
|
+
const studioRef = useRef();
|
|
310
|
+
|
|
311
|
+
// Access loading state
|
|
312
|
+
const isLoading = studioRef?.current?.loading;
|
|
313
|
+
|
|
314
|
+
// Set loading state
|
|
315
|
+
studioRef?.current?.setLoading(true);
|
|
316
|
+
|
|
317
|
+
// Trigger save
|
|
241
318
|
const handleSave = async () => {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
319
|
+
const data = await studioRef?.current?.onSave();
|
|
320
|
+
console.log('Saved data:', data);
|
|
321
|
+
// { elements: [array of elements], image: canvas image }
|
|
245
322
|
};
|
|
246
323
|
```
|