@ydesign/react-editor 0.1.2 → 0.1.4
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 +20 -119
- package/dist/canvas/workspace.d.ts +1 -1
- package/dist/chunk-3PMUQSBH.js +1 -0
- package/dist/{chunk-RBRSKAZL.js → chunk-AMEXYVS6.js} +1 -1
- package/dist/{chunk-QALZ5CAJ.js → chunk-ICMV2HE4.js} +15 -15
- package/dist/{chunk-63A6RW6Y.js → chunk-OEMIP6LV.js} +1 -1
- package/dist/{chunk-WFMCGQ5V.js → chunk-Q7N7SBSC.js} +1 -1
- package/dist/chunk-VR4OXDJV.js +1 -0
- package/dist/chunk-W4AOHCPQ.js +1 -0
- package/dist/chunk-Y7XQELAM.js +151 -0
- package/dist/config.d.ts +2 -221
- package/dist/config.js +1 -1
- package/dist/model/store.d.ts +1 -1
- package/dist/model/store.js +1 -1
- package/dist/project.d.ts +15 -2
- package/dist/project.js +1 -1
- package/dist/side-panel/index.d.ts +1 -1
- package/dist/side-panel/index.js +1 -1
- package/dist/side-panel/side-panel.d.ts +1 -1
- package/dist/side-panel/side-panel.js +1 -1
- package/dist/{store-DfmY1m2j.d.ts → store-CgxwnT-h.d.ts} +3 -0
- package/dist/toolbar/download-button.d.ts +1 -1
- package/dist/toolbar/download-button.js +1 -1
- package/dist/toolbar/toolbar.d.ts +1 -1
- package/dist/toolbar/toolbar.js +3 -3
- package/dist/toolbar/zoom-buttons.d.ts +1 -1
- package/dist/topbar/create-design.d.ts +1 -1
- package/dist/topbar/create-design.js +1 -1
- package/dist/topbar/topbar.d.ts +1 -1
- package/dist/topbar/topbar.js +2 -2
- package/dist/utils/l10n.d.ts +228 -0
- package/dist/utils/l10n.js +1 -0
- package/package.json +2 -2
- package/dist/chunk-2AZQIJ4K.js +0 -1
- package/dist/chunk-6XGFXDKJ.js +0 -151
- package/dist/chunk-EUTDQZKU.js +0 -1
- package/dist/chunk-KERQXVBL.js +0 -1
package/dist/chunk-6XGFXDKJ.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import{a as I,c as ne}from"./chunk-2AZQIJ4K.js";import{a as L}from"./chunk-EWOU5F3O.js";import{b as G,c as B}from"./chunk-5C2MNUBC.js";import{a as te,b as ie,e as oe}from"./chunk-EUTDQZKU.js";import{Modal as Be,Button as Ue,ColorPicker as Te,InputNumber as re,Select as Me,Tooltip as le,App as Re,theme as De}from"antd";import{Grid2X2 as Le,Star as We,ShoppingBag as $e,FileText as Ae,Presentation as Ee,Share2 as _e,Printer as Fe,ImagePlus as He,FolderPlus as i,LockKeyholeOpen as Ve,LockKeyhole as je}from"lucide-react";import{useRef as Oe,useState as u,useMemo as ce,useCallback as T}from"react";import A from"styled-components";import{App as ke,Modal as Se,Upload as se}from"antd";import{Inbox as Ce}from"lucide-react";import{useRef as Pe,useState as Ne}from"react";import{jsx as a,jsxs as U}from"react/jsx-runtime";var{Dragger:Ie}=se,ae=({visible:S,onClose:E})=>{let{message:b,modal:_}=ke.useApp(),[h,C]=Ne(!1),x=Pe(null),F=ne();return a(Se,{width:750,title:"\u4E0A\u4F20 PSD \u6587\u4EF6",open:S,onCancel:()=>{if(h){b.warning("\u6587\u4EF6\u6B63\u5728\u89E3\u6790\u4E2D\uFF0C\u8BF7\u7A0D\u5019...");return}E()},footer:null,mask:{closable:!h},styles:{body:{height:"calc(100% - 40px)",padding:"10px 0 0 0"},container:{height:500}},centered:!0,children:a("div",{style:{height:"100%"},children:U(Ie,{...{name:"file-psd",multiple:!1,accept:".psd",showUploadList:!1,beforeUpload(r){return r.name.toLowerCase().endsWith(".psd")?!0:(b.error("\u4EC5\u652F\u6301 .psd \u683C\u5F0F\u6587\u4EF6"),se.LIST_IGNORE)},customRequest(r){let{file:n,onSuccess:p,onError:s,onProgress:f}=r;C(!0),x.current=b.loading("PSD \u6587\u4EF6\u89E3\u6790\u4E2D\uFF0C\u8BF7\u7A0D\u5019...",0);let c=new FormData;c.append("file",n),I.post(ie().url,c,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress(d){d.total&&f&&f({percent:Math.round(d.loaded/d.total*100)})}}).then(d=>{p?.(d)}).catch(d=>{s?.(d)})},async onChange(r){let{status:n}=r.file;if(console.log("info",r),n==="done"){x.current?.(),x.current=null,C(!1),b.success(`${r.file.name} \u89E3\u6790\u6210\u529F`);let p=r.file.response;console.log("PSD \u89E3\u6790\u7ED3\u679C:",p.result);let{thumbnailUrl:s,content:f,name:c,width:d,height:m,filename:V,parseUrl:v}=p.result,M={sourceResourcesId:crypto.randomUUID(),content:f,width:d,height:m,parseUrl:v,thumbnailUrl:s,filename:V,name:c};console.log("postRecord ---> ",M);let y=oe(M);console.log("postData",y);try{let w=await I.post(y.url,y.data);console.log("res ---> ",w.result);let j=w.result,P=`${F.urls.editorUrl}?id=${j.id}&type=record`;console.log("editUrl",P);let z=window.open(P,"_blank");(!z||z.closed)&&_.info({title:"\u5141\u8BB8\u663E\u793A\u5F39\u51FA\u7A97\u53E3",width:480,content:U("div",{style:{padding:"16px 0"},children:[a("p",{style:{marginBottom:8,color:"#666"},children:"\u4F60\u9700\u8981\u6388\u6743\u672C\u7AD9\u5728\u6D4F\u89C8\u5668\u6253\u5F00\u591A\u4E2A\u7A97\u53E3\u3002"}),U("div",{style:{marginBottom:12},children:[a("p",{children:a("b",{children:"\u7B2C1\u6B65"})}),a("p",{children:"\u70B9\u51FB\u6D4F\u89C8\u5668\u53F3\u4FA7\u9876\u90E8\u5F39\u51FA\u7684\u963B\u6B62\u7A0B\u5E8F\u56FE\u6807\u3002"})]}),U("div",{style:{marginBottom:12},children:[a("p",{children:a("b",{children:"\u7B2C2\u6B65"})}),a("p",{children:"\u70B9\u51FB\u59CB\u7EC8\u5141\u8BB8\u663E\u793A\u5F39\u51FA\u5F0F\u7A97\u53E3\u548C\u8FDB\u884C\u91CD\u5B9A\u5411\u3002"})]}),U("div",{style:{marginBottom:12},children:[a("p",{children:a("b",{children:"\u7B2C3\u6B65"})}),a("p",{children:"\u70B9\u51FB\u5B8C\u6210\u6309\u94AE\uFF0C\u5373\u53EF\u6B63\u5E38\u4F7F\u7528\u529F\u80FD\u5566~"})]})]}),okText:"\u6211\u77E5\u9053\u5566"})}catch(w){console.error(w)}}else if(n==="error"){x.current?.(),x.current=null,C(!1);let p=r.file.error?.message||"\u89E3\u6790\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";b.error(p)}}},disabled:h,children:[a("p",{className:"flex items-center justify-center",children:a(Ce,{size:60})}),a("p",{className:"ant-upload-text",children:h?"\u89E3\u6790\u4E2D...":"\u62D6\u62FD\u6587\u4EF6\u5230\u6B64\u5904\u4E0A\u4F20\u6216\u70B9\u51FB\u4E0A\u4F20"}),a("p",{className:"ant-upload-hint",children:a("a",{href:"https://www.yuque.com/meitumcp/vvtts5/gfv8e5",target:"_blank",onClick:r=>{r.stopPropagation()},children:"PSD\u6587\u4EF6\u5BFC\u5165\u89C4\u8303"})})]})})})};import{Fragment as Ze,jsx as e,jsxs as l}from"react/jsx-runtime";var Xe=[{key:"all",label:"\u5168\u90E8",icon:Le},{key:"common",label:"\u5E38\u7528\u5C3A\u5BF8",icon:We},{key:"ecommerce",label:"\u7535\u5546\u7269\u6599",icon:$e},{key:"office",label:"\u884C\u653F\u529E\u516C",icon:Ae},{key:"presentation",label:"\u6F14\u793A\u6587\u7A3F",icon:Ee},{key:"social",label:"\u793E\u4EA4\u5A92\u4F53",icon:_e},{key:"print",label:"\u5370\u5237\u7269\u6599",icon:Fe}],de=[{key:"common",label:"\u5E38\u7528\u5C3A\u5BF8",sizes:[{icon:e(i,{size:24}),name:"\u7535\u5546\u4E3B\u56FE\uFF081:1\uFF09",desc:"1440x1440px",width:1440,height:1440,unit:"px"},{icon:e(i,{size:24}),name:"\u7535\u5546\u4E3B\u56FE\uFF081:1\uFF09",desc:"800x800px",width:800,height:800,unit:"px"},{icon:e(i,{size:24}),name:"\u624B\u673A\u6D77\u62A5",desc:"1242x2208px",width:1242,height:2208,unit:"px"},{icon:e(i,{size:24}),name:"\u5C0F\u7EA2\u4E66\u5C01\u9762",desc:"1242x1656px",width:1242,height:1656,unit:"px"},{icon:e(i,{size:24}),name:"\u7AD6\u7248\u89C6\u9891\u5C01\u9762",desc:"1080x1920px",width:1080,height:1920,unit:"px"},{icon:e(i,{size:24}),name:"PPT\uFF0816:9\uFF09",desc:"1920x1080px",width:1920,height:1080,unit:"px"}]},{key:"ecommerce",label:"\u7535\u5546\u7269\u6599",sizes:[{icon:e(i,{size:24}),name:"\u7535\u5546\u4E3B\u56FE\uFF081:1\uFF09",desc:"1440x1440px",width:1440,height:1440,unit:"px"},{icon:e(i,{size:24}),name:"\u7535\u5546\u4E3B\u56FE\uFF081:1\uFF09",desc:"800x800px",width:800,height:800,unit:"px"},{icon:e(i,{size:24}),name:"\u7535\u5546\u4E3B\u56FE\uFF083:4\uFF09",desc:"1440x1920px",width:1440,height:1920,unit:"px"},{icon:e(i,{size:24}),name:"\u7535\u5546\u4E3B\u56FE\uFF083:4\uFF09",desc:"750x1000px",width:750,height:1e3,unit:"px"},{icon:e(i,{size:24}),name:"\u76F4\u64AD\u95F4\u80CC\u666F",desc:"1242x2690px",width:1242,height:2690,unit:"px"},{icon:e(i,{size:24}),name:"\u7535\u5546\u8BE6\u60C5\u9875",desc:"750x1000px",width:750,height:1e3,unit:"px"},{icon:e(i,{size:24}),name:"\u7535\u5546\u7AD6\u7248\u6D77\u62A5",desc:"1200x1920px",width:1200,height:1920,unit:"px"}]},{key:"office",label:"\u884C\u653F\u529E\u516C",sizes:[{icon:e(i,{size:24}),name:"\u7B80\u5386",desc:"2480x3507px",width:2480,height:3507,unit:"px"},{icon:e(i,{size:24}),name:"\u5DE5\u724C\u5DE5\u4F5C\u8BC1",desc:"709x1087px",width:709,height:1087,unit:"px"},{icon:e(i,{size:24}),name:"\u5956\u72B6\u8BC1\u4E66",desc:"3437x2550px",width:3437,height:2550,unit:"px"}]},{key:"presentation",label:"\u6F14\u793A\u6587\u7A3F",sizes:[{icon:e(i,{size:24}),name:"PPT\uFF0816:9\uFF09",desc:"1920x1080px",width:1920,height:1080,unit:"px"},{icon:e(i,{size:24}),name:"PPT\uFF084:3\uFF09",desc:"1024x768px",width:1024,height:768,unit:"px"}]},{key:"social",label:"\u793E\u4EA4\u5A92\u4F53",sizes:[{icon:e(i,{size:24}),name:"\u624B\u673A\u6D77\u62A5",desc:"1242x2208px",width:1242,height:2208,unit:"px"},{icon:e(i,{size:24}),name:"\u624B\u673A\u5168\u5C4F\u6D77\u62A5",desc:"1242x2688px",width:1242,height:2688,unit:"px"},{icon:e(i,{size:24}),name:"\u7AD6\u7248\u89C6\u9891\u5C01\u9762",desc:"1080x1920px",width:1080,height:1920,unit:"px"},{icon:e(i,{size:24}),name:"\u6A2A\u7248\u89C6\u9891\u5C01\u9762",desc:"1920x1080px",width:1920,height:1080,unit:"px"},{icon:e(i,{size:24}),name:"\u5C0F\u7EA2\u4E66\u5C01\u9762",desc:"1242x1656px",width:1242,height:1656,unit:"px"},{icon:e(i,{size:24}),name:"\u6296\u97F3\u56FE\u6587\u5E26\u8D27",desc:"1242x1656px",width:1242,height:1656,unit:"px"},{icon:e(i,{size:24}),name:"\u516C\u4F17\u53F7\u9996\u56FE",desc:"900x383px",width:900,height:383,unit:"px"},{icon:e(i,{size:24}),name:"\u516C\u4F17\u53F7\u6B21\u56FE",desc:"900x800px",width:900,height:800,unit:"px"},{icon:e(i,{size:24}),name:"\u957F\u56FE\u6D77\u62A5",desc:"800x2000px",width:800,height:2e3,unit:"px"}]},{key:"print",label:"\u5370\u5237\u7269\u6599",sizes:[{icon:e(i,{size:24}),name:"\u4E00\u5BF8\u8BC1\u4EF6\u7167",desc:"23x35mm",width:25,height:35,unit:"mm"},{icon:e(i,{size:24}),name:"\u4E8C\u5BF8\u8BC1\u4EF6\u7167",desc:"35x53mm",width:35,height:53,unit:"mm"},{icon:e(i,{size:24}),name:"1.8\u7C73\u5C55\u67B6",desc:"80x180cm",width:80,height:180,unit:"cm"},{icon:e(i,{size:24}),name:"2m\u6613\u62C9\u5B9D",desc:"80x200cm",width:80,height:200,unit:"cm"},{icon:e(i,{size:24}),name:"\u540D\u7247",desc:"96x60mm",width:96,height:60,unit:"mm"},{icon:e(i,{size:24}),name:"\u4F18\u60E0\u5238",desc:"186x66mm",width:186,height:66,unit:"mm"},{icon:e(i,{size:24}),name:"\u4F20\u5355",desc:"216x291cm",width:216,height:291,unit:"cm"}]}],pe=A.div`
|
|
2
|
-
padding: 16px 24px;
|
|
3
|
-
height: 60px;
|
|
4
|
-
flex: 1;
|
|
5
|
-
display: flex;
|
|
6
|
-
cursor: pointer;
|
|
7
|
-
align-items: center;
|
|
8
|
-
border-radius: 8px;
|
|
9
|
-
border: 1px dashed #d0d2d6;
|
|
10
|
-
&:hover {
|
|
11
|
-
background-color: rgba(0, 31, 92, 0.06);
|
|
12
|
-
}
|
|
13
|
-
span {
|
|
14
|
-
margin-left: 8px;
|
|
15
|
-
}
|
|
16
|
-
`,qe=A.div`
|
|
17
|
-
flex: 1;
|
|
18
|
-
margin-left: 14px;
|
|
19
|
-
height: 100%;
|
|
20
|
-
|
|
21
|
-
.createrContentInner {
|
|
22
|
-
margin-bottom: 16px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.scrollbars div:first-child {
|
|
26
|
-
scroll-behavior: smooth;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.Widget.categorySection[data-is-folded='false'] .categoryFoldBtn,
|
|
30
|
-
.Widget.categorySection[data-is-multi-row='false'] .categoryFoldBtn {
|
|
31
|
-
display: none;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.Widget.categorySection[data-is-folded='true'] ul {
|
|
35
|
-
height: 97px;
|
|
36
|
-
overflow: hidden;
|
|
37
|
-
}
|
|
38
|
-
`,Ge=A.div`
|
|
39
|
-
width: 100%;
|
|
40
|
-
height: 100%;
|
|
41
|
-
position: relative;
|
|
42
|
-
padding-top: 16px;
|
|
43
|
-
overflow: hidden;
|
|
44
|
-
|
|
45
|
-
display: flex;
|
|
46
|
-
flex-direction: column;
|
|
47
|
-
align-items: center;
|
|
48
|
-
|
|
49
|
-
border-radius: 8px;
|
|
50
|
-
background-color: rgba(0, 0, 0, 0.05);
|
|
51
|
-
|
|
52
|
-
.canvasSizeName {
|
|
53
|
-
color: #616366;
|
|
54
|
-
font-size: 12px;
|
|
55
|
-
font-weight: 600;
|
|
56
|
-
line-height: 16px;
|
|
57
|
-
margin-top: 8px;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.canvasSizeSize {
|
|
61
|
-
height: 14px;
|
|
62
|
-
overflow: hidden;
|
|
63
|
-
width: 100%;
|
|
64
|
-
margin-top: 4px;
|
|
65
|
-
|
|
66
|
-
span {
|
|
67
|
-
color: #abadb2;
|
|
68
|
-
display: block;
|
|
69
|
-
font-size: 20px;
|
|
70
|
-
font-weight: 400;
|
|
71
|
-
height: 200%;
|
|
72
|
-
line-height: 26px;
|
|
73
|
-
text-align: center;
|
|
74
|
-
-webkit-transform: scale(0.5);
|
|
75
|
-
transform: scale(0.5);
|
|
76
|
-
-webkit-transform-origin: top left;
|
|
77
|
-
transform-origin: top left;
|
|
78
|
-
width: 200%;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.canvasSizeMask {
|
|
83
|
-
background: rgba(0, 0, 0, 0.25);
|
|
84
|
-
display: none;
|
|
85
|
-
height: 100%;
|
|
86
|
-
left: 0;
|
|
87
|
-
position: absolute;
|
|
88
|
-
top: 0;
|
|
89
|
-
width: 100%;
|
|
90
|
-
}
|
|
91
|
-
.canvasSizeMask,
|
|
92
|
-
.canvasSizeMask button {
|
|
93
|
-
justify-content: center;
|
|
94
|
-
align-items: center;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.canvasSizeMask button {
|
|
98
|
-
background-color: #fff;
|
|
99
|
-
width: 66px;
|
|
100
|
-
height: 26px;
|
|
101
|
-
display: flex;
|
|
102
|
-
padding: 0 8px;
|
|
103
|
-
outline: none;
|
|
104
|
-
line-height: 16px;
|
|
105
|
-
font-size: 12px;
|
|
106
|
-
cursor: pointer;
|
|
107
|
-
color: #1c1d1f;
|
|
108
|
-
border-radius: 6px;
|
|
109
|
-
}
|
|
110
|
-
.canvasSizeMask button:active {
|
|
111
|
-
background-color: #f2f2f2;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
&:hover .canvasSizeMask {
|
|
115
|
-
display: flex;
|
|
116
|
-
}
|
|
117
|
-
`,Ke=A.div`
|
|
118
|
-
display: flex;
|
|
119
|
-
margin-top: 20px;
|
|
120
|
-
flex-wrap: wrap;
|
|
121
|
-
align-items: center;
|
|
122
|
-
position: relative;
|
|
123
|
-
|
|
124
|
-
.sizeWarning {
|
|
125
|
-
width: 100%;
|
|
126
|
-
margin-bottom: 8px;
|
|
127
|
-
padding: 4px 8px;
|
|
128
|
-
font-size: 12px;
|
|
129
|
-
color: #ff4d4f;
|
|
130
|
-
background-color: #fff2f0;
|
|
131
|
-
border: 1px solid #ffccc7;
|
|
132
|
-
border-radius: 4px;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.Widget.sizeInpueBox {
|
|
136
|
-
display: flex;
|
|
137
|
-
align-items: center;
|
|
138
|
-
|
|
139
|
-
flex: 1;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.Widget.sizeInpueBox .sizeInput {
|
|
143
|
-
flex: 1;
|
|
144
|
-
}
|
|
145
|
-
.Widget.sizeInpueBox .linkIcon {
|
|
146
|
-
padding: 8px;
|
|
147
|
-
background-color: #001f5c0f;
|
|
148
|
-
border-radius: 8px;
|
|
149
|
-
margin: 0 4px;
|
|
150
|
-
}
|
|
151
|
-
`,k=72,W=130,$=8e3,gt=({project:S,visible:E,onClose:b,onConfirm:_})=>{let{message:h,modal:C}=Re.useApp(),[x,F]=u("all"),H=Oe(null),{token:r}=De.useToken(),[n,p]=u(null),[s,f]=u(null),[c,d]=u("px"),[m,V]=u(!1),[v,M]=u(1),[y,w]=u("#ffffff"),[j,P]=u(!1),z=ce(()=>n?B({unitVal:n,dpi:k,unit:c}):0,[n,c]),O=ce(()=>s?B({unitVal:s,dpi:k,unit:c}):0,[s,c]),X=n!=null&&s!=null&&n>0&&s>0,R=X&&(z>$||O>$),D=X&&(z<W||O<W),q=!X||R||D,K=R?`\u8D85\u51FA\u753B\u5E03\u5C3A\u5BF8\u9650\u5236\uFF1A${$} * ${$} px`:D?`\u4F4E\u4E8E\u753B\u5E03\u5C3A\u5BF8\u9650\u5236\uFF1A${W} * ${W} px`:"",me=T(t=>{p(t),m&&t&&t>0&&f(Math.round(t/v))},[m,v]),he=T(t=>{f(t),m&&t&&t>0&&p(Math.round(t*v))},[m,v]),ge=T(()=>{!m&&n&&s&&n>0&&s>0&&M(n/s),V(t=>!t)},[m,n,s]),ue=T(t=>{if(n){let o=B({unitVal:n,dpi:k,unit:c});p(Math.round(G({px:o,dpi:k,unit:t,precious:0})))}if(s){let o=B({unitVal:s,dpi:k,unit:c});f(Math.round(G({px:o,dpi:k,unit:t,precious:0})))}d(t)},[n,s,c]),xe=T(()=>{if(q)return;let t=JSON.stringify({bg:{backgroundColor:y}}),o=new URLSearchParams({create:"",createEmptyPoster:"true",createInfo:t,height:String(s),unit:c,width:String(n)});console.log("params \u7684\u53C2\u6570 ---> ",o.toString()),console.log("project ",S.urls.editorUrl),window.open(`${S.urls.editorUrl}?${o.toString()}`,"_blank")},[q,y,O,z,c]),fe=t=>{F(t);let o=H.current;if(!o)return;let g=o.querySelector(`[data-category-id="${t}"]`);g&&o.scrollTo({top:g.offsetTop,behavior:"smooth"})},[ye,be]=u(()=>{let t={};return de.forEach(o=>{t[o.key]=o.sizes.length>6}),t});return l(Ze,{children:[l(Be,{title:"\u521B\u5EFA\u8BBE\u8BA1",open:E,onCancel:b,footer:null,width:880,mask:{closable:!1},styles:{body:{display:"flex",flex:1,padding:"20px 0",height:"100%"},container:{height:550}},children:[e("div",{className:"createrSideBar",style:{width:140,"--sidebar-active-bg":r.colorPrimaryBg,"--sidebar-hover-bg":r.colorPrimaryBgHover},children:Xe.map(t=>l("div",{"data-active":t.key===x,className:L("createrSideBarItem","flex h-[40px] px-2 mb-2 cursor-pointer rounded-md items-center hover:bg-[var(--sidebar-hover-bg)]",{"bg-[var(--sidebar-active-bg)] hover:bg-[var(--sidebar-active-bg)]":t.key===x}),onClick:()=>fe(t.key),children:[e(t.icon,{size:16,className:"ml-2"}),e("span",{className:"ml-2",children:t.label})]},t.key))}),e(qe,{children:e("div",{className:"scrollbars",style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e("div",{ref:H,style:{position:"absolute",inset:0,overflow:"scroll"},children:l("div",{className:"createrContentInner",children:[e("div",{"data-category-id":"all"}),l("div",{className:"openBtns flex",children:[l(pe,{onClick:()=>{let t=document.createElement("input");t.type="file",t.accept="image/*",t.onchange=async()=>{let o=t.files?.[0];if(o)try{h.loading("\u6B63\u5728\u4E0A\u4F20...",0);let g=te(),N=new FormData;N.append("file",o);let Z=await I.post(g.url,N,{headers:{"Content-Type":"multipart/form-data"}});console.log("res",Z);let{url:J,width:Q,height:Y}=Z.result;console.log("url",J,Q,Y);let ve=encodeURIComponent(encodeURIComponent(J)),we=new URLSearchParams({createEmptyPoster:"true",width:String(Q),height:String(Y),unit:"px"});h.destroy();let ze=`${S.urls.editorUrl}/?${we.toString()}&open=${ve}`,ee=window.open(ze,"_blank");(!ee||ee.closed)&&C.info({title:"\u5141\u8BB8\u663E\u793A\u5F39\u51FA\u7A97\u53E3",width:480,content:l("div",{style:{padding:"16px 0"},children:[e("p",{style:{marginBottom:8,color:"#666"},children:"\u4F60\u9700\u8981\u6388\u6743\u672C\u7AD9\u5728\u6D4F\u89C8\u5668\u6253\u5F00\u591A\u4E2A\u7A97\u53E3\u3002"}),l("div",{style:{marginBottom:12},children:[e("p",{children:e("b",{children:"\u7B2C1\u6B65"})}),e("p",{children:"\u70B9\u51FB\u6D4F\u89C8\u5668\u53F3\u4FA7\u9876\u90E8\u5F39\u51FA\u7684\u963B\u6B62\u7A0B\u5E8F\u56FE\u6807\u3002"})]}),l("div",{style:{marginBottom:12},children:[e("p",{children:e("b",{children:"\u7B2C2\u6B65"})}),e("p",{children:"\u70B9\u51FB\u59CB\u7EC8\u5141\u8BB8\u663E\u793A\u5F39\u51FA\u5F0F\u7A97\u53E3\u548C\u8FDB\u884C\u91CD\u5B9A\u5411\u3002"})]}),l("div",{style:{marginBottom:12},children:[e("p",{children:e("b",{children:"\u7B2C3\u6B65"})}),e("p",{children:"\u70B9\u51FB\u5B8C\u6210\u6309\u94AE\uFF0C\u5373\u53EF\u6B63\u5E38\u4F7F\u7528\u529F\u80FD\u5566~"})]})]}),okText:"\u6211\u77E5\u9053\u5566"})}catch(g){h.destroy();let N=g?.message||"\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";h.error(N),console.error("\u4E0A\u4F20\u5931\u8D25:",N,g)}},t.click()},children:[e(He,{style:{color:r.colorPrimary}}),e("span",{children:"\u6253\u5F00\u56FE\u7247"})]}),e(le,{title:"\u4EC5\u652F\u6301psd\u683C\u5F0F\u6587\u4EF6",children:l(pe,{style:{marginLeft:12},onClick:()=>{P(!0),console.log("\u70B9\u51FB")},children:[e(i,{style:{color:r.colorPrimary}}),e("span",{children:"\u6253\u5F00PSD"})]})})]}),de.map(t=>l("div",{className:L("Widget categorySection","mt-6"),"data-category-id":t.key,"data-is-folded":ye[t.key]??!1,"data-is-multi-row":t.sizes.length>6,children:[l("div",{className:L("categoryHeader","flex items-center justify-between"),children:[e("div",{className:"categoryTitle text-sm font-semibold",children:t.label}),e("div",{className:"categoryFoldBtn flex items-center cursor-pointer",onClick:()=>be(o=>({...o,[t.key]:!1})),children:e("span",{className:"text-[#616366]",children:"\u67E5\u770B\u66F4\u591A"})})]}),t.key==="common"&&l(Ke,{children:[K&&e("div",{className:"sizeWarning",children:K}),l("div",{className:"Widget sizeInpueBox",children:[e("div",{className:"sizeInput",children:e(re,{prefix:"\u5BBD",value:n,min:0,precision:0,status:R||D?"error":void 0,onChange:me,styles:{actions:{opacity:1,width:24}},style:{width:"100%"}})}),e(le,{title:m?"\u89E3\u9501\u6BD4\u4F8B":"\u9501\u5B9A\u6BD4\u4F8B",children:e("div",{className:"linkIcon",style:{cursor:"pointer"},onClick:ge,children:m?e(je,{size:16}):e(Ve,{size:16})})}),e("div",{className:"sizeInput",children:e(re,{prefix:"\u9AD8",value:s,min:0,precision:0,status:R||D?"error":void 0,onChange:he,styles:{actions:{opacity:1,width:24}},style:{width:"100%"}})}),e("div",{className:"sizeUnitSelect",style:{width:98,marginLeft:12},children:e(Me,{value:c,style:{width:98},onChange:ue,options:[{label:"px \u50CF\u7D20",value:"px"},{label:"cm \u5398\u7C73",value:"cm"},{label:"mm \u6BEB\u7C73",value:"mm"}]})})]}),e("div",{className:"widgets-color-picker",style:{width:98,marginLeft:12},children:e(Te,{mode:"single",format:"hex",value:y,onChange:o=>w(o.toHexString()),styles:{root:{width:98},body:{width:92}}})}),e(Ue,{type:"primary",disabled:q,style:{width:98,marginLeft:12},onClick:xe,children:"\u521B\u5EFA"})]}),e("ul",{className:"flex mt-4 flex-wrap gap-3",children:t.sizes.map((o,g)=>e("li",{style:{width:"calc((100% - 60px) / 6)",height:97},children:l(Ge,{children:[o.icon,e("div",{className:"canvasSizeName",children:o.name}),e("div",{className:"canvasSizeSize",children:e("span",{children:o.desc})}),e("div",{className:"canvasSizeMask",onClick:()=>{_({...o,bgColor:y})},children:e("button",{type:"button",children:"\u521B\u5EFA"})})]})},g))})]},t.key))]})})})})]}),e(ae,{visible:j,onClose:()=>P(!1)})]})};export{gt as a};
|
package/dist/chunk-EUTDQZKU.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var s="http://219.151.185.37:9003",a=`${s}/api`,e=()=>s+"/api",r={fontList:()=>({url:`${e()}/fonts`}),templateList:()=>({url:`${e()}/templates/list`}),templateDetail:t=>({url:`${e()}/templates/detail/${t}`}),uploadImage:()=>({url:`${e()}/images/upload`}),psdParse:()=>({url:`${e()}/psd/parser`}),createRecord:t=>({method:"POST",url:`${e()}/record`,data:t}),recordDetail:t=>({url:`${e()}/record/${t}`}),resourcesDetail:t=>({method:"POST",url:`${e()}/resources/detail`,data:{type:"template",id:t}})};var n=()=>r.uploadImage(),l=()=>r.psdParse(),p=t=>r.resourcesDetail(t),i=t=>r.recordDetail(t),c=t=>r.createRecord(t),u=(t,o)=>{r[t]=o};export{n as a,l as b,p as c,i as d,c as e,u as f};
|
package/dist/chunk-KERQXVBL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as l,c as g,d as m,e as p}from"./chunk-YBC2DYJX.js";import{types as a,cast as b,flow as f,destroy as h,getSnapshot as E,onSnapshot as x}from"mobx-state-tree";async function u(e,t){let o=document.createElement("a"),i=URL.createObjectURL(e);o.href=i,o.download=t,document.body.appendChild(o),o.click(),setTimeout(function(){document.body.removeChild(o),window.URL.revokeObjectURL(i)},0)}import{observable as j,toJS as S}from"mobx";import{isEqual as F}from"es-toolkit/compat";var s=(e,t)=>{if(e?.objects)for(let o of e.objects){if(t(o)===!0)break;s(o,t)}},k=a.model("Font",{fontFamily:a.string,name:a.optional(a.string,""),url:a.optional(a.string,""),img:a.optional(a.string,""),styles:a.frozen()}).preProcessSnapshot(e=>Object.assign(Object.assign({},e),{fontFamily:e.fontFamily||e.name})),O=a.model("Store",{name:"yitu-design",token:"",workspaceId:"",width:1080,height:1080,scale:1,scaleToFit:1,unit:"px",dpi:72,bleed:0,bleedVisible:!1,rulesVisible:!1,openedSidePanel:"",selectedElementsIds:a.array(a.string),backgroundColor:a.optional(a.union(a.string,a.frozen()),"#fff"),fonts:a.array(k),editor:a.frozen(null),custom:a.frozen(),objects:a.array(a.frozen()),_key:"",_updateTrigger:0,_updateFontSize:0}).views(e=>({get selectedElements(){let t=e._updateTrigger;return console.log("_trigger\u90FD\u53D8\u5316\u662F\u89E6\u53D1\u805A\u7126\u5143\u7D20\u7684\u5237\u65B0 ---> ",t),e.selectedElementsIds.map(o=>e.editor?.objectsHandler.findOneById(o))}})).views(e=>({get selectedShapes(){let t=[];return s({objects:e.selectedElements},o=>{o?.type!=="group"&&t.push(o)}),t},find(t){let o,i=e.editor?.customCanvas.canvas.getObjects();if(i)return s({objects:i},r=>{if(!o&&t(r))return o=r,!0}),o},getElementById(t){return e.editor?.objectsHandler.findOneById(t)}})).actions(e=>({_setEditor(t){e.editor=t},_triggerUpdate(){e._updateTrigger=e._updateTrigger+1},_fontSizeUpdate(){e._updateFontSize=e._updateFontSize+1},_syncBackgroundColor(t){e.backgroundColor=t}})).actions(e=>({setBackgroundColor(t,o){e.backgroundColor=t,e.editor?.workareaHandler.setWorkareaBgColor(t,o)},set(t,o){e.editor?.objectsHandler.update(t,o?.id)},setUnit({unit:t,dpi:o}){e.unit=t||e.unit,e.dpi=o||e.dpi},setObjects(t){e.objects=t},selectElements(t){e.selectedElementsIds=b(t)},openSidePanel(t){e.openedSidePanel!==t&&(e.openedSidePanel=t)},deleteElements(t){t.forEach(o=>{e.editor?.objectsHandler.remove(o)})},setScale(t){e.scale=t},clone(){e.editor?.objectsHandler.clone()},addElement(t,o){return console.log("\u6DFB\u52A0json\u6570\u636E",t),e.editor?.objectsHandler.addJson(t,o)},setSize({width:t,height:o}){e.width=t,e.height=o,e.editor?.workareaHandler.setSize({width:t,height:o})},setupEditorListeners(){e.editor&&(e.editor.on("object:modified",()=>{e._triggerUpdate()}),e.editor.on("textbox:modified",()=>{e._fontSizeUpdate()}),e.editor.on("history:changed",t=>{t?.backgroundColor!==void 0&&e._syncBackgroundColor(t.backgroundColor)}))}})).actions(e=>({_forEachElementUp(t,o){if(!e.editor)return;let i=e.editor.layerHandler.getEffectiveLayers(),r=t.map(n=>({id:n,index:i.findIndex(d=>d.id===n)}));r.sort((n,d)=>d.index-n.index);for(let{index:n}of r){if(n==-1)continue;let d=n<i.length-1&&i[n+1],c=t.indexOf(d?.id)>=0;n===i.length-1||c||o(n)}},_forEachElementDown(t,o){if(!e.editor)return;let i=e.editor.layerHandler.getEffectiveLayers(),r=t.map(n=>({id:n,index:i.findIndex(d=>d.id===n)}));r.sort((n,d)=>d.index-n.index);for(let{index:n}of r){if(n==-1)continue;let d=n>0&&i[n-1],c=t.indexOf(d?.id)>=0;n===0||c||o(n)}return!1}})).actions(e=>({canMoveElementsUp(t){let o=!1;return e._forEachElementUp(t,()=>{o=!0}),o},moveElementsUp(t){if(!e.editor)return;let o=e.editor.layerHandler.getEffectiveLayers();[...t].map(r=>({id:r,index:o.findIndex(n=>n.id===r)})).filter(r=>r.index!==-1).sort((r,n)=>n.index-r.index).map(r=>r.id).forEach(r=>{e.editor?.layerHandler.bringForward(r)}),e._triggerUpdate()},canMoveElementsTop(t){return this.canMoveElementsUp(t)},moveElementsTop(t){e.editor&&(t.forEach(o=>{e.editor?.layerHandler.bringToFront(o)}),e._triggerUpdate())},canMoveElementsDown(t){let o=!1;return e._forEachElementDown(t,()=>{o=!0}),o},moveElementsDown(t){if(!e.editor)return;let o=e.editor.layerHandler.getEffectiveLayers();[...t].map(r=>({id:r,index:o.findIndex(n=>n.id===r)})).filter(r=>r.index!==-1).sort((r,n)=>r.index-n.index).map(r=>r.id).forEach(r=>{e.editor?.layerHandler.sendBackwards(r)}),e._triggerUpdate()},canMoveElementsBottom(t){return this.canMoveElementsDown(t)},moveElementsBottom(t){e.editor&&(t.forEach(o=>{e.editor?.layerHandler.sendToBack(o)}),e._triggerUpdate())},setElementZIndex(){}})).actions(e=>({async toDataURL(t){return e.editor?.rendererHandler.toDataURL(t)},async toBlob(t){return e.editor?.rendererHandler.toBlob(t)},async saveAsImage(t){if(!e.editor)return;let{fileName:o,...i}=t||{multiplier:1},r=await e.editor.rendererHandler.toBlob(i);r&&u(r,o||"yitu."+i.format)},toJSON(){return e.editor?.rendererHandler.toJSON()},toObject(){return e.editor?.rendererHandler.toObject()},loadJSON:f(function*(t){if(!e.editor)return;let o=yield e.editor.sceneHandler.importFromJSON(t);o&&(e.width=o.width,e.height=o.height,e.backgroundColor=o.fill)}),clear(){}})).actions(e=>({removeFont(t){e.fonts.filter(o=>o.fontFamily===t).forEach(o=>{h(o)})},addFont(t){this.removeFont(t.fontFamily),e.fonts.push(t),this.loadFont(t.fontFamily)},async loadFont(t){let o=e.fonts.find(n=>n.fontFamily===t)||l.find(n=>n.fontFamily===t),r=[{fontStyle:"normal",fontWeight:"normal"},{fontStyle:"normal",fontWeight:"bold"}];return o?(o.styles&&(r=o.styles.map(n=>({fontStyle:n.fontStyle||"normal",fontWeight:n.fontWeight||"normal"}))),m(o)):p(t),Promise.all(r.map(n=>g(t,n.fontStyle,n.fontWeight)))}})).actions(e=>({on(t,o){if(t==="change"){let i=E(e.objects);return x(e.objects,r=>{let n=r;F(i,n)||(i=n,o(n))})}}})),y=j({token:"",workspaceId:""}),T=()=>S(y);function w({key:e,token:t,workspaceId:o}){return y={token:t??"",workspaceId:o??""},O.create({_key:e,token:t??"",workspaceId:o??""})}var z=w;export{s as a,k as b,O as c,T as d,w as e,z as f};
|