@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.
Files changed (37) hide show
  1. package/README.md +20 -119
  2. package/dist/canvas/workspace.d.ts +1 -1
  3. package/dist/chunk-3PMUQSBH.js +1 -0
  4. package/dist/{chunk-RBRSKAZL.js → chunk-AMEXYVS6.js} +1 -1
  5. package/dist/{chunk-QALZ5CAJ.js → chunk-ICMV2HE4.js} +15 -15
  6. package/dist/{chunk-63A6RW6Y.js → chunk-OEMIP6LV.js} +1 -1
  7. package/dist/{chunk-WFMCGQ5V.js → chunk-Q7N7SBSC.js} +1 -1
  8. package/dist/chunk-VR4OXDJV.js +1 -0
  9. package/dist/chunk-W4AOHCPQ.js +1 -0
  10. package/dist/chunk-Y7XQELAM.js +151 -0
  11. package/dist/config.d.ts +2 -221
  12. package/dist/config.js +1 -1
  13. package/dist/model/store.d.ts +1 -1
  14. package/dist/model/store.js +1 -1
  15. package/dist/project.d.ts +15 -2
  16. package/dist/project.js +1 -1
  17. package/dist/side-panel/index.d.ts +1 -1
  18. package/dist/side-panel/index.js +1 -1
  19. package/dist/side-panel/side-panel.d.ts +1 -1
  20. package/dist/side-panel/side-panel.js +1 -1
  21. package/dist/{store-DfmY1m2j.d.ts → store-CgxwnT-h.d.ts} +3 -0
  22. package/dist/toolbar/download-button.d.ts +1 -1
  23. package/dist/toolbar/download-button.js +1 -1
  24. package/dist/toolbar/toolbar.d.ts +1 -1
  25. package/dist/toolbar/toolbar.js +3 -3
  26. package/dist/toolbar/zoom-buttons.d.ts +1 -1
  27. package/dist/topbar/create-design.d.ts +1 -1
  28. package/dist/topbar/create-design.js +1 -1
  29. package/dist/topbar/topbar.d.ts +1 -1
  30. package/dist/topbar/topbar.js +2 -2
  31. package/dist/utils/l10n.d.ts +228 -0
  32. package/dist/utils/l10n.js +1 -0
  33. package/package.json +2 -2
  34. package/dist/chunk-2AZQIJ4K.js +0 -1
  35. package/dist/chunk-6XGFXDKJ.js +0 -151
  36. package/dist/chunk-EUTDQZKU.js +0 -1
  37. package/dist/chunk-KERQXVBL.js +0 -1
