labellife-design-tool 1.2.1 → 1.2.3
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/dist/lib/lib/index.js
CHANGED
|
@@ -3120,19 +3120,12 @@ class SimpleCanvasStore {
|
|
|
3120
3120
|
name: initialDesign?.name || "Untitled Design",
|
|
3121
3121
|
width: initialDesign?.width || 800,
|
|
3122
3122
|
height: initialDesign?.height || 600,
|
|
3123
|
-
pages: initialDesign?.pages || [
|
|
3124
|
-
{
|
|
3125
|
-
id: "page-1",
|
|
3126
|
-
name: "Page 1",
|
|
3127
|
-
elements: [],
|
|
3128
|
-
background: "#ffffff"
|
|
3129
|
-
}
|
|
3130
|
-
],
|
|
3123
|
+
pages: initialDesign?.pages || [],
|
|
3131
3124
|
fonts: initialDesign?.fonts || [],
|
|
3132
3125
|
colors: initialDesign?.colors || [],
|
|
3133
3126
|
templateInputs: initialDesign?.templateInputs
|
|
3134
3127
|
};
|
|
3135
|
-
this._activePageId =
|
|
3128
|
+
this._activePageId = initialDesign?.pages?.[0]?.id || null;
|
|
3136
3129
|
this._activePanelId = null;
|
|
3137
3130
|
}
|
|
3138
3131
|
on(event, callback) {
|
|
@@ -3331,27 +3324,53 @@ var CanvasEditor = ({
|
|
|
3331
3324
|
width: 800,
|
|
3332
3325
|
height: 600
|
|
3333
3326
|
});
|
|
3334
|
-
const [design, setDesign] = useState3({
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3327
|
+
const [design, setDesign] = useState3(() => {
|
|
3328
|
+
if (externalStore) {
|
|
3329
|
+
return externalStore.design;
|
|
3330
|
+
}
|
|
3331
|
+
return {
|
|
3332
|
+
id: Date.now().toString(),
|
|
3333
|
+
name: "Untitled Design",
|
|
3334
|
+
width: 800,
|
|
3335
|
+
height: 600,
|
|
3336
|
+
pages: [
|
|
3337
|
+
{
|
|
3338
|
+
id: "1",
|
|
3339
|
+
name: "Page 1",
|
|
3340
|
+
elements: [],
|
|
3341
|
+
background: "#ffffff"
|
|
3342
|
+
}
|
|
3343
|
+
],
|
|
3344
|
+
fonts: FONT_FAMILIES,
|
|
3345
|
+
colors: DEFAULT_COLORS
|
|
3346
|
+
};
|
|
3349
3347
|
});
|
|
3350
|
-
const [currentPageId, setCurrentPageId] = useState3(
|
|
3348
|
+
const [currentPageId, setCurrentPageId] = useState3(() => externalStore?.activePageId || null);
|
|
3351
3349
|
const [selectedId, setSelectedId] = useState3(null);
|
|
3352
3350
|
const [selectedIds, setSelectedIds] = useState3([]);
|
|
3353
3351
|
const [tool, setTool] = useState3("select");
|
|
3354
3352
|
const [activePanelId, setActivePanelId] = useState3("elements");
|
|
3353
|
+
useEffect4(() => {
|
|
3354
|
+
if (externalStore) {
|
|
3355
|
+
const handleDesignChange = (newDesign) => {
|
|
3356
|
+
setDesign(newDesign);
|
|
3357
|
+
};
|
|
3358
|
+
const handleActivePageChange = (pageId) => {
|
|
3359
|
+
setCurrentPageId(pageId);
|
|
3360
|
+
};
|
|
3361
|
+
const handleActivePanelChange = (panelId) => {
|
|
3362
|
+
setActivePanelId(panelId || "elements");
|
|
3363
|
+
};
|
|
3364
|
+
externalStore.on("designChanged", handleDesignChange);
|
|
3365
|
+
externalStore.on("activePageChanged", handleActivePageChange);
|
|
3366
|
+
externalStore.on("activePanelChanged", handleActivePanelChange);
|
|
3367
|
+
return () => {
|
|
3368
|
+
externalStore.off("designChanged");
|
|
3369
|
+
externalStore.off("activePageChanged");
|
|
3370
|
+
externalStore.off("activePanelChanged");
|
|
3371
|
+
};
|
|
3372
|
+
}
|
|
3373
|
+
}, [externalStore]);
|
|
3355
3374
|
const [showUnsplash, setShowUnsplash] = useState3(false);
|
|
3356
3375
|
const [unsplashQuery, setUnsplashQuery] = useState3("");
|
|
3357
3376
|
const [unsplashResults, setUnsplashResults] = useState3([]);
|
|
@@ -3366,8 +3385,8 @@ var CanvasEditor = ({
|
|
|
3366
3385
|
const fileInputRef = useRef5(null);
|
|
3367
3386
|
const jsonInputRef = useRef5(null);
|
|
3368
3387
|
const containerRef = useRef5(null);
|
|
3369
|
-
const currentPage = design.pages.find((p) => p.id === currentPageId) || design.pages[0];
|
|
3370
|
-
const selectedElement = currentPage
|
|
3388
|
+
const currentPage = design.pages.find((p) => p.id === currentPageId) || design.pages[0] || null;
|
|
3389
|
+
const selectedElement = currentPage?.elements.find((el) => el.id === selectedId) || null;
|
|
3371
3390
|
const saveToHistory = useCallback4((newDesign) => {
|
|
3372
3391
|
const newHistory = history.slice(0, historyIndex + 1);
|
|
3373
3392
|
newHistory.push(JSON.parse(JSON.stringify(newDesign)));
|
|
@@ -3407,17 +3426,18 @@ var CanvasEditor = ({
|
|
|
3407
3426
|
textCase: "none",
|
|
3408
3427
|
strikethrough: false
|
|
3409
3428
|
};
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3429
|
+
const newDesign = {
|
|
3430
|
+
...design,
|
|
3431
|
+
pages: design.pages.map((page) => page.id === currentPageId ? { ...page, elements: [...page.elements, newElement] } : page)
|
|
3432
|
+
};
|
|
3433
|
+
setDesign(newDesign);
|
|
3434
|
+
saveToHistory(newDesign);
|
|
3435
|
+
if (externalStore) {
|
|
3436
|
+
externalStore.setDesign(newDesign);
|
|
3437
|
+
}
|
|
3418
3438
|
setSelectedId(newElement.id);
|
|
3419
3439
|
setTool("select");
|
|
3420
|
-
}, [currentPageId, saveToHistory, design.width, design.height]);
|
|
3440
|
+
}, [currentPageId, saveToHistory, design.width, design.height, externalStore]);
|
|
3421
3441
|
const addShape = useCallback4((shapeType) => {
|
|
3422
3442
|
const newElement = {
|
|
3423
3443
|
id: Date.now().toString(),
|
|
@@ -3976,7 +3996,7 @@ var CanvasEditor = ({
|
|
|
3976
3996
|
height: design.height,
|
|
3977
3997
|
onClick: handleStageClick,
|
|
3978
3998
|
onTap: handleStageClick
|
|
3979
|
-
}, /* @__PURE__ */ React18.createElement(Layer, null, /* @__PURE__ */ React18.createElement(Rect2, {
|
|
3999
|
+
}, /* @__PURE__ */ React18.createElement(Layer, null, currentPage && /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(Rect2, {
|
|
3980
4000
|
x: 0,
|
|
3981
4001
|
y: 0,
|
|
3982
4002
|
width: design.width,
|
|
@@ -4000,7 +4020,7 @@ var CanvasEditor = ({
|
|
|
4000
4020
|
default:
|
|
4001
4021
|
return null;
|
|
4002
4022
|
}
|
|
4003
|
-
}))))), config?.multiPage && /* @__PURE__ */ React18.createElement("div", {
|
|
4023
|
+
})))))), config?.multiPage && /* @__PURE__ */ React18.createElement("div", {
|
|
4004
4024
|
className: "absolute bottom-4 left-4 flex items-center space-x-2"
|
|
4005
4025
|
}, design.pages.map((page, index) => /* @__PURE__ */ React18.createElement("button", {
|
|
4006
4026
|
key: page.id,
|
package/dist/lib/wordpress.js
CHANGED
|
@@ -3120,19 +3120,12 @@ class SimpleCanvasStore {
|
|
|
3120
3120
|
name: initialDesign?.name || "Untitled Design",
|
|
3121
3121
|
width: initialDesign?.width || 800,
|
|
3122
3122
|
height: initialDesign?.height || 600,
|
|
3123
|
-
pages: initialDesign?.pages || [
|
|
3124
|
-
{
|
|
3125
|
-
id: "page-1",
|
|
3126
|
-
name: "Page 1",
|
|
3127
|
-
elements: [],
|
|
3128
|
-
background: "#ffffff"
|
|
3129
|
-
}
|
|
3130
|
-
],
|
|
3123
|
+
pages: initialDesign?.pages || [],
|
|
3131
3124
|
fonts: initialDesign?.fonts || [],
|
|
3132
3125
|
colors: initialDesign?.colors || [],
|
|
3133
3126
|
templateInputs: initialDesign?.templateInputs
|
|
3134
3127
|
};
|
|
3135
|
-
this._activePageId =
|
|
3128
|
+
this._activePageId = initialDesign?.pages?.[0]?.id || null;
|
|
3136
3129
|
this._activePanelId = null;
|
|
3137
3130
|
}
|
|
3138
3131
|
on(event, callback) {
|
|
@@ -3331,27 +3324,53 @@ var CanvasEditor = ({
|
|
|
3331
3324
|
width: 800,
|
|
3332
3325
|
height: 600
|
|
3333
3326
|
});
|
|
3334
|
-
const [design, setDesign] = useState3({
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3327
|
+
const [design, setDesign] = useState3(() => {
|
|
3328
|
+
if (externalStore) {
|
|
3329
|
+
return externalStore.design;
|
|
3330
|
+
}
|
|
3331
|
+
return {
|
|
3332
|
+
id: Date.now().toString(),
|
|
3333
|
+
name: "Untitled Design",
|
|
3334
|
+
width: 800,
|
|
3335
|
+
height: 600,
|
|
3336
|
+
pages: [
|
|
3337
|
+
{
|
|
3338
|
+
id: "1",
|
|
3339
|
+
name: "Page 1",
|
|
3340
|
+
elements: [],
|
|
3341
|
+
background: "#ffffff"
|
|
3342
|
+
}
|
|
3343
|
+
],
|
|
3344
|
+
fonts: FONT_FAMILIES,
|
|
3345
|
+
colors: DEFAULT_COLORS
|
|
3346
|
+
};
|
|
3349
3347
|
});
|
|
3350
|
-
const [currentPageId, setCurrentPageId] = useState3(
|
|
3348
|
+
const [currentPageId, setCurrentPageId] = useState3(() => externalStore?.activePageId || null);
|
|
3351
3349
|
const [selectedId, setSelectedId] = useState3(null);
|
|
3352
3350
|
const [selectedIds, setSelectedIds] = useState3([]);
|
|
3353
3351
|
const [tool, setTool] = useState3("select");
|
|
3354
3352
|
const [activePanelId, setActivePanelId] = useState3("elements");
|
|
3353
|
+
useEffect4(() => {
|
|
3354
|
+
if (externalStore) {
|
|
3355
|
+
const handleDesignChange = (newDesign) => {
|
|
3356
|
+
setDesign(newDesign);
|
|
3357
|
+
};
|
|
3358
|
+
const handleActivePageChange = (pageId) => {
|
|
3359
|
+
setCurrentPageId(pageId);
|
|
3360
|
+
};
|
|
3361
|
+
const handleActivePanelChange = (panelId) => {
|
|
3362
|
+
setActivePanelId(panelId || "elements");
|
|
3363
|
+
};
|
|
3364
|
+
externalStore.on("designChanged", handleDesignChange);
|
|
3365
|
+
externalStore.on("activePageChanged", handleActivePageChange);
|
|
3366
|
+
externalStore.on("activePanelChanged", handleActivePanelChange);
|
|
3367
|
+
return () => {
|
|
3368
|
+
externalStore.off("designChanged");
|
|
3369
|
+
externalStore.off("activePageChanged");
|
|
3370
|
+
externalStore.off("activePanelChanged");
|
|
3371
|
+
};
|
|
3372
|
+
}
|
|
3373
|
+
}, [externalStore]);
|
|
3355
3374
|
const [showUnsplash, setShowUnsplash] = useState3(false);
|
|
3356
3375
|
const [unsplashQuery, setUnsplashQuery] = useState3("");
|
|
3357
3376
|
const [unsplashResults, setUnsplashResults] = useState3([]);
|
|
@@ -3366,8 +3385,8 @@ var CanvasEditor = ({
|
|
|
3366
3385
|
const fileInputRef = useRef5(null);
|
|
3367
3386
|
const jsonInputRef = useRef5(null);
|
|
3368
3387
|
const containerRef = useRef5(null);
|
|
3369
|
-
const currentPage = design.pages.find((p) => p.id === currentPageId) || design.pages[0];
|
|
3370
|
-
const selectedElement = currentPage
|
|
3388
|
+
const currentPage = design.pages.find((p) => p.id === currentPageId) || design.pages[0] || null;
|
|
3389
|
+
const selectedElement = currentPage?.elements.find((el) => el.id === selectedId) || null;
|
|
3371
3390
|
const saveToHistory = useCallback4((newDesign) => {
|
|
3372
3391
|
const newHistory = history.slice(0, historyIndex + 1);
|
|
3373
3392
|
newHistory.push(JSON.parse(JSON.stringify(newDesign)));
|
|
@@ -3407,17 +3426,18 @@ var CanvasEditor = ({
|
|
|
3407
3426
|
textCase: "none",
|
|
3408
3427
|
strikethrough: false
|
|
3409
3428
|
};
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3429
|
+
const newDesign = {
|
|
3430
|
+
...design,
|
|
3431
|
+
pages: design.pages.map((page) => page.id === currentPageId ? { ...page, elements: [...page.elements, newElement] } : page)
|
|
3432
|
+
};
|
|
3433
|
+
setDesign(newDesign);
|
|
3434
|
+
saveToHistory(newDesign);
|
|
3435
|
+
if (externalStore) {
|
|
3436
|
+
externalStore.setDesign(newDesign);
|
|
3437
|
+
}
|
|
3418
3438
|
setSelectedId(newElement.id);
|
|
3419
3439
|
setTool("select");
|
|
3420
|
-
}, [currentPageId, saveToHistory, design.width, design.height]);
|
|
3440
|
+
}, [currentPageId, saveToHistory, design.width, design.height, externalStore]);
|
|
3421
3441
|
const addShape = useCallback4((shapeType) => {
|
|
3422
3442
|
const newElement = {
|
|
3423
3443
|
id: Date.now().toString(),
|
|
@@ -3976,7 +3996,7 @@ var CanvasEditor = ({
|
|
|
3976
3996
|
height: design.height,
|
|
3977
3997
|
onClick: handleStageClick,
|
|
3978
3998
|
onTap: handleStageClick
|
|
3979
|
-
}, /* @__PURE__ */ React18.createElement(Layer, null, /* @__PURE__ */ React18.createElement(Rect2, {
|
|
3999
|
+
}, /* @__PURE__ */ React18.createElement(Layer, null, currentPage && /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(Rect2, {
|
|
3980
4000
|
x: 0,
|
|
3981
4001
|
y: 0,
|
|
3982
4002
|
width: design.width,
|
|
@@ -4000,7 +4020,7 @@ var CanvasEditor = ({
|
|
|
4000
4020
|
default:
|
|
4001
4021
|
return null;
|
|
4002
4022
|
}
|
|
4003
|
-
}))))), config?.multiPage && /* @__PURE__ */ React18.createElement("div", {
|
|
4023
|
+
})))))), config?.multiPage && /* @__PURE__ */ React18.createElement("div", {
|
|
4004
4024
|
className: "absolute bottom-4 left-4 flex items-center space-x-2"
|
|
4005
4025
|
}, design.pages.map((page, index) => /* @__PURE__ */ React18.createElement("button", {
|
|
4006
4026
|
key: page.id,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Config
|
|
2
|
+
import { Config } from "./types/Config";
|
|
3
|
+
import { SimpleCanvasStore } from "./store/simpleStore";
|
|
3
4
|
declare const CanvasEditor: React.FC<{
|
|
4
5
|
name: string;
|
|
5
6
|
config?: Config;
|
|
6
|
-
store?:
|
|
7
|
+
store?: SimpleCanvasStore;
|
|
7
8
|
}>;
|
|
8
9
|
export default CanvasEditor;
|
|
9
10
|
//# sourceMappingURL=CanvasEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasEditor.d.ts","sourceRoot":"","sources":["../../src/CanvasEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6F,MAAM,OAAO,CAAC;AAkFlH,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"CanvasEditor.d.ts","sourceRoot":"","sources":["../../src/CanvasEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6F,MAAM,OAAO,CAAC;AAkFlH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAqB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE3E,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAAE,CA2hCxF,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleStore.d.ts","sourceRoot":"","sources":["../../../src/store/simpleStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;A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