@ydesign/react-editor 0.1.1 → 0.1.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/README.md +20 -119
- package/dist/canvas/workspace.d.ts +1 -1
- package/dist/chunk-3PMUQSBH.js +1 -0
- package/dist/chunk-3UOBPTKL.js +151 -0
- package/dist/{chunk-RBRSKAZL.js → chunk-AMEXYVS6.js} +1 -1
- package/dist/chunk-C4XMVZO4.js +1 -0
- package/dist/chunk-OV7AL42Z.js +1 -0
- package/dist/{chunk-WFMCGQ5V.js → chunk-Q7N7SBSC.js} +1 -1
- package/dist/{chunk-SR5OYO6O.js → chunk-SEZLO2OE.js} +15 -15
- package/dist/{chunk-63A6RW6Y.js → chunk-VIU27HHW.js} +1 -1
- 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 +11 -1
- 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 +28 -0
- package/dist/topbar/create-design.js +1 -0
- package/dist/topbar/topbar.d.ts +1 -1
- package/dist/topbar/topbar.js +5 -155
- 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-EUTDQZKU.js +0 -1
- package/dist/chunk-KERQXVBL.js +0 -1
package/README.md
CHANGED
|
@@ -1,129 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Ydesign
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
https://ydesign.com/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
JS framework for making your own canva-like design editors.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- [ ] 快捷键
|
|
9
|
-
- [ ] 右键菜单
|
|
10
|
-
- [ ] 导入PSD
|
|
11
|
-
- [ ] 导入AI文件
|
|
12
|
-
- [ ] 导入PDF
|
|
13
|
-
- [ ] 导入JSON数据
|
|
14
|
-
- [ ] 导出文件(SVG、jpg、png、PDF)
|
|
15
|
-
- [ ] 整个画布导出
|
|
16
|
-
- [ ] 指定元素导出
|
|
17
|
-
- [ ] 图层管理
|
|
18
|
-
- [ ] mock数据加载设置
|
|
7
|
+
## Install
|
|
19
8
|
|
|
20
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install @ydesign/react-editor
|
|
11
|
+
```
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
- [ ] 画布尺寸调整控件(画布外框的控件)
|
|
24
|
-
- [ ] 标尺
|
|
25
|
-
- [x] 画布缩放
|
|
26
|
-
- [ ] 画布移动(注意面板变化时的改动)
|
|
27
|
-
- [ ] 多画布编辑(待设计)
|
|
13
|
+
## Demo app
|
|
28
14
|
|
|
29
|
-
|
|
15
|
+
```js
|
|
16
|
+
import { createDemoApp } from '@ydesign/react-editor/ydesign-app';
|
|
30
17
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
- [ ] 元素透明度
|
|
37
|
-
- [ ] 元素吸附对齐(移动和缩放)
|
|
38
|
-
- [ ] 元素层级顺序调整
|
|
39
|
-
- [ ] 元素对齐
|
|
40
|
-
- [ ] 元素位置
|
|
18
|
+
const { store } = createDemoApp({
|
|
19
|
+
container: document.getElementById('root'),
|
|
20
|
+
key: 'YOUR_API_KEY', // you can create it here: https://ydesign.com/cabinet/
|
|
21
|
+
});
|
|
22
|
+
```
|
|
41
23
|
|
|
42
|
-
##
|
|
24
|
+
## License
|
|
43
25
|
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- [ ] 段间距
|
|
48
|
-
- [ ] 填充色
|
|
49
|
-
- [ ] 阴影
|
|
50
|
-
- [ ] 字体切换
|
|
51
|
-
- [ ] 文本边框(内边框,外边框)
|
|
52
|
-
- [ ] 边框样式()
|
|
26
|
+
1. You can use this package for free for non-commercial products and local development process.
|
|
27
|
+
2. For commercial usage you have to buy a licence here: https://ydesign.com/
|
|
28
|
+
3. Please respect the copyright.
|
|
53
29
|
|
|
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
|
-
## 其他工具
|
|
81
|
-
|
|
82
|
-
- [ ] 二维码工具
|
|
83
|
-
- [ ] 条形码工具
|
|
84
|
-
- [ ] 头像工具
|
|
85
|
-
- [ ] 表格工具
|
|
86
|
-
- [ ] cmyk
|
|
87
|
-
|
|
88
|
-
## 左侧面板(跟数据相关)
|
|
89
|
-
|
|
90
|
-
- [ ] 模板列表
|
|
91
|
-
- [ ] 素材列表
|
|
92
|
-
- [ ] 背景列表
|
|
93
|
-
- [ ] 图层管理
|
|
94
|
-
- [ ] 文字列表
|
|
95
|
-
- [ ] 图形列表
|
|
96
|
-
- [ ] 我的上传
|
|
97
|
-
|
|
98
|
-
## AI工具
|
|
99
|
-
|
|
100
|
-
- [ ] 抠图
|
|
101
|
-
- [ ] 美颜美白
|
|
102
|
-
- [ ] 图片修复
|
|
103
|
-
- [ ] 图像风格化
|
|
104
|
-
- [ ] 生图
|
|
105
|
-
- [ ] 改图
|
|
106
|
-
|
|
107
|
-
## 移动端的支持
|
|
108
|
-
|
|
109
|
-
- [ ] 双指缩放
|
|
110
|
-
- [ ] 双指旋转
|
|
111
|
-
- [ ] 文本编辑(移动端键盘会影响画布)
|
|
112
|
-
|
|
113
|
-
## 脚手架支持 - @ydesign/cli
|
|
114
|
-
|
|
115
|
-
- [ ] 图片编辑器
|
|
116
|
-
- [ ] 全画布编辑器
|
|
117
|
-
- [ ] 书籍编辑器
|
|
118
|
-
- [ ] 图形编辑器
|
|
119
|
-
- [ ] 签名打印编辑器
|
|
120
|
-
- [ ] ...
|
|
121
|
-
|
|
122
|
-
## 技术文档
|
|
123
|
-
|
|
124
|
-
- [ ] 体验demo
|
|
125
|
-
- [ ] 各组件功能示例
|
|
126
|
-
- [ ] iframe 接入示例
|
|
127
|
-
- [ ] 自定义布局示例
|
|
128
|
-
- [ ] 自定义样式
|
|
129
|
-
- [ ] 自定义logo
|
|
30
|
+
For more information take a look into [LICENSE.md](/LICENSE.md).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o="http://219.151.185.37:9003",a=`${o}/api`,e=()=>o+"/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}),updateRecord:(t,s)=>({method:"PATCH",url:`${e()}/record/${t}`,data:s}),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),c=t=>r.recordDetail(t),i=t=>r.createRecord(t),d=(t,s)=>r.updateRecord(t,s),u=(t,s)=>{r[t]=s};export{n as a,l as b,p as c,c as d,i as e,d as f,u as g};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import{a as P,c as ee}from"./chunk-OV7AL42Z.js";import{a as D}from"./chunk-EWOU5F3O.js";import{b as G,c as N}from"./chunk-5C2MNUBC.js";import{a as J,b as Q,e as Y}from"./chunk-3PMUQSBH.js";import{Modal as Be,Button as Te,ColorPicker as Ue,InputNumber as oe,Select as Me,Tooltip as ne,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 se,useCallback as B}from"react";import $ from"styled-components";import{App as ke,Modal as Se,Upload as te}from"antd";import{Inbox as Ce}from"lucide-react";import{useRef as Pe,useState as Ne}from"react";import{jsx as a,jsxs as I}from"react/jsx-runtime";var{Dragger:Ie}=te,ie=({visible:S,onClose:A})=>{let{message:y,modal:E}=ke.useApp(),[h,C]=Ne(!1),x=Pe(null),_=ee();return a(Se,{width:750,title:"\u4E0A\u4F20 PSD \u6587\u4EF6",open:S,onCancel:()=>{if(h){y.warning("\u6587\u4EF6\u6B63\u5728\u89E3\u6790\u4E2D\uFF0C\u8BF7\u7A0D\u5019...");return}A()},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:I(Ie,{...{name:"file-psd",multiple:!1,accept:".psd",showUploadList:!1,beforeUpload(r){return r.name.toLowerCase().endsWith(".psd")?!0:(y.error("\u4EC5\u652F\u6301 .psd \u683C\u5F0F\u6587\u4EF6"),te.LIST_IGNORE)},customRequest(r){let{file:n,onSuccess:p,onError:s,onProgress:f}=r;C(!0),x.current=y.loading("PSD \u6587\u4EF6\u89E3\u6790\u4E2D\uFF0C\u8BF7\u7A0D\u5019...",0);let l=new FormData;l.append("file",n),l.append("isTemporary","true"),P.post(Q().url,l,{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),y.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:l,width:d,height:m,filename:H,parseUrl:v}=p.result,V={sourceResourcesId:crypto.randomUUID(),content:f,width:d,height:m,parseUrl:v,thumbnailUrl:s,filename:H,name:l},b=Y(V);try{let j=(await P.post(b.url,b.data)).result,U=`${_.urls.editorUrl}?id=${j.id}&type=record`,w=window.open(U,"_blank");(!w||w.closed)&&E.info({title:"\u5141\u8BB8\u663E\u793A\u5F39\u51FA\u7A97\u53E3",width:480,content:I("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"}),I("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"})]}),I("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"})]}),I("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(T){console.error(T)}}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";y.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 c}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}],ae=[{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"}]}],re=$.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=$.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=$.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=$.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,L=130,W=8e3,gt=({project:S,visible:A,onClose:y,onConfirm:E})=>{let{message:h,modal:C}=Re.useApp(),[x,_]=u("all"),F=Oe(null),{token:r}=De.useToken(),[n,p]=u(null),[s,f]=u(null),[l,d]=u("px"),[m,H]=u(!1),[v,V]=u(1),[b,T]=u("#ffffff"),[j,U]=u(!1),w=se(()=>n?N({unitVal:n,dpi:k,unit:l}):0,[n,l]),O=se(()=>s?N({unitVal:s,dpi:k,unit:l}):0,[s,l]),X=n!=null&&s!=null&&n>0&&s>0,M=X&&(w>W||O>W),R=X&&(w<L||O<L),q=!X||M||R,K=M?`\u8D85\u51FA\u753B\u5E03\u5C3A\u5BF8\u9650\u5236\uFF1A${W} * ${W} px`:R?`\u4F4E\u4E8E\u753B\u5E03\u5C3A\u5BF8\u9650\u5236\uFF1A${L} * ${L} px`:"",le=B(t=>{p(t),m&&t&&t>0&&f(Math.round(t/v))},[m,v]),ce=B(t=>{f(t),m&&t&&t>0&&p(Math.round(t*v))},[m,v]),de=B(()=>{!m&&n&&s&&n>0&&s>0&&V(n/s),H(t=>!t)},[m,n,s]),pe=B(t=>{if(n){let o=N({unitVal:n,dpi:k,unit:l});p(Math.round(G({px:o,dpi:k,unit:t,precious:0})))}if(s){let o=N({unitVal:s,dpi:k,unit:l});f(Math.round(G({px:o,dpi:k,unit:t,precious:0})))}d(t)},[n,s,l]),me=B(()=>{if(q)return;let t=JSON.stringify({bg:{backgroundColor:b}}),o=new URLSearchParams({create:"",createEmptyPoster:"true",createInfo:t,height:String(s),unit:l,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,b,O,w,l]),he=t=>{_(t);let o=F.current;if(!o)return;let g=o.querySelector(`[data-category-id="${t}"]`);g&&o.scrollTo({top:g.offsetTop,behavior:"smooth"})},[ge,ue]=u(()=>{let t={};return ae.forEach(o=>{t[o.key]=o.sizes.length>6}),t});return c(Ze,{children:[c(Be,{title:"\u521B\u5EFA\u8BBE\u8BA1",open:A,onCancel:y,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=>c("div",{"data-active":t.key===x,className:D("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:()=>he(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:F,style:{position:"absolute",inset:0,overflow:"scroll"},children:c("div",{className:"createrContentInner",children:[e("div",{"data-category-id":"all"}),c("div",{className:"openBtns flex",children:[c(re,{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=J(),z=new FormData;z.append("file",o),z.append("isTemporary","true");let xe=await P.post(g.url,z,{headers:{"Content-Type":"multipart/form-data"}}),{url:fe,width:ye,height:be}=xe.result,ve=encodeURIComponent(encodeURIComponent(fe)),we=new URLSearchParams({createEmptyPoster:"true",width:String(ye),height:String(be),unit:"px"});h.destroy();let ze=`${S.urls.editorUrl}/?${we.toString()}&open=${ve}`,Z=window.open(ze,"_blank");(!Z||Z.closed)&&C.info({title:"\u5141\u8BB8\u663E\u793A\u5F39\u51FA\u7A97\u53E3",width:480,content:c("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"}),c("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"})]}),c("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"})]}),c("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 z=g?.message||"\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";h.error(z),console.error("\u4E0A\u4F20\u5931\u8D25:",z,g)}},t.click()},children:[e(He,{style:{color:r.colorPrimary}}),e("span",{children:"\u6253\u5F00\u56FE\u7247"})]}),e(ne,{title:"\u4EC5\u652F\u6301psd\u683C\u5F0F\u6587\u4EF6",children:c(re,{style:{marginLeft:12},onClick:()=>{U(!0),console.log("\u70B9\u51FB")},children:[e(i,{style:{color:r.colorPrimary}}),e("span",{children:"\u6253\u5F00PSD"})]})})]}),ae.map(t=>c("div",{className:D("Widget categorySection","mt-6"),"data-category-id":t.key,"data-is-folded":ge[t.key]??!1,"data-is-multi-row":t.sizes.length>6,children:[c("div",{className:D("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:()=>ue(o=>({...o,[t.key]:!1})),children:e("span",{className:"text-[#616366]",children:"\u67E5\u770B\u66F4\u591A"})})]}),t.key==="common"&&c(Ke,{children:[K&&e("div",{className:"sizeWarning",children:K}),c("div",{className:"Widget sizeInpueBox",children:[e("div",{className:"sizeInput",children:e(oe,{prefix:"\u5BBD",value:n,min:0,precision:0,status:M||R?"error":void 0,onChange:le,styles:{actions:{opacity:1,width:24}},style:{width:"100%"}})}),e(ne,{title:m?"\u89E3\u9501\u6BD4\u4F8B":"\u9501\u5B9A\u6BD4\u4F8B",children:e("div",{className:"linkIcon",style:{cursor:"pointer"},onClick:de,children:m?e(je,{size:16}):e(Ve,{size:16})})}),e("div",{className:"sizeInput",children:e(oe,{prefix:"\u9AD8",value:s,min:0,precision:0,status:M||R?"error":void 0,onChange:ce,styles:{actions:{opacity:1,width:24}},style:{width:"100%"}})}),e("div",{className:"sizeUnitSelect",style:{width:98,marginLeft:12},children:e(Me,{value:l,style:{width:98},onChange:pe,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(Ue,{mode:"single",format:"hex",value:b,onChange:o=>T(o.toHexString()),styles:{root:{width:98},body:{width:92}}})}),e(Te,{type:"primary",disabled:q,style:{width:98,marginLeft:12},onClick:me,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:c(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:()=>{E({...o,bgColor:b})},children:e("button",{type:"button",children:"\u521B\u5EFA"})})]})},g))})]},t.key))]})})})})]}),e(ie,{visible:j,onClose:()=>U(!1)})]})};export{gt as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e}from"./chunk-
|
|
1
|
+
import{c as e}from"./chunk-Q7N7SBSC.js";import{Download as n}from"lucide-react";import{useState as r}from"react";import{Button as m,Popover as u,Slider as d,Select as p}from"antd";import{observer as x}from"mobx-react-lite";import{jsx as t,jsxs as o}from"react/jsx-runtime";var b=x(({store:i})=>{let[l,v]=r("png"),[s,y]=r(1),[a,c]=r(1);return t(u,{content:o("div",{className:"w-80",children:[o("div",{className:"mb-4",children:[t("div",{style:{marginBottom:"8px"},className:"text-gray-500",children:e("toolbar.fileType")}),o(p,{value:l,onChange:v,style:{width:"100%"},children:[t(p.Option,{value:"png",children:"PNG"}),t(p.Option,{value:"jpeg",children:"JPEG"})]})]}),o("div",{className:"mb-4",children:[t("div",{style:{marginBottom:"8px"},className:"text-gray-500",children:e("toolbar.quality")}),t("div",{style:{padding:"0 15px"},children:t(d,{min:.2,max:1,value:s,step:.2,onChange:y,marks:{.2:"20%",.4:"40%",.6:"60%",.8:"80%",1:"100%"}})})]}),o("div",{className:"mb-4",children:[t("div",{style:{marginBottom:"8px"},className:"text-gray-500",children:e("toolbar.multiplier")}),t("div",{style:{padding:"0 15px"},children:t(d,{min:.5,max:3,value:a,step:.5,onChange:c,marks:{.5:.5,1:1,1.5:1.5,2:2,2.5:2.5,3:3}})}),o("div",{className:"text-sm text-gray-500 py-1",children:[e("toolbar.size"),"\uFF1A",Math.round(i.width*a)," x"," ",Math.round(i.height*a)," px"]})]}),t("div",{children:o(m,{type:"primary",block:!0,onClick:async()=>{let g=i.toJSON();console.log("\u5BFC\u51FAjson",g),i.saveAsImage({format:l,quality:s,multiplier:a})},icon:t(n,{size:16}),children:[e("toolbar.download")," ",l.toUpperCase()]})})]}),trigger:"click",children:t(m,{type:"primary",icon:t(n,{size:16}),style:{width:155},children:e("toolbar.download")})})}),B=b;export{b as a,B as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as l,c as g,d as m,e as p}from"./chunk-YBC2DYJX.js";import{types as a,cast as y,flow as h,destroy as f,getSnapshot as E,onSnapshot as x}from"mobx-state-tree";async function u(e,t){let r=document.createElement("a"),i=URL.createObjectURL(e);r.href=i,r.download=t,document.body.appendChild(r),r.click(),setTimeout(function(){document.body.removeChild(r),window.URL.revokeObjectURL(i)},0)}import{observable as S,toJS as j}from"mobx";import{isEqual as w}from"es-toolkit/compat";var s=(e,t)=>{if(e?.objects)for(let r of e.objects){if(t(r)===!0)break;s(r,t)}},F=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})),k=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(F),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(r=>e.editor?.objectsHandler.findOneById(r))}})).views(e=>({get selectedShapes(){let t=[];return s({objects:e.selectedElements},r=>{r?.type!=="group"&&t.push(r)}),t},find(t){let r,i=e.editor?.customCanvas.canvas.getObjects();if(i)return s({objects:i},o=>{if(!r&&t(o))return r=o,!0}),r},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},_workareaSizeChanged(t,r){e.width=t||e.width,e.height=r||e.height}})).actions(e=>({setBackgroundColor(t,r){e.backgroundColor=t,e.editor?.workareaHandler.setWorkareaBgColor(t,r)},set(t,r){e.editor?.objectsHandler.update(t,r?.id)},setUnit({unit:t,dpi:r}){e.unit=t||e.unit,e.dpi=r||e.dpi},setObjects(t){e.objects=t},selectElements(t){e.selectedElementsIds=y(t)},openSidePanel(t){e.openedSidePanel!==t&&(e.openedSidePanel=t)},deleteElements(t){t.forEach(r=>{e.editor?.objectsHandler.remove(r)})},setScale(t){e.scale=t},clone(){e.editor?.objectsHandler.clone()},addElement(t,r){return console.log("\u6DFB\u52A0json\u6570\u636E",t),e.editor?.objectsHandler.addJson(t,r)},setSize({width:t,height:r}){e.editor?.workareaHandler.setSize({width:t,height:r})},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)}),e.editor.on("workarea:changed",({target:t})=>{e._workareaSizeChanged(t.width,t.height)}))}})).actions(e=>({_forEachElementUp(t,r){if(!e.editor)return;let i=e.editor.layerHandler.getEffectiveLayers(),o=t.map(n=>({id:n,index:i.findIndex(d=>d.id===n)}));o.sort((n,d)=>d.index-n.index);for(let{index:n}of o){if(n==-1)continue;let d=n<i.length-1&&i[n+1],c=t.indexOf(d?.id)>=0;n===i.length-1||c||r(n)}},_forEachElementDown(t,r){if(!e.editor)return;let i=e.editor.layerHandler.getEffectiveLayers(),o=t.map(n=>({id:n,index:i.findIndex(d=>d.id===n)}));o.sort((n,d)=>d.index-n.index);for(let{index:n}of o){if(n==-1)continue;let d=n>0&&i[n-1],c=t.indexOf(d?.id)>=0;n===0||c||r(n)}return!1}})).actions(e=>({canMoveElementsUp(t){let r=!1;return e._forEachElementUp(t,()=>{r=!0}),r},moveElementsUp(t){if(!e.editor)return;let r=e.editor.layerHandler.getEffectiveLayers();[...t].map(o=>({id:o,index:r.findIndex(n=>n.id===o)})).filter(o=>o.index!==-1).sort((o,n)=>n.index-o.index).map(o=>o.id).forEach(o=>{e.editor?.layerHandler.bringForward(o)}),e._triggerUpdate()},canMoveElementsTop(t){return this.canMoveElementsUp(t)},moveElementsTop(t){e.editor&&(t.forEach(r=>{e.editor?.layerHandler.bringToFront(r)}),e._triggerUpdate())},canMoveElementsDown(t){let r=!1;return e._forEachElementDown(t,()=>{r=!0}),r},moveElementsDown(t){if(!e.editor)return;let r=e.editor.layerHandler.getEffectiveLayers();[...t].map(o=>({id:o,index:r.findIndex(n=>n.id===o)})).filter(o=>o.index!==-1).sort((o,n)=>o.index-n.index).map(o=>o.id).forEach(o=>{e.editor?.layerHandler.sendBackwards(o)}),e._triggerUpdate()},canMoveElementsBottom(t){return this.canMoveElementsDown(t)},moveElementsBottom(t){e.editor&&(t.forEach(r=>{e.editor?.layerHandler.sendToBack(r)}),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:r,...i}=t||{multiplier:1},o=await e.editor.rendererHandler.toBlob(i);o&&u(o,r||"yitu."+i.format)},toJSON(){return e.editor?.rendererHandler.toJSON()},toObject(){return e.editor?.rendererHandler.toObject()},loadJSON:h(function*(t){if(!e.editor)return;let r=yield e.editor.sceneHandler.importFromJSON(t);r&&(e.width=r.width,e.height=r.height,e.backgroundColor=r.fill)}),clear(){}})).actions(e=>({removeFont(t){e.fonts.filter(r=>r.fontFamily===t).forEach(r=>{f(r)})},addFont(t){this.removeFont(t.fontFamily),e.fonts.push(t),this.loadFont(t.fontFamily)},async loadFont(t){let r=e.fonts.find(n=>n.fontFamily===t)||l.find(n=>n.fontFamily===t),o=[{fontStyle:"normal",fontWeight:"normal"},{fontStyle:"normal",fontWeight:"bold"}];return r?(r.styles&&(o=r.styles.map(n=>({fontStyle:n.fontStyle||"normal",fontWeight:n.fontWeight||"normal"}))),m(r)):p(t),Promise.all(o.map(n=>g(t,n.fontStyle,n.fontWeight)))}})).actions(e=>({on(t,r){if(t==="change"){let i=E(e.objects);return x(e.objects,o=>{let n=o;w(i,n)||(i=n,r(n))})}}})),b=S({token:"",workspaceId:""}),T=()=>j(b);function O({key:e,token:t,workspaceId:r}){return b={token:t??"",workspaceId:r??""},k.create({_key:e,token:t??"",workspaceId:r??""})}var z=O;export{s as a,F as b,k as c,T as d,O as e,z as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as y}from"./chunk-C4XMVZO4.js";import{b as g}from"./chunk-YBC2DYJX.js";import{a as p,c as m,d,f as h}from"./chunk-3PMUQSBH.js";import{a}from"./chunk-O2XFH626.js";import*as w from"mobx";import{createContext as T,useContext as P}from"react";import f from"axios";var u=f.create({timeout:6e4});u.interceptors.request.use(t=>{let e=y();return e.token&&(t.headers.Authorization=`Bearer ${e.token}`,t.headers["yitu-workspace-id"]=e.workspaceId),t},t=>Promise.reject(t));u.interceptors.response.use(t=>{let{data:e}=t,s=e?.statusCode??e?.status;if(s!=null){if(s>=200&&s<=201)return e;let o=e?.result?.message||e?.message||"An error occurred";return Promise.reject(new Error(o))}if(t.status>=200&&t.status<300&&e)return e;let r=new Error(e?.message||"An error occurred");return Promise.reject(r)},t=>{let e=t?.response?.data,s=e?.result?.message||e?.message||t.message||"An error occurred";return Promise.reject(new Error(s))});var c=u;var b=t=>{try{return localStorage.getItem(t)}catch{return null}},v=(t,e)=>{try{localStorage.setItem(t,e)}catch{}},l=class{constructor({store:e}){a(this,"saveTimeout",null);a(this,"isOne",!1);a(this,"store");a(this,"id","");a(this,"type","");a(this,"name","");a(this,"user",{});a(this,"skipSaving",!1);a(this,"cloudEnabled",!1);a(this,"status","loading");a(this,"language",b("ydesign-language")||navigator.language||"en");a(this,"designsLength",0);a(this,"urls",{editorUrl:"/design"});w.makeAutoObservable(this),this.store=e,e.on("change",()=>{if(!this.isOne){this.isOne=!0;return}this.requestSave()})}setLanguage(e){this.language=e,v("ydesign-language",e)}requestSave(){this.status="has-changes",!this.saveTimeout&&(this.saveTimeout=setTimeout(()=>{this.saveTimeout=null,this.save()},5e3))}async firstLoad(e){if(e)await this.store.loadJSON(e),this.status="save";else{let s=new URL(window.location.href),r=new URLSearchParams(s.search),o=r.get("type")||"",n=r.get("id")||"";this.type=o,this.id=n;try{await this.loadById(n,o)}catch(i){console.error("loadById error",i)}finally{this.status="save"}}}async loadById(e,s){if(await new Promise(r=>setTimeout(r,2e3)),e){if(s==="me"){let r=m(e),o=await c.post(r.url,r.data),{content:n,name:i}=o.result;this.name=i,await this.store.loadJSON(n);return}if(s==="record"){let r=d(e),o=await c.get(r.url),{content:n,name:i}=o.result;this.name=i,await this.store.loadJSON(n);return}console.log("\u6CA1\u6709\u5339\u914D\u5230\u7684\u6765\u6E90")}else console.log("\u6CA1\u6709id\u65E0\u6CD5\u83B7\u53D6\u8FDC\u7A0B\u6570\u636E")}updateUrlWithProjectId(){if(!this.id||this.id==="local"){window.history.replaceState({},"","/");return}let e=new URL(window.location.href);new URLSearchParams(e.search).set("id",this.id),window.history.replaceState({},"",`/design/${this.id}`)}async save(){this.status="saving";let e=this.store.toJSON();console.log("\u4FDD\u5B58\u7684\u6570\u636E ---> ",e),console.log("\u4FDD\u5B58\u7684\u6587\u4EF6\u540D ---> ",this.name);try{let s=await this.store.toBlob();if(s){let{url:r,width:o,height:n}=await this.uploadFileToCos(s);if(this.type==="record"){let i=h(this.id,{thumbnailUrl:r,width:o,height:n,content:{...e,width:o,height:n,thumb:r},name:this.name});await c.patch(i.url,i.data)}}}catch(s){console.error("save error",s),alert("\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5")}this.status="saved"}async getGlobalFont(e){return e?.length?(g(e),e):[]}async uploadFileToCos(e){let s=e instanceof File?e:new File([e],"upload.png",{type:e.type||"image/png"}),r=p(),o=new FormData;return o.append("file",s),o.append("isTemporary","true"),(await c.post(r.url,o,{headers:{"Content-Type":"multipart/form-data"}})).result}},S=T(null),C=()=>{let t=P(S);if(!t)throw new Error("useProject must be used within a ProjectProvider");return t},j=t=>new l(t),L=j;export{c as a,S as b,C as c,j as d,L as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{observable as u,action as p,toJS as m}from"mobx";var r=u({toolbar:{undo:"Undo",redo:"Redo",duration:"Duration",opacity:"Opacity",effects:"Effects",blur:"Blur",textBackground:"Background",backgroundCornerRadius:"Corner radius",backgroundOpacity:"Opacity",backgroundPadding:"Padding",backgroundColor:"Background color",brightness:"Brightness",filters:"Filters",sepia:"Sepia",grayscale:"Grayscale",contrast:"Contrast",saturation:"Saturation",vibrance:"Vibrance",hueRotation:"Hue Rotation",noise:"Noise",pixelate:"Pixelate",textStroke:"Text Stroke",shadow:"Shadow",border:"Border",cornerRadius:"Corner Radius",textleft:"Text align left",textcenter:"Text align center",textright:"Text align right",textjustify:"Text align justify",textBold:"Bold",textItalic:"Italic",textUnderline:"Underline",textStrikethrough:"Strikethrough",splitByGrapheme:"Split by grapheme",position:"Position",layering:"Layering",toForward:"To Front",up:"Forward",down:"Backward",toBottom:"To back",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignTop:"Align top",alignMiddle:"Align middle",alignBottom:"Align bottom",flip:"Flip",flipHorizontally:"Flip horizontally",flipVertically:"Flip vertically",fitToBackground:"Fit to page",removeBackground:"Remove background",removeBackgroundTitle:"Remove background from image",cancelRemoveBackground:"Cancel",confirmRemoveBackground:"Confirm",eraserPen:"Eraser pen",eraserPenTitle:"Remove with an eraser tool",cancelEraserPen:"Cancel",confirmEraserPen:"Confirm",crop:"Crop",cropDone:"Done",cropCancel:"Cancel",clip:"Apply mask",removeClip:"Remove mask",removeMask:"Remove mask",transparency:"Transparency",lockedDescription:"Object is locked.",unlockedDescription:"Object is unlocked.",removeElements:"Remove elements",duplicateElements:"Duplicate elements",download:"Download",saveAsImage:"Save as image",saveAsPDF:"Save as PDF",lineHeight:"Line height",letterSpacing:"Letter spacing",offsetX:"Offset X",offsetY:"Offset Y",color:"Color",selectable:"Selectable",draggable:"Draggable",removable:"Removable",resizable:"Resizable",contentEditable:"Can change content",styleEditable:"Can change style",alwaysOnTop:"Always on top",showInExport:"Show in export",ungroupElements:"Ungroup",groupElements:"Group",lineSize:"Line size",fade:"Fade",move:"Move",zoom:"Zoom",rotate:"Rotate",none:"None",bounce:"Bounce",blink:"Blink",strength:"Strength",spaceEvenly:"Space evenly",horizontalDistribution:"Horizontally",verticalDistribution:"Vertically",strokeWidth:"Stroke Width",strokeSettings:"Stroke Settings",colorPicker:{solid:"Solid",linear:"Linear",angle:"Angle"},aiText:{aiWrite:"AI write",rewrite:"Rewrite",shorten:"Shorten",continue:"Continue writing",proofread:"Proofread",tones:"Tones",friendly:"Friendly",professional:"Professional",humorous:"Humorous",formal:"Formal",customPrompt:"Custom prompt",generatedResult:"Generated result",cancel:"Cancel",generate:"Generate",back:"Back",tryAgain:"Try Again",insert:"Insert",promptPlaceholder:"Describe what you want to generate"},addImage:"Add image",addText:"Add text",fileType:"File type",quality:"Quality",multiplier:"Multiplier",size:"Size"},workspace:{noPages:"There are no pages yet...",addPage:"Add page",removePage:"Remove page",duplicatePage:"Duplicate page",moveUp:"Move up",moveDown:"Move down"},scale:{reset:"Reset"},error:{removeBackground:"Ops! Something went wrong. Background can not be removed."},sidePanel:{templates:"Templates",searchTemplatesWithSameSize:"Show templates with the same size",searchPlaceholder:"Search...",otherFormats:"Other formats",noResults:"No results",error:"Loading is failed...",text:"Text",uploadFont:"Upload font",myFonts:"My fonts",photos:"Photos",videos:"Videos",animations:"Animations",effects:"Effects",elements:"Elements",shapes:"Shapes",lines:"Lines",upload:"Upload",uploadImage:"Add file",uploadTip:"Upload your assets",background:"Background",resize:"Resize",layers:"Layers",layerTypes:{image:"Image",text:"Text",svg:"SVG",line:"Line",figure:"Figure",group:"Group"},layersTip:"Elements on your active page:",noLayers:"No elements on the page...",namePlaceholder:"Type element name...",useMagicResize:"Use magic resize",clipImage:"Mask image",width:"Width",height:"Height",magicResizeDescription:"Magic resize will automatically resize and move all elements on the canvas",headerText:"Header",createHeader:"Create header",subHeaderText:"Sub Header",createSubHeader:"Create sub header",bodyText:"Body text",createBody:"Create body text",units:"Units"},topbar:{newDesign:"Create new design",language:"Language",editableTextPlaceholder:"Design name",statusLoading:"Save",statusSaved:"Saved",statusHasChanges:"Unsaved changes",statusSaving:"Saving..."}});function i(e){return e&&typeof e=="object"}function d(e,n){Object.keys(n).forEach(o=>{let t=e[o],a=n[o];i(a)&&i(t)?d(t,a):a!==void 0&&(e[o]=a)})}function g(e,n,o=""){Object.keys(n).forEach(t=>{let a=n[t],s=o?`${o}.${t}`:t;if(i(a)){let l=e[t];i(l)?g(l,a,s):console.warn(`Missing nested translation object at '${s}'`)}else e[t]===void 0&&console.warn(`Missing translation '${s}'`)})}var b=p((e,{validate:n=!1}={})=>{n&&g(e,r),d(r,e)}),y=()=>m(r),c={};function f(e,n){let o=n.split("."),t=e;for(let a of o){if(t==null||typeof t!="object")return;t=t[a]}return t}var k=e=>{let n=f(r,e);if(n!==void 0)return n;c[e]||(c[e]=!0,console.warn(`Missing translation '${e}'`));let o=e.split("."),t=o[o.length-1]||" ";return t.charAt(0).toUpperCase()+t.slice(1)};export{b as a,y as b,k as c};
|
|
1
|
+
import{observable as u,action as p,toJS as m}from"mobx";var r=u({toolbar:{undo:"Undo",redo:"Redo",duration:"Duration",opacity:"Opacity",effects:"Effects",blur:"Blur",textBackground:"Background",backgroundCornerRadius:"Corner radius",backgroundOpacity:"Opacity",backgroundPadding:"Padding",backgroundColor:"Background color",brightness:"Brightness",filters:"Filters",sepia:"Sepia",grayscale:"Grayscale",contrast:"Contrast",saturation:"Saturation",vibrance:"Vibrance",hueRotation:"Hue Rotation",noise:"Noise",pixelate:"Pixelate",textStroke:"Text Stroke",shadow:"Shadow",border:"Border",cornerRadius:"Corner Radius",textleft:"Text align left",textcenter:"Text align center",textright:"Text align right",textjustify:"Text align justify",textBold:"Bold",textItalic:"Italic",textUnderline:"Underline",textStrikethrough:"Strikethrough",splitByGrapheme:"Split by grapheme",position:"Position",layering:"Layering",toForward:"To Front",up:"Forward",down:"Backward",toBottom:"To back",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignTop:"Align top",alignMiddle:"Align middle",alignBottom:"Align bottom",flip:"Flip",flipHorizontally:"Flip horizontally",flipVertically:"Flip vertically",fitToBackground:"Fit to page",removeBackground:"Remove background",removeBackgroundTitle:"Remove background from image",cancelRemoveBackground:"Cancel",confirmRemoveBackground:"Confirm",eraserPen:"Eraser pen",eraserPenTitle:"Remove with an eraser tool",cancelEraserPen:"Cancel",confirmEraserPen:"Confirm",crop:"Crop",cropDone:"Done",cropCancel:"Cancel",clip:"Apply mask",removeClip:"Remove mask",removeMask:"Remove mask",transparency:"Transparency",lockedDescription:"Object is locked.",unlockedDescription:"Object is unlocked.",removeElements:"Remove elements",duplicateElements:"Duplicate elements",download:"Download",saveAsImage:"Save as image",saveAsPDF:"Save as PDF",lineHeight:"Line height",letterSpacing:"Letter spacing",offsetX:"Offset X",offsetY:"Offset Y",color:"Color",selectable:"Selectable",draggable:"Draggable",removable:"Removable",resizable:"Resizable",contentEditable:"Can change content",styleEditable:"Can change style",alwaysOnTop:"Always on top",showInExport:"Show in export",ungroupElements:"Ungroup",groupElements:"Group",lineSize:"Line size",fade:"Fade",move:"Move",zoom:"Zoom",rotate:"Rotate",none:"None",bounce:"Bounce",blink:"Blink",strength:"Strength",spaceEvenly:"Space evenly",horizontalDistribution:"Horizontally",verticalDistribution:"Vertically",strokeWidth:"Stroke Width",strokeSettings:"Stroke Settings",colorPicker:{solid:"Solid",linear:"Linear",angle:"Angle"},aiText:{aiWrite:"AI write",rewrite:"Rewrite",shorten:"Shorten",continue:"Continue writing",proofread:"Proofread",tones:"Tones",friendly:"Friendly",professional:"Professional",humorous:"Humorous",formal:"Formal",customPrompt:"Custom prompt",generatedResult:"Generated result",cancel:"Cancel",generate:"Generate",back:"Back",tryAgain:"Try Again",insert:"Insert",promptPlaceholder:"Describe what you want to generate"},addImage:"Add image",addText:"Add text",fileType:"File type",quality:"Quality",multiplier:"Multiplier",size:"Size"},workspace:{noPages:"There are no pages yet...",addPage:"Add page",removePage:"Remove page",duplicatePage:"Duplicate page",moveUp:"Move up",moveDown:"Move down"},scale:{reset:"Reset"},error:{removeBackground:"Ops! Something went wrong. Background can not be removed."},sidePanel:{templates:"Templates",searchTemplatesWithSameSize:"Show templates with the same size",searchPlaceholder:"Search...",otherFormats:"Other formats",noResults:"No results",error:"Loading is failed...",text:"Text",uploadFont:"Upload font",myFonts:"My fonts",photos:"Photos",videos:"Videos",animations:"Animations",effects:"Effects",elements:"Elements",shapes:"Shapes",lines:"Lines",upload:"Upload",uploadImage:"Add file",uploadTip:"Upload your assets",background:"Background",resize:"Resize",layers:"Layers",layerTypes:{image:"Image",text:"Text",svg:"SVG",line:"Line",figure:"Figure",group:"Group"},layersTip:"Elements on your active page:",noLayers:"No elements on the page...",namePlaceholder:"Type element name...",useMagicResize:"Use magic resize",clipImage:"Mask image",width:"Width",height:"Height",magicResizeDescription:"Magic resize will automatically resize and move all elements on the canvas",headerText:"Header",createHeader:"Create header",subHeaderText:"Sub Header",createSubHeader:"Create sub header",bodyText:"Body text",createBody:"Create body text",units:"Units"},topbar:{newDesign:"Create new design",language:"Language",editableTextPlaceholder:"Design name",statusLoading:"Loading...",statusSave:"Save",statusSaved:"Saved",statusHasChanges:"Unsaved changes",statusSaving:"Saving..."}});function i(e){return e&&typeof e=="object"}function d(e,n){Object.keys(n).forEach(o=>{let t=e[o],a=n[o];i(a)&&i(t)?d(t,a):a!==void 0&&(e[o]=a)})}function g(e,n,o=""){Object.keys(n).forEach(t=>{let a=n[t],s=o?`${o}.${t}`:t;if(i(a)){let l=e[t];i(l)?g(l,a,s):console.warn(`Missing nested translation object at '${s}'`)}else e[t]===void 0&&console.warn(`Missing translation '${s}'`)})}var b=p((e,{validate:n=!1}={})=>{n&&g(e,r),d(r,e)}),y=()=>m(r),c={};function f(e,n){let o=n.split("."),t=e;for(let a of o){if(t==null||typeof t!="object")return;t=t[a]}return t}var k=e=>{let n=f(r,e);if(n!==void 0)return n;c[e]||(c[e]=!0,console.warn(`Missing translation '${e}'`));let o=e.split("."),t=o[o.length-1]||" ";return t.charAt(0).toUpperCase()+t.slice(1)};export{b as a,y as b,k as c};
|