labellife-design-tool 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 +97 -0
- package/dist/lib/lib/index.js +243 -146
- package/dist/lib/wordpress.js +243 -146
- package/dist/types/CanvasEditor.d.ts.map +1 -1
- package/dist/types/components/LeftMenu.d.ts.map +1 -1
- package/dist/types/lib/index.d.ts +1 -0
- package/dist/types/lib/index.d.ts.map +1 -1
- package/dist/types/types/Config.d.ts +22 -0
- package/dist/types/types/Config.d.ts.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -54,6 +54,103 @@ function App() {
|
|
|
54
54
|
|
|
55
55
|
**Note on CSS**: The CSS is pre-processed and ready to use. Simply import it - no Tailwind configuration needed!
|
|
56
56
|
|
|
57
|
+
### Panel Configuration (Built-in + Custom)
|
|
58
|
+
|
|
59
|
+
Control which panels appear in the left sidebar and their order using a **single list** via `config.panels`. You can mix built-in panel ids and custom panel objects in one array.
|
|
60
|
+
|
|
61
|
+
#### Available Built-in Panels
|
|
62
|
+
|
|
63
|
+
| Panel ID | Description |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `"text"` | Add and edit text elements |
|
|
66
|
+
| `"elements"` | Add shapes (rect, circle, star, polygon, etc.) |
|
|
67
|
+
| `"image"` | Upload images, use Unsplash, crop/mask/filter |
|
|
68
|
+
| `"design"` | Canvas size, presets, design settings |
|
|
69
|
+
| `"background"` | Page background color/image |
|
|
70
|
+
| `"export"` | Export to PNG/JPG/JSON (requires `config.export`) |
|
|
71
|
+
| `"variables"` | Template variables (requires `config.variables`) |
|
|
72
|
+
|
|
73
|
+
#### Show Only Selected Built-in Panels
|
|
74
|
+
|
|
75
|
+
Omit any panel id to hide it. The order you list them is the order they appear:
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
<CanvasEditor
|
|
79
|
+
name="Limited Editor"
|
|
80
|
+
config={{
|
|
81
|
+
panels: ["text", "elements", "image", "background"],
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
This hides Design, Export, and Variables — only Text, Elements, Images, and Background are shown.
|
|
87
|
+
|
|
88
|
+
#### Add a Custom Panel
|
|
89
|
+
|
|
90
|
+
Create your own panel component and include it in the same list:
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { Sparkles } from "lucide-react";
|
|
94
|
+
|
|
95
|
+
// Your custom panel component — receives whatever props you pass
|
|
96
|
+
const MyAssetsPanel = ({ category }: { category: string }) => {
|
|
97
|
+
return (
|
|
98
|
+
<div style={{ padding: 16, color: "white" }}>
|
|
99
|
+
<h3>My Assets</h3>
|
|
100
|
+
<p>Showing assets for: {category}</p>
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
function App() {
|
|
106
|
+
return (
|
|
107
|
+
<CanvasEditor
|
|
108
|
+
name="Custom Panel Editor"
|
|
109
|
+
config={{
|
|
110
|
+
export: { png: true, jpg: true, json: true },
|
|
111
|
+
panels: [
|
|
112
|
+
"text",
|
|
113
|
+
"elements",
|
|
114
|
+
{
|
|
115
|
+
id: "my-assets",
|
|
116
|
+
title: "My Assets",
|
|
117
|
+
tooltip: "Browse my assets",
|
|
118
|
+
icon: <Sparkles className="w-5 h-5" />,
|
|
119
|
+
component: MyAssetsPanel,
|
|
120
|
+
props: { category: "stickers" },
|
|
121
|
+
},
|
|
122
|
+
"image",
|
|
123
|
+
"background",
|
|
124
|
+
"export",
|
|
125
|
+
],
|
|
126
|
+
}}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Custom Panel Definition
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
interface CustomPanelDefinition {
|
|
136
|
+
id: string; // Unique panel id
|
|
137
|
+
title: string; // Panel title
|
|
138
|
+
tooltip?: string; // Tooltip on hover (defaults to title)
|
|
139
|
+
icon: React.ReactElement; // Icon shown in the left sidebar
|
|
140
|
+
component: React.ComponentType<any>; // Your panel React component
|
|
141
|
+
props?: Record<string, any>; // Props passed to your component
|
|
142
|
+
actionType?: "setPanel" | "setToolAndPanel"; // Click behavior (default: "setPanel")
|
|
143
|
+
toolValue?: ToolType; // Tool to activate (if actionType is "setToolAndPanel")
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### Default Behavior
|
|
148
|
+
|
|
149
|
+
If `config.panels` is **not provided**, the editor shows the default set:
|
|
150
|
+
- `text`, `elements`, `image`, `design`, `background`
|
|
151
|
+
- Plus `variables` if `config.variables` is set
|
|
152
|
+
- Plus `export` if `config.export` is set
|
|
153
|
+
|
|
57
154
|
### Configure Unsplash API Key
|
|
58
155
|
|
|
59
156
|
```tsx
|
package/dist/lib/lib/index.js
CHANGED
|
@@ -23,7 +23,7 @@ function initJsxCompat() {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// src/CanvasEditor.tsx
|
|
26
|
-
import React18, { useState as useState3, useRef as useRef5, useEffect as useEffect4, useCallback as useCallback4, forwardRef, useImperativeHandle } from "react";
|
|
26
|
+
import React18, { useState as useState3, useRef as useRef5, useEffect as useEffect4, useMemo, useCallback as useCallback4, forwardRef, useImperativeHandle } from "react";
|
|
27
27
|
import { Stage, Layer, Rect as Rect2 } from "react-konva";
|
|
28
28
|
import {
|
|
29
29
|
PlusCircle,
|
|
@@ -1092,7 +1092,97 @@ var Header_default = Header;
|
|
|
1092
1092
|
|
|
1093
1093
|
// src/components/LeftMenu.tsx
|
|
1094
1094
|
import React8 from "react";
|
|
1095
|
-
import {
|
|
1095
|
+
import {
|
|
1096
|
+
Type,
|
|
1097
|
+
Square,
|
|
1098
|
+
Image as ImageIcon,
|
|
1099
|
+
Palette,
|
|
1100
|
+
Download,
|
|
1101
|
+
Layers,
|
|
1102
|
+
Variable
|
|
1103
|
+
} from "lucide-react";
|
|
1104
|
+
var BUILT_IN_MENU_ITEMS = {
|
|
1105
|
+
text: {
|
|
1106
|
+
id: "text",
|
|
1107
|
+
tooltip: "Text",
|
|
1108
|
+
icon: /* @__PURE__ */ React8.createElement(Type, {
|
|
1109
|
+
className: "w-5 h-5"
|
|
1110
|
+
}),
|
|
1111
|
+
actionType: "setToolAndPanel",
|
|
1112
|
+
toolValue: "text",
|
|
1113
|
+
panelValue: "text"
|
|
1114
|
+
},
|
|
1115
|
+
elements: {
|
|
1116
|
+
id: "elements",
|
|
1117
|
+
tooltip: "Elements",
|
|
1118
|
+
icon: /* @__PURE__ */ React8.createElement(Square, {
|
|
1119
|
+
className: "w-5 h-5"
|
|
1120
|
+
}),
|
|
1121
|
+
actionType: "setToolAndPanel",
|
|
1122
|
+
panelValue: "elements",
|
|
1123
|
+
toolValue: "shape"
|
|
1124
|
+
},
|
|
1125
|
+
image: {
|
|
1126
|
+
id: "image",
|
|
1127
|
+
tooltip: "Images",
|
|
1128
|
+
icon: /* @__PURE__ */ React8.createElement(ImageIcon, {
|
|
1129
|
+
className: "w-5 h-5"
|
|
1130
|
+
}),
|
|
1131
|
+
actionType: "setPanel",
|
|
1132
|
+
panelValue: "image"
|
|
1133
|
+
},
|
|
1134
|
+
design: {
|
|
1135
|
+
id: "design",
|
|
1136
|
+
tooltip: "Design",
|
|
1137
|
+
icon: /* @__PURE__ */ React8.createElement(Palette, {
|
|
1138
|
+
className: "w-5 h-5"
|
|
1139
|
+
}),
|
|
1140
|
+
actionType: "setPanel",
|
|
1141
|
+
panelValue: "design"
|
|
1142
|
+
},
|
|
1143
|
+
background: {
|
|
1144
|
+
id: "background",
|
|
1145
|
+
tooltip: "Background",
|
|
1146
|
+
icon: /* @__PURE__ */ React8.createElement(Layers, {
|
|
1147
|
+
className: "w-5 h-5"
|
|
1148
|
+
}),
|
|
1149
|
+
actionType: "setPanel",
|
|
1150
|
+
panelValue: "background"
|
|
1151
|
+
},
|
|
1152
|
+
export: {
|
|
1153
|
+
id: "export",
|
|
1154
|
+
tooltip: "Export",
|
|
1155
|
+
icon: /* @__PURE__ */ React8.createElement(Download, {
|
|
1156
|
+
className: "w-5 h-5"
|
|
1157
|
+
}),
|
|
1158
|
+
actionType: "setPanel",
|
|
1159
|
+
panelValue: "export"
|
|
1160
|
+
},
|
|
1161
|
+
variables: {
|
|
1162
|
+
id: "variables",
|
|
1163
|
+
tooltip: "Variables",
|
|
1164
|
+
icon: /* @__PURE__ */ React8.createElement(Variable, {
|
|
1165
|
+
className: "w-5 h-5"
|
|
1166
|
+
}),
|
|
1167
|
+
actionType: "setPanel",
|
|
1168
|
+
panelValue: "variables"
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
var isCustomPanel = (panel) => typeof panel === "object" && panel !== null;
|
|
1172
|
+
var getDefaultPanelOrder = (config) => {
|
|
1173
|
+
const defaults = [
|
|
1174
|
+
"text",
|
|
1175
|
+
"elements",
|
|
1176
|
+
"image",
|
|
1177
|
+
"design",
|
|
1178
|
+
"background"
|
|
1179
|
+
];
|
|
1180
|
+
if (config?.variables)
|
|
1181
|
+
defaults.push("variables");
|
|
1182
|
+
if (config?.export)
|
|
1183
|
+
defaults.push("export");
|
|
1184
|
+
return defaults;
|
|
1185
|
+
};
|
|
1096
1186
|
var LeftMenu = ({
|
|
1097
1187
|
tool,
|
|
1098
1188
|
activePanel,
|
|
@@ -1100,77 +1190,32 @@ var LeftMenu = ({
|
|
|
1100
1190
|
onSetActivePanel,
|
|
1101
1191
|
config
|
|
1102
1192
|
}) => {
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
toolValue: "text",
|
|
1112
|
-
panelValue: "text"
|
|
1113
|
-
},
|
|
1114
|
-
{
|
|
1115
|
-
id: "elements",
|
|
1116
|
-
tooltip: "Elements",
|
|
1117
|
-
icon: /* @__PURE__ */ React8.createElement(Square, {
|
|
1118
|
-
className: "w-5 h-5"
|
|
1119
|
-
}),
|
|
1120
|
-
actionType: "setToolAndPanel",
|
|
1121
|
-
panelValue: "elements",
|
|
1122
|
-
toolValue: "shape"
|
|
1123
|
-
},
|
|
1124
|
-
{
|
|
1125
|
-
id: "image",
|
|
1126
|
-
tooltip: "Images",
|
|
1127
|
-
icon: /* @__PURE__ */ React8.createElement(ImageIcon, {
|
|
1128
|
-
className: "w-5 h-5"
|
|
1129
|
-
}),
|
|
1130
|
-
actionType: "setPanel",
|
|
1131
|
-
panelValue: "image"
|
|
1132
|
-
},
|
|
1133
|
-
{
|
|
1134
|
-
id: "design",
|
|
1135
|
-
tooltip: "Design",
|
|
1136
|
-
icon: /* @__PURE__ */ React8.createElement(Palette, {
|
|
1137
|
-
className: "w-5 h-5"
|
|
1138
|
-
}),
|
|
1139
|
-
actionType: "setPanel",
|
|
1140
|
-
panelValue: "design"
|
|
1193
|
+
const requestedPanels = config?.panels && config.panels.length > 0 ? config.panels : getDefaultPanelOrder(config);
|
|
1194
|
+
const seenIds = new Set;
|
|
1195
|
+
const menuItems = requestedPanels.map((panel) => {
|
|
1196
|
+
if (typeof panel === "string") {
|
|
1197
|
+
if (panel === "variables" && !config?.variables)
|
|
1198
|
+
return null;
|
|
1199
|
+
const builtIn = BUILT_IN_MENU_ITEMS[panel];
|
|
1200
|
+
return builtIn || null;
|
|
1141
1201
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
className: "w-5 h-5"
|
|
1159
|
-
}),
|
|
1160
|
-
actionType: "setPanel",
|
|
1161
|
-
panelValue: "background"
|
|
1202
|
+
if (isCustomPanel(panel)) {
|
|
1203
|
+
return {
|
|
1204
|
+
id: panel.id,
|
|
1205
|
+
tooltip: panel.tooltip || panel.title,
|
|
1206
|
+
icon: panel.icon,
|
|
1207
|
+
actionType: panel.actionType || "setPanel",
|
|
1208
|
+
toolValue: panel.toolValue,
|
|
1209
|
+
panelValue: panel.id
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
return null;
|
|
1213
|
+
}).filter((item) => !!item).filter((item) => {
|
|
1214
|
+
if (seenIds.has(item.id))
|
|
1215
|
+
return false;
|
|
1216
|
+
seenIds.add(item.id);
|
|
1217
|
+
return true;
|
|
1162
1218
|
});
|
|
1163
|
-
if (config?.variables) {
|
|
1164
|
-
menuItems.push({
|
|
1165
|
-
id: "variables",
|
|
1166
|
-
tooltip: "Variables",
|
|
1167
|
-
icon: /* @__PURE__ */ React8.createElement(Variable, {
|
|
1168
|
-
className: "w-5 h-5"
|
|
1169
|
-
}),
|
|
1170
|
-
actionType: "setPanel",
|
|
1171
|
-
panelValue: "variables"
|
|
1172
|
-
});
|
|
1173
|
-
}
|
|
1174
1219
|
const handleItemClick = (item) => {
|
|
1175
1220
|
if (item.actionType === "setTool" && item.toolValue) {
|
|
1176
1221
|
onSetTool(item.toolValue);
|
|
@@ -3566,73 +3611,73 @@ var CanvasEditor = forwardRef(({
|
|
|
3566
3611
|
delete window.__pendingImportReject;
|
|
3567
3612
|
}
|
|
3568
3613
|
};
|
|
3569
|
-
const panelConfigs =
|
|
3570
|
-
{
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
},
|
|
3587
|
-
{
|
|
3588
|
-
id: "image",
|
|
3589
|
-
title: "Images",
|
|
3590
|
-
component: ImagePanel_default,
|
|
3591
|
-
props: {
|
|
3592
|
-
selectedElement,
|
|
3593
|
-
updateElement,
|
|
3594
|
-
onUploadClick: () => fileInputRef.current?.click(),
|
|
3595
|
-
onUnsplashClick: () => {
|
|
3596
|
-
setShowUnsplash(true);
|
|
3597
|
-
setUnsplashMode("element");
|
|
3598
|
-
},
|
|
3599
|
-
canvasWidth: design.width,
|
|
3600
|
-
canvasHeight: design.height
|
|
3601
|
-
}
|
|
3602
|
-
},
|
|
3603
|
-
{
|
|
3604
|
-
id: "design",
|
|
3605
|
-
title: "Design",
|
|
3606
|
-
component: DesignPanel_default,
|
|
3607
|
-
props: {
|
|
3608
|
-
design,
|
|
3609
|
-
currentPage,
|
|
3610
|
-
selectedElement,
|
|
3611
|
-
setDesign,
|
|
3612
|
-
updateElement,
|
|
3613
|
-
onSetUnsplashBackground: () => {
|
|
3614
|
-
setShowUnsplash(true);
|
|
3615
|
-
setUnsplashMode("background");
|
|
3616
|
-
},
|
|
3617
|
-
config
|
|
3618
|
-
}
|
|
3619
|
-
},
|
|
3620
|
-
{
|
|
3621
|
-
id: "background",
|
|
3622
|
-
title: "Background",
|
|
3623
|
-
component: BackgroundPanel_default,
|
|
3624
|
-
props: {
|
|
3625
|
-
design,
|
|
3626
|
-
currentPage,
|
|
3627
|
-
setDesign,
|
|
3628
|
-
onSetUnsplashBackground: () => {
|
|
3629
|
-
setShowUnsplash(true);
|
|
3630
|
-
setUnsplashMode("background");
|
|
3614
|
+
const panelConfigs = useMemo(() => {
|
|
3615
|
+
const builtInConfigs = {
|
|
3616
|
+
elements: {
|
|
3617
|
+
id: "elements",
|
|
3618
|
+
title: "Elements",
|
|
3619
|
+
component: ElementPanel_default,
|
|
3620
|
+
props: { onAddShape: addShape }
|
|
3621
|
+
},
|
|
3622
|
+
text: {
|
|
3623
|
+
id: "text",
|
|
3624
|
+
title: "Text",
|
|
3625
|
+
component: TextPanel_default,
|
|
3626
|
+
props: {
|
|
3627
|
+
selectedElement,
|
|
3628
|
+
updateElement,
|
|
3629
|
+
setTool,
|
|
3630
|
+
onAddText: addText
|
|
3631
3631
|
}
|
|
3632
|
-
}
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3632
|
+
},
|
|
3633
|
+
image: {
|
|
3634
|
+
id: "image",
|
|
3635
|
+
title: "Images",
|
|
3636
|
+
component: ImagePanel_default,
|
|
3637
|
+
props: {
|
|
3638
|
+
selectedElement,
|
|
3639
|
+
updateElement,
|
|
3640
|
+
onUploadClick: () => fileInputRef.current?.click(),
|
|
3641
|
+
onUnsplashClick: () => {
|
|
3642
|
+
setShowUnsplash(true);
|
|
3643
|
+
setUnsplashMode("element");
|
|
3644
|
+
},
|
|
3645
|
+
canvasWidth: design.width,
|
|
3646
|
+
canvasHeight: design.height
|
|
3647
|
+
}
|
|
3648
|
+
},
|
|
3649
|
+
design: {
|
|
3650
|
+
id: "design",
|
|
3651
|
+
title: "Design",
|
|
3652
|
+
component: DesignPanel_default,
|
|
3653
|
+
props: {
|
|
3654
|
+
design,
|
|
3655
|
+
currentPage,
|
|
3656
|
+
selectedElement,
|
|
3657
|
+
setDesign,
|
|
3658
|
+
updateElement,
|
|
3659
|
+
onSetUnsplashBackground: () => {
|
|
3660
|
+
setShowUnsplash(true);
|
|
3661
|
+
setUnsplashMode("background");
|
|
3662
|
+
},
|
|
3663
|
+
config
|
|
3664
|
+
}
|
|
3665
|
+
},
|
|
3666
|
+
background: {
|
|
3667
|
+
id: "background",
|
|
3668
|
+
title: "Background",
|
|
3669
|
+
component: BackgroundPanel_default,
|
|
3670
|
+
props: {
|
|
3671
|
+
design,
|
|
3672
|
+
currentPage,
|
|
3673
|
+
setDesign,
|
|
3674
|
+
onSetUnsplashBackground: () => {
|
|
3675
|
+
setShowUnsplash(true);
|
|
3676
|
+
setUnsplashMode("background");
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
},
|
|
3680
|
+
variables: config?.variables ? {
|
|
3636
3681
|
id: "variables",
|
|
3637
3682
|
title: "Variables",
|
|
3638
3683
|
component: VariablesPanel_default,
|
|
@@ -3641,29 +3686,81 @@ var CanvasEditor = forwardRef(({
|
|
|
3641
3686
|
design,
|
|
3642
3687
|
setDesign
|
|
3643
3688
|
}
|
|
3644
|
-
}
|
|
3645
|
-
|
|
3646
|
-
...config?.export ? [
|
|
3647
|
-
{
|
|
3689
|
+
} : null,
|
|
3690
|
+
export: {
|
|
3648
3691
|
id: "export",
|
|
3649
3692
|
title: "Export",
|
|
3650
3693
|
component: ExportPanel_default,
|
|
3651
3694
|
props: {
|
|
3652
|
-
onExportToPNG: config
|
|
3695
|
+
onExportToPNG: config?.export?.png ? () => {
|
|
3653
3696
|
if (stageRef.current)
|
|
3654
3697
|
exportToPNG(stageRef.current, design);
|
|
3655
3698
|
} : undefined,
|
|
3656
|
-
onExportToJPG: config
|
|
3699
|
+
onExportToJPG: config?.export?.jpg ? () => {
|
|
3657
3700
|
if (stageRef.current)
|
|
3658
3701
|
exportToJPG(stageRef.current, design);
|
|
3659
3702
|
} : undefined,
|
|
3660
|
-
onExportToJSON: config
|
|
3703
|
+
onExportToJSON: config?.export?.json ? () => exportToJSON(design) : undefined,
|
|
3661
3704
|
onImportJSON: () => jsonInputRef.current?.click(),
|
|
3662
3705
|
onLoadJSON: () => setShowJsonModal(true)
|
|
3663
3706
|
}
|
|
3664
3707
|
}
|
|
3665
|
-
|
|
3666
|
-
|
|
3708
|
+
};
|
|
3709
|
+
const defaultPanels = [
|
|
3710
|
+
"text",
|
|
3711
|
+
"elements",
|
|
3712
|
+
"image",
|
|
3713
|
+
"design",
|
|
3714
|
+
"background",
|
|
3715
|
+
...config?.variables ? ["variables"] : [],
|
|
3716
|
+
...config?.export ? ["export"] : []
|
|
3717
|
+
];
|
|
3718
|
+
const requestedPanels = config?.panels && config.panels.length > 0 ? config.panels : defaultPanels;
|
|
3719
|
+
const seen = new Set;
|
|
3720
|
+
const ordered = [];
|
|
3721
|
+
requestedPanels.forEach((panel) => {
|
|
3722
|
+
if (typeof panel === "string") {
|
|
3723
|
+
const builtIn = builtInConfigs[panel];
|
|
3724
|
+
if (!builtIn)
|
|
3725
|
+
return;
|
|
3726
|
+
if (seen.has(builtIn.id))
|
|
3727
|
+
return;
|
|
3728
|
+
seen.add(builtIn.id);
|
|
3729
|
+
ordered.push(builtIn);
|
|
3730
|
+
return;
|
|
3731
|
+
}
|
|
3732
|
+
const custom = panel;
|
|
3733
|
+
if (!custom?.id || !custom?.component)
|
|
3734
|
+
return;
|
|
3735
|
+
if (seen.has(custom.id))
|
|
3736
|
+
return;
|
|
3737
|
+
seen.add(custom.id);
|
|
3738
|
+
ordered.push({
|
|
3739
|
+
id: custom.id,
|
|
3740
|
+
title: custom.title,
|
|
3741
|
+
component: custom.component,
|
|
3742
|
+
props: custom.props || {}
|
|
3743
|
+
});
|
|
3744
|
+
});
|
|
3745
|
+
return ordered;
|
|
3746
|
+
}, [
|
|
3747
|
+
addShape,
|
|
3748
|
+
addText,
|
|
3749
|
+
config,
|
|
3750
|
+
currentPage,
|
|
3751
|
+
design,
|
|
3752
|
+
selectedElement,
|
|
3753
|
+
setTool,
|
|
3754
|
+
updateElement
|
|
3755
|
+
]);
|
|
3756
|
+
useEffect4(() => {
|
|
3757
|
+
if (!panelConfigs.length)
|
|
3758
|
+
return;
|
|
3759
|
+
const exists = panelConfigs.some((panel) => panel.id === activePanelId);
|
|
3760
|
+
if (!exists) {
|
|
3761
|
+
setActivePanelId(panelConfigs[0].id);
|
|
3762
|
+
}
|
|
3763
|
+
}, [panelConfigs, activePanelId]);
|
|
3667
3764
|
const DynamicPanelRenderer = () => {
|
|
3668
3765
|
const activePanelConfig = panelConfigs.find((p) => p.id === activePanelId);
|
|
3669
3766
|
if (!activePanelConfig) {
|
package/dist/lib/wordpress.js
CHANGED
|
@@ -23,7 +23,7 @@ function initJsxCompat() {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// src/CanvasEditor.tsx
|
|
26
|
-
import React18, { useState as useState3, useRef as useRef5, useEffect as useEffect4, useCallback as useCallback4, forwardRef, useImperativeHandle } from "react";
|
|
26
|
+
import React18, { useState as useState3, useRef as useRef5, useEffect as useEffect4, useMemo, useCallback as useCallback4, forwardRef, useImperativeHandle } from "react";
|
|
27
27
|
import { Stage, Layer, Rect as Rect2 } from "react-konva";
|
|
28
28
|
import {
|
|
29
29
|
PlusCircle,
|
|
@@ -1092,7 +1092,97 @@ var Header_default = Header;
|
|
|
1092
1092
|
|
|
1093
1093
|
// src/components/LeftMenu.tsx
|
|
1094
1094
|
import React8 from "react";
|
|
1095
|
-
import {
|
|
1095
|
+
import {
|
|
1096
|
+
Type,
|
|
1097
|
+
Square,
|
|
1098
|
+
Image as ImageIcon,
|
|
1099
|
+
Palette,
|
|
1100
|
+
Download,
|
|
1101
|
+
Layers,
|
|
1102
|
+
Variable
|
|
1103
|
+
} from "lucide-react";
|
|
1104
|
+
var BUILT_IN_MENU_ITEMS = {
|
|
1105
|
+
text: {
|
|
1106
|
+
id: "text",
|
|
1107
|
+
tooltip: "Text",
|
|
1108
|
+
icon: /* @__PURE__ */ React8.createElement(Type, {
|
|
1109
|
+
className: "w-5 h-5"
|
|
1110
|
+
}),
|
|
1111
|
+
actionType: "setToolAndPanel",
|
|
1112
|
+
toolValue: "text",
|
|
1113
|
+
panelValue: "text"
|
|
1114
|
+
},
|
|
1115
|
+
elements: {
|
|
1116
|
+
id: "elements",
|
|
1117
|
+
tooltip: "Elements",
|
|
1118
|
+
icon: /* @__PURE__ */ React8.createElement(Square, {
|
|
1119
|
+
className: "w-5 h-5"
|
|
1120
|
+
}),
|
|
1121
|
+
actionType: "setToolAndPanel",
|
|
1122
|
+
panelValue: "elements",
|
|
1123
|
+
toolValue: "shape"
|
|
1124
|
+
},
|
|
1125
|
+
image: {
|
|
1126
|
+
id: "image",
|
|
1127
|
+
tooltip: "Images",
|
|
1128
|
+
icon: /* @__PURE__ */ React8.createElement(ImageIcon, {
|
|
1129
|
+
className: "w-5 h-5"
|
|
1130
|
+
}),
|
|
1131
|
+
actionType: "setPanel",
|
|
1132
|
+
panelValue: "image"
|
|
1133
|
+
},
|
|
1134
|
+
design: {
|
|
1135
|
+
id: "design",
|
|
1136
|
+
tooltip: "Design",
|
|
1137
|
+
icon: /* @__PURE__ */ React8.createElement(Palette, {
|
|
1138
|
+
className: "w-5 h-5"
|
|
1139
|
+
}),
|
|
1140
|
+
actionType: "setPanel",
|
|
1141
|
+
panelValue: "design"
|
|
1142
|
+
},
|
|
1143
|
+
background: {
|
|
1144
|
+
id: "background",
|
|
1145
|
+
tooltip: "Background",
|
|
1146
|
+
icon: /* @__PURE__ */ React8.createElement(Layers, {
|
|
1147
|
+
className: "w-5 h-5"
|
|
1148
|
+
}),
|
|
1149
|
+
actionType: "setPanel",
|
|
1150
|
+
panelValue: "background"
|
|
1151
|
+
},
|
|
1152
|
+
export: {
|
|
1153
|
+
id: "export",
|
|
1154
|
+
tooltip: "Export",
|
|
1155
|
+
icon: /* @__PURE__ */ React8.createElement(Download, {
|
|
1156
|
+
className: "w-5 h-5"
|
|
1157
|
+
}),
|
|
1158
|
+
actionType: "setPanel",
|
|
1159
|
+
panelValue: "export"
|
|
1160
|
+
},
|
|
1161
|
+
variables: {
|
|
1162
|
+
id: "variables",
|
|
1163
|
+
tooltip: "Variables",
|
|
1164
|
+
icon: /* @__PURE__ */ React8.createElement(Variable, {
|
|
1165
|
+
className: "w-5 h-5"
|
|
1166
|
+
}),
|
|
1167
|
+
actionType: "setPanel",
|
|
1168
|
+
panelValue: "variables"
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
var isCustomPanel = (panel) => typeof panel === "object" && panel !== null;
|
|
1172
|
+
var getDefaultPanelOrder = (config) => {
|
|
1173
|
+
const defaults = [
|
|
1174
|
+
"text",
|
|
1175
|
+
"elements",
|
|
1176
|
+
"image",
|
|
1177
|
+
"design",
|
|
1178
|
+
"background"
|
|
1179
|
+
];
|
|
1180
|
+
if (config?.variables)
|
|
1181
|
+
defaults.push("variables");
|
|
1182
|
+
if (config?.export)
|
|
1183
|
+
defaults.push("export");
|
|
1184
|
+
return defaults;
|
|
1185
|
+
};
|
|
1096
1186
|
var LeftMenu = ({
|
|
1097
1187
|
tool,
|
|
1098
1188
|
activePanel,
|
|
@@ -1100,77 +1190,32 @@ var LeftMenu = ({
|
|
|
1100
1190
|
onSetActivePanel,
|
|
1101
1191
|
config
|
|
1102
1192
|
}) => {
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
toolValue: "text",
|
|
1112
|
-
panelValue: "text"
|
|
1113
|
-
},
|
|
1114
|
-
{
|
|
1115
|
-
id: "elements",
|
|
1116
|
-
tooltip: "Elements",
|
|
1117
|
-
icon: /* @__PURE__ */ React8.createElement(Square, {
|
|
1118
|
-
className: "w-5 h-5"
|
|
1119
|
-
}),
|
|
1120
|
-
actionType: "setToolAndPanel",
|
|
1121
|
-
panelValue: "elements",
|
|
1122
|
-
toolValue: "shape"
|
|
1123
|
-
},
|
|
1124
|
-
{
|
|
1125
|
-
id: "image",
|
|
1126
|
-
tooltip: "Images",
|
|
1127
|
-
icon: /* @__PURE__ */ React8.createElement(ImageIcon, {
|
|
1128
|
-
className: "w-5 h-5"
|
|
1129
|
-
}),
|
|
1130
|
-
actionType: "setPanel",
|
|
1131
|
-
panelValue: "image"
|
|
1132
|
-
},
|
|
1133
|
-
{
|
|
1134
|
-
id: "design",
|
|
1135
|
-
tooltip: "Design",
|
|
1136
|
-
icon: /* @__PURE__ */ React8.createElement(Palette, {
|
|
1137
|
-
className: "w-5 h-5"
|
|
1138
|
-
}),
|
|
1139
|
-
actionType: "setPanel",
|
|
1140
|
-
panelValue: "design"
|
|
1193
|
+
const requestedPanels = config?.panels && config.panels.length > 0 ? config.panels : getDefaultPanelOrder(config);
|
|
1194
|
+
const seenIds = new Set;
|
|
1195
|
+
const menuItems = requestedPanels.map((panel) => {
|
|
1196
|
+
if (typeof panel === "string") {
|
|
1197
|
+
if (panel === "variables" && !config?.variables)
|
|
1198
|
+
return null;
|
|
1199
|
+
const builtIn = BUILT_IN_MENU_ITEMS[panel];
|
|
1200
|
+
return builtIn || null;
|
|
1141
1201
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
className: "w-5 h-5"
|
|
1159
|
-
}),
|
|
1160
|
-
actionType: "setPanel",
|
|
1161
|
-
panelValue: "background"
|
|
1202
|
+
if (isCustomPanel(panel)) {
|
|
1203
|
+
return {
|
|
1204
|
+
id: panel.id,
|
|
1205
|
+
tooltip: panel.tooltip || panel.title,
|
|
1206
|
+
icon: panel.icon,
|
|
1207
|
+
actionType: panel.actionType || "setPanel",
|
|
1208
|
+
toolValue: panel.toolValue,
|
|
1209
|
+
panelValue: panel.id
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
return null;
|
|
1213
|
+
}).filter((item) => !!item).filter((item) => {
|
|
1214
|
+
if (seenIds.has(item.id))
|
|
1215
|
+
return false;
|
|
1216
|
+
seenIds.add(item.id);
|
|
1217
|
+
return true;
|
|
1162
1218
|
});
|
|
1163
|
-
if (config?.variables) {
|
|
1164
|
-
menuItems.push({
|
|
1165
|
-
id: "variables",
|
|
1166
|
-
tooltip: "Variables",
|
|
1167
|
-
icon: /* @__PURE__ */ React8.createElement(Variable, {
|
|
1168
|
-
className: "w-5 h-5"
|
|
1169
|
-
}),
|
|
1170
|
-
actionType: "setPanel",
|
|
1171
|
-
panelValue: "variables"
|
|
1172
|
-
});
|
|
1173
|
-
}
|
|
1174
1219
|
const handleItemClick = (item) => {
|
|
1175
1220
|
if (item.actionType === "setTool" && item.toolValue) {
|
|
1176
1221
|
onSetTool(item.toolValue);
|
|
@@ -3566,73 +3611,73 @@ var CanvasEditor = forwardRef(({
|
|
|
3566
3611
|
delete window.__pendingImportReject;
|
|
3567
3612
|
}
|
|
3568
3613
|
};
|
|
3569
|
-
const panelConfigs =
|
|
3570
|
-
{
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
},
|
|
3587
|
-
{
|
|
3588
|
-
id: "image",
|
|
3589
|
-
title: "Images",
|
|
3590
|
-
component: ImagePanel_default,
|
|
3591
|
-
props: {
|
|
3592
|
-
selectedElement,
|
|
3593
|
-
updateElement,
|
|
3594
|
-
onUploadClick: () => fileInputRef.current?.click(),
|
|
3595
|
-
onUnsplashClick: () => {
|
|
3596
|
-
setShowUnsplash(true);
|
|
3597
|
-
setUnsplashMode("element");
|
|
3598
|
-
},
|
|
3599
|
-
canvasWidth: design.width,
|
|
3600
|
-
canvasHeight: design.height
|
|
3601
|
-
}
|
|
3602
|
-
},
|
|
3603
|
-
{
|
|
3604
|
-
id: "design",
|
|
3605
|
-
title: "Design",
|
|
3606
|
-
component: DesignPanel_default,
|
|
3607
|
-
props: {
|
|
3608
|
-
design,
|
|
3609
|
-
currentPage,
|
|
3610
|
-
selectedElement,
|
|
3611
|
-
setDesign,
|
|
3612
|
-
updateElement,
|
|
3613
|
-
onSetUnsplashBackground: () => {
|
|
3614
|
-
setShowUnsplash(true);
|
|
3615
|
-
setUnsplashMode("background");
|
|
3616
|
-
},
|
|
3617
|
-
config
|
|
3618
|
-
}
|
|
3619
|
-
},
|
|
3620
|
-
{
|
|
3621
|
-
id: "background",
|
|
3622
|
-
title: "Background",
|
|
3623
|
-
component: BackgroundPanel_default,
|
|
3624
|
-
props: {
|
|
3625
|
-
design,
|
|
3626
|
-
currentPage,
|
|
3627
|
-
setDesign,
|
|
3628
|
-
onSetUnsplashBackground: () => {
|
|
3629
|
-
setShowUnsplash(true);
|
|
3630
|
-
setUnsplashMode("background");
|
|
3614
|
+
const panelConfigs = useMemo(() => {
|
|
3615
|
+
const builtInConfigs = {
|
|
3616
|
+
elements: {
|
|
3617
|
+
id: "elements",
|
|
3618
|
+
title: "Elements",
|
|
3619
|
+
component: ElementPanel_default,
|
|
3620
|
+
props: { onAddShape: addShape }
|
|
3621
|
+
},
|
|
3622
|
+
text: {
|
|
3623
|
+
id: "text",
|
|
3624
|
+
title: "Text",
|
|
3625
|
+
component: TextPanel_default,
|
|
3626
|
+
props: {
|
|
3627
|
+
selectedElement,
|
|
3628
|
+
updateElement,
|
|
3629
|
+
setTool,
|
|
3630
|
+
onAddText: addText
|
|
3631
3631
|
}
|
|
3632
|
-
}
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3632
|
+
},
|
|
3633
|
+
image: {
|
|
3634
|
+
id: "image",
|
|
3635
|
+
title: "Images",
|
|
3636
|
+
component: ImagePanel_default,
|
|
3637
|
+
props: {
|
|
3638
|
+
selectedElement,
|
|
3639
|
+
updateElement,
|
|
3640
|
+
onUploadClick: () => fileInputRef.current?.click(),
|
|
3641
|
+
onUnsplashClick: () => {
|
|
3642
|
+
setShowUnsplash(true);
|
|
3643
|
+
setUnsplashMode("element");
|
|
3644
|
+
},
|
|
3645
|
+
canvasWidth: design.width,
|
|
3646
|
+
canvasHeight: design.height
|
|
3647
|
+
}
|
|
3648
|
+
},
|
|
3649
|
+
design: {
|
|
3650
|
+
id: "design",
|
|
3651
|
+
title: "Design",
|
|
3652
|
+
component: DesignPanel_default,
|
|
3653
|
+
props: {
|
|
3654
|
+
design,
|
|
3655
|
+
currentPage,
|
|
3656
|
+
selectedElement,
|
|
3657
|
+
setDesign,
|
|
3658
|
+
updateElement,
|
|
3659
|
+
onSetUnsplashBackground: () => {
|
|
3660
|
+
setShowUnsplash(true);
|
|
3661
|
+
setUnsplashMode("background");
|
|
3662
|
+
},
|
|
3663
|
+
config
|
|
3664
|
+
}
|
|
3665
|
+
},
|
|
3666
|
+
background: {
|
|
3667
|
+
id: "background",
|
|
3668
|
+
title: "Background",
|
|
3669
|
+
component: BackgroundPanel_default,
|
|
3670
|
+
props: {
|
|
3671
|
+
design,
|
|
3672
|
+
currentPage,
|
|
3673
|
+
setDesign,
|
|
3674
|
+
onSetUnsplashBackground: () => {
|
|
3675
|
+
setShowUnsplash(true);
|
|
3676
|
+
setUnsplashMode("background");
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
},
|
|
3680
|
+
variables: config?.variables ? {
|
|
3636
3681
|
id: "variables",
|
|
3637
3682
|
title: "Variables",
|
|
3638
3683
|
component: VariablesPanel_default,
|
|
@@ -3641,29 +3686,81 @@ var CanvasEditor = forwardRef(({
|
|
|
3641
3686
|
design,
|
|
3642
3687
|
setDesign
|
|
3643
3688
|
}
|
|
3644
|
-
}
|
|
3645
|
-
|
|
3646
|
-
...config?.export ? [
|
|
3647
|
-
{
|
|
3689
|
+
} : null,
|
|
3690
|
+
export: {
|
|
3648
3691
|
id: "export",
|
|
3649
3692
|
title: "Export",
|
|
3650
3693
|
component: ExportPanel_default,
|
|
3651
3694
|
props: {
|
|
3652
|
-
onExportToPNG: config
|
|
3695
|
+
onExportToPNG: config?.export?.png ? () => {
|
|
3653
3696
|
if (stageRef.current)
|
|
3654
3697
|
exportToPNG(stageRef.current, design);
|
|
3655
3698
|
} : undefined,
|
|
3656
|
-
onExportToJPG: config
|
|
3699
|
+
onExportToJPG: config?.export?.jpg ? () => {
|
|
3657
3700
|
if (stageRef.current)
|
|
3658
3701
|
exportToJPG(stageRef.current, design);
|
|
3659
3702
|
} : undefined,
|
|
3660
|
-
onExportToJSON: config
|
|
3703
|
+
onExportToJSON: config?.export?.json ? () => exportToJSON(design) : undefined,
|
|
3661
3704
|
onImportJSON: () => jsonInputRef.current?.click(),
|
|
3662
3705
|
onLoadJSON: () => setShowJsonModal(true)
|
|
3663
3706
|
}
|
|
3664
3707
|
}
|
|
3665
|
-
|
|
3666
|
-
|
|
3708
|
+
};
|
|
3709
|
+
const defaultPanels = [
|
|
3710
|
+
"text",
|
|
3711
|
+
"elements",
|
|
3712
|
+
"image",
|
|
3713
|
+
"design",
|
|
3714
|
+
"background",
|
|
3715
|
+
...config?.variables ? ["variables"] : [],
|
|
3716
|
+
...config?.export ? ["export"] : []
|
|
3717
|
+
];
|
|
3718
|
+
const requestedPanels = config?.panels && config.panels.length > 0 ? config.panels : defaultPanels;
|
|
3719
|
+
const seen = new Set;
|
|
3720
|
+
const ordered = [];
|
|
3721
|
+
requestedPanels.forEach((panel) => {
|
|
3722
|
+
if (typeof panel === "string") {
|
|
3723
|
+
const builtIn = builtInConfigs[panel];
|
|
3724
|
+
if (!builtIn)
|
|
3725
|
+
return;
|
|
3726
|
+
if (seen.has(builtIn.id))
|
|
3727
|
+
return;
|
|
3728
|
+
seen.add(builtIn.id);
|
|
3729
|
+
ordered.push(builtIn);
|
|
3730
|
+
return;
|
|
3731
|
+
}
|
|
3732
|
+
const custom = panel;
|
|
3733
|
+
if (!custom?.id || !custom?.component)
|
|
3734
|
+
return;
|
|
3735
|
+
if (seen.has(custom.id))
|
|
3736
|
+
return;
|
|
3737
|
+
seen.add(custom.id);
|
|
3738
|
+
ordered.push({
|
|
3739
|
+
id: custom.id,
|
|
3740
|
+
title: custom.title,
|
|
3741
|
+
component: custom.component,
|
|
3742
|
+
props: custom.props || {}
|
|
3743
|
+
});
|
|
3744
|
+
});
|
|
3745
|
+
return ordered;
|
|
3746
|
+
}, [
|
|
3747
|
+
addShape,
|
|
3748
|
+
addText,
|
|
3749
|
+
config,
|
|
3750
|
+
currentPage,
|
|
3751
|
+
design,
|
|
3752
|
+
selectedElement,
|
|
3753
|
+
setTool,
|
|
3754
|
+
updateElement
|
|
3755
|
+
]);
|
|
3756
|
+
useEffect4(() => {
|
|
3757
|
+
if (!panelConfigs.length)
|
|
3758
|
+
return;
|
|
3759
|
+
const exists = panelConfigs.some((panel) => panel.id === activePanelId);
|
|
3760
|
+
if (!exists) {
|
|
3761
|
+
setActivePanelId(panelConfigs[0].id);
|
|
3762
|
+
}
|
|
3763
|
+
}, [panelConfigs, activePanelId]);
|
|
3667
3764
|
const DynamicPanelRenderer = () => {
|
|
3668
3765
|
const activePanelConfig = panelConfigs.find((p) => p.id === activePanelId);
|
|
3669
3766
|
if (!activePanelConfig) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasEditor.d.ts","sourceRoot":"","sources":["../../src/CanvasEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CanvasEditor.d.ts","sourceRoot":"","sources":["../../src/CanvasEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6F,MAAM,OAAO,CAAC;AAGlH,OAAO,KAAK,MAAM,OAAO,CAAC;AA0C1B,OAAO,EAEL,YAAY,EAKb,MAAM,SAAS,CAAC;AAiCjB,OAAO,EAAkB,MAAM,EAA0C,MAAM,gBAAgB,CAAC;AAGhG,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,YAAY,CAAC;IAC9B,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACxD;AAED,QAAA,MAAM,YAAY;UAAuC,MAAM;aAAW,MAAM;yCAguC9E,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeftMenu.d.ts","sourceRoot":"","sources":["../../../src/components/LeftMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LeftMenu.d.ts","sourceRoot":"","sources":["../../../src/components/LeftMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAEL,MAAM,EAGP,MAAM,iBAAiB,CAAC;AAWzB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,aAAa,CAAC;IAC3B,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACpC,gBAAgB,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA2ED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA2F5C,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -15,6 +15,7 @@ export interface CanvasEditorRef {
|
|
|
15
15
|
}
|
|
16
16
|
export { default as CanvasEditor } from '../CanvasEditor';
|
|
17
17
|
export * from '../types';
|
|
18
|
+
export type { BuiltInPanelId, CustomPanelDefinition, PanelDefinition, } from '../types/Config';
|
|
18
19
|
export { exportToPNG, exportToJPG, exportToJSON, exportToJSONObject, importFromJSON, importFromJSONData, // Import JSON data directly (no file needed)
|
|
19
20
|
loadTemplateFromJSON, // Simplified template loading utility
|
|
20
21
|
findRequiredInputs, replaceUserInputs, convertTemplateToCanvasDesign, canvasToDataURL, canvasToBlob, } from '../utils/exportImportUtils';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AASxC,MAAM,W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,SAAS,EAAE,MAAM,YAAY,CAAC;IAC9B,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,UAAU,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAGD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG1D,cAAc,UAAU,CAAC;AAGzB,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAAE,6CAA6C;AACjE,oBAAoB,EAAE,sCAAsC;AAC5D,kBAAkB,EAClB,iBAAiB,EACjB,6BAA6B,EAC7B,eAAe,EACf,YAAY,GACb,MAAM,4BAA4B,CAAC;AAGpC,cAAc,aAAa,CAAC;AAG5B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG7E,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ToolType } from "./ToolType";
|
|
3
|
+
export type BuiltInPanelId = "elements" | "design" | "text" | "image" | "background" | "export" | "variables";
|
|
4
|
+
export interface CustomPanelDefinition {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
tooltip?: string;
|
|
8
|
+
icon: React.ReactElement<React.ComponentProps<any>>;
|
|
9
|
+
component: React.ComponentType<any>;
|
|
10
|
+
props?: Record<string, any>;
|
|
11
|
+
actionType?: "setPanel" | "setToolAndPanel";
|
|
12
|
+
toolValue?: ToolType;
|
|
13
|
+
}
|
|
14
|
+
export type PanelDefinition = BuiltInPanelId | CustomPanelDefinition;
|
|
1
15
|
export interface NavbarSection {
|
|
2
16
|
id: string;
|
|
3
17
|
type: 'default' | 'custom';
|
|
@@ -36,5 +50,13 @@ export interface Config {
|
|
|
36
50
|
variable: string;
|
|
37
51
|
}[];
|
|
38
52
|
navbar?: NavbarConfig;
|
|
53
|
+
/**
|
|
54
|
+
* Single source of truth for left-panel order/visibility and custom panels.
|
|
55
|
+
*
|
|
56
|
+
* Built-in panel ids: "text", "elements", "image", "design", "background", "export", "variables"
|
|
57
|
+
* Custom panel objects can be mixed in this same list.
|
|
58
|
+
* If not provided, defaults to all built-in panels.
|
|
59
|
+
*/
|
|
60
|
+
panels?: PanelDefinition[];
|
|
39
61
|
}
|
|
40
62
|
//# sourceMappingURL=Config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../../src/types/Config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACtC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IAEjC,eAAe,CAAC,EAAE;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAA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AM,GAAG,OAAO,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;KAClB,EAAE,CAAC;IACJ,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;CAC5B"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "labellife-design-tool",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Professional canvas editor built with React, TypeScript, and Konva",
|
|
5
|
-
"main": "./dist/lib/index.js",
|
|
6
|
-
"module": "./dist/lib/index.js",
|
|
7
|
-
"types": "./dist/lib/index.d.ts",
|
|
5
|
+
"main": "./dist/lib/lib/index.js",
|
|
6
|
+
"module": "./dist/lib/lib/index.js",
|
|
7
|
+
"types": "./dist/lib/lib/index.d.ts",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"import": "./dist/lib/index.js",
|
|
12
|
-
"types": "./dist/lib/index.d.ts"
|
|
11
|
+
"import": "./dist/lib/lib/index.js",
|
|
12
|
+
"types": "./dist/lib/lib/index.d.ts"
|
|
13
13
|
},
|
|
14
14
|
"./wordpress": {
|
|
15
15
|
"import": "./dist/lib/wordpress.js",
|