@@ -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};
@@ -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";import{message as k}from"antd";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})),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(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},n=>{if(!r&&t(n))return r=n,!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)}),e.editor.on("workarea:max-size",t=>{k.info(`\u6700\u5927\u5BBD\u5EA6\uFF1A${t.maxWidth}\uFF0C\u6700\u5927\u9AD8\u5EA6\uFF1A${t.maxHeight}`)}))}})).actions(e=>({_forEachElementUp(t,r){if(!e.editor)return;let i=e.editor.layerHandler.getEffectiveLayers(),n=t.map(o=>({id:o,index:i.findIndex(d=>d.id===o)}));n.sort((o,d)=>d.index-o.index);for(let{index:o}of n){if(o==-1)continue;let d=o<i.length-1&&i[o+1],c=t.indexOf(d?.id)>=0;o===i.length-1||c||r(o)}},_forEachElementDown(t,r){if(!e.editor)return;let i=e.editor.layerHandler.getEffectiveLayers(),n=t.map(o=>({id:o,index:i.findIndex(d=>d.id===o)}));n.sort((o,d)=>d.index-o.index);for(let{index:o}of n){if(o==-1)continue;let d=o>0&&i[o-1],c=t.indexOf(d?.id)>=0;o===0||c||r(o)}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(n=>({id:n,index:r.findIndex(o=>o.id===n)})).filter(n=>n.index!==-1).sort((n,o)=>o.index-n.index).map(n=>n.id).forEach(n=>{e.editor?.layerHandler.bringForward(n)}),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(n=>({id:n,index:r.findIndex(o=>o.id===n)})).filter(n=>n.index!==-1).sort((n,o)=>n.index-o.index).map(n=>n.id).forEach(n=>{e.editor?.layerHandler.sendBackwards(n)}),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},n=await e.editor.rendererHandler.toBlob(i);n&&u(n,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(o=>o.fontFamily===t)||l.find(o=>o.fontFamily===t),n=[{fontStyle:"normal",fontWeight:"normal"},{fontStyle:"normal",fontWeight:"bold"}];return r?(r.styles&&(n=r.styles.map(o=>({fontStyle:o.fontStyle||"normal",fontWeight:o.fontWeight||"normal"}))),m(r)):p(t),Promise.all(n.map(o=>g(t,o.fontStyle,o.fontWeight)))}})).actions(e=>({on(t,r){if(t==="change"){let i=E(e.objects);return x(e.objects,n=>{let o=n;w(i,o)||(i=o,r(o))})}}})),b=S({token:"",workspaceId:""}),L=()=>j(b);function v({key:e,token:t,workspaceId:r}){return b={token:t??"",workspaceId:r??""},O.create({_key:e,token:t??"",workspaceId:r??""})}var A=v;export{s as a,F as b,O as c,L as d,v as e,A as f};
@@ -0,0 +1 @@
1
+ import{d as P}from"./chunk-VR4OXDJV.js";import{b as v}from"./chunk-YBC2DYJX.js";import{a as d,c as g,d as y,e as f,f as w}from"./chunk-3PMUQSBH.js";import{a}from"./chunk-O2XFH626.js";import*as S from"mobx";import{createContext as b,useContext as j}from"react";import T from"axios";var p=T.create({timeout:16e4});p.interceptors.request.use(r=>{let e=P();return e.token&&(r.headers.Authorization=`Bearer ${e.token}`,r.headers["yitu-workspace-id"]=e.workspaceId),r},r=>Promise.reject(r));p.interceptors.response.use(r=>{let{data:e}=r,t=e?.statusCode??e?.status;if(t!=null){if(t>=200&&t<=201)return e;let o=e?.result?.message||e?.message||"An error occurred";return Promise.reject(new Error(o))}if(r.status>=200&&r.status<300&&e)return e;let s=new Error(e?.message||"An error occurred");return Promise.reject(s)},r=>{let e=r?.response?.data,t=e?.result?.message||e?.message||r.message||"An error occurred";return Promise.reject(new Error(t))});var l=p;var x=r=>{try{return localStorage.getItem(r)}catch{return null}},R=(r,e)=>{try{localStorage.setItem(r,e)}catch{}},m=class{constructor({store:e}){a(this,"saveTimeout",null);a(this,"isOne",!1);a(this,"saving",!1);a(this,"pendingSave",!1);a(this,"store");a(this,"id","");a(this,"type","");a(this,"createEmptyPoster",!1);a(this,"name","");a(this,"user",{});a(this,"skipSaving",!1);a(this,"cloudEnabled",!1);a(this,"status","loading");a(this,"language",x("ydesign-language")||navigator.language||"en");a(this,"designsLength",0);a(this,"urls",{editorUrl:"/design"});S.makeAutoObservable(this),this.store=e,e.on("change",()=>{if(!this.isOne){this.isOne=!0;return}this.requestSave()})}setLanguage(e){this.language=e,R("ydesign-language",e)}requestSave(){this.status="has-changes",!this.saveTimeout&&(this.saveTimeout=setTimeout(()=>{if(this.saveTimeout=null,this.saving){this.pendingSave=!0;return}this.save()},5e3))}async firstLoad(e){if(e)await this.store.loadJSON(e),this.status="save";else{let t=new URL(window.location.href),s=new URLSearchParams(t.search),o=s.get("type")||"",n=s.get("id")||"",i=s.get("createEmptyPoster")||"";this.createEmptyPoster=i==="true",this.type=o,this.id=n,console.log("this.type",this.type),console.log("this.id",this.id),console.log("this.createEmptyPoster",this.createEmptyPoster);try{await this.loadById(n,o)}catch(c){console.error("loadById error",c)}finally{this.status="save"}}}async loadById(e,t){if(await new Promise(s=>setTimeout(s,2e3)),e){if(t==="me"){let s=g(e),o=await l.post(s.url,s.data),{content:n,name:i}=o.result;this.name=i,await this.store.loadJSON(n);return}if(t==="record"){let s=y(e),o=await l.get(s.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(e,t){let s=e||this.id,o=t||this.type;if(!s){window.history.replaceState({},"","/");return}let n=new URLSearchParams({id:s,type:o});window.history.replaceState({},"",`${this.urls.editorUrl}?${n.toString()}`)}async save(){if(this.saving){this.pendingSave=!0;return}this.saving=!0,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 t=await this.store.toBlob({multiplier:1,format:"jpeg",quality:.8});if(t){console.log("blob",t);let{url:s,width:o,height:n}=await this.uploadFileToCos(t),i={...e,width:o,height:n,thumb:s};if(this.createEmptyPoster){let c=f({thumbnailUrl:s,width:o,height:n,content:i,name:this.name,filename:this.name,sourceResourcesId:crypto.randomUUID()}),u=await l.post(c.url,c.data);if(console.log("recordRes",u.result),u.result){let h=u.result;this.id=h.id,this.type="record",this.createEmptyPoster=!1,this.updateUrlWithProjectId(h.id,"record")}}else if(this.type==="record"){let c=w(this.id,{thumbnailUrl:s,width:o,height:n,content:i,name:this.name});await l.patch(c.url,c.data)}else console.log("\u6CA1\u6709\u4EFB\u4F55\u6765\u6E90\uFF0C\u65E0\u6CD5\u8FDC\u7A0B\u5B58\u50A8")}}catch(t){console.error("save error",t);let s=t instanceof Error?t.message:String(t);alert(`\u4FDD\u5B58\u5931\u8D25\uFF1A${s}`)}this.status="saved",this.saving=!1,this.pendingSave&&(this.pendingSave=!1,this.requestSave())}async getGlobalFont(e){return e?.length?(v(e),e):[]}async uploadFileToCos(e){let t=e instanceof File?e:new File([e],"upload.png",{type:e.type||"image/png"}),s=d(),o=new FormData;return o.append("file",t),o.append("isTemporary","true"),(await l.post(s.url,o,{headers:{"Content-Type":"multipart/form-data"}})).result}},E=b(null),B=()=>{let r=j(E);if(!r)throw new Error("useProject must be used within a ProjectProvider");return r},O=r=>new m(r),L=O;export{l as a,E as b,B as c,O as d,L as e};
@@ -0,0 +1,151 @@
1
+ import{a as P,c as ee}from"./chunk-W4AOHCPQ.js";import{b as G,c as N}from"./chunk-5C2MNUBC.js";import{a as D}from"./chunk-EWOU5F3O.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};
package/dist/config.d.ts CHANGED
@@ -1,224 +1,5 @@
1
1
  import { XY } from '@ydesign/core';
2
-
3
- /**
4
- * 设置/更新翻译
5
- * @param {object} newTranslations - 新的翻译对象
6
- * @param {object} options - 配置选项
7
- * @param {boolean} options.validate - 是否验证翻译完整性
8
- */
9
- declare const setTranslations: (newTranslations: any, { validate }?: {
10
- validate?: boolean | undefined;
11
- }) => void;
12
- /**
13
- * 获取所有翻译(返回普通 JS 对象)
14
- * @returns {object}
15
- */
16
- declare const getTranslations: () => {
17
- toolbar: {
18
- undo: string;
19
- redo: string;
20
- duration: string;
21
- opacity: string;
22
- effects: string;
23
- blur: string;
24
- textBackground: string;
25
- backgroundCornerRadius: string;
26
- backgroundOpacity: string;
27
- backgroundPadding: string;
28
- backgroundColor: string;
29
- brightness: string;
30
- filters: string;
31
- sepia: string;
32
- grayscale: string;
33
- contrast: string;
34
- saturation: string;
35
- vibrance: string;
36
- hueRotation: string;
37
- noise: string;
38
- pixelate: string;
39
- textStroke: string;
40
- shadow: string;
41
- border: string;
42
- cornerRadius: string;
43
- textleft: string;
44
- textcenter: string;
45
- textright: string;
46
- textjustify: string;
47
- textBold: string;
48
- textItalic: string;
49
- textUnderline: string;
50
- textStrikethrough: string;
51
- splitByGrapheme: string;
52
- position: string;
53
- layering: string;
54
- toForward: string;
55
- up: string;
56
- down: string;
57
- toBottom: string;
58
- alignLeft: string;
59
- alignCenter: string;
60
- alignRight: string;
61
- alignTop: string;
62
- alignMiddle: string;
63
- alignBottom: string;
64
- flip: string;
65
- flipHorizontally: string;
66
- flipVertically: string;
67
- fitToBackground: string;
68
- removeBackground: string;
69
- removeBackgroundTitle: string;
70
- cancelRemoveBackground: string;
71
- confirmRemoveBackground: string;
72
- eraserPen: string;
73
- eraserPenTitle: string;
74
- cancelEraserPen: string;
75
- confirmEraserPen: string;
76
- crop: string;
77
- cropDone: string;
78
- cropCancel: string;
79
- clip: string;
80
- removeClip: string;
81
- removeMask: string;
82
- transparency: string;
83
- lockedDescription: string;
84
- unlockedDescription: string;
85
- removeElements: string;
86
- duplicateElements: string;
87
- download: string;
88
- saveAsImage: string;
89
- saveAsPDF: string;
90
- lineHeight: string;
91
- letterSpacing: string;
92
- offsetX: string;
93
- offsetY: string;
94
- color: string;
95
- selectable: string;
96
- draggable: string;
97
- removable: string;
98
- resizable: string;
99
- contentEditable: string;
100
- styleEditable: string;
101
- alwaysOnTop: string;
102
- showInExport: string;
103
- ungroupElements: string;
104
- groupElements: string;
105
- lineSize: string;
106
- fade: string;
107
- move: string;
108
- zoom: string;
109
- rotate: string;
110
- none: string;
111
- bounce: string;
112
- blink: string;
113
- strength: string;
114
- spaceEvenly: string;
115
- horizontalDistribution: string;
116
- verticalDistribution: string;
117
- strokeWidth: string;
118
- strokeSettings: string;
119
- colorPicker: {
120
- solid: string;
121
- linear: string;
122
- angle: string;
123
- };
124
- aiText: {
125
- aiWrite: string;
126
- rewrite: string;
127
- shorten: string;
128
- continue: string;
129
- proofread: string;
130
- tones: string;
131
- friendly: string;
132
- professional: string;
133
- humorous: string;
134
- formal: string;
135
- customPrompt: string;
136
- generatedResult: string;
137
- cancel: string;
138
- generate: string;
139
- back: string;
140
- tryAgain: string;
141
- insert: string;
142
- promptPlaceholder: string;
143
- };
144
- addImage: string;
145
- addText: string;
146
- fileType: string;
147
- quality: string;
148
- multiplier: string;
149
- size: string;
150
- };
151
- workspace: {
152
- noPages: string;
153
- addPage: string;
154
- removePage: string;
155
- duplicatePage: string;
156
- moveUp: string;
157
- moveDown: string;
158
- };
159
- scale: {
160
- reset: string;
161
- };
162
- error: {
163
- removeBackground: string;
164
- };
165
- sidePanel: {
166
- templates: string;
167
- searchTemplatesWithSameSize: string;
168
- searchPlaceholder: string;
169
- otherFormats: string;
170
- noResults: string;
171
- error: string;
172
- text: string;
173
- uploadFont: string;
174
- myFonts: string;
175
- photos: string;
176
- videos: string;
177
- animations: string;
178
- effects: string;
179
- elements: string;
180
- shapes: string;
181
- lines: string;
182
- upload: string;
183
- uploadImage: string;
184
- uploadTip: string;
185
- background: string;
186
- resize: string;
187
- layers: string;
188
- layerTypes: {
189
- image: string;
190
- text: string;
191
- svg: string;
192
- line: string;
193
- figure: string;
194
- group: string;
195
- };
196
- layersTip: string;
197
- noLayers: string;
198
- namePlaceholder: string;
199
- useMagicResize: string;
200
- clipImage: string;
201
- width: string;
202
- height: string;
203
- magicResizeDescription: string;
204
- headerText: string;
205
- createHeader: string;
206
- subHeaderText: string;
207
- createSubHeader: string;
208
- bodyText: string;
209
- createBody: string;
210
- units: string;
211
- };
212
- topbar: {
213
- newDesign: string;
214
- language: string;
215
- editableTextPlaceholder: string;
216
- statusLoading: string;
217
- statusSaved: string;
218
- statusHasChanges: string;
219
- statusSaving: string;
220
- };
221
- };
2
+ export { getTranslations, setTranslations } from './utils/l10n.js';
222
3
 
223
4
  type UrlResult = {
224
5
  method?: string;
@@ -277,4 +58,4 @@ interface PresetLine {
277
58
  declare const LinePoolItems: LinePoolItem[];
278
59
  declare const PathLineLibs: PresetLine[];
279
60
 
280
- export { type LinePoint, type LinePoolItem, LinePoolItems, PathLineLibs, type PathListItem, type PathPoolItem, PathShapeLibs, type PresetLine, ShapePathFormulasKeys, getTranslations, setAPI, setTranslations };
61
+ export { type LinePoint, type LinePoolItem, LinePoolItems, PathLineLibs, type PathListItem, type PathPoolItem, PathShapeLibs, type PresetLine, ShapePathFormulasKeys, setAPI };
package/dist/config.js CHANGED
@@ -1 +1 @@
1
- import{c as d,d as e,e as f,f as g}from"./chunk-45NWLCOP.js";import{f as c}from"./chunk-EUTDQZKU.js";import{a,b}from"./chunk-WFMCGQ5V.js";import"./chunk-O2XFH626.js";export{f as LinePoolItems,g as PathLineLibs,e as PathShapeLibs,d as ShapePathFormulasKeys,b as getTranslations,c as setAPI,a as setTranslations};
1
+ import{c as d,d as e,e as f,f as g}from"./chunk-45NWLCOP.js";import{a,b}from"./chunk-Q7N7SBSC.js";import{g as c}from"./chunk-3PMUQSBH.js";import"./chunk-O2XFH626.js";export{f as LinePoolItems,g as PathLineLibs,e as PathShapeLibs,d as ShapePathFormulasKeys,b as getTranslations,c as setAPI,a as setTranslations};
@@ -2,4 +2,4 @@ import 'fabric';
2
2
  import 'mobx-state-tree/dist/internal';
3
3
  import 'mobx-state-tree';
4
4
  import '@ydesign/core';
5
- export { E as ExportOptions, a as Font, b as Store, d as StoreProps, S as StoreType, c as createStore, c as default, f as forEveryChild, g as getToken } from '../store-DfmY1m2j.js';
5
+ export { E as ExportOptions, a as Font, b as Store, d as StoreProps, S as StoreType, c as createStore, c as default, f as forEveryChild, g as getToken } from '../store-CgxwnT-h.js';
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"../chunk-KERQXVBL.js";import"../chunk-YBC2DYJX.js";import"../chunk-O2XFH626.js";export{b as Font,c as Store,e as createStore,f as default,a as forEveryChild,d as getToken};
1
+ import{a,b,c,d,e,f}from"../chunk-VR4OXDJV.js";import"../chunk-YBC2DYJX.js";import"../chunk-O2XFH626.js";export{b as Font,c as Store,e as createStore,f as default,a as forEveryChild,d as getToken};
package/dist/project.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { S as StoreType, F as FONT } from './store-DfmY1m2j.js';
2
+ import { S as StoreType, F as FONT } from './store-CgxwnT-h.js';
3
3
  import 'fabric';
4
4
  import 'mobx-state-tree/dist/internal';
5
5
  import 'mobx-state-tree';
@@ -11,8 +11,12 @@ interface ProjectOptions {
11
11
  declare class Project {
12
12
  private saveTimeout;
13
13
  private isOne;
14
+ private saving;
15
+ private pendingSave;
14
16
  store: StoreType;
15
17
  id: string;
18
+ type: string;
19
+ createEmptyPoster: boolean;
16
20
  name: string;
17
21
  user: {};
18
22
  skipSaving: boolean;
@@ -38,9 +42,18 @@ declare class Project {
38
42
  * @returns
39
43
  */
40
44
  loadById(id?: string, type?: string): Promise<void>;
41
- updateUrlWithProjectId(): void;
45
+ updateUrlWithProjectId(id?: string, type?: string): void;
46
+ /**
47
+ * 保存数据
48
+ * - 保存到线上
49
+ */
42
50
  save(): Promise<void>;
43
51
  getGlobalFont(fonts?: FONT[]): Promise<FONT[]>;
52
+ uploadFileToCos(file: Blob): Promise<{
53
+ url: string;
54
+ width: number;
55
+ height: number;
56
+ }>;
44
57
  }
45
58
  declare const ProjectContext: react.Context<Project | null>;
46
59
  declare const useProject: () => Project;
package/dist/project.js CHANGED
@@ -1 +1 @@
1
- import{b as a,c as b,d as c,e as d}from"./chunk-2AZQIJ4K.js";import"./chunk-KERQXVBL.js";import"./chunk-YBC2DYJX.js";import"./chunk-EUTDQZKU.js";import"./chunk-O2XFH626.js";export{a as ProjectContext,c as createProject,d as default,b as useProject};
1
+ import{b as a,c as b,d as c,e as d}from"./chunk-W4AOHCPQ.js";import"./chunk-VR4OXDJV.js";import"./chunk-YBC2DYJX.js";import"./chunk-3PMUQSBH.js";import"./chunk-O2XFH626.js";export{a as ProjectContext,c as createProject,d as default,b as useProject};
@@ -1,5 +1,5 @@
1
1
  export { BackgroundSection, DEFAULT_SECTIONS, LayersSection, PhotosSection, Section, SectionTab, ShapesSection, default as SidePanel, SizeSection, TemplatesSection, TextSection, UploadSection } from './side-panel.js';
2
- import '../store-DfmY1m2j.js';
2
+ import '../store-CgxwnT-h.js';
3
3
  import 'fabric';
4
4
  import 'mobx-state-tree/dist/internal';
5
5
  import 'mobx-state-tree';
@@ -1 +1 @@
1
- import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c}from"../chunk-QALZ5CAJ.js";import"../chunk-63A6RW6Y.js";import"../chunk-EWOU5F3O.js";import"../chunk-RVXI723F.js";import"../chunk-5C2MNUBC.js";import"../chunk-45NWLCOP.js";import"../chunk-EUTDQZKU.js";import"../chunk-WFMCGQ5V.js";import"../chunk-O2XFH626.js";export{t as BackgroundSection,b as DEFAULT_SECTIONS,x as LayersSection,f as PhotosSection,o as SectionTab,m as ShapesSection,c as SidePanel,a as SizeSection,r as TemplatesSection,e as TextSection,p as UploadSection};
1
+ import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c}from"../chunk-ICMV2HE4.js";import"../chunk-5C2MNUBC.js";import"../chunk-OEMIP6LV.js";import"../chunk-EWOU5F3O.js";import"../chunk-45NWLCOP.js";import"../chunk-Q7N7SBSC.js";import"../chunk-3PMUQSBH.js";import"../chunk-RVXI723F.js";import"../chunk-O2XFH626.js";export{t as BackgroundSection,b as DEFAULT_SECTIONS,x as LayersSection,f as PhotosSection,o as SectionTab,m as ShapesSection,c as SidePanel,a as SizeSection,r as TemplatesSection,e as TextSection,p as UploadSection};
@@ -1,4 +1,4 @@
1
- import { S as StoreType } from '../store-DfmY1m2j.js';
1
+ import { S as StoreType } from '../store-CgxwnT-h.js';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import 'fabric';
4
4
  import 'mobx-state-tree/dist/internal';
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l}from"../chunk-QALZ5CAJ.js";import"../chunk-63A6RW6Y.js";import"../chunk-EWOU5F3O.js";import"../chunk-RVXI723F.js";import"../chunk-5C2MNUBC.js";import"../chunk-45NWLCOP.js";import"../chunk-EUTDQZKU.js";import"../chunk-WFMCGQ5V.js";import"../chunk-O2XFH626.js";export{g as BackgroundSection,j as DEFAULT_SECTIONS,h as LayersSection,d as PhotosSection,a as SectionTab,e as ShapesSection,k as SidePanel,i as SizeSection,b as TemplatesSection,c as TextSection,f as UploadSection,l as default};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l}from"../chunk-ICMV2HE4.js";import"../chunk-5C2MNUBC.js";import"../chunk-OEMIP6LV.js";import"../chunk-EWOU5F3O.js";import"../chunk-45NWLCOP.js";import"../chunk-Q7N7SBSC.js";import"../chunk-3PMUQSBH.js";import"../chunk-RVXI723F.js";import"../chunk-O2XFH626.js";export{g as BackgroundSection,j as DEFAULT_SECTIONS,h as LayersSection,d as PhotosSection,a as SectionTab,e as ShapesSection,k as SidePanel,i as SizeSection,b as TemplatesSection,c as TextSection,f as UploadSection,l as default};
@@ -94,6 +94,7 @@ declare const Store: mobx_state_tree.IModelType<{
94
94
  _triggerUpdate(): void;
95
95
  _fontSizeUpdate(): void;
96
96
  _syncBackgroundColor(color: any): void;
97
+ _workareaSizeChanged(width: number, height: number): void;
97
98
  } & {
98
99
  setBackgroundColor(color: string | Record<string, any>, isHistory?: boolean): void;
99
100
  set(options: any, element?: FabricObject): void;
@@ -210,6 +211,7 @@ declare function createStore({ key, token, workspaceId }: StoreProps): mobx_stat
210
211
  _triggerUpdate(): void;
211
212
  _fontSizeUpdate(): void;
212
213
  _syncBackgroundColor(color: any): void;
214
+ _workareaSizeChanged(width: number, height: number): void;
213
215
  } & {
214
216
  setBackgroundColor(color: string | Record<string, any>, isHistory?: boolean): void;
215
217
  set(options: any, element?: FabricObject): void;
@@ -315,6 +317,7 @@ declare function createStore({ key, token, workspaceId }: StoreProps): mobx_stat
315
317
  _triggerUpdate(): void;
316
318
  _fontSizeUpdate(): void;
317
319
  _syncBackgroundColor(color: any): void;
320
+ _workareaSizeChanged(width: number, height: number): void;
318
321
  } & {
319
322
  setBackgroundColor(color: string | Record<string, any>, isHistory?: boolean): void;
320
323
  set(options: any, element?: FabricObject): void;
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { S as StoreType } from '../store-DfmY1m2j.js';
2
+ import { S as StoreType } from '../store-CgxwnT-h.js';
3
3
  import 'fabric';
4
4
  import 'mobx-state-tree/dist/internal';
5
5
  import 'mobx-state-tree';
@@ -1 +1 @@
1
- import{a,b}from"../chunk-RBRSKAZL.js";import"../chunk-WFMCGQ5V.js";import"../chunk-O2XFH626.js";export{a as DownloadButton,b as default};
1
+ import{a,b}from"../chunk-AMEXYVS6.js";import"../chunk-Q7N7SBSC.js";import"../chunk-O2XFH626.js";export{a as DownloadButton,b as default};
@@ -2,7 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as styled_components_dist_types from 'styled-components/dist/types';
3
3
  import * as styled_components from 'styled-components';
4
4
  import * as react from 'react';
5
- import { S as StoreType } from '../store-DfmY1m2j.js';
5
+ import { S as StoreType } from '../store-CgxwnT-h.js';
6
6
  import 'fabric';
7
7
  import 'mobx-state-tree/dist/internal';
8
8
  import 'mobx-state-tree';