polotno 3.17.0 → 3.19.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.
- package/blueprint/side-panel/select-video.d.ts +18 -16
- package/canvas/animated-shadow.d.ts +11 -0
- package/canvas/animated-shadow.js +1 -0
- package/canvas/apply-filters.d.ts +5 -1
- package/canvas/apply-filters.js +1 -1
- package/canvas/downscale.js +1 -1
- package/canvas/element.js +1 -1
- package/canvas/figure-element.js +1 -1
- package/canvas/gif-element.js +1 -1
- package/canvas/html-element.js +1 -1
- package/canvas/image-element.d.ts +1 -0
- package/canvas/image-element.js +1 -1
- package/canvas/line-element.js +1 -1
- package/canvas/page.js +1 -1
- package/canvas/render-tag-element.js +1 -1
- package/canvas/rich-editor.d.ts +2 -0
- package/canvas/rich-editor.js +8 -5
- package/canvas/text-element.js +1 -1
- package/canvas/use-animated-blur.d.ts +4 -0
- package/canvas/use-animated-blur.js +1 -0
- package/canvas/use-color.d.ts +1 -1
- package/canvas/use-filtered-source.js +1 -1
- package/canvas/use-offscreen-canvas.d.ts +2 -0
- package/canvas/use-offscreen-canvas.js +1 -0
- package/canvas/use-transformer-snap.js +1 -1
- package/canvas/video-element.js +1 -1
- package/icons/animation-icons.d.ts +30 -7
- package/icons/animation-icons.js +1 -1
- package/icons/registry.d.ts +22 -0
- package/icons/registry.js +1 -1
- package/image-tools/raster.js +1 -1
- package/model/figure-model.d.ts +10 -9
- package/model/gif-model.d.ts +10 -9
- package/model/group-model.d.ts +78 -68
- package/model/group-model.js +1 -1
- package/model/history.d.ts +3 -0
- package/model/history.js +1 -1
- package/model/image-model.d.ts +10 -9
- package/model/line-model.d.ts +10 -9
- package/model/node-model.d.ts +8 -8
- package/model/page-model.d.ts +228 -204
- package/model/shape-model.d.ts +15 -9
- package/model/shape-model.js +1 -1
- package/model/store.d.ts +31 -17
- package/model/store.js +1 -1
- package/model/svg-model.d.ts +9 -8
- package/model/table-model.d.ts +8 -7
- package/model/text-model.d.ts +9 -8
- package/model/video-model.d.ts +10 -9
- package/package.json +24 -21
- package/pages-timeline/element-track.js +1 -1
- package/pages-timeline/page-preview.js +1 -1
- package/polotno.bundle.js +195 -177
- package/side-panel/animations-panel.js +1 -1
- package/side-panel/select-video.d.ts +18 -16
- package/side-panel/text-panel.js +1 -1
- package/side-panel/text-template.js +1 -1
- package/toolbar/animations-picker.js +1 -1
- package/toolbar/use-copy-style.d.ts +1 -0
- package/toolbar/use-copy-style.js +1 -1
- package/ui.css +1 -1
- package/utils/animations.d.ts +212 -10
- package/utils/animations.js +1 -1
- package/utils/clipboard.d.ts +17 -15
- package/utils/clipboard.js +1 -1
- package/utils/duplicate.js +1 -1
- package/utils/fonts.js +1 -1
- package/utils/from-svg.js +1 -1
- package/utils/image-dpi.js +1 -1
- package/utils/image-edit.js +1 -1
- package/utils/l10n.d.ts +44 -0
- package/utils/l10n.js +1 -1
- package/utils/px.d.ts +1 -0
- package/utils/px.js +1 -1
- package/utils/timeline.d.ts +3 -1
- package/utils/timeline.js +1 -1
- package/utils/validate-key.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as n}from"react/jsx-runtime";import i from"react";import{Button as t}from"../primitives/button.js";import{SliderField as a}from"../primitives/slider-field.js";import{NumericInput as o}from"../primitives/numeric-input.js";import{Select as l,SelectContent as r,SelectItem as d,SelectTrigger as m,SelectValue as s}from"../primitives/select.js";import{observer as p}from"mobx-react-lite";import{isAlive as c}from"mobx-state-tree";import{PolotnoIcon as u}from"../icons/registry.js";import{t as v}from"../utils/l10n.js";import{cn as h}from"../lib/utils.js";import{PanelHeader as g}from"../primitives/panel-header.js";import{PanelScrollArea as f}from"../primitives/panel-scroll-area.js";export{o as NumberInput};const b=e=>!!e&&c(e),x=(e,n)=>{var i;const t=n.filter(b),a=null===(i=t[0])||void 0===i?void 0:i.page;if(!a){return}const o=e.activePage;e.play({animatedElementsIds:t.map(e=>e.id),currentTime:a.startTime}),setTimeout(()=>{e.stop(),o&&c(o)&&e.selectPage(o.id)},1e3)},y=p(({element:i,store:a,enabled:o})=>{const l=i.animations.find(e=>"enter"===e.type),r=i.animations.find(e=>"exit"===e.type);return o?n("div",{children:[e("div",{style:{padding:"10px 0px"},children:"Animate"}),n("div",{style:{display:"flex",gap:10},children:[e(t,{variant:"outline",className:h("pn:flex-1",(null==l?void 0:l.enabled)&&!(null==r?void 0:r.enabled)&&"pn:bg-muted"),onClick:()=>{b(i)&&a.history.transaction(()=>{i.setAnimation("enter",{enabled:!0}),i.setAnimation("exit",{enabled:!1})})},children:"Enter"}),e(t,{variant:"outline",className:h("pn:flex-1",(null==l?void 0:l.enabled)&&(null==r?void 0:r.enabled)&&"pn:bg-muted"),onClick:()=>{b(i)&&a.history.transaction(()=>{i.setAnimation("enter",{enabled:!0}),i.setAnimation("exit",{enabled:!0})})},children:"Both"}),e(t,{variant:"outline",className:h("pn:flex-1",(null==r?void 0:r.enabled)&&!(null==l?void 0:l.enabled)&&"pn:bg-muted"),onClick:()=>{b(i)&&a.history.transaction(()=>{i.setAnimation("enter",{enabled:!1}),i.setAnimation("exit",{enabled:!0})})},children:"Exit"})]})]}):null}),k=["right","left","up","down","bottom-right","bottom-left","top-right","top-left"],C={right:e(u,{name:"animation.directionRight"}),left:e(u,{name:"animation.directionLeft"}),up:e(u,{name:"animation.directionUp"}),down:e(u,{name:"animation.directionDown"}),"bottom-right":e(u,{name:"animation.directionBottomRight"}),"bottom-left":e(u,{name:"animation.directionBottomLeft"}),"top-right":e(u,{name:"animation.directionTopRight"}),"top-left":e(u,{name:"animation.directionTopLeft"})},A=p(({value:i,onChange:t})=>n("div",{style:{paddingTop:"10px"},children:[e("div",{style:{paddingBottom:"10px"},children:"Direction"}),n(l,{value:i,onValueChange:e=>{null!==e&&t(e)},children:[e(m,{className:"pn:w-full",children:n("div",{className:"pn:flex pn:items-center pn:gap-2",children:[C[i],e(s,{})]})}),e(r,{children:k.map(i=>e(d,{value:i,children:n("div",{className:"pn:flex pn:items-center pn:gap-2",children:[C[i],i]})},i))})]})]})),j=p(({value:i,onChange:t})=>n("div",{style:{paddingTop:"10px"},children:[e("div",{style:{paddingBottom:"10px"},children:"Direction"}),n(l,{value:i,onValueChange:e=>{null!==e&&t(e)},children:[e(m,{className:"pn:w-full",children:e(s,{children:"out"===i?"Zoom Out":"Zoom In"})}),n(r,{children:[e(d,{value:"in",children:"Zoom In"}),e(d,{value:"out",children:"Zoom Out"})]})]})]})),N=p(({element:n})=>{const i=n.animations.find(e=>"enter"===e.type);if(!i){return null}const t=n.page.duration;return e("div",{style:{padding:"10px"},children:e(a,{label:"Delay",value:parseFloat((i.delay/1e3).toFixed(2)),onChange:e=>{b(n)&&n.setAnimation("enter",{delay:1e3*e})},min:0,max:t/1e3,step:.01})})}),T=p(({element:n,store:i})=>{const t=n.animations.find(e=>"loop"===e.type&&e.enabled);if(!t){return null}const o=500/t.duration;return e("div",{style:{padding:"10px"},children:e(a,{label:"Speed",value:o,onChange:e=>{b(n)&&n.setAnimation("loop",{duration:500/e})},min:.1,max:3,step:.01,onCommit:()=>x(i,[n])})})}),E=p(({element:n})=>{const i=n.animations.find(e=>"enter"===e.type);if(!i){return null}const t=n.page.duration;return e("div",{style:{padding:"10px"},children:e(a,{label:"Duration",value:parseFloat((i.duration/1e3).toFixed(2)),onChange:e=>{b(n)&&(n.setAnimation("enter",{duration:1e3*e}),n.setAnimation("exit",{duration:1e3*e}))},min:0,max:t/1e3,step:.01})})}),z=p(({element:n,store:i,animationName:t})=>{var o,l;const r=n.animations.find(e=>e.name===t&&e.enabled);if(!r){return null}const d=null!==(l=null===(o=r.data)||void 0===o?void 0:o.strength)&&void 0!==l?l:1,m=e=>{b(n)&&(i.history.transaction(()=>{n.animations.forEach(i=>{if(i.name===t){const t=i.data||{};n.setAnimation(i.type,{data:Object.assign(Object.assign({},t),{strength:e})})}})}),(()=>{let e;return(...t)=>{e&&clearTimeout(e),e=setTimeout(()=>{(()=>{i.isPlaying||x(i,[n])})(...t)},300)}})()())},s=Math.max(3,d);return e("div",{style:{padding:"10px"},children:e(a,{label:v("toolbar.strength"),value:parseFloat(d.toFixed(2)),onChange:e=>m(e),min:.1,sliderMax:s,step:.05})})}),F=p(({element:n})=>{const i=n.animations.find(e=>"exit"===e.type);if(!i){return null}const t=n.page.duration;return e("div",{style:{padding:"10px"},children:e(a,{label:"End Delay",value:parseFloat((i.delay/1e3).toFixed(2)),onChange:e=>{b(n)&&n.setAnimation("exit",{delay:1e3*e})},min:0,max:t/1e3,step:.01})})}),w=[{key:"move",icon:"animation.typeMove",label:"toolbar.move"},{key:"fade",icon:"animation.typeFade",label:"toolbar.fade"},{key:"zoom",icon:"animation.typeZoom",label:"toolbar.zoom"}],B=[{key:"rotate",icon:"animation.typeRotate",label:"toolbar.rotate"},{key:"blink",icon:"animation.typeBlink",label:"toolbar.blink"},{key:"bounce",icon:"animation.typeBounce",label:"toolbar.bounce"}];export const AnimationsPanel=p(({store:a})=>{var o,l,r,d;const m=a.selectedElements,s=m[0],p=s,c=m.map(e=>e.id).join(","),k="animation"===a.openedSidePanel;if(i.useEffect(()=>{k&&(s&&s.animations||a.restoreSidePanel())},[k,c]),!s||!s.animations){return null}const C=()=>a.selectedElements.filter(b),O=(e,n)=>{const i=C();i.length&&(a.history.transaction(()=>{i.forEach(i=>{i.setAnimation("enter",Object.assign({name:e},n)),i.setAnimation("exit",Object.assign(Object.assign({name:e},n),{from:n.to,to:n.from}))})}),n.enabled&&x(a,i))},P=(e,n=s)=>{var i;return!!((e?null===(i=null==n?void 0:n.animations)||void 0===i?void 0:i.filter(n=>n.name===e||n.type===e):null==n?void 0:n.animations)||[]).find(e=>e.enabled)},D=P("move")||P("fade")||P("zoom"),R=P("rotate")||P("blink")||P("bounce");return n(f,{header:e(g,{title:v("sidePanel.animate"),onClose:()=>a.restoreSidePanel()}),children:[n("div",{style:{paddingTop:"10px",lineHeight:"35px"},children:["Animations"," ",e(t,{variant:"outline",style:{marginLeft:"10px",display:D?"inline-flex":"none"},onClick:()=>{b(p)&&p.set({animations:[]})},children:"Remove All"})]}),n("div",{style:{paddingTop:"25px"},children:[e("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(100px, 1fr))",gap:"5px",paddingBottom:"10px"},children:w.map(({key:i,icon:a,label:o})=>e("div",{children:n(t,{variant:"outline",size:"lg",className:h("pn:flex pn:h-auto pn:w-full pn:flex-col pn:items-center pn:gap-2 pn:p-5",P(i)&&"pn:bg-muted"),onClick:()=>{O(i,{enabled:!P(i,C()[0])})},children:[e(u,{name:a}),v(o)]})},i))}),n("div",{className:"pn:bg-black/5 pn:dark:bg-white/5",style:{display:D?"block":"none",padding:"10px"},children:[e(y,{element:s,store:a,enabled:P("enter")||P("exit")}),P("move")&&e(A,{value:(null===(l=null===(o=s.animations.find(e=>"move"===e.name))||void 0===o?void 0:o.data)||void 0===l?void 0:l.direction)||"right",onChange:e=>{O("move",{data:{direction:e},enabled:!0})}}),P("move")&&e(z,{store:a,element:p,animationName:"move"}),P("zoom")&&e(j,{value:(null===(d=null===(r=s.animations.find(e=>"zoom"===e.name))||void 0===r?void 0:r.data)||void 0===d?void 0:d.direction)||"in",onChange:e=>{O("zoom",{data:{direction:e},enabled:!0})}}),P("zoom")&&e(z,{store:a,element:p,animationName:"zoom"}),P("enter")&&e(N,{store:a,element:p}),P("enter")&&e(E,{store:a,element:p}),P("exit")&&e(F,{store:a,element:p})]}),n("div",{style:{paddingTop:"10px",lineHeight:"35px"},children:["Effects"," ",e(t,{variant:"outline",style:{marginLeft:"10px",display:R?"inline-flex":"none"},onClick:()=>{b(p)&&p.set({animations:[]})},children:"Remove All"})]}),e("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(100px, 1fr))",gap:"5px",paddingTop:"10px"},children:B.map(({key:i,icon:o,label:l})=>e("div",{children:n(t,{variant:"outline",size:"lg",className:h("pn:flex pn:h-auto pn:w-full pn:flex-col pn:items-center pn:gap-2 pn:p-5",P(i)&&"pn:bg-muted"),onClick:()=>{((e,n)=>{const i=C();i.length&&(a.history.transaction(()=>{i.forEach(i=>{i.setAnimation("loop",Object.assign({name:e},n))})}),n.enabled&&x(a,i))})(i,{enabled:!P(i,C()[0])})},children:[e(u,{name:o}),v(l)]})},i))}),R&&e(T,{store:a,element:p}),P("bounce")&&e(z,{store:a,element:p,animationName:"bounce"})]})]})});
|
|
1
|
+
var e=this&&this.__rest||function(e,n){var t={};for(var i in e){Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i])}if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++){n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]])}}return t};import{jsx as n,jsxs as t,Fragment as i}from"react/jsx-runtime";import o from"react";import{SliderField as a}from"../primitives/slider-field.js";import{FieldRow as r}from"../primitives/field-row.js";import{ColorPicker as l}from"../toolbar/color-picker.js";import{NumericInput as s}from"../primitives/numeric-input.js";import{runInAction as p}from"mobx";import{observer as d}from"mobx-react-lite";import{clone as m,getSnapshot as c,isAlive as u,unprotect as b}from"mobx-state-tree";import{PolotnoIcon as f}from"../icons/registry.js";import{t as g}from"../utils/l10n.js";import{removeTags as y}from"@polotno/core/text";import{MOVE_OFFSETS as v,ZOOM_FROM as h,transitionWindows as x,zoomDirection as k}from"@polotno/core/animation-presets";import{glowColor as w,hasNumber as P,KEN_BURNS_PAN as j,loopWindow as N,playedAnimations as C,setAnimationOf as O,spansElementTime as M}from"../utils/animations.js";import{getElementTimeRange as B,setElementTimeRange as E}from"../utils/timeline.js";import{cn as z}from"../lib/utils.js";import{PanelHeader as A}from"../primitives/panel-header.js";import{PanelScrollArea as F}from"../primitives/panel-scroll-area.js";export{s as NumberInput};const R=e=>!!e&&u(e),T=e=>e.selectedElements.filter(R),W=e=>{var n;return null!==(n=null==e?void 0:e.data)&&void 0!==n?n:{}},L=["enter","exit"],S=(e,n)=>{const t=e.animations.find(e=>e.type===n);return(null==t?void 0:t.enabled)&&"none"!==t.name?t:void 0},_=e=>{var n;return null!==(n=S(e,"enter"))&&void 0!==n?n:S(e,"exit")},D=e=>{const n=_(e);return n?L.filter(t=>{var i;return(null===(i=S(e,t))||void 0===i?void 0:i.name)===n.name}):[]},I=(e,n)=>{if("loop"===n){return["loop"]}const t=D(e);return t.length?t:L},G=e=>{e._animationPreview&&e._endAnimationPreview()},$=(e,n,t=null)=>{var i;const o=T(e),a=null===(i=o[0])||void 0===i?void 0:i.page;if(!a){return}const r=o.filter(e=>e.page===a).map(e=>((e,n,t=C(e))=>{var i;const o=e.page.duration;if("loop"===n){const n=t.find(e=>"loop"===e.type&&e.enabled&&"none"!==e.name);if(!n){return null}const i=B(t,o),{start:a,animation:r}=N(e,n,t),l=Math.max(a,i.start),s=Math.min(l+Math.max(r.duration,1e3),i.end);return l<s?[l,s]:null}const a=x(t,o),r=null!==(i=a.enter)&&void 0!==i?i:a.exit;return r?[r.start,r.end]:null})(e,n,null==t?void 0:t[e.id])).filter(e=>!!e);if(!r.length){return}const l=Math.max(0,Math.min(...r.map(([e])=>e))),s=Math.min(a.duration,Math.max(...r.map(([,e])=>e)));e._previewAnimation({preview:t,animatedElementsIds:o.map(e=>e.id),startTime:a.startTime+l,endTime:a.startTime+s})},q={right:n(f,{name:"animation.directionRight"}),left:n(f,{name:"animation.directionLeft"}),up:n(f,{name:"animation.directionUp"}),down:n(f,{name:"animation.directionDown"}),"bottom-right":n(f,{name:"animation.directionBottomRight"}),"bottom-left":n(f,{name:"animation.directionBottomLeft"}),"top-right":n(f,{name:"animation.directionTopRight"}),"top-left":n(f,{name:"animation.directionTopLeft"}),none:n(f,{name:"animation.typeNone"})},K=[{key:"move",icon:"animation.typeMove",label:"toolbar.move",strength:!0,directions:Object.keys(v)},{key:"fade",icon:"animation.typeFade",label:"toolbar.fade"},{key:"zoom",icon:"animation.typeZoom",label:"toolbar.zoom",strength:!0,directions:Object.keys(h)},{key:"pop",icon:"animation.typePop",label:"toolbar.pop",strength:!0},{key:"rise",icon:"animation.typeRise",label:"toolbar.rise",strength:!0},{key:"growTurn",icon:"animation.typeGrowTurn",label:"toolbar.growTurn",strength:!0},{key:"flip",icon:"animation.typeFlip",label:"toolbar.flipAnimation"},{key:"wipe",icon:"animation.typeWipe",label:"toolbar.wipe",directions:["right","left","up","down"]},{key:"blur",icon:"animation.typeBlur",label:"toolbar.blur",types:["text","image","svg","video","gif"]},{key:"count",icon:"animation.typeCount",label:"toolbar.count",types:["text"],offered:e=>P(Z(e))}],U=[{key:"typewriter",icon:"animation.typeTypewriter",label:"toolbar.typewriter",types:["text"],duration:e=>H(Z(e))},{key:"lineRise",icon:"animation.typeLineRise",label:"toolbar.lineRise",types:["text"],duration:1e3},{key:"wordRise",icon:"animation.typeWordRise",label:"toolbar.wordRise",types:["text"],duration:1e3},{key:"wordFade",icon:"animation.typeWordFade",label:"toolbar.wordFade",types:["text"],duration:1e3},{key:"letterPop",icon:"animation.typeLetterPop",label:"toolbar.letterPop",types:["text"],duration:1e3},{key:"wordBlur",icon:"animation.typeWordBlur",label:"toolbar.wordBlur",types:["text"],duration:1e3},{key:"lineWipe",icon:"animation.typeLineWipe",label:"toolbar.lineWipe",types:["text"],duration:1e3}],Z=e=>"text"in e&&"string"==typeof e.text?e.text:"",H=e=>Math.min(4e3,Math.max(1e3,50*Array.from(y(e).replace(/\s/g,"")).length)),J=(e,n,t)=>{var i,o;const a=null===(i=e.animations.find(e=>e.type===n))||void 0===i?void 0:i.name;if(a===t){return{}}const r=null!==(o=X(t,e))&&void 0!==o?o:X(a,e)?500:void 0;return void 0===r?{}:{duration:r}},Q=[{key:"rotate",icon:"animation.typeRotate",label:"toolbar.spinAnimation",duration:4e3},{key:"blink",icon:"animation.typeBlink",label:"toolbar.blink",duration:1500},{key:"bounce",icon:"animation.typeBounce",label:"toolbar.bounce",strength:!0,offered:()=>!1},{key:"pulse",icon:"animation.typePulse",label:"toolbar.pulse",strength:!0,duration:1500},{key:"float",icon:"animation.typeFloat",label:"toolbar.float",strength:!0,duration:2500},{key:"shake",icon:"animation.typeShake",label:"toolbar.shake",strength:!0,duration:1e3},{key:"letterWave",icon:"animation.typeLetterWave",label:"toolbar.letterWave",types:["text"],strength:!0,duration:2e3},{key:"glow",icon:"animation.typeGlow",label:"toolbar.glow",types:["text","image","svg","video","gif","figure","line"],strength:!0,duration:2e3},{key:"kenBurns",icon:"animation.typeKenBurns",label:"toolbar.kenBurns",types:["image","svg","video","gif"],strength:!0,directions:["none",...Object.keys(j)]}],V=e=>[...K,...U,...Q].find(n=>n.key===e),X=(e,n)=>{var t;const i=null===(t=V(e))||void 0===t?void 0:t.duration;return"function"==typeof i?i(n):i},Y=e=>parseFloat((e/1e3).toFixed(2)),ee={key:"none",icon:"animation.typeNone",label:"toolbar.none"},ne=(n,t,i,o)=>{var a,r;for(const l of I(n,t)){if((null===(a=S(n,l))||void 0===a?void 0:a.name)===i){continue}const t=W(n.animations.find(e=>e.type===l)),{direction:s}=t,p=e(t,["direction"]),d=null===(r=V(i))||void 0===r?void 0:r.directions;o(l,Object.assign(Object.assign({name:i,enabled:!0},J(n,l,i)),d&&s&&!d.includes(s)?{data:p}:{}))}},te=(e,n,t)=>{const i=m(e.animations);return b(i),p(()=>ne(e,n,t,(e,n)=>O(i,e,n))),c(i)},ie=({icon:e,label:i,active:o,settings:a,onClick:r,onPreview:l,onPreviewEnd:s})=>t("button",{type:"button","aria-pressed":o,"data-active":o?"true":void 0,onClick:r,onPointerEnter:l,onPointerLeave:s,onFocus:l,onBlur:s,className:"pn:group pn:flex pn:min-w-0 pn:flex-col pn:items-center pn:gap-1.5 pn:text-xs pn:leading-tight pn:outline-none",children:[t("span",{className:"pn:relative pn:grid pn:aspect-square pn:w-full pn:place-items-center pn:rounded-xl pn:border-[1.5px] pn:border-border pn:bg-background pn:transition-colors pn:group-hover:border-foreground/30 pn:group-focus-visible:ring-[3px] pn:group-focus-visible:ring-ring/50 pn:group-data-[active=true]:border-2 pn:group-data-[active=true]:border-primary pn:group-data-[active=true]:bg-primary/5",children:[n(f,{name:e,className:"pn:size-[58%] pn:text-foreground"}),a&&n(f,{name:"animation.settings",className:"pn:absolute pn:top-1.5 pn:right-1.5 pn:size-3.5 pn:text-primary"})]}),n("span",{className:"pn:text-center",children:i})]}),oe=({active:e,onClick:t,label:i,children:o})=>n("button",{type:"button","aria-pressed":e,"aria-label":i,onClick:t,className:z("pn:grid pn:min-w-0 pn:flex-1 pn:place-items-center pn:rounded-md pn:border-[1.5px] pn:border-border pn:bg-background pn:px-1 pn:py-1.5 pn:text-sm",e&&"pn:border-primary pn:font-medium pn:text-primary"),children:o}),ae=({column:e,children:i})=>t("div",{className:"pn:relative pn:col-span-3 pn:mt-1 pn:flex pn:flex-col pn:gap-3 pn:rounded-lg pn:border pn:border-border pn:bg-background pn:p-3",children:[n("span",{"aria-hidden":"true",className:"pn:absolute pn:-top-[7px] pn:size-3 pn:rotate-45 pn:rounded-tl-[2px] pn:border-t pn:border-l pn:border-border pn:bg-background",style:{left:`calc(${(e+.5)/3*100}% - 6px)`}}),i]});export const AnimationsPanel=d(({store:s})=>{const p=s.selectedElements,d=p[0],m=p.map(e=>e.id).join(","),[c,u]=o.useState({ids:"",groups:[]}),b=c.ids===m?c.groups:[],f=(e,n)=>u({ids:m,groups:n?[...b,e]:b.filter(n=>n!==e)}),y="animation"===s.openedSidePanel;if(o.useEffect(()=>{y&&(d&&d.animations||s.restoreSidePanel())},[y,m]),o.useEffect(()=>()=>s._endAnimationPreview(),[s,y,m]),!d||!d.animations){return null}const v=e=>{const n=T(s);n.length&&s.history.transaction(()=>n.forEach(e))},h=e=>{v(n=>{const t=_(n);if(!t){return}const{name:i,duration:o,data:a}=t;for(const r of L){e.includes(r)?n.setAnimation(r,{name:i,enabled:!0,duration:o,data:a}):S(n,r)&&n.setAnimation(r,Object.assign({name:"none"},J(n,r,"none")))}}),$(s,"transition")},x=(n,t)=>{var{data:i}=t,o=e(t,["data"]);return v(e=>{for(const t of I(e,n)){const n=S(e,t);n&&e.setAnimation(t,i?Object.assign(Object.assign({},o),{data:Object.assign(Object.assign({},n.data),i)}):o)}})},P=({start:e,end:n})=>v(t=>{const i=t.page.duration,o=B(t.animations,i);E(t,i,null!=e?e:o.start,null!=n?n:o.end)}),j=_(d),N=D(d),C=S(d,"loop"),O=e=>{const n=new Set(p.map(n=>{var t,i;return null!==(i=null===(t=e(n))||void 0===t?void 0:t.name)&&void 0!==i?i:null}));return 1===n.size?[...n][0]:void 0},z=O(_),R=O(e=>S(e,"loop")),Z=(e,n)=>e.filter(({key:e,types:t,offered:i})=>n===e||p.every(e=>(!t||t.includes(e.type))&&(!i||i(e)))),H=Z(K,z),V=Z(U,z),X=Z(Q,R),re=d.page.duration,le=B(d.animations,re),se=(e,t)=>{var i;const o=null!==(i=W(t).strength)&&void 0!==i?i:1;return n(a,{label:g("toolbar.strength"),value:parseFloat(o.toFixed(2)),onChange:n=>x(e,{data:{strength:n}}),min:.1,sliderMax:Math.max(3,o),step:.05,onCommit:()=>$(s,e)})},pe=(e,i,o)=>{const a=W(i).direction,r=a&&o.includes(a)?a:o[0];return t("div",{className:"pn:flex pn:flex-col pn:gap-2",children:[n("span",{className:"pn:text-sm",children:g("sidePanel.animationDirection")}),n("div",{className:"pn:flex pn:gap-1",children:o.map(t=>n(oe,{active:r===t,label:g(`sidePanel.animationDirections.${t}`),onClick:()=>{x(e,{data:{direction:t}}),$(s,e)},children:q[t]},t))})]})},de=(e,i,o,a)=>t("div",{className:"pn:flex pn:flex-col pn:gap-2",children:[n("span",{className:"pn:text-sm",children:g(i)}),n("div",{className:"pn:flex pn:gap-1.5",children:["in","out"].map(t=>n(oe,{active:a===t,onClick:()=>{x(e,{data:{[o]:t}}),$(s,e)},children:g("in"===t?"sidePanel.zoomIn":"sidePanel.zoomOut")},t))})]}),me=(e,o)=>t(i,{children:[n("div",{className:"pn:flex pn:gap-1.5",children:[[L,"sidePanel.animationBoth"],[["enter"],"sidePanel.animationEnter"],[["exit"],"sidePanel.animationExit"]].map(([e,t])=>n(oe,{active:N.length===e.length&&e.every(e=>N.includes(e)),onClick:()=>h(e),children:g(t)},t))}),"zoom"===o.name?de("transition","sidePanel.animationDirection","direction",k(W(o).direction)):e.directions&&pe("transition",o,e.directions),e.strength&&se("transition",o),n(a,{label:g("sidePanel.animationDuration"),value:Y(o.duration),onChange:e=>x("transition",{duration:1e3*e}),min:0,max:re/1e3,step:.1,onCommit:()=>$(s,"transition")}),N.includes("enter")&&n(a,{label:g("sidePanel.animationStartAt"),value:Y(le.start),onChange:e=>P({start:1e3*e}),min:0,max:re/1e3,step:.1}),N.includes("exit")&&n(a,{label:g("sidePanel.animationEndAt"),value:Y(le.end),onChange:e=>P({end:1e3*e}),min:0,max:re/1e3,step:.1})]}),ce=(e,o)=>t(i,{children:["kenBurns"===o.name&&de("loop","toolbar.zoom","zoom","out"===W(o).zoom?"out":"in"),e.directions&&pe("loop",o,e.directions),!M(o.name)&&n(a,{label:g("sidePanel.animationRepeatEvery"),value:Y(o.duration),onChange:e=>x("loop",{duration:1e3*e}),min:.1,sliderMax:Math.max(10,o.duration/1e3),step:.1,onCommit:()=>$(s,"loop")}),e.strength&&se("loop",o),"glow"===o.name&&n(r,{label:g("toolbar.color"),children:n(l,{value:w(d),size:30,onChange:e=>v(n=>n.set({shadowColor:e})),store:s})})]}),ue=(e,t,i)=>{const o=t.map(t=>{const o=("none"===t.key?null:t.key)===i;return n(ie,{icon:t.icon,label:g(t.label),active:o,settings:o&&"none"!==t.key,onPreview:()=>{o||"none"===t.key||((e,n)=>{const t={};for(const i of T(s)){t[i.id]=te(i,e,n)}$(s,e,t)})(e,t.key)},onPreviewEnd:()=>G(s),onClick:()=>{G(s),o?f(e,!b.includes(e)):"none"!==t.key?(((e,n)=>{v(t=>ne(t,e,n,(e,n)=>t.setAnimation(e,n)))})(e,t.key),f(e,!1),$(s,e)):"loop"===e?x("loop",{enabled:!1}):h([])}},t.key)}),a=t.findIndex(e=>e.key===i),r="loop"===e?C:j;if(!b.includes(e)&&i&&a>=0&&r){const i=t[a],l=Math.min(t.length-1,3*Math.floor(a/3)+2);o.splice(l+1,0,n(ae,{column:a%3,children:"loop"===e?ce(i,r):me(i,r)},"settings"))}return n("div",{className:"pn:grid pn:grid-cols-3 pn:gap-x-2.5 pn:gap-y-3",children:o})};return n(F,{header:n(A,{title:g("sidePanel.animate"),onClose:()=>s.restoreSidePanel()}),children:t("div",{className:"pn:flex pn:flex-col pn:gap-5 pn:pt-2 pn:pb-24",children:[t("section",{className:"pn:flex pn:flex-col pn:gap-2.5",children:[n("h3",{className:"pn:text-sm pn:font-semibold",children:g("sidePanel.animationGeneral")}),ue("transition",[ee,...H],z)]}),V.length>0&&t("section",{className:"pn:flex pn:flex-col pn:gap-2.5",children:[n("h3",{className:"pn:text-sm pn:font-semibold",children:g("sidePanel.animationTextPresets")}),ue("transition",V,z)]}),t("section",{className:"pn:flex pn:flex-col pn:gap-2.5",children:[n("h3",{className:"pn:text-sm pn:font-semibold",children:g("sidePanel.animationLoop")}),ue("loop",[ee,...X],R)]})]})})});
|
|
@@ -14,7 +14,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
14
14
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
15
15
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
16
16
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
17
|
-
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" | "
|
|
17
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
18
18
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
19
19
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
20
20
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -35,6 +35,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
35
35
|
type: import("mobx-state-tree").ISimpleType<"exit" | "enter" | "loop">;
|
|
36
36
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
37
37
|
data: import("mobx-state-tree").IType<{} | null | undefined, {}, {}>;
|
|
38
|
+
easing: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
|
|
38
39
|
}, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
39
40
|
blurEnabled: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
40
41
|
blurRadius: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
@@ -91,7 +92,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
91
92
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
92
93
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
93
94
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
94
|
-
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" | "
|
|
95
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
95
96
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
96
97
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
97
98
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -103,7 +104,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
103
104
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
104
105
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
105
106
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
106
|
-
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" | "
|
|
107
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
107
108
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
108
109
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
109
110
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -115,7 +116,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
115
116
|
type: string | undefined;
|
|
116
117
|
name: string | undefined;
|
|
117
118
|
opacity: number | undefined;
|
|
118
|
-
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "
|
|
119
|
+
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light" | undefined;
|
|
119
120
|
custom: any;
|
|
120
121
|
visible: boolean | undefined;
|
|
121
122
|
selectable: boolean | undefined;
|
|
@@ -134,7 +135,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
134
135
|
alwaysOnTop: boolean;
|
|
135
136
|
showInExport: boolean;
|
|
136
137
|
} | {
|
|
137
|
-
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "
|
|
138
|
+
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
|
|
138
139
|
id: string;
|
|
139
140
|
type: string;
|
|
140
141
|
name: string;
|
|
@@ -162,7 +163,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
162
163
|
alwaysOnTop: boolean;
|
|
163
164
|
showInExport: boolean;
|
|
164
165
|
} | {
|
|
165
|
-
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "
|
|
166
|
+
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
|
|
166
167
|
id: string;
|
|
167
168
|
type: string;
|
|
168
169
|
name: string;
|
|
@@ -197,7 +198,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
197
198
|
readonly isSelected: boolean;
|
|
198
199
|
readonly isSelectedDirectly: boolean;
|
|
199
200
|
} & {
|
|
200
|
-
setAnimation(type:
|
|
201
|
+
setAnimation(type: "enter" | "exit" | "loop", attrs: import("../utils/animations.js").AnimationAttrs): void;
|
|
201
202
|
setFilter(type: any, value: any): void;
|
|
202
203
|
} & {
|
|
203
204
|
_setSourceSize(size: import("../image-tools/types.js").Size, src: string): void;
|
|
@@ -221,7 +222,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
221
222
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
222
223
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
223
224
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
224
|
-
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" | "
|
|
225
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
225
226
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
226
227
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
227
228
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -242,6 +243,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
242
243
|
type: import("mobx-state-tree").ISimpleType<"exit" | "enter" | "loop">;
|
|
243
244
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
244
245
|
data: import("mobx-state-tree").IType<{} | null | undefined, {}, {}>;
|
|
246
|
+
easing: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
|
|
245
247
|
}, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
|
|
246
248
|
blurEnabled: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
247
249
|
blurRadius: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
@@ -298,7 +300,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
298
300
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
299
301
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
300
302
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
301
|
-
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" | "
|
|
303
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
302
304
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
303
305
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
304
306
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -310,7 +312,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
310
312
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
311
313
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
312
314
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
313
|
-
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" | "
|
|
315
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
314
316
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
315
317
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
316
318
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -322,7 +324,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
322
324
|
type: string | undefined;
|
|
323
325
|
name: string | undefined;
|
|
324
326
|
opacity: number | undefined;
|
|
325
|
-
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "
|
|
327
|
+
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light" | undefined;
|
|
326
328
|
custom: any;
|
|
327
329
|
visible: boolean | undefined;
|
|
328
330
|
selectable: boolean | undefined;
|
|
@@ -341,7 +343,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
341
343
|
alwaysOnTop: boolean;
|
|
342
344
|
showInExport: boolean;
|
|
343
345
|
} | {
|
|
344
|
-
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "
|
|
346
|
+
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
|
|
345
347
|
id: string;
|
|
346
348
|
type: string;
|
|
347
349
|
name: string;
|
|
@@ -369,7 +371,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
369
371
|
alwaysOnTop: boolean;
|
|
370
372
|
showInExport: boolean;
|
|
371
373
|
} | {
|
|
372
|
-
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "
|
|
374
|
+
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
|
|
373
375
|
id: string;
|
|
374
376
|
type: string;
|
|
375
377
|
name: string;
|
|
@@ -404,7 +406,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
404
406
|
readonly isSelected: boolean;
|
|
405
407
|
readonly isSelectedDirectly: boolean;
|
|
406
408
|
} & {
|
|
407
|
-
setAnimation(type:
|
|
409
|
+
setAnimation(type: "enter" | "exit" | "loop", attrs: import("../utils/animations.js").AnimationAttrs): void;
|
|
408
410
|
setFilter(type: any, value: any): void;
|
|
409
411
|
} & {
|
|
410
412
|
_setSourceSize(size: import("../image-tools/types.js").Size, src: string): void;
|
|
@@ -428,7 +430,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
428
430
|
type: string | undefined;
|
|
429
431
|
name: string | undefined;
|
|
430
432
|
opacity: number | undefined;
|
|
431
|
-
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "
|
|
433
|
+
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light" | undefined;
|
|
432
434
|
custom: any;
|
|
433
435
|
visible: boolean | undefined;
|
|
434
436
|
selectable: boolean | undefined;
|
|
@@ -447,7 +449,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
447
449
|
alwaysOnTop: boolean;
|
|
448
450
|
showInExport: boolean;
|
|
449
451
|
} | {
|
|
450
|
-
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "
|
|
452
|
+
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
|
|
451
453
|
id: string;
|
|
452
454
|
type: string;
|
|
453
455
|
name: string;
|
package/side-panel/text-panel.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=this&&this.__rest||function(e,t){var o={};for(var n in e){Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n])}if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++){t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]])}}return o};import{jsx as t,jsxs as o}from"react/jsx-runtime";import*as n from"react";import{observer as i}from"mobx-react-lite";import l from"swr";import{PolotnoIcon as a}from"../icons/registry.js";import{t as r}from"../utils/l10n.js";import{isMobile as s}from"../utils/screen.js";import{textTemplateList as p}from"../utils/api.js";import{fetcher as c}from"../utils/use-api.js";import{localFileToURL as f}from"../utils/file.js";import{cssFontFamily as m}from"@polotno/core/fonts";import{registerNextDomDrop as d}from"../canvas/page.js";import{Button as h}from"../primitives/button.js";import{Tabs as
|
|
1
|
+
var e=this&&this.__rest||function(e,t){var o={};for(var n in e){Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n])}if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++){t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]])}}return o};import{jsx as t,jsxs as o}from"react/jsx-runtime";import*as n from"react";import{observer as i}from"mobx-react-lite";import l from"swr";import{PolotnoIcon as a}from"../icons/registry.js";import{t as r}from"../utils/l10n.js";import{isMobile as s}from"../utils/screen.js";import{textTemplateList as p}from"../utils/api.js";import{fetcher as c}from"../utils/use-api.js";import{localFileToURL as f}from"../utils/file.js";import{cssFontFamily as m}from"@polotno/core/fonts";import{registerNextDomDrop as d}from"../canvas/page.js";import{Button as h}from"../primitives/button.js";import{Tabs as u,TabsList as y,TabsTrigger as x}from"../primitives/tabs.js";import{ImagesGrid as g}from"./images-grid.js";import{loadTextTemplate as v}from"./text-template.js";import{PanelScrollArea as b}from"../primitives/panel-scroll-area.js";let j=async e=>f(e);export function setFontUploadFunc(e){j=e}const w=i(({onSelect:e,onRemove:n,font:i})=>o("div",{style:{fontFamily:m(i.fontFamily)},className:"polotno-font-item pn:relative pn:mb-2.5 pn:flex pn:h-[100px] pn:cursor-pointer pn:flex-col pn:justify-center pn:rounded-md pn:bg-black/40 pn:text-center pn:text-[25px] pn:text-white pn:shadow-[0_0_5px_rgba(16,22,26,0.3)]",onClick:e,children:[i.fontFamily," text",t(h,{style:{position:"absolute",right:0,bottom:0},variant:"ghost",size:"icon-sm",onClick:e=>{e.stopPropagation(),n()},children:t(a,{name:"action.remove"})})]})),S=o=>{var{onSelect:n}=o,i=e(o,["onSelect"]);return t(h,Object.assign({},i,{draggable:!0,className:"polotno-close-panel",onClick:()=>n(),onDragStart:()=>{d(({x:e,y:t})=>{n({x:e,y:t})})},onDragEnd:()=>{d(null)}}))},F=[{previewSize:"25px",fontSize:76,labelKey:"sidePanel.createHeader",textKey:"sidePanel.headerText"},{previewSize:"18px",fontSize:44,labelKey:"sidePanel.createSubHeader",textKey:"sidePanel.subHeaderText"},{previewSize:"14px",fontSize:30,labelKey:"sidePanel.createBody",textKey:"sidePanel.bodyText"}];export const TextPanel=i(({store:e})=>{n.useEffect(()=>{e.loadFont("Roboto")},[]);const i=t=>{var o;const n=t.width||e.width/2,i=((null==t?void 0:t.x)||e.width/2)-n/2,l=((null==t?void 0:t.y)||e.height/2)-t.fontSize/2,a=(e.width+e.height)/2160,r=null===(o=e.activePage)||void 0===o?void 0:o.addElement(Object.assign(Object.assign({type:"text",fontFamily:"Roboto"},t),{x:i,y:l,width:n,fontSize:t.fontSize*a}));s()||null==r||r.toggleEditMode(!0)};n.useEffect(()=>{e.fonts.forEach(t=>e.loadFont(t.fontFamily))},[e.fonts]);const{data:f,error:m}=l(p(),c),[d,P]=n.useState("text"),[z,O]=n.useState(null),E=n.useRef(null),C=e=>{E.current=e,O(e)},[K,N]=n.useState(null);return o("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[t(u,{value:d,onValueChange:e=>P(String(e)),className:"pn:mb-3",children:o(y,{className:"pn:w-full pn:h-10",children:[t(x,{value:"text",children:r("sidePanel.text")}),t(x,{value:"font",children:r("sidePanel.myFonts")})]})}),"text"===d&&o("div",{className:"polotno-text-panel-container pn:flex pn:flex-col",style:{height:"calc(100% - 52px)"},children:[F.map(({previewSize:e,fontSize:o,labelKey:n,textKey:l})=>t(S,{style:{fontSize:e},variant:"ghost",className:"pn:mb-[5px] pn:w-full pn:h-auto pn:min-h-[2.5rem] pn:py-1 pn:justify-start pn:font-['Roboto']",onSelect:e=>{i(Object.assign(Object.assign({},e),{fontSize:o,text:r(l),fontFamily:"Roboto"}))},children:r(n)},n)),t(g,{shadowEnabled:!1,images:null==f?void 0:f.items,getPreview:e=>e.preview,getImageClassName:e=>e.json.indexOf("plain")>=0?"polotno-text-preview-plain":"",isLoading:!f,error:m||K,getIsLoading:e=>e.json===z,onSelect:async(t,o)=>{if(E.current===t.json){return}let n;N(null),C(t.json);try{n=await v(e,t)}catch(r){return console.warn("polotno: failed to load the text template",r),void(E.current===t.json&&N(r))}finally{E.current===t.json&&C(null)}if(!e.activePage){return}const i=(e.width+e.height)/2160,l=o?o.x-n.width/2*i:e.width/2-n.width/2*i,a=o?o.y-n.height/2*i:e.height/2-n.height/2*i;e.history.transaction(()=>{const t=n.pages[0].children,o=[];t.forEach(t=>{delete t.id;const{id:n}=e.activePage.addElement(Object.assign(Object.assign({},t),{fontSize:t.fontSize*i,x:t.x*i+l,y:t.y*i+a,width:t.width*i,height:t.height*i}));o.push(n)}),e.selectElements(o)})}})]}),"font"===d&&o("div",{style:{display:"flex",flexDirection:"column",height:"calc(100% - 62px)"},children:[o("label",{htmlFor:"polotno-font-upload",children:[o(h,{style:{width:"100%"},onClick:()=>{var e;null===(e=document.querySelector("#polotno-font-upload"))||void 0===e||e.click()},children:[t(a,{name:"text.uploadFont"}),r("sidePanel.uploadFont")]}),t("input",{type:"file",accept:".ttf, .otf, .woff, .woff2, .eot",id:"polotno-font-upload",style:{display:"none"},onChange:async t=>{const{target:o}=t;for(const n of Array.from(o.files||[])){const t=await j(n),o=n.name.split(".")[0].replace(/,/g,"");e.addFont({fontFamily:o,url:t})}o.value=""}})]}),t(b,{className:"pn:mt-4",children:e.fonts.map((o,n)=>t(w,{font:o,onSelect:()=>{i({fontSize:80,text:"Cool text",fontFamily:o.fontFamily})},onRemove:()=>{e.find(e=>("text"===e.type&&e.fontFamily===o.fontFamily&&e.set({fontFamily:"Roboto"}),!1)),e.removeFont(o.fontFamily)}},n))})]})]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extractFontSpecsFromHtml as t}from"../utils/rich-text-html.js";export async function loadTextTemplate(o,e){const a=Date.now(),l=((o=[])=>o.filter(t=>t.fontFamily).flatMap(o=>{var e,a;return t("",{fontFamily:o.fontFamily,fontWeight:null!==(e=o.fontWeight)&&void 0!==e?e:"normal",fontStyle:null!==(a=o.fontStyle)&&void 0!==a?a:"normal"})}))(e.fonts).map(t=>o.loadFont(t.family,t.style,t.weight).catch(()=>{})),n=await
|
|
1
|
+
import{extractFontSpecsFromHtml as t}from"../utils/rich-text-html.js";export async function loadTextTemplate(o,e){const a=Date.now(),l=((o=[])=>o.filter(t=>t.fontFamily).flatMap(o=>{var e,a;return t("",{fontFamily:o.fontFamily,fontWeight:null!==(e=o.fontWeight)&&void 0!==e?e:"normal",fontStyle:null!==(a=o.fontStyle)&&void 0!==a?a:"normal"})}))(e.fonts).map(t=>o.loadFont(t.family,t.style,t.weight).catch(()=>{})),n=await fetch(e.json);if(!n.ok){throw new Error(`polotno: text template request failed with ${n.status}`)}const i=await n.json(),r=3e3-(Date.now()-a);if(r>0){let t;await Promise.race([Promise.all(l),new Promise(o=>{t=setTimeout(o,r)})]),clearTimeout(t)}return i}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{observer as t}from"mobx-react-lite";import{PolotnoIcon as i}from"../icons/registry.js";import{t as a}from"../utils/l10n.js";import{
|
|
1
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{observer as t}from"mobx-react-lite";import{PolotnoIcon as i}from"../icons/registry.js";import{t as a}from"../utils/l10n.js";import{MOVE_OFFSETS as o}from"@polotno/core/animation-presets";import{Button as l}from"../primitives/button.js";import{ButtonGroup as s}from"../primitives/button-group.js";import{NumberInput as r}from"../primitives/numeric-input.js";export{NumberInput}from"../primitives/numeric-input.js";import{Slider as m}from"../primitives/slider.js";import{Switch as d}from"../primitives/switch.js";import{Popover as p,PopoverContent as c,PopoverTrigger as u}from"../primitives/popover.js";import{Select as h,SelectContent as b,SelectItem as g,SelectTrigger as v,SelectValue as f}from"../primitives/select.js";import{cn as x,firstSliderValue as y}from"../lib/utils.js";const j=({checked:t,label:i,onChange:a})=>n("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"8px"},children:[e("label",{className:"pn:text-xs",children:i}),e(d,{checked:t,onCheckedChange:a})]}),C=t(({element:t,store:i,enabled:a})=>{const o=t.animations.find(e=>"enter"===e.type),r=t.animations.find(e=>"exit"===e.type);return a?n(s,{fill:!0,children:[e(l,{variant:"outline",size:"sm",className:x("pn:flex-1",(null==o?void 0:o.enabled)&&!(null==r?void 0:r.enabled)&&"pn:bg-accent pn:text-accent-foreground"),onClick:()=>{i.history.transaction(()=>{t.setAnimation("enter",{enabled:!0}),t.setAnimation("exit",{enabled:!1})})},children:"Enter"}),e(l,{variant:"outline",size:"sm",className:x("pn:flex-1",(null==o?void 0:o.enabled)&&(null==r?void 0:r.enabled)&&"pn:bg-accent pn:text-accent-foreground"),onClick:()=>{i.history.transaction(()=>{t.setAnimation("enter",{enabled:!0}),t.setAnimation("exit",{enabled:!0})})},children:"Both"}),e(l,{variant:"outline",size:"sm",className:x("pn:flex-1",(null==r?void 0:r.enabled)&&!(null==o?void 0:o.enabled)&&"pn:bg-accent pn:text-accent-foreground"),onClick:()=>{i.history.transaction(()=>{t.setAnimation("enter",{enabled:!1}),t.setAnimation("exit",{enabled:!0})})},children:"Exit"})]}):null}),A=Object.keys(o),z={right:e(i,{name:"animation.directionRight",className:"pn:size-4"}),left:e(i,{name:"animation.directionLeft",className:"pn:size-4"}),up:e(i,{name:"animation.directionUp",className:"pn:size-4"}),down:e(i,{name:"animation.directionDown",className:"pn:size-4"}),"bottom-right":e(i,{name:"animation.directionBottomRight",className:"pn:size-4"}),"bottom-left":e(i,{name:"animation.directionBottomLeft",className:"pn:size-4"}),"top-right":e(i,{name:"animation.directionTopRight",className:"pn:size-4"}),"top-left":e(i,{name:"animation.directionTopLeft",className:"pn:size-4"})},N=t(({value:t,onChange:i})=>e("div",{style:{paddingTop:"10px"},children:n(h,{value:t,onValueChange:e=>{null!==e&&i(e)},children:[e(v,{className:"pn:w-full",children:e(f,{children:n("span",{className:"pn:flex pn:items-center pn:gap-2",children:[z[t],t]})})}),e(b,{children:A.map(t=>e(g,{value:t,children:n("span",{className:"pn:flex pn:items-center pn:gap-2",children:[z[t],t]})},t))})]})})),k=t(({element:t})=>{const i=t.animations.find(e=>"enter"===e.type);return i?n("div",{style:{padding:"10px"},children:[n("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[e("div",{children:"Delay"}),e("div",{children:e(r,{value:parseFloat((i.delay/1e3).toFixed(2)),onValueChange:e=>{t.setAnimation("enter",{delay:1e3*e})},style:{width:"50px"},step:.01,min:0,max:2.5})})]}),e(m,{min:0,max:1e3,step:1,value:[i.delay],onValueChange:e=>{const n=y(e);t.setAnimation("enter",{delay:n})}})]}):null}),T=t(({element:t})=>{const i=t.animations.find(e=>"enter"===e.type);return i?n("div",{style:{padding:"10px"},children:[n("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[e("div",{children:"Duration"}),e("div",{children:e(r,{value:parseFloat((i.duration/1e3).toFixed(2)),onValueChange:e=>{t.setAnimation("enter",{duration:1e3*e}),t.setAnimation("exit",{duration:1e3*e})},style:{width:"50px"},step:.01,min:0,max:2.5})})]}),e(m,{min:0,max:2500,step:1,value:[i.duration],onValueChange:e=>{const n=y(e);t.setAnimation("enter",{duration:n}),t.setAnimation("exit",{duration:n})}})]}):null});export const AnimationsPickerOld=t(({element:t,store:i,elements:o})=>{var s,r;const m=o||[t],d=m[0],h=(e,n)=>{i.history.transaction(()=>{m.forEach(t=>{t.setAnimation("enter",Object.assign({name:e},n)),t.setAnimation("exit",Object.assign(Object.assign({name:e},n),{from:n.to,to:n.from}))})}),n.enabled&&(i.play({animatedElementsIds:m.map(e=>e.id),currentTime:d.page.startTime}),setTimeout(()=>{i.stop()},1e3))},b=(e,n)=>{var t;return!!((e?null===(t=d.animations)||void 0===t?void 0:t.filter(n=>n.name===e):d.animations)||[]).find(e=>e.enabled)};return n(p,{children:[e(u,{render:e(l,{variant:"ghost",size:"sm",children:a("toolbar.animate")})}),n(c,{align:"start",initialFocus:!1,style:{padding:"15px",paddingTop:"25px",width:"230px"},children:[e(j,{checked:b("fade"),label:a("toolbar.fade"),onChange:e=>{h("fade",{enabled:e})}}),e(j,{checked:b("move"),label:a("toolbar.move"),onChange:e=>{h("move",{enabled:e})}}),e(j,{checked:b("zoom"),label:a("toolbar.zoom"),onChange:e=>{h("zoom",{enabled:e})}}),e(C,{element:d,store:i,enabled:b()}),b("move")&&e(N,{value:(null===(r=null===(s=d.animations.find(e=>"move"===e.name))||void 0===s?void 0:s.data)||void 0===r?void 0:r.direction)||"right",onChange:e=>{h("move",{data:{direction:e},enabled:!0})}}),b()&&e(k,{store:i,element:d}),b()&&e(T,{store:i,element:d}),e(j,{checked:b("rotate"),label:a("toolbar.rotate"),onChange:e=>{var n;n={enabled:e},i.history.transaction(()=>{m.forEach(e=>{e.setAnimation("loop",Object.assign({name:"rotate"},n))})}),n.enabled&&(i.play({animatedElementsIds:m.map(e=>e.id),currentTime:d.page.startTime}),setTimeout(()=>{i.stop()},1e3))}})]})]})});export const AnimationsPicker=t(({element:n,store:t})=>n.contentEditable?e(l,{variant:"ghost",size:"sm",onClickCapture:e=>{e.stopPropagation(),t.openSidePanel("animation")},children:a("toolbar.animate")}):null);export default AnimationsPicker;
|
|
@@ -2,6 +2,7 @@ import type { ElementType } from '../model/group-model.js';
|
|
|
2
2
|
import type { StoreType } from '../model/store.js';
|
|
3
3
|
import type { TableElementType } from '../model/table-model.js';
|
|
4
4
|
export declare function copyTableCellStyles(source: TableElementType, target: TableElementType): void;
|
|
5
|
+
export declare function applyCopiedStyle(source: ElementType, target: ElementType): void;
|
|
5
6
|
export declare const useCopyStyle: (store: StoreType) => {
|
|
6
7
|
elementToCopy: ElementType | null;
|
|
7
8
|
disabled: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as e,useState as o}from"react";import{
|
|
1
|
+
import{useEffect as e,useState as o}from"react";import{getSnapshot as t,isStateTreeNode as r}from"mobx-state-tree";import{intersect as l}from"../utils/array.js";export function copyTableCellStyles(e,o){const t=Math.min(e.rows,o.rows),r=Math.min(e.cols,o.cols);for(let l=0;l<t;l++){for(let t=0;t<r;t++){const r=e.getCell(l,t),i=o.getCell(l,t);if(!r||!i){continue}const n={};for(const e of g){n[e]=r[e]}i.set(n)}}}export function applyCopiedStyle(e,o){const i=l(f[o.type],f[e.type]).reduce((o,l)=>{const i=e[l];return Object.assign(Object.assign({},o),{[l]:r(i)?t(i):i})},{});o.type!==e.type&&h.forEach(e=>{delete i[e]}),o.set(Object.assign({},i)),"table"===e.type&&"table"===o.type&©TableCellStyles(e,o)}export const useCopyStyle=t=>{const[r,l]=o(null);e(()=>{const e=t.selectedElements;r&&(e.forEach(e=>applyCopiedStyle(r,e)),l(null))},[t.selectedElements[0]]);const i=1!==t.selectedElements.length;return{elementToCopy:r,disabled:i,setElementToCopy:l}};const i=["opacity","visible","height","width","shadowEnabled","shadowBlur","shadowColor","shadowOffsetX","shadowOffsetY","blurEnabled","blurRadius","brightnessEnabled","brightness","sepiaEnabled","grayscaleEnabled"],n=[...i,"fontSize","fontWeight","fontFamily","lineHeight","stroke","strokeWidth","textDecoration","fill","align","verticalAlign","letterSpacing","backgroundEnabled","backgroundColor","backgroundOpacity","backgroundCornerRadius","backgroundPadding","borderColor","borderSize"],a=[...i,"flipX","flipY","keepRatio","borderColor","borderSize","cornerRadius","cropX","cropY","cropWidth","cropHeight"],s=[...i,"flipX","flipY","keepRatio","borderColor","borderSize","cornerRadius","cropX","cropY","cropWidth","cropHeight"],c=[...i,"color","dash","endHead","startHead"],d=[...i,"dash","cornerRadius","fill","stroke","strokeWidth"],p=[...i,"cornerRadius","borderColor","borderSize","colorsReplace","cropHeight","cropWidth","cropX","cropY","flipX","flipY","keepRatio"],b=[...i,"borderColor","borderWidth","borderStyle"],g=["fontSize","fontFamily","fontWeight","fontStyle","textDecoration","fill","align","verticalAlign","lineHeight","letterSpacing","cellBackground","cellPadding","borders"],f={figure:d,image:a,line:c,svg:p,text:n,video:s,table:b},h=["width","height"];
|