polotno 3.13.0 → 3.14.0

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 (75) hide show
  1. package/blueprint/side-panel/select-video.d.ts +105 -36
  2. package/canvas/apply-filters.js +1 -1
  3. package/canvas/downscale.d.ts +4 -0
  4. package/canvas/downscale.js +1 -1
  5. package/canvas/element.d.ts +1 -1
  6. package/canvas/element.js +1 -1
  7. package/canvas/figure-element.js +1 -1
  8. package/canvas/gif-element.js +1 -1
  9. package/canvas/html-element.js +1 -1
  10. package/canvas/image-element.js +1 -1
  11. package/canvas/line-element.js +1 -1
  12. package/canvas/page.js +1 -1
  13. package/canvas/paint-opacity.d.ts +12 -0
  14. package/canvas/paint-opacity.js +1 -0
  15. package/canvas/render-tag-element.js +1 -1
  16. package/canvas/rich-editor.js +11 -3
  17. package/canvas/table-element.js +1 -1
  18. package/canvas/text-element/font-specs-loader.js +1 -1
  19. package/canvas/text-element.js +1 -1
  20. package/canvas/use-filtered-source.js +1 -1
  21. package/canvas/video-element.js +1 -1
  22. package/canvas/workspace-canvas.js +1 -1
  23. package/model/audio-model.d.ts +54 -2
  24. package/model/figure-model.d.ts +65 -24
  25. package/model/gif-model.d.ts +65 -24
  26. package/model/group-model.d.ts +497 -182
  27. package/model/group-model.js +1 -1
  28. package/model/history.js +1 -1
  29. package/model/image-model.d.ts +65 -24
  30. package/model/line-model.d.ts +65 -24
  31. package/model/node-model.d.ts +65 -24
  32. package/model/node-model.js +1 -1
  33. package/model/page-model.d.ts +4369 -445
  34. package/model/page-model.js +1 -1
  35. package/model/shape-model.d.ts +65 -24
  36. package/model/store.d.ts +480 -18060
  37. package/model/store.js +1 -1
  38. package/model/svg-model.d.ts +64 -24
  39. package/model/table-model.d.ts +40 -12
  40. package/model/table-model.js +1 -1
  41. package/model/text-model.d.ts +64 -24
  42. package/model/text-model.js +1 -1
  43. package/model/video-model.d.ts +65 -24
  44. package/package.json +8 -8
  45. package/polotno.bundle.js +167 -156
  46. package/primitives/panel-header.js +1 -1
  47. package/primitives/panel-scroll-area.d.ts +4 -0
  48. package/primitives/panel-scroll-area.js +1 -0
  49. package/primitives/select.js +1 -1
  50. package/side-panel/animations-panel.js +1 -1
  51. package/side-panel/draw-panel.js +1 -1
  52. package/side-panel/effects-panel.js +1 -1
  53. package/side-panel/elements-panel.js +1 -1
  54. package/side-panel/image-clip-panel.js +1 -1
  55. package/side-panel/layers-panel.js +1 -1
  56. package/side-panel/select-video.d.ts +105 -36
  57. package/side-panel/side-panel.js +1 -1
  58. package/side-panel/size-panel.js +1 -1
  59. package/side-panel/text-panel.js +1 -1
  60. package/toolbar/color-picker.js +1 -1
  61. package/toolbar/html-toolbar.js +3 -3
  62. package/toolbar/opacity-picker.js +1 -1
  63. package/toolbar/text-toolbar.js +1 -1
  64. package/ui.css +1 -1
  65. package/utils/canvas.d.ts +0 -3
  66. package/utils/canvas.js +1 -1
  67. package/utils/clipboard.d.ts +104 -36
  68. package/utils/fonts.js +1 -1
  69. package/utils/from-svg.js +1 -1
  70. package/utils/l10n.d.ts +21 -0
  71. package/utils/l10n.js +1 -1
  72. package/utils/pointer-drag.js +1 -1
  73. package/utils/text-format-state.d.ts +3 -0
  74. package/utils/text-format-state.js +1 -1
  75. package/utils/validate-key.js +1 -1
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import i from"react";import{observer as o}from"mobx-react-lite";import{isAlive as n}from"mobx-state-tree";import{nodeAutorun as a}from"../utils/mobx.js";import{Arc as s,Group as d,Image as h,Rect as l,Text as c}from"react-konva";import{ROLES as u}from"../model/store.js";import{DEFAULT_RETRIES as m,isDeterministicUrl as g,retryDelayMs as p}from"@polotno/core/retry";import f from"konva";import{useWorkspaceStyle as v}from"./workspace-style.js";import{incrementLoader as w,triggerLoadError as x}from"../utils/loader.js";import{polotnoError as M}from"@polotno/core/errors";import{getCropRect as E}from"@polotno/core/image";import*as y from"@polotno/core/svg";import{roundEnabledPx as L,activeAnchorOf as T,roundedCropFraction as b,roundedGeometryPx as C,roundedPosition as I,isCornerAnchor as R,scaledBoxStyleAttrs as k,roundedBoxStyleAttrs as H}from"../utils/px.js";import{useFilteredSource as S}from"./use-filtered-source.js";import{useEvent as j}from"../hooks/use-event.js";import{useFadeIn as O}from"./use-fadein.js";import{isTouchDevice as P}from"../utils/screen.js";import{createPlayGate as A,playMedia as W}from"../utils/media.js";import{useMediabunnyVideo as X}from"./use-mediabunny-video.js";import{getElementTimeRange as Y,getVideoRestMs as V}from"../utils/timeline.js";import{drawReduced as _,exportKernelEnabled as D,shouldResample as z}from"./downscale.js";import{trySetCanvasSize as U}from"../utils/canvas.js";import{useClipImage as N}from"./image-element.js";import{CropOverlay as Z,CROP_CORNER_ANCHORS as B}from"./crop-overlay.js";function F(){return document.createElement("canvas")}const $=new window.Image;$.src=y.svgToURL('\n <svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path opacity="0.6" d="M4 5.49683V18.5032C4 20.05 5.68077 21.0113 7.01404 20.227L18.0694 13.7239C19.384 12.9506 19.384 11.0494 18.0694 10.2761L7.01404 3.77296C5.68077 2.98869 4 3.95 4 5.49683Z" fill="white"/>\n <path d="M4 5.49683V18.5032C4 20.05 5.68077 21.0113 7.01404 20.227L18.0694 13.7239C19.384 12.9506 19.384 11.0494 18.0694 10.2761L7.01404 3.77296C5.68077 2.98869 4 3.95 4 5.49683Z" stroke="#323232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n');const q=new window.Image;q.src=y.svgToURL('\n <svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path opacity="0.6" d="M14 19L14 5C14 3.89543 14.8954 3 16 3L17 3C18.1046 3 19 3.89543 19 5L19 19C19 20.1046 18.1046 21 17 21L16 21C14.8954 21 14 20.1046 14 19Z" fill="white"/>\n <path opacity="0.6" d="M10 19L10 5C10 3.89543 9.10457 3 8 3L7 3C5.89543 3 5 3.89543 5 5L5 19C5 20.1046 5.89543 21 7 21L8 21C9.10457 21 10 20.1046 10 19Z" fill="white"/>\n <path d="M14 19L14 5C14 3.89543 14.8954 3 16 3L17 3C18.1046 3 19 3.89543 19 5L19 19C19 20.1046 18.1046 21 17 21L16 21C14.8954 21 14 20.1046 14 19Z" stroke="#323232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M10 19L10 5C10 3.89543 9.10457 3 8 3L7 3C5.89543 3 5 3.89543 5 5L5 19C5 20.1046 5.89543 21 7 21L8 21C9.10457 21 10 20.1046 10 19Z" stroke="#323232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n');export const useCornerRadiusAndCrop=(e,t,r,o,n=0,a=!1)=>{var s;const d=Math.floor(Math.max(e.width*o,1)),h=Math.floor(Math.max(e.height*o,1)),l=Math.min(n*o,d/2,h/2),c=Math.max(e.width/r.width,e.height/r.height)*o,u=D(e.page)&&!a&&z(c,d,h),m=t instanceof HTMLVideoElement?t.videoWidth:null==t?void 0:t.width,g=t instanceof HTMLVideoElement?t.videoHeight:null==t?void 0:t.height,p=0===r.x&&0===r.y&&r.width===m&&r.height===g,v=i.useMemo(()=>{if(t&&m&&g){return p&&0===l&&!u?void 0:F()}},[t,l,u,p,m,g]),w=()=>{if(!v||!t){return}v.width=d,v.height=h;const e=v.getContext("2d");e&&(l&&(e.beginPath(),e.moveTo(l,0),e.lineTo(d-l,0),e.arc(d-l,l,l,3*Math.PI/2,0,!1),e.lineTo(d,h-l),e.arc(d-l,h-l,l,0,Math.PI/2,!1),e.lineTo(l,h),e.arc(l,h-l,l,Math.PI/2,Math.PI,!1),e.lineTo(0,l),e.arc(l,l,l,Math.PI,3*Math.PI/2,!1),e.clip()),u?_(e,t,r,v.width,v.height):e.drawImage(t,r.x,r.y,r.width,r.height,0,0,v.width,v.height))};return i.useLayoutEffect(()=>{w()},[v,e.width,e.height,r.x,r.y,r.width,r.height,n,o,a,null===(s=e.page)||void 0===s?void 0:s._exportingOrRendering,u]),i.useEffect(()=>()=>{v&&"CANVAS"===v.nodeName&&f.Util.releaseCanvas(v)},[v]),[v||t,w]};export const useClip=(e,t,r,o)=>{const[n,a]=N(e.clipSrc||""),s=e.clipSrc?a:"loaded";useLoader(s,e.clipSrc,e.id);const d=!!t&&!!n,h=i.useMemo(()=>d?{canvas:F(),mask:F(),width:0,height:0}:void 0,[d]),l=null==h?void 0:h.canvas;function c(){const i=t instanceof HTMLVideoElement?t.videoWidth:null==t?void 0:t.width,o=t instanceof HTMLVideoElement?t.videoHeight:null==t?void 0:t.height;if(!(h&&l&&t&&i&&o)){return}const n=Math.min(1e4,Math.max(i,Math.ceil(e.a.width*r),1)),a=Math.min(1e4,Math.max(o,Math.ceil(e.a.height*r),1));h.width===n&&h.height===a||(U(l,n,a),h.width=n,h.height=a);const s=l.getContext("2d");s&&(s.clearRect(0,0,l.width,l.height),s.save(),s.drawImage(h.mask,0,0,l.width,l.height),s.globalCompositeOperation="source-in",s.drawImage(t,0,0,l.width,l.height),s.restore())}return i.useLayoutEffect(()=>{var t;if(!h||!(null==n?void 0:n.width)||!n.height){return}const i=Math.max(e.a.width/n.width*r,e.a.height/n.height*r);U(h.mask,Math.min(1e4,Math.max(n.width*i,1)),Math.min(1e4,Math.max(n.height*i,1))),null===(t=h.mask.getContext("2d"))||void 0===t||t.drawImage(n,0,0,h.mask.width,h.mask.height)},[h,n,e.a.width,e.a.height,r]),i.useLayoutEffect(()=>{c()},[h,t,n,e.a.width,e.a.height,r,...o]),i.useEffect(()=>()=>{h&&f.Util.releaseCanvas(h.canvas,h.mask)},[h]),[d?l:t,c]};const G=F(),J=o(({element:r})=>{const o=Math.min(30,r.width/4,r.height/4),n=i.useRef(null);i.useEffect(()=>{const e=n.current;if(!e){return}const t=new f.Animation(t=>{e.rotate(((null==t?void 0:t.timeDiff)||0)/2)},e.getLayer());return t.start(),()=>{t.stop()}});const{mediaLoadingStyle:a}=v();return t(d,{x:r.a.x,y:r.a.y,rotation:r.a.rotation,listening:!1,opacity:r.a.opacity,hideInExport:!r.showInExport,children:[e(l,{width:r.width,height:r.height,fill:a.fill}),e(s,{ref:n,x:r.width/2,y:r.height/2,fill:a.textFill,outerRadius:Math.abs(o),innerRadius:Math.max(1,o-5),angle:270})]})}),K=o(({element:r})=>{const{mediaErrorStyle:i}=v(),o=Math.max(10,Math.min(30,r.width/25));return t(d,{x:r.a.x,y:r.a.y,rotation:r.a.rotation,listening:!1,opacity:r.a.opacity,hideInExport:!r.showInExport,children:[e(l,{width:r.width,height:r.height,fill:i.fill}),e(c,{text:"Can not load the video...",fontSize:o,width:r.width,height:r.height,align:"center",fill:i.textFill,verticalAlign:"middle",padding:5})]})});let Q=function(e,t,r){const o=i.useRef("loading"),n=i.useRef(void 0),[a,s]=i.useState(0),d=i.useRef(void 0),h=i.useRef(void 0),l=i.useRef(void 0);return d.current===e&&h.current===t&&l.current===r||(o.current="loading",n.current=void 0,d.current=e,h.current=t,l.current=r),i.useLayoutEffect(()=>{if(!e){return}const i=g(e)?1:m;let a,d,h,l=0,c=!1,u=!1;const f=e=>{e&&(e.removeAttribute("src"),e.load())},v=()=>{l+=1;const m=document.createElement("video");function g(){c||(m.removeEventListener("canplay",g),u=!0,o.current="loaded",n.current=m,m.currentTime=0,s(Math.random()))}function w(e){var t;const r=4===m.readyState,h=m.buffered&&m.buffered.length>0&&m.buffered.end(m.buffered.length-1)/m.duration*100>=100;if(r&&h){return}if(c){return}if(!u&&l<i){return null==d||d(),f(m),void(a=setTimeout(v,p(l)))}const g=e.message||(null===(t=m.error)||void 0===t?void 0:t.message)||"Unknown error";console.error(new Error("Video failed to load: "+g)),o.current="failed",n.current=void 0,s(Math.random())}h=m,m.addEventListener("canplay",g),m.addEventListener("error",w),d=()=>{m.removeEventListener("canplay",g),m.removeEventListener("error",w)},t&&(m.crossOrigin=t),r&&(m.referrerPolicy=r),m.src=e,m.load()};return v(),()=>{c=!0,clearTimeout(a),null==d||d(),u||f(h)}},[e,t,r]),[n.current,o.current]};export const setVideoLoaderHook=e=>{Q=e};function ee(e){return e.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA}export const useLoader=(e,t,r)=>{const o=i.useRef(void 0),n=()=>{var e;null===(e=o.current)||void 0===e||e.call(o),o.current=void 0};i.useEffect(()=>n,[]),i.useLayoutEffect(()=>{const i=t.slice(0,200),a=`video with id ${r} url: ${i}`;"loading"!==e||o.current||(o.current=w(a)),"loading"!==e&&n(),"failed"===e&&x(M("VIDEO_FAILED",a,{src:i,elementId:r,reason:"load"}))},[e])};export const VideoElement=o(({element:o,store:s})=>{var c,m,g;const[p,v]=i.useState(!1),x=i.useRef(null),M=o.isSelected,[_,D]=i.useState(!1),[z,U]=Q(o.src,"anonymous"),[N,te]=i.useState(!1),re=s.activePage===o.page,ie=(null===(c=o.page)||void 0===c?void 0:c._exportingOrRendering)&&"loaded"===U,oe=X(o,s,ie);useLoader(U,o.src,o.id),z&&(z.playsInline=!0);const ne=((e,t,r)=>{const o=i.useMemo(()=>{var i,o;const{flipX:n,flipY:a}=e,s="svg"===e.type||y.isSvgUrl(e.src),d=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;if(!(n||a||d&&s)){return t}if(!t){return null}const h=t instanceof HTMLVideoElement?t.videoWidth:null==t?void 0:t.width,l=t instanceof HTMLVideoElement?t.videoHeight:null==t?void 0:t.height;if(!h||!l){return null}const c=F();let u=1;"svg"===e.type&&(u=Math.max(e.width/h*r,e.height/l*r)),c.width=Math.max(h*u,1),c.height=Math.max(l*u,1);let m=n?-c.width:0,g=a?-c.height:0;return null===(i=c.getContext("2d"))||void 0===i||i.scale(n?-1:1,a?-1:1),null===(o=c.getContext("2d"))||void 0===o||o.drawImage(t,m,g,c.width,c.height),c},[e.flipX,e.flipY,t,e.width,e.height,r]);return i.useEffect(()=>()=>{o&&"CANVAS"===o.nodeName&&f.Util.releaseCanvas(o)},[o]),o})(o,z,s._elementsPixelRatio),ae=ie&&oe||ne||G,[se=G,de]=S(o,ae);i.useEffect(()=>{z&&s.history.ignore(()=>{o.set({duration:1e3*z.duration})})},[z]);const he=i.useMemo(A,[z]);i.useEffect(()=>{var e;if(!z){return}const t=s.animatedElementsIds,r=(!t.length||t.includes(o.id))&&s.isPlaying;if(!re||!r&&!_){return void z.pause()}_&&(z.muted=!1,z.currentTime=o.startTime*z.duration,W(z).then(e=>{"refused"===e&&D(!1)}));const i=new f.Animation(()=>{Ie()},null===(e=x.current)||void 0===e?void 0:e.getLayer());i.start();const n=()=>{D(!1),z.currentTime=o.startTime*z.duration},a=()=>{z.currentTime>=o.endTime*z.duration&&(z.pause(),z.currentTime=o.startTime*z.duration,D(!1))};return z.addEventListener("ended",n),z.addEventListener("timeupdate",a),()=>{z.pause(),i.stop(),z.removeEventListener("ended",n),z.removeEventListener("timeupdate",a)}},[z,_,s.isPlaying,re]),i.useEffect(()=>{z&&(z.volume=o.volume)},[z,o.volume]),i.useEffect(()=>{z&&(z.playbackRate=o.speed,z.preservesPitch=!1)},[z,o.speed]);const le=i.useRef(null);i.useEffect(()=>{const e=a(o,()=>{var e,t;if(z){if(ie&&oe){return Ie(),void s.currentTime}const r=s.animatedElementsIds;if(r.length&&!r.includes(o.id)){return}const i=s.activePage===o.page,n=s.currentTime>=o.page.startTime&&s.currentTime<o.page.startTime+o.page.duration,a=o.startTime*z.duration*1e3,d=z.duration*(o.endTime-o.startTime)*1e3,{start:h,end:l}=Y(o.animations,o.page.duration),c=(s.currentTime||o.page.startTime)-o.page.startTime,u=n?V(s.currentTime,o.page.startTime,h,d,a,o.speed):0,m=u/1e3,g=n&&c>=h&&c<l;_||(z.muted=!g,g&&s.isPlaying&&i?z.paused?(z.currentTime=m,he.play(z)):Math.abs(1e3*z.currentTime-u)>500&&(z.currentTime=m):(he.reset(),z.paused||z.pause(),m!==z.currentTime&&(z.currentTime=m),!ee(z)&&!s.isPlaying&&!le.current&&(le.current=w(`video ${o.id}`)))),Ie(),null===(t=null===(e=x.current)||void 0===e?void 0:e.getLayer())||void 0===t||t.batchDraw()}});return()=>{e(),le.current&&(le.current(),le.current=null)}},[s,z,ie,oe,_]),i.useEffect(()=>{var e,t;if(!z){return}if(ie){return null===(e=le.current)||void 0===e||e.call(le),void(le.current=null)}const r=()=>{var e,t,r;!ee(z)&&(null===(e=o.page)||void 0===e?void 0:e._exportingOrRendering)||le.current&&(Ie(),null===(r=null===(t=x.current)||void 0===t?void 0:t.getLayer())||void 0===r||r.batchDraw(),le.current(),le.current=null)};let i;return(null===(t=o.page)||void 0===t?void 0:t._exportingOrRendering)&&(i=setInterval(r,20)),z.addEventListener("timeupdate",r),z.addEventListener("canplay",r),()=>{clearInterval(i),z.removeEventListener("timeupdate",r),z.removeEventListener("canplay",r)}},[null===(m=o.page)||void 0===m?void 0:m._exportingOrRendering,z,o.id,w,ie]);let{cropX:ce,cropY:ue,cropWidth:me,cropHeight:ge}=o;"loaded"!==U&&(ce=ue=0,me=ge=1);const pe=(fe=se)instanceof HTMLVideoElement?fe.videoWidth:(null==fe?void 0:fe.width)||0;var fe;const ve=(e=>e instanceof HTMLVideoElement?e.videoHeight:(null==e?void 0:e.height)||0)(se),we=E({stretchEnabled:o.stretchEnabled,cropX:ce,cropY:ue,cropWidth:me,cropHeight:ge,width:o.a.width,height:o.a.height},{width:pe,height:ve}),xe=we.width,Me=we.height,Ee=o.stretchEnabled,ye=null!==(g=o.cornerRadius)&&void 0!==g?g:0,[Le,Te]=useCornerRadiusAndCrop(o,se,we,s._elementsPixelRatio,ye,!0);let[be,Ce]=useClip(o,Le,s._elementsPixelRatio,[we,ye,s._elementsPixelRatio]);const Ie=j(()=>{var e,t;de(),Te(),Ce(),null===(t=null===(e=x.current)||void 0===e?void 0:e.getLayer())||void 0===t||t.batchDraw()});i.useEffect(()=>{Ie()});const Re=()=>{o._cropEnabled&&setTimeout(()=>{n(o)&&o.toggleCropMode(!0)})},ke="loading"===U,He="failed"===U,Se=!ke&&!He,je=i.useRef({cropX:0,cropY:0,cropWidth:0,cropHeight:0}),Oe=i.useRef(!1),Pe=Se?o.a.opacity:0;O(x,Pe);const Ae=o.selectable||s.role===u.ADMIN,We=P();return e(r,{children:t(d,{onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),children:[ke&&e(J,{element:o}),He&&e(K,{element:o}),e(h,{ref:x,name:"element",id:o.id,image:be,x:o.a.x,y:o.a.y,width:o.a.width||1,height:o.a.height||1,rotation:o.a.rotation,opacity:Pe,shadowEnabled:o.shadowEnabled,shadowBlur:o.shadowBlur,shadowOffsetX:o.shadowOffsetX,shadowOffsetY:o.shadowOffsetY,shadowColor:o.shadowColor,shadowOpacity:o.shadowOpacity,customCrop:we,listening:Ae,draggable:We?o.draggable&&M:o.draggable,preventDefault:!We||M,hideInExport:!o.showInExport,onDragMove:e=>{o.set({x:e.target.x(),y:e.target.y()})},onDragEnd:e=>{o.set(I(e.target))},onDblClick:Re,onDblTap:Re,onTransformStart:e=>{v(!0),Oe.current=R(T(e.target)),je.current={cropX:o.cropX,cropY:o.cropY,cropWidth:o.cropWidth,cropHeight:o.cropHeight}},onTransform:e=>{const t=e.currentTarget,r=Math.abs(t.scaleX()-1)<1e-7?1:t.scaleX(),i=Math.abs(t.scaleY()-1)<1e-7?1:t.scaleY();t.scaleX(1),t.scaleY(1);const n=1-xe/pe,a=Math.min(n,Math.max(0,o.cropX)),s=1-Me/ve,d=Math.min(s,Math.max(0,o.cropY)),h=Oe.current,l=!h&&r<1&&je.current.cropHeight>Me/ve;let c=h?o.cropWidth:o.cropWidth*r;l&&(c=o.cropWidth);const u=!h&&i<1&&je.current.cropWidth>xe/pe;let m=h?o.cropHeight:o.cropHeight*i;u&&(m=o.cropHeight),Ee&&(c=o.cropWidth,m=o.cropHeight);const g=h?Math.min(r,i):1;o.set(Object.assign({cropX:a,cropY:d,x:t.x(),y:t.y(),width:t.width()*r,height:t.height()*i,rotation:e.target.rotation(),cropWidth:Math.min(c,1-a),cropHeight:Math.min(m,1-d)},1!==g&&Object.assign(Object.assign({},k(o,g)),{borderSize:o.borderSize*g})))},onTransformEnd:e=>{const t=e.currentTarget;o.set(Object.assign(Object.assign({width:C(t.width()),height:C(t.height()),x:C(t.x()),y:C(t.y()),rotation:C(e.target.rotation()),cropX:b(o.cropX),cropY:b(o.cropY),cropWidth:b(xe/pe),cropHeight:b(Me/ve)},H(o)),{borderSize:L(o.borderSize)})),v(!1)}}),e(l,{x:o.a.x,y:o.a.y,width:Math.max(o.a.width-o.borderSize,0),height:Math.max(o.a.height-o.borderSize,0),opacity:Pe,offsetX:-o.borderSize/2,offsetY:-o.borderSize/2,stroke:o.borderColor,strokeWidth:o.borderSize,listening:!1,visible:!!o.borderSize,rotation:o.rotation,cornerRadius:Math.max(0,ye-o.borderSize),hideInExport:!o.showInExport}),!s.isPlaying&&e(h,{image:_?N||We?q:void 0:$,x:o.a.x,y:o.a.y,offsetX:-o.a.width/2+15/s.scale,offsetY:-o.a.height/2+15/s.scale,rotation:o.a.rotation,width:30/s.scale,height:30/s.scale,hideInExport:!0,onClick:()=>D(!_),onTap:()=>D(!_)}),o._cropModeEnabled&&e(Z,{element:o,store:s,previewImage:be,sourceImage:se,sourceWidth:pe,sourceHeight:ve,cropAbsoluteWidth:xe,cropAbsoluteHeight:Me,innerAnchors:B})]})})});
1
+ import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{elementOpacity as i}from"./paint-opacity.js";import o from"react";import{observer as n}from"mobx-react-lite";import{isAlive as a}from"mobx-state-tree";import{nodeAutorun as s}from"../utils/mobx.js";import{Arc as d,Group as c,Image as h,Rect as l,Text as u}from"react-konva";import{ROLES as m}from"../model/store.js";import{DEFAULT_RETRIES as g,isDeterministicUrl as p,retryDelayMs as f}from"@polotno/core/retry";import v from"konva";import{useWorkspaceStyle as w}from"./workspace-style.js";import{incrementLoader as x,triggerLoadError as E}from"../utils/loader.js";import{polotnoError as y}from"@polotno/core/errors";import{getCropRect as M}from"@polotno/core/image";import*as L from"@polotno/core/svg";import{roundEnabledPx as b,activeAnchorOf as C,roundedCropFraction as T,roundedGeometryPx as k,roundedPosition as I,isCornerAnchor as R,scaledBoxStyleAttrs as j,roundedBoxStyleAttrs as S}from"../utils/px.js";import{useFilteredSource as P}from"./use-filtered-source.js";import{useEvent as A}from"../hooks/use-event.js";import{useFadeIn as O}from"./use-fadein.js";import{isTouchDevice as X}from"../utils/screen.js";import{createPlayGate as Y,playMedia as H}from"../utils/media.js";import{useMediabunnyVideo as W}from"./use-mediabunny-video.js";import{getElementTimeRange as _,getVideoRestMs as z}from"../utils/timeline.js";import{drawReduced as D,exportKernelEnabled as V,shouldResample as U,sourceSize as N}from"./downscale.js";import{trySetCanvasSize as Z}from"../utils/canvas.js";import{useClipImage as B}from"./image-element.js";import{CropOverlay as F,CROP_CORNER_ANCHORS as $}from"./crop-overlay.js";const q=new window.Image;q.src=L.svgToURL('\n <svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path opacity="0.6" d="M4 5.49683V18.5032C4 20.05 5.68077 21.0113 7.01404 20.227L18.0694 13.7239C19.384 12.9506 19.384 11.0494 18.0694 10.2761L7.01404 3.77296C5.68077 2.98869 4 3.95 4 5.49683Z" fill="white"/>\n <path d="M4 5.49683V18.5032C4 20.05 5.68077 21.0113 7.01404 20.227L18.0694 13.7239C19.384 12.9506 19.384 11.0494 18.0694 10.2761L7.01404 3.77296C5.68077 2.98869 4 3.95 4 5.49683Z" stroke="#323232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n');const G=new window.Image;G.src=L.svgToURL('\n <svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path opacity="0.6" d="M14 19L14 5C14 3.89543 14.8954 3 16 3L17 3C18.1046 3 19 3.89543 19 5L19 19C19 20.1046 18.1046 21 17 21L16 21C14.8954 21 14 20.1046 14 19Z" fill="white"/>\n <path opacity="0.6" d="M10 19L10 5C10 3.89543 9.10457 3 8 3L7 3C5.89543 3 5 3.89543 5 5L5 19C5 20.1046 5.89543 21 7 21L8 21C9.10457 21 10 20.1046 10 19Z" fill="white"/>\n <path d="M14 19L14 5C14 3.89543 14.8954 3 16 3L17 3C18.1046 3 19 3.89543 19 5L19 19C19 20.1046 18.1046 21 17 21L16 21C14.8954 21 14 20.1046 14 19Z" stroke="#323232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n <path d="M10 19L10 5C10 3.89543 9.10457 3 8 3L7 3C5.89543 3 5 3.89543 5 5L5 19C5 20.1046 5.89543 21 7 21L8 21C9.10457 21 10 20.1046 10 19Z" stroke="#323232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n');export const useCornerRadiusAndCrop=(e,t,r,i,n=0,a=!1)=>{var s;const d=Math.floor(Math.max(e.width*i,1)),c=Math.floor(Math.max(e.height*i,1)),h=Math.min(n*i,d/2,c/2),l=Math.max(e.width/r.width,e.height/r.height)*i,u=V(e.page)&&!a&&U(l,d,c),{width:m,height:g}=t?N(t):{},p=0===r.x&&0===r.y&&r.width===m&&r.height===g,f=o.useMemo(()=>{if(t&&m&&g){return p&&0===h&&!u?void 0:document.createElement("canvas")}},[t,h,u,p,m,g]),w=()=>{if(!f||!t){return}f.width=d,f.height=c;const e=f.getContext("2d");e&&(h&&(e.beginPath(),e.moveTo(h,0),e.lineTo(d-h,0),e.arc(d-h,h,h,3*Math.PI/2,0,!1),e.lineTo(d,c-h),e.arc(d-h,c-h,h,0,Math.PI/2,!1),e.lineTo(h,c),e.arc(h,c-h,h,Math.PI/2,Math.PI,!1),e.lineTo(0,h),e.arc(h,h,h,Math.PI,3*Math.PI/2,!1),e.clip()),u?D(e,t,r,f.width,f.height):e.drawImage(t,r.x,r.y,r.width,r.height,0,0,f.width,f.height))};return o.useLayoutEffect(()=>{w()},[f,e.width,e.height,r.x,r.y,r.width,r.height,n,i,a,null===(s=e.page)||void 0===s?void 0:s._exportingOrRendering,u]),o.useEffect(()=>()=>{f&&"CANVAS"===f.nodeName&&v.Util.releaseCanvas(f)},[f]),[f||t,w]};export const useClip=(e,t,r,i)=>{const[n,a]=B(e.clipSrc||""),s=e.clipSrc?a:"loaded";useLoader(s,e.clipSrc,e.id);const d=!!t&&!!n,c=o.useMemo(()=>d?{canvas:document.createElement("canvas"),mask:document.createElement("canvas"),width:0,height:0}:void 0,[d]),h=null==c?void 0:c.canvas;function l(){if(!c||!h||!t){return}const{width:i,height:o}=N(t);if(!i||!o){return}const n=Math.min(1e4,Math.max(i,Math.ceil(e.a.width*r),1)),a=Math.min(1e4,Math.max(o,Math.ceil(e.a.height*r),1));c.width===n&&c.height===a||(Z(h,n,a),c.width=n,c.height=a);const s=h.getContext("2d");s&&(s.clearRect(0,0,h.width,h.height),s.save(),s.drawImage(c.mask,0,0,h.width,h.height),s.globalCompositeOperation="source-in",s.drawImage(t,0,0,h.width,h.height),s.restore())}return o.useLayoutEffect(()=>{var t;if(!c||!(null==n?void 0:n.width)||!n.height){return}const i=Math.max(e.a.width/n.width*r,e.a.height/n.height*r);Z(c.mask,Math.min(1e4,Math.max(n.width*i,1)),Math.min(1e4,Math.max(n.height*i,1))),null===(t=c.mask.getContext("2d"))||void 0===t||t.drawImage(n,0,0,c.mask.width,c.mask.height)},[c,n,e.a.width,e.a.height,r]),o.useLayoutEffect(()=>{l()},[c,t,n,e.a.width,e.a.height,r,...i]),o.useEffect(()=>()=>{c&&v.Util.releaseCanvas(c.canvas,c.mask)},[c]),[d?h:t,l]};const J=document.createElement("canvas"),K=n(({element:r})=>{const n=Math.min(30,r.width/4,r.height/4),a=o.useRef(null);o.useEffect(()=>{const e=a.current;if(!e){return}const t=new v.Animation(t=>{e.rotate(((null==t?void 0:t.timeDiff)||0)/2)},e.getLayer());return t.start(),()=>{t.stop()}});const{mediaLoadingStyle:s}=w();return t(c,{x:r.a.x,y:r.a.y,rotation:r.a.rotation,listening:!1,opacity:i(r),hideInExport:!r.showInExport,children:[e(l,{width:r.width,height:r.height,fill:s.fill}),e(d,{ref:a,x:r.width/2,y:r.height/2,fill:s.textFill,outerRadius:Math.abs(n),innerRadius:Math.max(1,n-5),angle:270})]})}),Q=n(({element:r})=>{const{mediaErrorStyle:o}=w(),n=Math.max(10,Math.min(30,r.width/25));return t(c,{x:r.a.x,y:r.a.y,rotation:r.a.rotation,listening:!1,opacity:i(r),hideInExport:!r.showInExport,children:[e(l,{width:r.width,height:r.height,fill:o.fill}),e(u,{text:"Can not load the video...",fontSize:n,width:r.width,height:r.height,align:"center",fill:o.textFill,verticalAlign:"middle",padding:5})]})});let ee=function(e,t,r){const i=o.useRef("loading"),n=o.useRef(void 0),[a,s]=o.useState(0),d=o.useRef(void 0),c=o.useRef(void 0),h=o.useRef(void 0);return d.current===e&&c.current===t&&h.current===r||(i.current="loading",n.current=void 0,d.current=e,c.current=t,h.current=r),o.useLayoutEffect(()=>{if(!e){return}const o=p(e)?1:g;let a,d,c,h=0,l=!1,u=!1;const m=e=>{e&&(e.removeAttribute("src"),e.load())},v=()=>{h+=1;const g=document.createElement("video");function p(){l||(g.removeEventListener("canplay",p),u=!0,i.current="loaded",n.current=g,g.currentTime=0,s(Math.random()))}function w(e){var t;const r=4===g.readyState,c=g.buffered&&g.buffered.length>0&&g.buffered.end(g.buffered.length-1)/g.duration*100>=100;if(r&&c){return}if(l){return}if(!u&&h<o){return null==d||d(),m(g),void(a=setTimeout(v,f(h)))}const p=e.message||(null===(t=g.error)||void 0===t?void 0:t.message)||"Unknown error";console.error(new Error("Video failed to load: "+p)),i.current="failed",n.current=void 0,s(Math.random())}c=g,g.addEventListener("canplay",p),g.addEventListener("error",w),d=()=>{g.removeEventListener("canplay",p),g.removeEventListener("error",w)},t&&(g.crossOrigin=t),r&&(g.referrerPolicy=r),g.src=e,g.load()};return v(),()=>{l=!0,clearTimeout(a),null==d||d(),u||m(c)}},[e,t,r]),[n.current,i.current]};export const setVideoLoaderHook=e=>{ee=e};function te(e){return!e.seeking&&e.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA}export const useLoader=(e,t,r)=>{const i=o.useRef(void 0),n=()=>{var e;null===(e=i.current)||void 0===e||e.call(i),i.current=void 0};o.useEffect(()=>n,[]),o.useLayoutEffect(()=>{const o=t.slice(0,200),a=`video with id ${r} url: ${o}`;"loading"!==e||i.current||(i.current=x(a)),"loading"!==e&&n(),"failed"===e&&E(y("VIDEO_FAILED",a,{src:o,elementId:r,reason:"load"}))},[e])};export const VideoElement=n(({element:n,store:d})=>{var u,g,p;const[f,w]=o.useState(!1),E=o.useRef(null),y=n.isSelected,[D,V]=o.useState(!1),[U,Z]=ee(n.src,"anonymous"),[B,re]=o.useState(!1),ie=d.activePage===n.page,oe=(null===(u=n.page)||void 0===u?void 0:u._exportingOrRendering)&&"loaded"===Z,ne=W(n,d,oe);useLoader(Z,n.src,n.id),U&&(U.playsInline=!0);const ae=((e,t,r)=>{const i=o.useMemo(()=>{var i,o;const{flipX:n,flipY:a}=e,s="svg"===e.type||L.isSvgUrl(e.src),d=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;if(!(n||a||d&&s)){return t}if(!t){return null}const{width:c,height:h}=N(t);if(!c||!h){return null}const l=document.createElement("canvas");let u=1;"svg"===e.type&&(u=Math.max(e.width/c*r,e.height/h*r)),l.width=Math.max(c*u,1),l.height=Math.max(h*u,1);let m=n?-l.width:0,g=a?-l.height:0;return null===(i=l.getContext("2d"))||void 0===i||i.scale(n?-1:1,a?-1:1),null===(o=l.getContext("2d"))||void 0===o||o.drawImage(t,m,g,l.width,l.height),l},[e.flipX,e.flipY,t,e.width,e.height,r]);return o.useEffect(()=>()=>{i&&"CANVAS"===i.nodeName&&v.Util.releaseCanvas(i)},[i]),i})(n,U,d._elementsPixelRatio),se=oe&&ne||ae||J,[de=J,ce]=P(n,se);o.useEffect(()=>{U&&d.history.ignore(()=>{n.set({duration:1e3*U.duration})})},[U]);const he=o.useMemo(Y,[U]);o.useEffect(()=>{var e;if(!U){return}const t=d.animatedElementsIds,r=(!t.length||t.includes(n.id))&&d.isPlaying;if(!ie||!r&&!D){return void U.pause()}D&&(U.muted=!1,U.currentTime=n.startTime*U.duration,H(U).then(e=>{"refused"===e&&V(!1)}));const i=new v.Animation(()=>{ke()},null===(e=E.current)||void 0===e?void 0:e.getLayer());i.start();const o=()=>{V(!1),U.currentTime=n.startTime*U.duration},a=()=>{U.currentTime>=n.endTime*U.duration&&(U.pause(),U.currentTime=n.startTime*U.duration,V(!1))};return U.addEventListener("ended",o),U.addEventListener("timeupdate",a),()=>{U.pause(),i.stop(),U.removeEventListener("ended",o),U.removeEventListener("timeupdate",a)}},[U,D,d.isPlaying,ie]),o.useEffect(()=>{U&&(U.volume=n.volume)},[U,n.volume]),o.useEffect(()=>{U&&(U.playbackRate=n.speed,U.preservesPitch=!1)},[U,n.speed]);const le=o.useRef(null);o.useEffect(()=>{const e=s(n,()=>{var e,t;if(U){if(oe&&ne){return ke(),void d.currentTime}const r=d.animatedElementsIds;if(r.length&&!r.includes(n.id)){return}const i=d.activePage===n.page,o=d.currentTime>=n.page.startTime&&d.currentTime<n.page.startTime+n.page.duration,a=n.startTime*U.duration*1e3,s=U.duration*(n.endTime-n.startTime)*1e3,{start:c,end:h}=_(n.animations,n.page.duration),l=(d.currentTime||n.page.startTime)-n.page.startTime,u=o?z(d.currentTime,n.page.startTime,c,s,a,n.speed):0,m=u/1e3,g=o&&l>=c&&l<h;D||(U.muted=!g,g&&d.isPlaying&&i?U.paused?(U.currentTime=m,he.play(U)):Math.abs(1e3*U.currentTime-u)>500&&(U.currentTime=m):(he.reset(),U.paused||U.pause(),m!==U.currentTime&&(U.currentTime=m),!te(U)&&!d.isPlaying&&!le.current&&(le.current=x(`video ${n.id}`)))),ke(),null===(t=null===(e=E.current)||void 0===e?void 0:e.getLayer())||void 0===t||t.batchDraw()}});return()=>{e(),le.current&&(le.current(),le.current=null)}},[d,U,oe,ne,D]),o.useEffect(()=>{var e,t;if(!U){return}if(oe){return null===(e=le.current)||void 0===e||e.call(le),void(le.current=null)}const r=()=>{var e;te(U)&&(ke(),null===(e=le.current)||void 0===e||e.call(le),le.current=null)};let i;return(null===(t=n.page)||void 0===t?void 0:t._exportingOrRendering)&&(i=setInterval(r,20)),U.addEventListener("timeupdate",r),U.addEventListener("canplay",r),U.addEventListener("seeked",r),()=>{clearInterval(i),U.removeEventListener("timeupdate",r),U.removeEventListener("canplay",r),U.removeEventListener("seeked",r)}},[null===(g=n.page)||void 0===g?void 0:g._exportingOrRendering,U,n.id,x,oe]);let{cropX:ue,cropY:me,cropWidth:ge,cropHeight:pe}=n;"loaded"!==Z&&(ue=me=0,ge=pe=1);const{width:fe,height:ve}=N(de),we=M({stretchEnabled:n.stretchEnabled,cropX:ue,cropY:me,cropWidth:ge,cropHeight:pe,width:n.a.width,height:n.a.height},{width:fe,height:ve}),xe=we.width,Ee=we.height,ye=n.stretchEnabled,Me=null!==(p=n.cornerRadius)&&void 0!==p?p:0,[Le,be]=useCornerRadiusAndCrop(n,de,we,d._elementsPixelRatio,Me,!0);let[Ce,Te]=useClip(n,Le,d._elementsPixelRatio,[we,Me,d._elementsPixelRatio]);const ke=A(()=>{var e,t;ce(),be(),Te(),null===(t=null===(e=E.current)||void 0===e?void 0:e.getLayer())||void 0===t||t.batchDraw()});o.useEffect(()=>{ke()});const Ie=()=>{n._cropEnabled&&setTimeout(()=>{a(n)&&n.toggleCropMode(!0)})},Re="loading"===Z,je="failed"===Z,Se=!Re&&!je,Pe=o.useRef({cropX:0,cropY:0,cropWidth:0,cropHeight:0}),Ae=o.useRef(!1),Oe=Se?i(n):0;O(E,Oe);const Xe=n.selectable||d.role===m.ADMIN,Ye=X();return e(r,{children:t(c,{onMouseEnter:()=>re(!0),onMouseLeave:()=>re(!1),children:[Re&&e(K,{element:n}),je&&e(Q,{element:n}),e(h,{ref:E,name:"element",id:n.id,image:Ce,x:n.a.x,y:n.a.y,width:n.a.width||1,height:n.a.height||1,rotation:n.a.rotation,opacity:Oe,shadowEnabled:n.shadowEnabled,shadowBlur:n.shadowBlur,shadowOffsetX:n.shadowOffsetX,shadowOffsetY:n.shadowOffsetY,shadowColor:n.shadowColor,shadowOpacity:n.shadowOpacity,customCrop:we,listening:Xe,draggable:Ye?n.draggable&&y:n.draggable,preventDefault:!Ye||y,hideInExport:!n.showInExport,onDragMove:e=>{n.set({x:e.target.x(),y:e.target.y()})},onDragEnd:e=>{n.set(I(e.target))},onDblClick:Ie,onDblTap:Ie,onTransformStart:e=>{w(!0),Ae.current=R(C(e.target)),Pe.current={cropX:n.cropX,cropY:n.cropY,cropWidth:n.cropWidth,cropHeight:n.cropHeight}},onTransform:e=>{const t=e.currentTarget,r=Math.abs(t.scaleX()-1)<1e-7?1:t.scaleX(),i=Math.abs(t.scaleY()-1)<1e-7?1:t.scaleY();t.scaleX(1),t.scaleY(1);const o=1-xe/fe,a=Math.min(o,Math.max(0,n.cropX)),s=1-Ee/ve,d=Math.min(s,Math.max(0,n.cropY)),c=Ae.current,h=!c&&r<1&&Pe.current.cropHeight>Ee/ve;let l=c?n.cropWidth:n.cropWidth*r;h&&(l=n.cropWidth);const u=!c&&i<1&&Pe.current.cropWidth>xe/fe;let m=c?n.cropHeight:n.cropHeight*i;u&&(m=n.cropHeight),ye&&(l=n.cropWidth,m=n.cropHeight);const g=c?Math.min(r,i):1;n.set(Object.assign({cropX:a,cropY:d,x:t.x(),y:t.y(),width:t.width()*r,height:t.height()*i,rotation:e.target.rotation(),cropWidth:Math.min(l,1-a),cropHeight:Math.min(m,1-d)},1!==g&&Object.assign(Object.assign({},j(n,g)),{borderSize:n.borderSize*g})))},onTransformEnd:e=>{const t=e.currentTarget;n.set(Object.assign(Object.assign({width:k(t.width()),height:k(t.height()),x:k(t.x()),y:k(t.y()),rotation:k(e.target.rotation()),cropX:T(n.cropX),cropY:T(n.cropY),cropWidth:T(xe/fe),cropHeight:T(Ee/ve)},S(n)),{borderSize:b(n.borderSize)})),w(!1)}}),e(l,{x:n.a.x,y:n.a.y,width:Math.max(n.a.width-n.borderSize,0),height:Math.max(n.a.height-n.borderSize,0),opacity:Oe,offsetX:-n.borderSize/2,offsetY:-n.borderSize/2,stroke:n.borderColor,strokeWidth:n.borderSize,listening:!1,visible:!!n.borderSize,rotation:n.rotation,cornerRadius:Math.max(0,Me-n.borderSize),hideInExport:!n.showInExport}),!d.isPlaying&&e(h,{image:D?B||Ye?G:void 0:q,x:n.a.x,y:n.a.y,offsetX:-n.a.width/2+15/d.scale,offsetY:-n.a.height/2+15/d.scale,rotation:n.a.rotation,width:30/d.scale,height:30/d.scale,hideInExport:!0,onClick:()=>V(!D),onTap:()=>V(!D)}),n._cropModeEnabled&&e(F,{element:n,store:d,previewImage:Ce,sourceImage:de,sourceWidth:fe,sourceHeight:ve,cropAbsoluteWidth:xe,cropAbsoluteHeight:Ee,innerAnchors:$})]})})});
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import r from"react";import{observer as o}from"mobx-react-lite";import n from"./page.js";import{TopRules as l}from"./rules.js";import{AudioElement as i}from"./audio.js";import{handleHotkey as s,handleCopyEvent as a,handleCutEvent as c,handlePasteEvent as u}from"./hotkeys.js";import{t as d}from"../utils/l10n.js";import{WorkspaceStyleProvider as h,useResolvedWorkspaceStyle as g}from"./workspace-style.js";const p=(e,t,r)=>Math.max(t,Math.min(r,e)),f=(e,t)=>Math.sqrt(Math.pow(t.clientX-e.clientX,2)+Math.pow(t.clientY-e.clientY,2)),m=({store:r})=>t("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center"},children:[e("p",{children:d("workspace.noPages")}),e("button",{onClick:()=>{r.addPage()},children:d("workspace.addPage")})]}),v=({width:t,height:r,xPadding:o,yPadding:n,backgroundColor:l})=>e("div",{style:{width:t+"px",height:r+"px",backgroundColor:l,paddingLeft:o+"px",paddingRight:o+"px",paddingTop:n+"px",paddingBottom:n+"px",flexShrink:0},children:e("div",{style:{width:" 100%",height:"100%",backgroundColor:"white"}})});export const WorkspaceCanvas=o(({store:o,layout:d="vertical",pageControlsEnabled:w,backgroundColor:x,transparencyBackgroundColor:y,pageBorderColor:L,activePageBorderColor:T,bleedColor:b,snapGuideStroke:k,snapGuideStrokeWidth:S,snapGuideDash:E,selectionRectFill:M,selectionRectStroke:C,selectionRectStrokeWidth:P,transformLabelFill:R,transformLabelTextFill:F,cropOverlayFill:W,cropGridStyle:B,transformerStyle:O,innerImageCropTransformerStyle:z,outerImageCropTransformerStyle:j,highlighterStyle:N,mediaLoadingStyle:H,mediaErrorStyle:G,textOverflowIndicatorStyle:I,distanceGuideStroke:_,distanceLabelFill:Y,distanceLabelTextFill:D,rulerBackgroundColor:X,rulerTextColor:A,rulerBorderColor:K,rulerBorderSize:q,rulerTickColor:V,rulerTickSize:J,components:Q,onKeyDown:U,onPaste:Z,paddingX:$,paddingY:ee,pageGap:te,altCloneEnabled:re=!0,groupSelectionMode:oe="drill",visiblePagesOffset:ne,renderOnlyActivePage:le,scrollToPageThreshold:ie=.5,tooltipSafeArea:se})=>{var ae;const ce="horizontal"===d,ue=null!=$?$:20,de=null!=ee?ee:55,[he,ge]=r.useState({width:100,height:100}),pe=r.useRef(he),fe=r.useRef(null),me=r.useRef(null),ve=r.useRef(0);let we=0,xe=0,ye=0,Le=0;if(o.bleedVisible){for(const e of o.pages){const t=e.computedBleed;we=Math.max(we,t.left),xe=Math.max(xe,t.right),ye=Math.max(ye,t.top),Le=Math.max(Le,t.bottom)}}const Te=Math.max(...o.pages.map(e=>e.computedWidth)),be=Math.max(...o.pages.map(e=>e.computedHeight)),ke=(null===(ae=o.activePage)||void 0===ae?void 0:ae.computedHeight)||0,Se=Te+we+xe,Ee=(le?ke:be)+ye+Le,Me=async({skipTimeout:e}={skipTimeout:!1})=>{if(e||await new Promise(e=>setTimeout(e,50)),null===fe.current){return}if(!Number.isFinite(Se)||!Number.isFinite(Ee)){return}const t=fe.current.getBoundingClientRect();0!==t.width&&0!==t.height||(console.warn("Polotno warning: <Workspace /> component can not automatically detect its size.\nWidth or height of parent elements is equal 0.\nPlease make sure it has non-zero size. You may need to adjust it with your styles. <Workspace /> will automatically fit into parent container.\nFor simpler debugging here is the log of the parent element:"),console.log(fe.current));const r=me.current.clientWidth||t.width,n={width:r,height:t.height};(pe.current.width!==n.width||pe.current.height!==n.height)&&(ge(n),pe.current=n);const l=(r-2*ue)/Se,i=o.pages.length>1?3.1:2,s=(t.height-de*i)/Ee,a=o.pages.length>1?3.1:2,c=(r-ue*a)/Se,u=(t.height-2*de)/Ee,d=o.pages.length?Math.max(Math.min(ce?c:l,ce?u:s),.01):1;o.scaleToFit!==d&&(o.setScale(d),o._setScaleToFit(d))};r.useLayoutEffect(()=>{Me({skipTimeout:!0})},[]),r.useEffect(()=>{Me()},[Se,Ee,ee,$]),r.useLayoutEffect(()=>{Me({skipTimeout:!0})},[o.openedSidePanel]),r.useEffect(()=>{o.__()},[]),r.useEffect(()=>{const e=fe.current;if(window.ResizeObserver){const t=new ResizeObserver(()=>{Me({skipTimeout:!0})});return t.observe(e),()=>t.unobserve(e)}{const e=setInterval(()=>{Me({skipTimeout:!0})},100);return()=>clearInterval(e)}},[Se,Ee]);const Ce=le?1:o.pages.length;let Pe,Re;if(ce){const e=Se*o.scale*Ce;Pe=Math.max(ue,(he.width-e)/Ce/2),Re=Math.max(de,(he.height-Ee*o.scale)/2)}else{Pe=Math.max(ue,(he.width-Se*o.scale)/2);const e=Ee*o.scale*Ce;Re=Math.max(de,(he.height-e)/Ce/2)}Number.isNaN(Pe)&&(Pe=ue),Number.isNaN(Re)&&(Re=de),r.useEffect(()=>{const e=e=>{(U||s)(e,o)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),r.useEffect(()=>{const e=e=>a(e,o),t=e=>c(e,o),r=e=>(Z||u)(e,o);return window.addEventListener("copy",e),window.addEventListener("cut",t),window.addEventListener("paste",r),()=>{window.removeEventListener("copy",e),window.removeEventListener("cut",t),window.removeEventListener("paste",r)}},[Z]),r.useEffect(()=>{const e=e=>{if(e.ctrlKey||e.metaKey){e.preventDefault();const t=Math.max(5,o.scaleToFit);let r=Math.min(.1,o.scaleToFit);ce&&Se>0&&Number.isFinite(Se)&&(r=Math.max(r,300/Se)),r=Math.max(r,.01);const n=.03,l=p(e.deltaY<0?o.scale*(1+n):o.scale/(1+n),r,t);return void o.setScale(l)}},t=me.current;return null==t||t.addEventListener("wheel",e),()=>null==t?void 0:t.removeEventListener("wheel",e)},[ce,Se,o]),r.useEffect(()=>{const e=me.current;if(!e){return}const t=e=>{2===e.touches.length&&(ve.current=f(e.touches[0],e.touches[1]))},r=t=>{if(2===t.touches.length&&ve.current>0){t.preventDefault();const r=f(t.touches[0],t.touches[1]),n=r/ve.current,l=Math.max(5,o.scaleToFit);let i=Math.min(.1,o.scaleToFit);ce&&Se>0&&Number.isFinite(Se)&&(i=Math.max(i,300/Se)),i=Math.max(i,.01);const s=o.scale,a=p(s*n,i,l),c=a/s,u=e.getBoundingClientRect(),d=(t.touches[0].clientX+t.touches[1].clientX)/2-u.left,h=(t.touches[0].clientY+t.touches[1].clientY)/2-u.top,g=e.scrollLeft+d,m=e.scrollTop+h;Ne.current=!0,o.setScale(a),e.scrollLeft=g*c-d,e.scrollTop=m*c-h,ve.current=r}},n=()=>{ve.current=0};return e.addEventListener("touchstart",t,{passive:!0}),e.addEventListener("touchmove",r,{passive:!1}),e.addEventListener("touchend",n,{passive:!0}),()=>{e.removeEventListener("touchstart",t),e.removeEventListener("touchmove",r),e.removeEventListener("touchend",n)}},[ce,Se,o]);const Fe=void 0!==te,We=o.pages.map(e=>{if(ce){const t=(e.computedWidth+we+xe)*o.scale;return Fe?t+te:t+2*Pe}{const t=(e.computedHeight+ye+Le)*o.scale;return Fe?t+te:t+2*Re}}),Be=[];let Oe=Fe?ce?Pe:Re:0;for(let e=0;e<We.length;e++){Be.push(Oe),Oe+=We[e]}const ze=We.reduce((e,t)=>e+t,0),je=Fe?ze+(ce?2*Pe:2*Re):ze,Ne=r.useRef(!1),[,He]=r.useReducer(e=>e+1,0);((e,t,o,n,l)=>{const i=r.useRef(0),s=r.useRef(0),a=r.useRef(null),c=r.useRef(null),u=r.useRef(!1),d=r.useRef(n.pages.length);u.current=d.current!==n.pages.length,d.current=n.pages.length,r.useEffect(()=>{const t=e.current,r=()=>{i.current=t.scrollLeft,s.current=t.scrollTop,a.current=t.scrollWidth,c.current=t.scrollHeight};return t.addEventListener("scroll",r),r(),()=>{t.removeEventListener("scroll",r)}},[]),r.useLayoutEffect(()=>{if(!e.current){return}if(u.current){const t=e.current;return a.current=t.scrollWidth,c.current=t.scrollHeight,i.current=t.scrollLeft,void(s.current=t.scrollTop)}const t=e.current,r=a.current,o=c.current;if(null===r||null===o){return a.current=t.scrollWidth,c.current=t.scrollHeight,i.current=t.scrollLeft,void(s.current=t.scrollTop)}l.current=!0;const n=t.offsetWidth,d=t.offsetHeight,h=(i.current+n/2)/r,g=(s.current+d/2)/o,f=Math.max(0,t.scrollWidth-n),m=Math.max(0,t.scrollHeight-d);t.scrollLeft=p(h*t.scrollWidth-n/2,0,f),t.scrollTop=p(g*t.scrollHeight-d/2,0,m),a.current=t.scrollWidth,c.current=t.scrollHeight,i.current=t.scrollLeft,s.current=t.scrollTop},[o,t])})(me,je,o.scale,o,Ne);const{handleScroll:Ge}=((e,t,o,n,l,i,s,a,c,u)=>{const d=r.useRef(!1),h=r.useRef(null),g=r.useRef(!1),p="horizontal"===c;r.useEffect(()=>{const t=e.current,r=()=>{s.current};return t.addEventListener("scroll",r),()=>{t.removeEventListener("scroll",r)}},[]);const f=n.pages.indexOf(n.activePage);return r.useLayoutEffect(()=>{if(a){return}if(!n.activePage){return}if(!e.current){return}if(d.current){return}const r=e.current,i=n.pages.indexOf(n.activePage),s=t[i]||0,c=p?r.scrollLeft:r.scrollTop,h=p?r.scrollWidth-r.clientWidth:r.scrollHeight-r.clientHeight,f=Math.min(s,Math.max(0,h)),m=o[i]||o[0]||0;let v=()=>{};return(Math.abs(f-c)>m*l||g.current)&&(g.current=!0,v=(({element:e,scrollTop:t,scrollLeft:r,duration:o=300,onFinish:n=()=>{}})=>{const l=void 0!==t,i=l?e.scrollTop:e.scrollLeft,s=l?t:r,a=s-i;let c=0,u=!1;if(0===o){return l?e.scrollTop=s:e.scrollLeft=s,()=>{}}const d=()=>{if(u){return}c+=20;const t=h(c,i,a,o);l?e.scrollTop=t:e.scrollLeft=t,c<o?setTimeout(d,20):n()},h=(e,t,r,o)=>(e/=o/2)<1?r/2*e*e+t:-r/2*(--e*(e-2)-1)+t;return d(),()=>{u=!0}})(Object.assign(Object.assign({element:r},p?{scrollLeft:f}:{scrollTop:f}),{onFinish:()=>{g.current=!1,null==u||u()},duration:n.isPlaying?0:300}))),v},[n.activePage,f,n.isPlaying,a,c,t,o]),{handleScroll:e=>{if(a){return}if(g.current){return}d.current=!0,clearTimeout(h.current),h.current=setTimeout(()=>{d.current=!1},300);const r=(p?e.currentTarget.scrollLeft:e.currentTarget.scrollTop)+(p?i.width:i.height)/3;let o=0;for(let n=t.length-1;n>=0;n--){if(r>=t[n]){o=n;break}}const l=n.pages[o];l&&n.activePage!==l&&l.select()}}})(me,Be,We,o,ie,he,Ne,le,d,He),Ie=he.width>=Se*o.scale+2*Pe,_e=he.height>=Ee*o.scale+2*Re,Ye=x||"rgba(232, 232, 232, 0.9)",De=(null==Q?void 0:Q.NoPages)||m,Xe=ce?he.width:he.height,Ae=me.current?ce?me.current.scrollLeft:me.current.scrollTop:0,Ke=e=>{for(let t=Be.length-1;t>=0;t--){if(e>=Be[t]){return t}}return 0},qe=Math.max(0,Ke(Ae)),Ve=Math.min(o.pages.length-1,Ke(Ae+Xe)),Je=null!=ne?ne:1,Qe=Math.max(0,qe-Je),Ue=Math.min(o.pages.length-1,Ve+Je),Ze=g({cropOverlayFill:W,cropGridStyle:B,workspaceBackgroundColor:x,pageBorderColor:L,activePageBorderColor:T,bleedColor:b,transparencyBackgroundColor:y,transformerStyle:O,innerImageCropTransformerStyle:z,outerImageCropTransformerStyle:j,highlighterStyle:N,snapGuideStroke:k,snapGuideStrokeWidth:S,snapGuideDash:E,selectionRectFill:M,selectionRectStroke:C,selectionRectStrokeWidth:P,transformLabelFill:R,transformLabelTextFill:F,distanceGuideStroke:_,distanceLabelFill:Y,distanceLabelTextFill:D,mediaLoadingStyle:H,mediaErrorStyle:G,textOverflowIndicatorStyle:I,rulerBackgroundColor:X,rulerTextColor:A,rulerBorderColor:K,rulerBorderSize:q,rulerTickColor:V,rulerTickSize:J});return e(h,{value:Ze,children:e("div",{ref:fe,style:{width:"100%",height:"100%",position:"relative",outline:"none",flex:1,backgroundColor:Ye,overflow:"hidden"},tabIndex:0,className:"polotno-workspace-container",children:t("div",{ref:me,onScroll:Ge,style:Object.assign({position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",flexDirection:ce?"row":"column",overflow:"auto",overflowX:ce?"auto":Ie?"hidden":"auto",overflowY:ce&&_e?"hidden":"auto"},Fe&&{paddingTop:ce?0:Re,paddingBottom:ce?0:Re,paddingLeft:ce?Pe:0,paddingRight:ce?Pe:0,boxSizing:"border-box"}),className:"polotno-workspace-inner",children:[o.pages.map((t,r)=>{const l=t===o.activePage;if(le&&!l&&!t._exportingOrRendering&&!t._forceMount){return null}const i=l||r>=Qe&&r<=Ue||t._exportingOrRendering||t._forceMount,s=ce?We[r]:Se*o.scale+2*Pe,a=ce?Ee*o.scale+2*Re:We[r];if(!i){return e("div",{style:{flexShrink:0},children:e(v,{width:s,height:a,backgroundColor:Ye,xPadding:Pe,yPadding:Re})},t.id)}const c=e(n,{page:t,xPadding:Pe,yPadding:Re,width:s,height:a,store:o,pageControlsEnabled:w,altCloneEnabled:re,groupSelectionMode:oe,components:Q,viewportSize:he,layout:d,tooltipSafeArea:se},t.id);return(t._exportingOrRendering||t._forceMount)&&!l&&le?e("div",{style:{display:"none",flexShrink:0},children:c},t.id):c}),o.rulesVisible&&e(l,{store:o,xPadding:Pe,yPadding:Re,width:Se*o.scale+2*Pe,height:Ee*o.scale+2*Re,pageSizes:We,layout:d,renderOnlyActivePage:le}),0===o.pages.length&&e(De,{store:o}),o.audios.map(t=>e(i,{audio:t,store:o},t.id))]})})})});export default WorkspaceCanvas;
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import r from"react";import{observer as o}from"mobx-react-lite";import n from"./page.js";import{TopRules as l}from"./rules.js";import{AudioElement as i}from"./audio.js";import{handleHotkey as s,handleCopyEvent as a,handleCutEvent as c,handlePasteEvent as u}from"./hotkeys.js";import{t as d}from"../utils/l10n.js";import{WorkspaceStyleProvider as h,useResolvedWorkspaceStyle as g}from"./workspace-style.js";const p=(e,t,r)=>Math.max(t,Math.min(r,e)),f=(e,t)=>Math.sqrt(Math.pow(t.clientX-e.clientX,2)+Math.pow(t.clientY-e.clientY,2)),m=({store:r})=>t("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center"},children:[e("p",{children:d("workspace.noPages")}),e("button",{onClick:()=>{r.addPage()},children:d("workspace.addPage")})]}),v=({width:t,height:r,xPadding:o,yPadding:n,backgroundColor:l})=>e("div",{style:{width:t+"px",height:r+"px",backgroundColor:l,paddingLeft:o+"px",paddingRight:o+"px",paddingTop:n+"px",paddingBottom:n+"px",flexShrink:0},children:e("div",{style:{width:" 100%",height:"100%",backgroundColor:"white"}})});export const WorkspaceCanvas=o(({store:o,layout:d="vertical",pageControlsEnabled:w,backgroundColor:x,transparencyBackgroundColor:y,pageBorderColor:L,activePageBorderColor:T,bleedColor:b,snapGuideStroke:k,snapGuideStrokeWidth:S,snapGuideDash:E,selectionRectFill:M,selectionRectStroke:C,selectionRectStrokeWidth:P,transformLabelFill:R,transformLabelTextFill:F,cropOverlayFill:W,cropGridStyle:B,transformerStyle:O,innerImageCropTransformerStyle:z,outerImageCropTransformerStyle:j,highlighterStyle:N,mediaLoadingStyle:H,mediaErrorStyle:G,textOverflowIndicatorStyle:I,distanceGuideStroke:_,distanceLabelFill:Y,distanceLabelTextFill:D,rulerBackgroundColor:X,rulerTextColor:A,rulerBorderColor:K,rulerBorderSize:q,rulerTickColor:V,rulerTickSize:J,components:Q,onKeyDown:U,onPaste:Z,paddingX:$,paddingY:ee,pageGap:te,altCloneEnabled:re=!0,groupSelectionMode:oe="drill",visiblePagesOffset:ne,renderOnlyActivePage:le,scrollToPageThreshold:ie=.5,tooltipSafeArea:se})=>{var ae;const ce="horizontal"===d,ue=null!=$?$:20,de=null!=ee?ee:55,[he,ge]=r.useState({width:100,height:100}),pe=r.useRef(he),fe=r.useRef(null),me=r.useRef(null),ve=r.useRef(0);let we=0,xe=0,ye=0,Le=0;if(o.bleedVisible){for(const e of o.pages){const t=e.computedBleed;we=Math.max(we,t.left),xe=Math.max(xe,t.right),ye=Math.max(ye,t.top),Le=Math.max(Le,t.bottom)}}const Te=Math.max(...o.pages.map(e=>e.computedWidth)),be=Math.max(...o.pages.map(e=>e.computedHeight)),ke=(null===(ae=o.activePage)||void 0===ae?void 0:ae.computedHeight)||0,Se=Te+we+xe,Ee=(le?ke:be)+ye+Le,Me=async({skipTimeout:e}={skipTimeout:!1})=>{if(e||await new Promise(e=>setTimeout(e,50)),null===fe.current){return}if(!Number.isFinite(Se)||!Number.isFinite(Ee)){return}const t=fe.current.getBoundingClientRect();0!==t.width&&0!==t.height||(console.warn("Polotno warning: <Workspace /> component can not automatically detect its size.\nWidth or height of parent elements is equal 0.\nPlease make sure it has non-zero size. You may need to adjust it with your styles. <Workspace /> will automatically fit into parent container.\nFor simpler debugging here is the log of the parent element:"),console.log(fe.current));const r=me.current.clientWidth||t.width,n={width:r,height:t.height};(pe.current.width!==n.width||pe.current.height!==n.height)&&(ge(n),pe.current=n);const l=(r-2*ue)/Se,i=o.pages.length>1?3.1:2,s=(t.height-de*i)/Ee,a=o.pages.length>1?3.1:2,c=(r-ue*a)/Se,u=(t.height-2*de)/Ee,d=o.pages.length?Math.max(Math.min(ce?c:l,ce?u:s),.01):1;o.scaleToFit!==d&&(o.setScale(d),o._setScaleToFit(d))};r.useLayoutEffect(()=>{Me({skipTimeout:!0})},[]),r.useEffect(()=>{Me()},[Se,Ee,ee,$]),r.useLayoutEffect(()=>{Me({skipTimeout:!0})},[o.openedSidePanel]),r.useEffect(()=>{o.__()},[]),r.useEffect(()=>{const e=fe.current;if(window.ResizeObserver){const t=new ResizeObserver(()=>{Me({skipTimeout:!0})});return t.observe(e),()=>t.unobserve(e)}{const e=setInterval(()=>{Me({skipTimeout:!0})},100);return()=>clearInterval(e)}},[Se,Ee]);const Ce=le?1:o.pages.length;let Pe,Re;if(ce){const e=Se*o.scale*Ce;Pe=Math.max(ue,(he.width-e)/Ce/2),Re=Math.max(de,(he.height-Ee*o.scale)/2)}else{Pe=Math.max(ue,(he.width-Se*o.scale)/2);const e=Ee*o.scale*Ce;Re=Math.max(de,(he.height-e)/Ce/2)}Number.isNaN(Pe)&&(Pe=ue),Number.isNaN(Re)&&(Re=de),r.useEffect(()=>{const e=e=>{(U||s)(e,o)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),r.useEffect(()=>{const e=e=>a(e,o),t=e=>c(e,o),r=e=>(Z||u)(e,o);return window.addEventListener("copy",e),window.addEventListener("cut",t),window.addEventListener("paste",r),()=>{window.removeEventListener("copy",e),window.removeEventListener("cut",t),window.removeEventListener("paste",r)}},[Z]),r.useEffect(()=>{const e=e=>{if(e.ctrlKey||e.metaKey){e.preventDefault();const t=Math.max(5,o.scaleToFit);let r=Math.min(.1,o.scaleToFit);ce&&Se>0&&Number.isFinite(Se)&&(r=Math.max(r,300/Se)),r=Math.max(r,.01);const n=.03,l=p(e.deltaY<0?o.scale*(1+n):o.scale/(1+n),r,t);return void o.setScale(l)}},t=me.current;return null==t||t.addEventListener("wheel",e),()=>null==t?void 0:t.removeEventListener("wheel",e)},[ce,Se,o]),r.useEffect(()=>{const e=me.current;if(!e){return}const t=e=>{2===e.touches.length&&(ve.current=f(e.touches[0],e.touches[1]))},r=t=>{if(2===t.touches.length&&ve.current>0){t.preventDefault();const r=f(t.touches[0],t.touches[1]),n=r/ve.current,l=Math.max(5,o.scaleToFit);let i=Math.min(.1,o.scaleToFit);ce&&Se>0&&Number.isFinite(Se)&&(i=Math.max(i,300/Se)),i=Math.max(i,.01);const s=o.scale,a=p(s*n,i,l),c=a/s,u=e.getBoundingClientRect(),d=(t.touches[0].clientX+t.touches[1].clientX)/2-u.left,h=(t.touches[0].clientY+t.touches[1].clientY)/2-u.top,g=e.scrollLeft+d,m=e.scrollTop+h;Ne.current=!0,o.setScale(a),e.scrollLeft=g*c-d,e.scrollTop=m*c-h,ve.current=r}},n=()=>{ve.current=0};return e.addEventListener("touchstart",t,{passive:!0}),e.addEventListener("touchmove",r,{passive:!1}),e.addEventListener("touchend",n,{passive:!0}),()=>{e.removeEventListener("touchstart",t),e.removeEventListener("touchmove",r),e.removeEventListener("touchend",n)}},[ce,Se,o]);const Fe=void 0!==te,We=o.pages.map(e=>{if(ce){const t=(e.computedWidth+we+xe)*o.scale;return Fe?t+te:t+2*Pe}{const t=(e.computedHeight+ye+Le)*o.scale;return Fe?t+te:t+2*Re}}),Be=[];let Oe=Fe?ce?Pe:Re:0;for(let e=0;e<We.length;e++){Be.push(Oe),Oe+=We[e]}const ze=We.reduce((e,t)=>e+t,0),je=Fe?ze+(ce?2*Pe:2*Re):ze,Ne=r.useRef(!1),[,He]=r.useReducer(e=>e+1,0);((e,t,o,n,l)=>{const i=r.useRef(0),s=r.useRef(0),a=r.useRef(null),c=r.useRef(null),u=r.useRef(!1),d=r.useRef(n.pages.length);u.current=d.current!==n.pages.length,d.current=n.pages.length,r.useEffect(()=>{const t=e.current,r=()=>{i.current=t.scrollLeft,s.current=t.scrollTop,a.current=t.scrollWidth,c.current=t.scrollHeight};return t.addEventListener("scroll",r),r(),()=>{t.removeEventListener("scroll",r)}},[]),r.useLayoutEffect(()=>{if(!e.current){return}if(u.current){const t=e.current;return a.current=t.scrollWidth,c.current=t.scrollHeight,i.current=t.scrollLeft,void(s.current=t.scrollTop)}const t=e.current,r=a.current,o=c.current;if(null===r||null===o){return a.current=t.scrollWidth,c.current=t.scrollHeight,i.current=t.scrollLeft,void(s.current=t.scrollTop)}l.current=!0;const n=t.offsetWidth,d=t.offsetHeight,h=(i.current+n/2)/r,g=(s.current+d/2)/o,f=Math.max(0,t.scrollWidth-n),m=Math.max(0,t.scrollHeight-d);t.scrollLeft=p(h*t.scrollWidth-n/2,0,f),t.scrollTop=p(g*t.scrollHeight-d/2,0,m),a.current=t.scrollWidth,c.current=t.scrollHeight,i.current=t.scrollLeft,s.current=t.scrollTop},[o,t])})(me,je,o.scale,o,Ne);const{handleScroll:Ge}=((e,t,o,n,l,i,s,a,c,u)=>{const d=r.useRef(!1),h=r.useRef(null),g=r.useRef(!1),p="horizontal"===c;r.useEffect(()=>{const t=e.current,r=()=>{s.current};return t.addEventListener("scroll",r),()=>{t.removeEventListener("scroll",r)}},[]);const f=n.pages.indexOf(n.activePage);return r.useLayoutEffect(()=>{if(a){return}if(!n.activePage){return}if(!e.current){return}if(d.current){return}const r=e.current,i=n.pages.indexOf(n.activePage),s=t[i]||0,c=p?r.scrollLeft:r.scrollTop,h=p?r.scrollWidth-r.clientWidth:r.scrollHeight-r.clientHeight,f=Math.min(s,Math.max(0,h)),m=o[i]||o[0]||0;let v=()=>{};return(Math.abs(f-c)>m*l||g.current)&&(g.current=!0,v=(({element:e,scrollTop:t,scrollLeft:r,duration:o=300,onFinish:n=()=>{}})=>{const l=void 0!==t,i=l?e.scrollTop:e.scrollLeft,s=l?t:r,a=s-i;let c=0,u=!1;if(0===o){return l?e.scrollTop=s:e.scrollLeft=s,()=>{}}const d=()=>{if(u){return}c+=20;const t=h(c,i,a,o);l?e.scrollTop=t:e.scrollLeft=t,c<o?setTimeout(d,20):n()},h=(e,t,r,o)=>(e/=o/2)<1?r/2*e*e+t:-r/2*(--e*(e-2)-1)+t;return d(),()=>{u=!0}})(Object.assign(Object.assign({element:r},p?{scrollLeft:f}:{scrollTop:f}),{onFinish:()=>{g.current=!1,null==u||u()},duration:n.isPlaying?0:300}))),v},[n.activePage,f,n.isPlaying,a,c]),{handleScroll:e=>{if(a){return}if(g.current){return}d.current=!0,clearTimeout(h.current),h.current=setTimeout(()=>{d.current=!1},300);const r=(p?e.currentTarget.scrollLeft:e.currentTarget.scrollTop)+(p?i.width:i.height)/3;let o=0;for(let n=t.length-1;n>=0;n--){if(r>=t[n]){o=n;break}}const l=n.pages[o];l&&n.activePage!==l&&l.select()}}})(me,Be,We,o,ie,he,Ne,le,d,He),Ie=he.width>=Se*o.scale+2*Pe,_e=he.height>=Ee*o.scale+2*Re,Ye=x||"rgba(232, 232, 232, 0.9)",De=(null==Q?void 0:Q.NoPages)||m,Xe=ce?he.width:he.height,Ae=me.current?ce?me.current.scrollLeft:me.current.scrollTop:0,Ke=e=>{for(let t=Be.length-1;t>=0;t--){if(e>=Be[t]){return t}}return 0},qe=Math.max(0,Ke(Ae)),Ve=Math.min(o.pages.length-1,Ke(Ae+Xe)),Je=null!=ne?ne:1,Qe=Math.max(0,qe-Je),Ue=Math.min(o.pages.length-1,Ve+Je),Ze=g({cropOverlayFill:W,cropGridStyle:B,workspaceBackgroundColor:x,pageBorderColor:L,activePageBorderColor:T,bleedColor:b,transparencyBackgroundColor:y,transformerStyle:O,innerImageCropTransformerStyle:z,outerImageCropTransformerStyle:j,highlighterStyle:N,snapGuideStroke:k,snapGuideStrokeWidth:S,snapGuideDash:E,selectionRectFill:M,selectionRectStroke:C,selectionRectStrokeWidth:P,transformLabelFill:R,transformLabelTextFill:F,distanceGuideStroke:_,distanceLabelFill:Y,distanceLabelTextFill:D,mediaLoadingStyle:H,mediaErrorStyle:G,textOverflowIndicatorStyle:I,rulerBackgroundColor:X,rulerTextColor:A,rulerBorderColor:K,rulerBorderSize:q,rulerTickColor:V,rulerTickSize:J});return e(h,{value:Ze,children:e("div",{ref:fe,style:{width:"100%",height:"100%",position:"relative",outline:"none",flex:1,backgroundColor:Ye,overflow:"hidden"},tabIndex:0,className:"polotno-workspace-container",children:t("div",{ref:me,onScroll:Ge,style:Object.assign({position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",flexDirection:ce?"row":"column",overflow:"auto",overflowX:ce?"auto":Ie?"hidden":"auto",overflowY:ce&&_e?"hidden":"auto"},Fe&&{paddingTop:ce?0:Re,paddingBottom:ce?0:Re,paddingLeft:ce?Pe:0,paddingRight:ce?Pe:0,boxSizing:"border-box"}),className:"polotno-workspace-inner",children:[o.pages.map((t,r)=>{const l=t===o.activePage;if(le&&!l&&!t._exportingOrRendering&&!t._forceMount){return null}const i=l||r>=Qe&&r<=Ue||t._exportingOrRendering||t._forceMount,s=ce?We[r]:Se*o.scale+2*Pe,a=ce?Ee*o.scale+2*Re:We[r];if(!i){return e("div",{style:{flexShrink:0},children:e(v,{width:s,height:a,backgroundColor:Ye,xPadding:Pe,yPadding:Re})},t.id)}const c=e(n,{page:t,xPadding:Pe,yPadding:Re,width:s,height:a,store:o,pageControlsEnabled:w,altCloneEnabled:re,groupSelectionMode:oe,components:Q,viewportSize:he,layout:d,tooltipSafeArea:se},t.id);return(t._exportingOrRendering||t._forceMount)&&!l&&le?e("div",{style:{display:"none",flexShrink:0},children:c},t.id):c}),o.rulesVisible&&e(l,{store:o,xPadding:Pe,yPadding:Re,width:Se*o.scale+2*Pe,height:Ee*o.scale+2*Re,pageSizes:We,layout:d,renderOnlyActivePage:le}),0===o.pages.length&&e(De,{store:o}),o.audios.map(t=>e(i,{audio:t,store:o},t.id))]})})})});export default WorkspaceCanvas;
@@ -1,4 +1,4 @@
1
- import { Instance } from 'mobx-state-tree';
1
+ import { Instance, SnapshotIn } from 'mobx-state-tree';
2
2
  export declare const Audio: import("mobx-state-tree").IModelType<{
3
3
  id: import("mobx-state-tree").ISimpleType<string>;
4
4
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
@@ -26,6 +26,58 @@ export declare const Audio: import("mobx-state-tree").IModelType<{
26
26
  custom: any;
27
27
  };
28
28
  } & {
29
- set(attrs: any): void;
29
+ set(attrs: Partial<SnapshotIn<import("mobx-state-tree").ModelInstanceTypeProps<{
30
+ id: import("mobx-state-tree").ISimpleType<string>;
31
+ name: import("mobx-state-tree").IType<string | undefined, string, string>;
32
+ src: import("mobx-state-tree").IType<string | undefined, string, string>;
33
+ duration: import("mobx-state-tree").IType<number | undefined, number, number>;
34
+ startTime: import("mobx-state-tree").IType<number | undefined, number, number>;
35
+ endTime: import("mobx-state-tree").IType<number | undefined, number, number>;
36
+ volume: import("mobx-state-tree").IType<number | undefined, number, number>;
37
+ delay: import("mobx-state-tree").IType<number | undefined, number, number>;
38
+ speed: import("mobx-state-tree").IType<number | undefined, number, number>;
39
+ custom: import("mobx-state-tree").IType<any, any, any>;
40
+ }> & {
41
+ readonly visibleDuration: number;
42
+ } & {
43
+ toJSON(): {
44
+ id: string;
45
+ name: string;
46
+ src: string;
47
+ duration: number;
48
+ startTime: number;
49
+ endTime: number;
50
+ volume: number;
51
+ delay: number;
52
+ speed: number;
53
+ custom: any;
54
+ };
55
+ } & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
56
+ id: import("mobx-state-tree").ISimpleType<string>;
57
+ name: import("mobx-state-tree").IType<string | undefined, string, string>;
58
+ src: import("mobx-state-tree").IType<string | undefined, string, string>;
59
+ duration: import("mobx-state-tree").IType<number | undefined, number, number>;
60
+ startTime: import("mobx-state-tree").IType<number | undefined, number, number>;
61
+ endTime: import("mobx-state-tree").IType<number | undefined, number, number>;
62
+ volume: import("mobx-state-tree").IType<number | undefined, number, number>;
63
+ delay: import("mobx-state-tree").IType<number | undefined, number, number>;
64
+ speed: import("mobx-state-tree").IType<number | undefined, number, number>;
65
+ custom: import("mobx-state-tree").IType<any, any, any>;
66
+ }, {
67
+ readonly visibleDuration: number;
68
+ } & {
69
+ toJSON(): {
70
+ id: string;
71
+ name: string;
72
+ src: string;
73
+ duration: number;
74
+ startTime: number;
75
+ endTime: number;
76
+ volume: number;
77
+ delay: number;
78
+ speed: number;
79
+ custom: any;
80
+ };
81
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>>): void;
30
82
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
31
83
  export type AudioType = Instance<typeof Audio>;
@@ -4,6 +4,7 @@ export declare const FigureElement: import("mobx-state-tree").IModelType<{
4
4
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
5
5
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
6
6
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
7
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
7
8
  custom: import("mobx-state-tree").IType<any, any, any>;
8
9
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
9
10
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -64,6 +65,7 @@ export declare const FigureElement: import("mobx-state-tree").IModelType<{
64
65
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
65
66
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
66
67
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
68
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
67
69
  custom: import("mobx-state-tree").IType<any, any, any>;
68
70
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
69
71
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -75,6 +77,7 @@ export declare const FigureElement: import("mobx-state-tree").IModelType<{
75
77
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
76
78
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
77
79
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
80
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
78
81
  custom: import("mobx-state-tree").IType<any, any, any>;
79
82
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
80
83
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -86,24 +89,37 @@ export declare const FigureElement: import("mobx-state-tree").IModelType<{
86
89
  type: string | undefined;
87
90
  name: string | undefined;
88
91
  opacity: number | undefined;
92
+ blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
89
93
  custom: any;
90
94
  visible: boolean | undefined;
91
95
  selectable: boolean | undefined;
92
96
  removable: boolean | undefined;
93
97
  alwaysOnTop: boolean | undefined;
94
98
  showInExport: boolean | undefined;
95
- }>, import("mobx-state-tree").ModelSnapshotType<{
96
- id: import("mobx-state-tree").ISimpleType<string>;
97
- type: import("mobx-state-tree").IType<string | undefined, string, string>;
98
- name: import("mobx-state-tree").IType<string | undefined, string, string>;
99
- opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
100
- custom: import("mobx-state-tree").IType<any, any, any>;
101
- visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
102
- selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
103
- removable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
104
- alwaysOnTop: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
105
- showInExport: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
106
- }>>>;
99
+ }>, {
100
+ id: string;
101
+ type: string;
102
+ name: string;
103
+ opacity: number;
104
+ custom: any;
105
+ visible: boolean;
106
+ selectable: boolean;
107
+ removable: boolean;
108
+ alwaysOnTop: boolean;
109
+ showInExport: boolean;
110
+ } | {
111
+ blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
112
+ id: string;
113
+ type: string;
114
+ name: string;
115
+ opacity: number;
116
+ custom: any;
117
+ visible: boolean;
118
+ selectable: boolean;
119
+ removable: boolean;
120
+ alwaysOnTop: boolean;
121
+ showInExport: boolean;
122
+ }>>;
107
123
  readonly parent: any;
108
124
  readonly zIndex: any;
109
125
  } & {
@@ -118,6 +134,18 @@ export declare const FigureElement: import("mobx-state-tree").IModelType<{
118
134
  removable: boolean;
119
135
  alwaysOnTop: boolean;
120
136
  showInExport: boolean;
137
+ } | {
138
+ blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
139
+ id: string;
140
+ type: string;
141
+ name: string;
142
+ opacity: number;
143
+ custom: any;
144
+ visible: boolean;
145
+ selectable: boolean;
146
+ removable: boolean;
147
+ alwaysOnTop: boolean;
148
+ showInExport: boolean;
121
149
  };
122
150
  } & {
123
151
  clone(attrs?: any, { skipSelect }?: {
@@ -149,22 +177,35 @@ export declare const FigureElement: import("mobx-state-tree").IModelType<{
149
177
  type: string | undefined;
150
178
  name: string | undefined;
151
179
  opacity: number | undefined;
180
+ blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
152
181
  custom: any;
153
182
  visible: boolean | undefined;
154
183
  selectable: boolean | undefined;
155
184
  removable: boolean | undefined;
156
185
  alwaysOnTop: boolean | undefined;
157
186
  showInExport: boolean | undefined;
158
- }>, import("mobx-state-tree").ModelSnapshotType<{
159
- id: import("mobx-state-tree").ISimpleType<string>;
160
- type: import("mobx-state-tree").IType<string | undefined, string, string>;
161
- name: import("mobx-state-tree").IType<string | undefined, string, string>;
162
- opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
163
- custom: import("mobx-state-tree").IType<any, any, any>;
164
- visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
165
- selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
166
- removable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
167
- alwaysOnTop: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
168
- showInExport: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
169
- }>>;
187
+ }>, {
188
+ id: string;
189
+ type: string;
190
+ name: string;
191
+ opacity: number;
192
+ custom: any;
193
+ visible: boolean;
194
+ selectable: boolean;
195
+ removable: boolean;
196
+ alwaysOnTop: boolean;
197
+ showInExport: boolean;
198
+ } | {
199
+ blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
200
+ id: string;
201
+ type: string;
202
+ name: string;
203
+ opacity: number;
204
+ custom: any;
205
+ visible: boolean;
206
+ selectable: boolean;
207
+ removable: boolean;
208
+ alwaysOnTop: boolean;
209
+ showInExport: boolean;
210
+ }>;
170
211
  export type FigureElementType = Instance<typeof FigureElement>;
@@ -4,6 +4,7 @@ export declare const GifElement: import("mobx-state-tree").IModelType<{
4
4
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
5
5
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
6
6
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
7
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
7
8
  custom: import("mobx-state-tree").IType<any, any, any>;
8
9
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
9
10
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -77,6 +78,7 @@ export declare const GifElement: import("mobx-state-tree").IModelType<{
77
78
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
78
79
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
79
80
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
81
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
80
82
  custom: import("mobx-state-tree").IType<any, any, any>;
81
83
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
82
84
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -88,6 +90,7 @@ export declare const GifElement: import("mobx-state-tree").IModelType<{
88
90
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
89
91
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
90
92
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
93
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
91
94
  custom: import("mobx-state-tree").IType<any, any, any>;
92
95
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
93
96
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -99,24 +102,37 @@ export declare const GifElement: import("mobx-state-tree").IModelType<{
99
102
  type: string | undefined;
100
103
  name: string | undefined;
101
104
  opacity: number | undefined;
105
+ blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
102
106
  custom: any;
103
107
  visible: boolean | undefined;
104
108
  selectable: boolean | undefined;
105
109
  removable: boolean | undefined;
106
110
  alwaysOnTop: boolean | undefined;
107
111
  showInExport: boolean | undefined;
108
- }>, import("mobx-state-tree").ModelSnapshotType<{
109
- id: import("mobx-state-tree").ISimpleType<string>;
110
- type: import("mobx-state-tree").IType<string | undefined, string, string>;
111
- name: import("mobx-state-tree").IType<string | undefined, string, string>;
112
- opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
113
- custom: import("mobx-state-tree").IType<any, any, any>;
114
- visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
115
- selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
116
- removable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
117
- alwaysOnTop: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
118
- showInExport: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
119
- }>>>;
112
+ }>, {
113
+ id: string;
114
+ type: string;
115
+ name: string;
116
+ opacity: number;
117
+ custom: any;
118
+ visible: boolean;
119
+ selectable: boolean;
120
+ removable: boolean;
121
+ alwaysOnTop: boolean;
122
+ showInExport: boolean;
123
+ } | {
124
+ blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
125
+ id: string;
126
+ type: string;
127
+ name: string;
128
+ opacity: number;
129
+ custom: any;
130
+ visible: boolean;
131
+ selectable: boolean;
132
+ removable: boolean;
133
+ alwaysOnTop: boolean;
134
+ showInExport: boolean;
135
+ }>>;
120
136
  readonly parent: any;
121
137
  readonly zIndex: any;
122
138
  } & {
@@ -131,6 +147,18 @@ export declare const GifElement: import("mobx-state-tree").IModelType<{
131
147
  removable: boolean;
132
148
  alwaysOnTop: boolean;
133
149
  showInExport: boolean;
150
+ } | {
151
+ blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
152
+ id: string;
153
+ type: string;
154
+ name: string;
155
+ opacity: number;
156
+ custom: any;
157
+ visible: boolean;
158
+ selectable: boolean;
159
+ removable: boolean;
160
+ alwaysOnTop: boolean;
161
+ showInExport: boolean;
134
162
  };
135
163
  } & {
136
164
  clone(attrs?: any, { skipSelect }?: {
@@ -169,22 +197,35 @@ export declare const GifElement: import("mobx-state-tree").IModelType<{
169
197
  type: string | undefined;
170
198
  name: string | undefined;
171
199
  opacity: number | undefined;
200
+ blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
172
201
  custom: any;
173
202
  visible: boolean | undefined;
174
203
  selectable: boolean | undefined;
175
204
  removable: boolean | undefined;
176
205
  alwaysOnTop: boolean | undefined;
177
206
  showInExport: boolean | undefined;
178
- }>, import("mobx-state-tree").ModelSnapshotType<{
179
- id: import("mobx-state-tree").ISimpleType<string>;
180
- type: import("mobx-state-tree").IType<string | undefined, string, string>;
181
- name: import("mobx-state-tree").IType<string | undefined, string, string>;
182
- opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
183
- custom: import("mobx-state-tree").IType<any, any, any>;
184
- visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
185
- selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
186
- removable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
187
- alwaysOnTop: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
188
- showInExport: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
189
- }>>;
207
+ }>, {
208
+ id: string;
209
+ type: string;
210
+ name: string;
211
+ opacity: number;
212
+ custom: any;
213
+ visible: boolean;
214
+ selectable: boolean;
215
+ removable: boolean;
216
+ alwaysOnTop: boolean;
217
+ showInExport: boolean;
218
+ } | {
219
+ blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
220
+ id: string;
221
+ type: string;
222
+ name: string;
223
+ opacity: number;
224
+ custom: any;
225
+ visible: boolean;
226
+ selectable: boolean;
227
+ removable: boolean;
228
+ alwaysOnTop: boolean;
229
+ showInExport: boolean;
230
+ }>;
190
231
  export type GifElementType = Instance<typeof GifElement>;