polotno 3.19.1 → 3.20.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/LICENSE.md +8 -2
- package/THIRD_PARTY_NOTICES.md +2871 -0
- package/blueprint/canvas/context-menu/context-menu.js +1 -1
- package/blueprint/canvas/page-controls.d.ts +3 -3
- package/blueprint/pages-timeline/pages-timeline.js +2 -2
- package/blueprint/pages-timeline/play-button.js +2 -2
- package/blueprint/side-panel/animations-panel.d.ts +1 -1
- package/blueprint/side-panel/draw-panel.js +2 -2
- package/blueprint/side-panel/effect-card.js +3 -3
- package/blueprint/side-panel/effects-panel.d.ts +1 -1
- package/blueprint/side-panel/effects-panel.js +1 -1
- package/blueprint/side-panel/elements-panel.d.ts +1 -1
- package/blueprint/side-panel/select-video.d.ts +19 -19
- package/blueprint/side-panel/videos-grid.d.ts +4 -4
- package/blueprint/toolbar/animations-picker.d.ts +1 -1
- package/blueprint/toolbar/element-container.d.ts +1 -1
- package/blueprint/toolbar/figure-toolbar.js +1 -1
- package/blueprint/toolbar/filters-picker.d.ts +1 -1
- package/blueprint/toolbar/filters-picker.js +1 -1
- package/blueprint/toolbar/group-button.js +1 -1
- package/blueprint/toolbar/image-remove-background-button.js +1 -1
- package/blueprint/toolbar/image-toolbar.js +1 -1
- package/blueprint/toolbar/line-toolbar.js +1 -1
- package/blueprint/toolbar/page-toolbar.d.ts +1 -1
- package/blueprint/toolbar/position-picker.js +1 -1
- package/blueprint/toolbar/sketch.d.ts +5 -5
- package/blueprint/toolbar/svg-toolbar.js +1 -1
- package/blueprint/toolbar/table-toolbar.js +1 -1
- package/blueprint/toolbar/text-ai-write.js +1 -1
- package/blueprint/toolbar/text-toolbar.d.ts +1 -1
- package/blueprint.polotno.css +164 -153
- package/canvas/apply-filters.d.ts +2 -6
- package/canvas/apply-filters.js +1 -1
- package/canvas/context-menu/context-menu.js +1 -1
- package/canvas/crop-overlay.d.ts +1 -1
- package/canvas/crop-overlay.js +1 -1
- package/canvas/downscale.d.ts +1 -24
- package/canvas/downscale.js +1 -1
- package/canvas/element.d.ts +3 -1
- package/canvas/element.js +1 -1
- package/canvas/fade-overlay.js +1 -1
- package/canvas/figure-element.js +1 -1
- package/canvas/gif-element.d.ts +32 -0
- package/canvas/gif-element.js +1 -1
- package/canvas/hotkeys.d.ts +1 -1
- package/canvas/hotkeys.js +1 -1
- package/canvas/html-element.js +1 -1
- package/canvas/image-element.d.ts +4 -48
- package/canvas/image-element.js +1 -1
- package/canvas/image-tool-controls.js +1 -1
- package/canvas/line-element.js +1 -1
- package/canvas/lottie-element.d.ts +11 -0
- package/canvas/lottie-element.js +1 -0
- package/canvas/lottie-player.d.ts +2 -0
- package/canvas/lottie-player.js +1 -0
- package/canvas/lottie-player.wasm.d.ts +1 -0
- package/canvas/lottie-player.wasm.js +1 -0
- package/canvas/media-placeholders.d.ts +23 -0
- package/canvas/media-placeholders.js +1 -0
- package/canvas/page-controls.d.ts +3 -3
- package/canvas/page.js +1 -1
- package/canvas/quill-font-formats.d.ts +2 -2
- package/canvas/rect-control.js +1 -1
- package/canvas/render-tag-element.js +1 -1
- package/canvas/rich-editor.d.ts +7 -4
- package/canvas/rich-editor.js +5 -5
- package/canvas/rules.js +2 -2
- package/canvas/table-cell-text.d.ts +18 -0
- package/canvas/table-cell-text.js +1 -0
- package/canvas/table-element.js +1 -1
- package/canvas/text-element/caret-color.d.ts +3 -1
- package/canvas/text-element/render-tag-source.d.ts +33 -0
- package/canvas/text-element/render-tag-source.js +1 -0
- package/canvas/text-element.d.ts +1 -1
- package/canvas/text-element.js +1 -1
- package/canvas/use-color.d.ts +5 -5
- package/canvas/use-filtered-source.js +1 -1
- package/canvas/use-mediabunny-video.js +1 -1
- package/canvas/use-transformer-snap.d.ts +2 -2
- package/canvas/video-element.d.ts +4 -2
- package/canvas/video-element.js +1 -1
- package/icons/animation-icons.d.ts +1 -0
- package/icons/animation-icons.js +1 -1
- package/icons/registry.d.ts +35 -32
- package/icons/registry.js +1 -1
- package/image-tools/geometry.d.ts +2 -2
- package/image-tools/target.d.ts +6 -6
- package/image-tools/target.js +1 -1
- package/lib/utils.d.ts +1 -1
- package/model/figure-model.d.ts +10 -10
- package/model/gif-model.d.ts +10 -10
- package/model/group-model.d.ts +393 -84
- package/model/group-model.js +1 -1
- package/model/image-model.d.ts +10 -10
- package/model/image-tools.d.ts +1 -1
- package/model/line-model.d.ts +10 -10
- package/model/lottie-model.d.ts +242 -0
- package/model/lottie-model.js +5 -0
- package/model/node-model.d.ts +8 -8
- package/model/page-model.d.ts +1186 -297
- package/model/page-model.js +1 -1
- package/model/shape-model.d.ts +11 -11
- package/model/shape-model.js +1 -1
- package/model/store.d.ts +30 -26
- package/model/store.js +1 -1
- package/model/svg-model.d.ts +9 -9
- package/model/table-model.d.ts +127 -20
- package/model/table-model.js +1 -1
- package/model/text-model.d.ts +9 -9
- package/model/video-model.d.ts +10 -10
- package/package.json +36 -55
- package/pages-timeline/pages-timeline.js +1 -1
- package/pages-timeline/track-styles.d.ts +12 -12
- package/polotno-app.d.ts +1 -1
- package/polotno.bundle.js +183 -179
- package/primitives/button.d.ts +4 -4
- package/primitives/dialog.d.ts +4 -4
- package/primitives/dropdown-menu.d.ts +18 -18
- package/primitives/input-group.d.ts +1 -1
- package/primitives/popover.d.ts +4 -4
- package/primitives/select.d.ts +5 -5
- package/primitives/tooltip.d.ts +3 -3
- package/side-panel/animations-panel.js +1 -1
- package/side-panel/background-panel.js +1 -1
- package/side-panel/draw-panel.js +1 -1
- package/side-panel/effect-card.js +1 -1
- package/side-panel/effects-panel.js +1 -1
- package/side-panel/photos-panel.js +1 -1
- package/side-panel/select-lottie.d.ts +11 -0
- package/side-panel/select-lottie.js +1 -0
- package/side-panel/select-video.d.ts +19 -19
- package/side-panel/size-panel.js +1 -1
- package/side-panel/unsplash-credit.d.ts +4 -1
- package/side-panel/unsplash-credit.js +1 -1
- package/side-panel/upload-panel.js +1 -1
- package/themes/carbon.css +1 -1
- package/toolbar/gif-toolbar.d.ts +3 -0
- package/toolbar/gif-toolbar.js +1 -1
- package/toolbar/group-button.js +1 -1
- package/toolbar/html-toolbar.d.ts +1 -0
- package/toolbar/html-toolbar.js +3 -3
- package/toolbar/image-remove-background-button.js +1 -1
- package/toolbar/index.d.ts +1 -1
- package/toolbar/index.js +1 -1
- package/toolbar/line-toolbar.js +1 -1
- package/toolbar/position-picker.js +1 -1
- package/toolbar/table-toolbar.js +1 -1
- package/toolbar/text-ai-write.js +1 -1
- package/toolbar/text-toolbar.js +1 -1
- package/toolbar/toolbar-shared.d.ts +15 -4
- package/toolbar/toolbar-shared.js +1 -1
- package/toolbar/toolbar.js +1 -1
- package/ui.css +2 -2
- package/utils/animations.d.ts +47 -44
- package/utils/animations.js +1 -1
- package/utils/base64.d.ts +1 -2
- package/utils/base64.js +1 -1
- package/utils/clipboard.d.ts +19 -18
- package/utils/clipboard.js +1 -1
- package/utils/fade-gradient.d.ts +1 -1
- package/utils/file.d.ts +4 -3
- package/utils/file.js +1 -1
- package/utils/font-metric.d.ts +29 -28
- package/utils/fonts.js +1 -1
- package/utils/gif-lib.d.ts +1 -1
- package/utils/html2canvas.js +1 -1
- package/utils/image-dpi.d.ts +1 -1
- package/utils/image-dpi.js +1 -1
- package/utils/insert-file.js +1 -1
- package/utils/l10n.d.ts +1 -0
- package/utils/l10n.js +1 -1
- package/utils/lottie.d.ts +12 -0
- package/utils/lottie.js +1 -0
- package/utils/math.d.ts +4 -4
- package/utils/px.d.ts +3 -0
- package/utils/px.js +1 -1
- package/utils/react-color/components/common/Checkboard.d.ts +12 -12
- package/utils/react-color/components/common/Swatch.d.ts +6 -6
- package/utils/react-color/helpers/interaction.d.ts +6 -6
- package/utils/reactcss/components/active.d.ts +6 -6
- package/utils/reactcss/components/hover.d.ts +6 -6
- package/utils/rich-text-html.js +1 -1
- package/utils/selection-colors.js +1 -1
- package/utils/selection-transform.d.ts +4 -4
- package/utils/selection-transform.js +1 -1
- package/utils/split-element.js +1 -1
- package/utils/text-format-state.d.ts +1 -0
- package/utils/text-format-state.js +1 -1
- package/utils/text-format.d.ts +2 -2
- package/utils/text-sizing.d.ts +1 -1
- package/utils/timeline.d.ts +30 -2
- package/utils/timeline.js +1 -1
- package/utils/to-html.js +1 -1
- package/utils/to-svg.js +1 -1
- package/utils/validate-key.js +1 -1
- package/canvas/downscale-bands.d.ts +0 -10
- package/canvas/downscale-bands.js +0 -1
- package/canvas/downscale-kernel.d.ts +0 -7
- package/canvas/downscale-kernel.js +0 -1
- package/canvas/downscale-kernel.wasm.d.ts +0 -1
- package/canvas/downscale-kernel.wasm.js +0 -1
- package/canvas/downscale-passes.d.ts +0 -7
- package/canvas/downscale-passes.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=this&&this.__rest||function(e,n){var t={};for(var a in e){Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a])}if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++){n.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(t[a[o]]=e[a[o]])}}return t};import{jsx as n,jsxs as t,Fragment as a}from"react/jsx-runtime";import o from"react";import{Button as i,Position as r,Switch as l,Slider as d,Alignment as s,NumericInput as c}from"@blueprintjs/core";import{Popover as h}from"@blueprintjs/core";import{observer as u}from"mobx-react-lite";import{flags as p}from"../../utils/flags.js";import{LeftJoin as g}from"@blueprintjs/icons";import b from"./color-picker.js";import{t as m}from"../../utils/l10n.js";const x=(e,n,t)=>Math.max(n,Math.min(t,e));export const NumberInput=t=>{var{value:a,onValueChange:i}=t,r=e(t,["value","onValueChange"]);const[l,d]=o.useState(a.toString());return o.useEffect(()=>{d(a.toString())},[a]),n(c,Object.assign({value:l,onValueChange:(e,n)=>{d(n),Number.isNaN(e)||i(e)}},r))};const y=({label:e,enabled:o,visible:i=!0,onEnabledChange:r,numberValue:h,onNumberValueChange:u,min:p,max:g})=>i?t(a,{children:[n(l,{checked:o,label:e,onChange:e=>{r(e.target.checked)},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),o&&t("div",{style:{display:"flex",width:"100%",justifyContent:"space-between"},children:[n("div",{style:{paddingTop:"7px"},children:n(d,{value:h,onChange:e=>{u(e)},min:p,max:g,labelStepSize:50,showTrackFill:!1,labelRenderer:!1})}),n(c,{value:h,onValueChange:e=>{u(x(e,p,g))},buttonPosition:"none",style:{width:"45px",padding:"0 5px",marginLeft:"10px"},min:p,max:g})]})]}):null;export const CurvePowerSlider=u(({textEl:e,eachSet:t})=>{const[a,i]=o.useState(null),r=o.useRef(0),l=o.useRef(null),s=null!=a?a:100*e.curvePower,c=p.htmlRenderEnabled&&!p.renderTagTextEnabled?300:0,h=e=>{t({curvePower:e/100}),r.current=Date.now()};return n(d,{value:s,onChange:e=>{const n=x(e,-100,100);if(i(n),l.current&&clearTimeout(l.current),0===c){return void h(n)}const t=Date.now()-r.current;t>=c?h(n):l.current=setTimeout(()=>{h(n)},c-t)},onRelease:e=>{l.current&&clearTimeout(l.current),i(null),h(x(e,-100,100))},min:-100,max:100,labelStepSize:50,labelRenderer:e=>0===e?"0":e.toString()})});export const FiltersPicker=u(({element:e,store:a,elements:u})=>{const p=u||[e],f=p[0],v="text"===f.type,w="image"===f.type,C="svg"===f.type,k=w||C,T=f,R=f,I=e=>{a.history.transaction(()=>{p.forEach(n=>{n.set(e)})})};return n(h,{content:t("div",{style:{padding:"15px",paddingTop:"15px",width:"230px",maxHeight:"calc(100vh - 150px)",overflow:"auto"},children:[n(y,{label:m("toolbar.blur"),enabled:f.blurEnabled,visible:k||v,onEnabledChange:e=>{I({blurEnabled:e})},numberValue:f.blurRadius,onNumberValueChange:e=>{I({blurRadius:e})},min:0,max:100}),n(y,{label:m("toolbar.brightness"),visible:k,enabled:f.brightnessEnabled,onEnabledChange:e=>{I({brightnessEnabled:e})},numberValue:100*f.brightness+100,onNumberValueChange:e=>{I({brightness:(e-100)/100})},min:0,max:200}),k&&n(l,{checked:f.sepiaEnabled,label:m("toolbar.sepia"),onChange:e=>{I({sepiaEnabled:e.target.checked})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),k&&n(l,{checked:f.grayscaleEnabled,label:m("toolbar.grayscale"),onChange:e=>{I({grayscaleEnabled:e.target.checked})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),v&&n(l,{checked:!!T.curveEnabled,label:m("toolbar.curvedText")||"Curved text",onChange:e=>{I({curveEnabled:e.target.checked})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),v&&T.curveEnabled&&t(o.Fragment,{children:[t("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[n("div",{children:m("toolbar.curvePower")||"Curve"}),n("div",{children:n(NumberInput,{value:Math.round(100*T.curvePower),onValueChange:e=>{I({curvePower:x(e,-100,100)/100})},style:{width:"50px"},min:-100,max:100,buttonPosition:"none"})})]}),n(CurvePowerSlider,{textEl:T,eachSet:I})]}),v&&n(l,{checked:!!T.strokeWidth,label:m("toolbar.textStroke"),onChange:e=>{I({strokeWidth:e.target.checked?2:0})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),v&&!!T.strokeWidth&&n(o.Fragment,{children:t("div",{style:{display:"flex",justifyContent:"space-between"},children:[n(b,{value:T.stroke,size:30,onChange:e=>{I({stroke:e})},store:a}),n(c,{defaultValue:T.strokeWidth,onValueChange:e=>{I({strokeWidth:x(e,1,30)})},style:{width:"80px"},min:1,max:Math.round(T.fontSize/2)})]})}),v&&n(l,{checked:!!T.backgroundEnabled,label:m("toolbar.textBackground"),onChange:e=>{I({backgroundEnabled:e.target.checked})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),!!T.backgroundEnabled&&t(o.Fragment,{children:[t("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[n("div",{children:m("toolbar.backgroundCornerRadius")}),n("div",{children:n(NumberInput,{value:100*T.backgroundCornerRadius,onValueChange:e=>{I({backgroundCornerRadius:x(e,0,100)/100})},style:{width:"50px"},min:0,max:100,buttonPosition:"none"})})]}),n(d,{value:100*T.backgroundCornerRadius,onChange:e=>{I({backgroundCornerRadius:x(e,0,100)/100})},min:0,max:100,labelRenderer:!1}),t("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[n("div",{children:m("toolbar.backgroundPadding")}),n("div",{children:n(NumberInput,{value:Math.round(100*T.backgroundPadding),onValueChange:e=>{I({backgroundPadding:x(e,0,100)/100})},style:{width:"50px"},min:0,max:100,buttonPosition:"none"})})]}),n(d,{value:Math.round(100*T.backgroundPadding),onChange:e=>{I({backgroundPadding:x(e,0,100)/100})},min:0,max:100,labelRenderer:!1}),t("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[n("div",{children:m("toolbar.opacity")}),n("div",{children:n(NumberInput,{value:Math.round(100*T.backgroundOpacity),onValueChange:e=>{I({backgroundOpacity:e/100})},style:{width:"50px"},min:0,max:100,buttonPosition:"none"})})]}),n(d,{value:100*T.backgroundOpacity,onChange:e=>{I({backgroundOpacity:e/100})},min:0,max:100,labelRenderer:!1}),t("div",{style:{display:"flex",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[n("div",{style:{lineHeight:"30px"},children:m("toolbar.color")}),n(b,{value:T.backgroundColor,size:30,onChange:e=>{I({backgroundColor:e})},store:a})]})]}),k&&n(l,{checked:!!R.borderSize,label:m("toolbar.border"),onChange:e=>{I({borderSize:e.target.checked?2:0})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),!!R.borderSize&&n(o.Fragment,{children:t("div",{style:{display:"flex",justifyContent:"space-between"},children:[n(b,{value:R.borderColor,size:30,onChange:e=>{I({borderColor:e})},store:a}),n(c,{defaultValue:R.borderSize,onValueChange:e=>{I({borderSize:x(e,1,Math.min(f.width,f.height)/2)})},style:{width:"80px"},min:1,max:Math.max(1,Math.min(f.width,f.height)/2)})]})}),k&&n(l,{checked:!!R.cornerRadius,label:m("toolbar.cornerRadius"),onChange:e=>{I({cornerRadius:e.target.checked?Math.min(f.width/4,f.height/4):0})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),k&&!!R.cornerRadius&&t("div",{style:{display:"flex",width:"100%",justifyContent:"space-between"},children:[n("div",{style:{width:"150px",paddingTop:"7px"},children:n(d,{value:Math.min(R.cornerRadius,Math.round(Math.min(f.width/2,f.height/2))),onChange:e=>{I({cornerRadius:e})},min:1,max:Math.round(Math.min(f.width/2,f.height/2)),labelStepSize:50,showTrackFill:!1,labelRenderer:!1})}),n(c,{value:R.cornerRadius,onValueChange:e=>{I({cornerRadius:x(e,1,Math.min(f.width,f.height)/2)})},buttonPosition:"none",style:{width:"45px",padding:"0 5px"},min:1,max:Math.round(Math.min(f.width/2,f.height/2))})]}),n(l,{checked:f.shadowEnabled,label:m("toolbar.shadow"),onChange:e=>{I({shadowEnabled:e.target.checked})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),f.shadowEnabled&&t(o.Fragment,{children:[t("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[n("div",{children:m("toolbar.blur")}),n("div",{children:n(NumberInput,{value:f.shadowBlur,onValueChange:e=>{I({shadowBlur:x(e,-50,50)})},style:{width:"50px"},min:0,max:50,buttonPosition:"none"})})]}),n(d,{value:f.shadowBlur,onChange:e=>{I({shadowBlur:e})},min:0,max:50,showTrackFill:!1,labelRenderer:!1}),t("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[n("div",{children:m("toolbar.offsetX")}),n("div",{children:n(NumberInput,{value:f.shadowOffsetX,onValueChange:e=>{I({shadowOffsetX:x(e,-50,50)})},style:{width:"50px"},min:-50,max:50,buttonPosition:"none"})})]}),n(d,{value:f.shadowOffsetX,onChange:e=>{I({shadowOffsetX:e})},min:-50,max:50,showTrackFill:!1,labelRenderer:!1}),t("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[n("div",{children:m("toolbar.offsetY")}),n("div",{children:n(NumberInput,{value:f.shadowOffsetY,onValueChange:e=>{I({shadowOffsetY:x(e,-50,50)})},style:{width:"50px"},min:-50,max:50,buttonPosition:"none"})})]}),n(d,{value:f.shadowOffsetY,onChange:e=>{I({shadowOffsetY:e})},min:-50,max:50,showTrackFill:!1,labelRenderer:!1}),t("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[n("div",{children:m("toolbar.opacity")}),n("div",{children:n(NumberInput,{value:Math.round(100*f.shadowOpacity),onValueChange:e=>{I({shadowOpacity:e/100})},style:{width:"50px"},min:0,max:100,buttonPosition:"none"})})]}),n(d,{value:100*f.shadowOpacity,onChange:e=>{I({shadowOpacity:e/100})},min:0,max:100,labelRenderer:!1}),t("div",{style:{display:"flex",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[n("div",{style:{lineHeight:"30px"},children:m("toolbar.color")}),n(b,{value:f.shadowColor,size:30,onChange:e=>{I({shadowColor:e})},store:a})]})]})]}),position:r.BOTTOM,children:n(i,{icon:n(g,{}),text:m("toolbar.effects"),minimal:!0})})});export const EffectsPicker=u(({element:e,store:t})=>e.contentEditable?n(i,{minimal:!0,icon:n(g,{}),text:m("toolbar.effects"),onClickCapture:e=>{e.stopPropagation(),t.openSidePanel("effects")}}):null);export default EffectsPicker;
|
|
1
|
+
var e=this&&this.__rest||function(e,n){var t={};for(var a in e){Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a])}if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++){n.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(t[a[o]]=e[a[o]])}}return t};import{Fragment as n,jsx as t,jsxs as a}from"react/jsx-runtime";import o from"react";import{Button as i,Position as r,Switch as l,Slider as d,Alignment as s,NumericInput as c}from"@blueprintjs/core";import{Popover as h}from"@blueprintjs/core";import{observer as u}from"mobx-react-lite";import{flags as p}from"../../utils/flags.js";import{LeftJoin as g}from"@blueprintjs/icons";import b from"./color-picker.js";import{t as m}from"../../utils/l10n.js";const x=(e,n,t)=>Math.max(n,Math.min(t,e));export const NumberInput=n=>{var{value:a,onValueChange:i}=n,r=e(n,["value","onValueChange"]);const[l,d]=o.useState(a.toString());return o.useEffect(()=>{d(a.toString())},[a]),t(c,Object.assign({value:l,onValueChange:(e,n)=>{d(n),Number.isNaN(e)||i(e)}},r))};const y=({label:e,enabled:o,visible:i=!0,onEnabledChange:r,numberValue:h,onNumberValueChange:u,min:p,max:g})=>i?a(n,{children:[t(l,{checked:o,label:e,onChange:e=>{r(e.target.checked)},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),o&&a("div",{style:{display:"flex",width:"100%",justifyContent:"space-between"},children:[t("div",{style:{paddingTop:"7px"},children:t(d,{value:h,onChange:e=>{u(e)},min:p,max:g,labelStepSize:50,showTrackFill:!1,labelRenderer:!1})}),t(c,{value:h,onValueChange:e=>{u(x(e,p,g))},buttonPosition:"none",style:{width:"45px",padding:"0 5px",marginLeft:"10px"},min:p,max:g})]})]}):null;export const CurvePowerSlider=u(({textEl:e,eachSet:n})=>{const[a,i]=o.useState(null),r=o.useRef(0),l=o.useRef(null),s=null!=a?a:100*e.curvePower,c=p.htmlRenderEnabled&&!p.renderTagTextEnabled?300:0,h=e=>{n({curvePower:e/100}),r.current=Date.now()};return t(d,{value:s,onChange:e=>{const n=x(e,-100,100);if(i(n),l.current&&clearTimeout(l.current),0===c){return void h(n)}const t=Date.now()-r.current;t>=c?h(n):l.current=setTimeout(()=>{h(n)},c-t)},onRelease:e=>{l.current&&clearTimeout(l.current),i(null),h(x(e,-100,100))},min:-100,max:100,labelStepSize:50,labelRenderer:e=>0===e?"0":e.toString()})});export const FiltersPicker=u(({element:e,store:n,elements:u})=>{const p=u||[e],f=p[0],v="text"===f.type,w="image"===f.type,C="svg"===f.type,k=w||C,T=f,R=f,I=e=>{n.history.transaction(()=>{p.forEach(n=>{n.set(e)})})};return t(h,{content:a("div",{style:{padding:"15px",paddingTop:"15px",width:"230px",maxHeight:"calc(100vh - 150px)",overflow:"auto"},children:[t(y,{label:m("toolbar.blur"),enabled:f.blurEnabled,visible:k||v,onEnabledChange:e=>{I({blurEnabled:e})},numberValue:f.blurRadius,onNumberValueChange:e=>{I({blurRadius:e})},min:0,max:100}),t(y,{label:m("toolbar.brightness"),visible:k,enabled:f.brightnessEnabled,onEnabledChange:e=>{I({brightnessEnabled:e})},numberValue:100*f.brightness+100,onNumberValueChange:e=>{I({brightness:(e-100)/100})},min:0,max:200}),k&&t(l,{checked:f.sepiaEnabled,label:m("toolbar.sepia"),onChange:e=>{I({sepiaEnabled:e.target.checked})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),k&&t(l,{checked:f.grayscaleEnabled,label:m("toolbar.grayscale"),onChange:e=>{I({grayscaleEnabled:e.target.checked})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),v&&t(l,{checked:!!T.curveEnabled,label:m("toolbar.curvedText")||"Curved text",onChange:e=>{I({curveEnabled:e.target.checked})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),v&&T.curveEnabled&&a(o.Fragment,{children:[a("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[t("div",{children:m("toolbar.curvePower")||"Curve"}),t("div",{children:t(NumberInput,{value:Math.round(100*T.curvePower),onValueChange:e=>{I({curvePower:x(e,-100,100)/100})},style:{width:"50px"},min:-100,max:100,buttonPosition:"none"})})]}),t(CurvePowerSlider,{textEl:T,eachSet:I})]}),v&&t(l,{checked:!!T.strokeWidth,label:m("toolbar.textStroke"),onChange:e=>{I({strokeWidth:e.target.checked?2:0})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),v&&!!T.strokeWidth&&t(o.Fragment,{children:a("div",{style:{display:"flex",justifyContent:"space-between"},children:[t(b,{value:T.stroke,size:30,onChange:e=>{I({stroke:e})},store:n}),t(c,{defaultValue:T.strokeWidth,onValueChange:e=>{I({strokeWidth:x(e,1,30)})},style:{width:"80px"},min:1,max:Math.round(T.fontSize/2)})]})}),v&&t(l,{checked:!!T.backgroundEnabled,label:m("toolbar.textBackground"),onChange:e=>{I({backgroundEnabled:e.target.checked})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),!!T.backgroundEnabled&&a(o.Fragment,{children:[a("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[t("div",{children:m("toolbar.backgroundCornerRadius")}),t("div",{children:t(NumberInput,{value:100*T.backgroundCornerRadius,onValueChange:e=>{I({backgroundCornerRadius:x(e,0,100)/100})},style:{width:"50px"},min:0,max:100,buttonPosition:"none"})})]}),t(d,{value:100*T.backgroundCornerRadius,onChange:e=>{I({backgroundCornerRadius:x(e,0,100)/100})},min:0,max:100,labelRenderer:!1}),a("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[t("div",{children:m("toolbar.backgroundPadding")}),t("div",{children:t(NumberInput,{value:Math.round(100*T.backgroundPadding),onValueChange:e=>{I({backgroundPadding:x(e,0,100)/100})},style:{width:"50px"},min:0,max:100,buttonPosition:"none"})})]}),t(d,{value:Math.round(100*T.backgroundPadding),onChange:e=>{I({backgroundPadding:x(e,0,100)/100})},min:0,max:100,labelRenderer:!1}),a("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[t("div",{children:m("toolbar.opacity")}),t("div",{children:t(NumberInput,{value:Math.round(100*T.backgroundOpacity),onValueChange:e=>{I({backgroundOpacity:e/100})},style:{width:"50px"},min:0,max:100,buttonPosition:"none"})})]}),t(d,{value:100*T.backgroundOpacity,onChange:e=>{I({backgroundOpacity:e/100})},min:0,max:100,labelRenderer:!1}),a("div",{style:{display:"flex",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[t("div",{style:{lineHeight:"30px"},children:m("toolbar.color")}),t(b,{value:T.backgroundColor,size:30,onChange:e=>{I({backgroundColor:e})},store:n})]})]}),k&&t(l,{checked:!!R.borderSize,label:m("toolbar.border"),onChange:e=>{I({borderSize:e.target.checked?2:0})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),!!R.borderSize&&t(o.Fragment,{children:a("div",{style:{display:"flex",justifyContent:"space-between"},children:[t(b,{value:R.borderColor,size:30,onChange:e=>{I({borderColor:e})},store:n}),t(c,{defaultValue:R.borderSize,onValueChange:e=>{I({borderSize:x(e,1,Math.min(f.width,f.height)/2)})},style:{width:"80px"},min:1,max:Math.max(1,Math.min(f.width,f.height)/2)})]})}),k&&t(l,{checked:!!R.cornerRadius,label:m("toolbar.cornerRadius"),onChange:e=>{I({cornerRadius:e.target.checked?Math.min(f.width/4,f.height/4):0})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),k&&!!R.cornerRadius&&a("div",{style:{display:"flex",width:"100%",justifyContent:"space-between"},children:[t("div",{style:{width:"150px",paddingTop:"7px"},children:t(d,{value:Math.min(R.cornerRadius,Math.round(Math.min(f.width/2,f.height/2))),onChange:e=>{I({cornerRadius:e})},min:1,max:Math.round(Math.min(f.width/2,f.height/2)),labelStepSize:50,showTrackFill:!1,labelRenderer:!1})}),t(c,{value:R.cornerRadius,onValueChange:e=>{I({cornerRadius:x(e,1,Math.min(f.width,f.height)/2)})},buttonPosition:"none",style:{width:"45px",padding:"0 5px"},min:1,max:Math.round(Math.min(f.width/2,f.height/2))})]}),t(l,{checked:f.shadowEnabled,label:m("toolbar.shadow"),onChange:e=>{I({shadowEnabled:e.target.checked})},alignIndicator:s.RIGHT,style:{marginTop:"20px"}}),f.shadowEnabled&&a(o.Fragment,{children:[a("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[t("div",{children:m("toolbar.blur")}),t("div",{children:t(NumberInput,{value:f.shadowBlur,onValueChange:e=>{I({shadowBlur:x(e,-50,50)})},style:{width:"50px"},min:0,max:50,buttonPosition:"none"})})]}),t(d,{value:f.shadowBlur,onChange:e=>{I({shadowBlur:e})},min:0,max:50,showTrackFill:!1,labelRenderer:!1}),a("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[t("div",{children:m("toolbar.offsetX")}),t("div",{children:t(NumberInput,{value:f.shadowOffsetX,onValueChange:e=>{I({shadowOffsetX:x(e,-50,50)})},style:{width:"50px"},min:-50,max:50,buttonPosition:"none"})})]}),t(d,{value:f.shadowOffsetX,onChange:e=>{I({shadowOffsetX:e})},min:-50,max:50,showTrackFill:!1,labelRenderer:!1}),a("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[t("div",{children:m("toolbar.offsetY")}),t("div",{children:t(NumberInput,{value:f.shadowOffsetY,onValueChange:e=>{I({shadowOffsetY:x(e,-50,50)})},style:{width:"50px"},min:-50,max:50,buttonPosition:"none"})})]}),t(d,{value:f.shadowOffsetY,onChange:e=>{I({shadowOffsetY:e})},min:-50,max:50,showTrackFill:!1,labelRenderer:!1}),a("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[t("div",{children:m("toolbar.opacity")}),t("div",{children:t(NumberInput,{value:Math.round(100*f.shadowOpacity),onValueChange:e=>{I({shadowOpacity:e/100})},style:{width:"50px"},min:0,max:100,buttonPosition:"none"})})]}),t(d,{value:100*f.shadowOpacity,onChange:e=>{I({shadowOpacity:e/100})},min:0,max:100,labelRenderer:!1}),a("div",{style:{display:"flex",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[t("div",{style:{lineHeight:"30px"},children:m("toolbar.color")}),t(b,{value:f.shadowColor,size:30,onChange:e=>{I({shadowColor:e})},store:n})]})]})]}),position:r.BOTTOM,children:t(i,{icon:t(g,{}),text:m("toolbar.effects"),minimal:!0})})});export const EffectsPicker=u(({element:e,store:n})=>e.contentEditable?t(i,{minimal:!0,icon:t(g,{}),text:m("toolbar.effects"),onClickCapture:e=>{e.stopPropagation(),n.openSidePanel("effects")}}):null);export default EffectsPicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Fragment as e,jsx as t,jsxs as l}from"react/jsx-runtime";import{observer as r}from"mobx-react-lite";import{Button as n}from"@blueprintjs/core";import{t as o}from"../../utils/l10n.js";export const GroupButton=r(({store:r})=>{const s=r.selectedElements.length>1,m=1===r.selectedElements.length&&"group"===r.selectedElements[0].type;return l(e,{children:[s&&t(n,{minimal:!0,onClick:()=>{r.groupElements(r.selectedElements.map(e=>e.id))},style:{marginLeft:"auto"},children:o("toolbar.groupElements")}),m&&t(n,{minimal:!0,onClick:()=>{r.ungroupElements([r.selectedElements[0].id])},style:{marginLeft:"auto"},children:o("toolbar.ungroupElements")})]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Fragment as e,jsx as r,jsxs as o}from"react/jsx-runtime";import t from"react";import{observer as n}from"mobx-react-lite";import{Button as l,Dialog as c,Classes as a}from"@blueprintjs/core";import{removeBackground as i}from"../../utils/api.js";import{t as s}from"../../utils/l10n.js";let m=async(e,r)=>{const o=await fetch(i(),{method:"POST",body:JSON.stringify({url:e}),signal:r});return 200!==o.status?(alert(s("error.removeBackground")),e):(await o.json()).url};export function setRemoveBackgroundFunc(e){m=e}export const RemoveBackgroundDialog=n(({isOpen:n,onClose:i,element:u})=>{const[d,g]=t.useState(u.src),v=t.useRef(null);t.useEffect(()=>(g(u.src),()=>{var e;null===(e=v.current)||void 0===e||e.abort(),v.current=null}),[u.src]);const[h,p]=t.useState(!1),b=()=>{var e;null===(e=v.current)||void 0===e||e.abort()},k=d!==u.src;return o(c,{onClose:()=>{b(),i()},title:s("toolbar.removeBackgroundTitle"),isOpen:n,style:{width:"80%",maxWidth:"700px"},children:[r("div",{className:a.DIALOG_BODY,children:r("img",{src:d,style:{width:"100%",maxHeight:"400px",objectFit:"contain"}})}),r("div",{className:a.DIALOG_FOOTER,style:{position:"relative"},children:o("div",{className:a.DIALOG_FOOTER_ACTIONS,children:[!k&&o(e,{children:[h&&r(l,{onClick:b,children:s("toolbar.cancelRemoveBackground")}),r(l,{onClick:async()=>{const e=new AbortController;v.current=e,p(!0);try{const r=await m(u.src,e.signal);e.signal.aborted||g(r)}catch(r){"AbortError"!==(null==r?void 0:r.name)&&console.error(r)}finally{v.current===e&&(v.current=null),p(!1)}},loading:h,disabled:h,children:s("toolbar.removeBackground")})]}),k&&o(e,{children:[r(l,{onClick:()=>{g(u.src),i()},loading:h,children:s("toolbar.cancelRemoveBackground")}),r(l,{onClick:()=>{u.set({src:d}),i()},loading:h,intent:"primary",children:s("toolbar.confirmRemoveBackground")})]})]})})]})});export const ImageRemoveBackground=({element:n})=>{const[c,a]=t.useState(!1);return o(e,{children:[r(l,{text:s("toolbar.removeBackground"),minimal:!0,onClick:e=>{a(!0)}}),r(RemoveBackgroundDialog,{isOpen:c,onClose:()=>{a(!1)},element:n})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Fragment as e,jsx as o,jsxs as t}from"react/jsx-runtime";import r from"react";import{observer as i}from"mobx-react-lite";import{Button as n,Navbar as m,Tooltip as a}from"@blueprintjs/core";import{ElementContainer as l,extendToolbar as c}from"./element-container.js";import{Crop as p,Tick as s,Cross as g}from"@blueprintjs/icons";import d from"./filters-picker.js";import{AnimationsPicker as u}from"./animations-picker.js";import b from"./flip-button.js";import{flags as C}from"../../utils/flags.js";import{ImageRemoveBackground as h}from"./image-remove-background-button.js";export{ImageRemoveBackground}from"./image-remove-background-button.js";import{getCrop as I,getImageSize as f}from"../../utils/image.js";import{t as k}from"../../utils/l10n.js";export const ImageFitToBackground=({element:e})=>o(n,{text:k("toolbar.fitToBackground"),minimal:!0,onClick:async()=>{const{page:o}=e,t=o.computedWidth+2*o.bleed,r=o.computedHeight+2*o.bleed,i=await f(e.src),n=e.stretchEnabled?{cropX:0,cropY:0,cropWidth:1,cropHeight:1}:I({width:t,height:r},i);e.set(Object.assign({x:-o.bleed,y:-o.bleed,width:t,height:r,rotation:0},n))}});export const ImageClip=i(({element:e,store:t,elements:r})=>e.contentEditable?e.clipSrc?o(n,{text:k("toolbar.removeClip"),minimal:!0,onClickCapture:e=>{r.forEach(e=>{e.set({clipSrc:""})})}}):o(n,{minimal:!0,text:k("toolbar.clip"),onClickCapture:e=>{e.stopPropagation(),t.openSidePanel("image-clip")}}):null);export const ImageCrop=i(({element:e,store:t})=>e.contentEditable?e.stretchEnabled?null:o(a,{content:k("toolbar.crop"),position:"bottom",children:o(n,{minimal:!0,icon:o(p,{}),onClickCapture:o=>{o.stopPropagation(),e.toggleCropMode(!0)},"aria-label":k("toolbar.crop")})}):null);export const ImageRemoveClip=i(({element:e,store:t})=>e.clipSrc?o(n,{text:k("toolbar.removeClip"),minimal:!0,onClickCapture:o=>{e.set({clipSrc:""})}}):null);const x={ImageFlip:b,ImageFilters:d,ImageFitToBackground,ImageCrop,ImageClip,ImageRemoveBackground:h,ImageAnimations:u};export const ImageToolbar=i(({store:i,components:a})=>{const p=i.selectedElements[0],d=p._cropModeEnabled,u=r.useRef({});r.useEffect(()=>{d&&(u.current={x:p.x,y:p.y,width:p.width,height:p.height,cropX:p.cropX,cropY:p.cropY,cropWidth:p.cropWidth,cropHeight:p.cropHeight})},[d]);const b=["ImageFlip","ImageFilters","ImageFitToBackground","ImageClip","ImageCrop",C.animationsEnabled&&"ImageAnimations",C.removeBackgroundEnabled&&"ImageRemoveBackground"],h=c({type:"image",usedItems:b,components:a});return t(e,{children:[!d&&o(l,{items:h,itemRender:e=>{const t=a[e]||x[e];return o(t,{element:p,store:i,elements:i.selectedElements},e)}}),d&&t(m.Group,{children:[o(n,{text:k("toolbar.cropDone"),minimal:!0,icon:o(s,{}),onClickCapture:e=>{p.toggleCropMode(!1)}}),o(n,{text:k("toolbar.cropCancel"),minimal:!0,icon:o(g,{}),onClickCapture:e=>{p.set(Object.assign({},u.current)),p.toggleCropMode(!1)}})]})]})});export default ImageToolbar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Fragment as e,jsx as t,jsxs as r}from"react/jsx-runtime";import{observer as n}from"mobx-react-lite";import{Button as o,Position as i,Slider as s,Tooltip as a}from"@blueprintjs/core";import{Popover as l}from"@blueprintjs/core";import{Settings as d}from"@blueprintjs/icons";import c from"./color-picker.js";import{AnimationsPicker as h}from"./animations-picker.js";import{NumberInput as p}from"./filters-picker.js";import{ElementContainer as m,extendToolbar as g}from"./element-container.js";import{getMiddlePoints as u,getLinePositionFromMiddlePoints as w}from"../../canvas/line-element.js";import{t as k}from"../../utils/l10n.js";import{flags as x}from"../../utils/flags.js";export const LineSettings=n(({store:e,elements:n})=>{const c=t=>{e.history.transaction(()=>{n.forEach(e=>{e.set(t)})})},h=t=>{e.history.transaction(()=>{n.forEach(e=>{const{middleLeft:r,middleRight:n}=u(e),{x:o,y:i,rotation:s}=w(r,n,t);e.set({x:o,y:i,rotation:s,height:t})})})};return t(l,{position:i.BOTTOM,content:r("div",{style:{padding:"15px",paddingTop:"15px",width:"230px"},children:[r("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:"5px"},children:[t("div",{children:k("toolbar.lineSize")}),t("div",{children:t(p,{value:n[0].height,onValueChange:e=>{h(e)},style:{width:"50px"},min:1,max:100,buttonPosition:"none"})})]}),t(s,{value:n[0].height,onChange:e=>{h(e)},min:1,max:100,labelRenderer:!1}),r("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:"5px",paddingTop:"15px"},children:[t(o,{onClick:()=>{c({dash:[]})},active:0===n[0].dash.length,children:t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:t("line",{x2:"24",y1:"50%",y2:"50%",stroke:"currentColor",strokeWidth:"2"})})}),t(o,{onClick:()=>{c({dash:[4,1]})},active:4===n[0].dash[0],children:t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:t("line",{x1:"-1",x2:"25",y1:"50%",y2:"50%",stroke:"currentColor",strokeDasharray:"12 2",strokeWidth:"2"})})}),t(o,{onClick:()=>{c({dash:[2,1]})},active:2===n[0].dash[0],children:t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:t("line",{x1:"1",x2:"23",y1:"50%",y2:"50%",stroke:"currentColor",strokeDasharray:"6 2",strokeWidth:"2"})})}),t(o,{onClick:()=>{c({dash:[1,1]})},active:1===n[0].dash[0],children:t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:t("line",{x1:"1",x2:"23",y1:"50%",y2:"50%",stroke:"currentColor",strokeDasharray:"2 2",strokeWidth:"2"})})})]})]}),children:t(a,{content:k("toolbar.lineStyle"),position:i.BOTTOM,children:t(o,{icon:t(d,{}),minimal:!0,"aria-label":k("toolbar.lineStyle")})})})});export const LineColor=n(({elements:e,store:r})=>t(c,{value:e[0].color,style:{marginRight:"5px"},gradientEnabled:!1,onChange:t=>r.history.transaction(()=>{e.forEach(e=>{e.set({color:t})})}),store:r}));const L={"":t("span",{"aria-hidden":"true",className:"bp6-icon",children:t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:t("path",{stroke:"currentColor",strokeWidth:"2",d:"M 1 8 L 16 8"})})}),arrow:t("span",{"aria-hidden":"true",className:"bp6-icon",children:r("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[t("path",{stroke:"currentColor",strokeWidth:"2",d:"M 8 3 L 1 8 L 8 13",fill:"none",strokeLinejoin:"round",strokeLinecap:"round"}),t("path",{stroke:"currentColor",strokeWidth:"2",d:"M 1 8 L 15 8",strokeLinejoin:"round",strokeLinecap:"round"})]})}),triangle:t("span",{"aria-hidden":"true",className:"bp6-icon",children:r("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[t("path",{stroke:"currentColor",strokeWidth:"2",d:"M 8 3 L 1 8 L 8 13 Z",fill:"currentColor",strokeLinejoin:"round",strokeLinecap:"round"}),t("path",{stroke:"currentColor",strokeWidth:"2",d:"M 1 8 L 15 8",strokeLinejoin:"round",strokeLinecap:"round"})]})}),bar:t("span",{"aria-hidden":"true",className:"bp6-icon",children:r("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[t("path",{stroke:"currentColor",strokeWidth:"2",d:"M 1 3 L 1 13",strokeLinejoin:"round",strokeLinecap:"round"}),t("path",{stroke:"currentColor",strokeWidth:"2",d:"M 1 8 L 15 8",strokeLinejoin:"round",strokeLinecap:"round"})]})}),square:t("span",{"aria-hidden":"true",className:"bp6-icon",children:r("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[t("path",{stroke:"currentColor",strokeWidth:"2",d:"M 1 4 L 9 4 L 9 12 L 1 12 Z",fill:"currentColor",strokeLinejoin:"round",strokeLinecap:"round"}),t("path",{stroke:"currentColor",strokeWidth:"2",d:"M 1 8 L 15 8",strokeLinejoin:"round",strokeLinecap:"round"})]})}),circle:t("span",{"aria-hidden":"true",className:"bp6-icon",children:r("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",children:[t("circle",{cx:"4",cy:"8",r:"4",fill:"currentColor"}),t("path",{stroke:"currentColor",strokeWidth:"2",d:"M 1 8 L 15 8",strokeLinejoin:"round",strokeLinecap:"round"})]})})},y=({type:e,active:r,onClick:n,flipped:i})=>{const s=L[e];return t(o,{icon:i?t("span",{style:{transform:"scaleX(-1)"},children:s}):s,minimal:!0,onClick:n,active:r})};export const BasicHead=n(({elements:e,store:n,property:s})=>{const d="endHead"===s,c=L[e[0][s]],h=d?t("span",{style:{transform:"scaleX(-1)"},children:c}):c,p=t=>{n.history.transaction(()=>{e.forEach(e=>{e.set({[s]:t})})})},m=k("startHead"===s?"toolbar.lineStartHead":"toolbar.lineEndHead");return t(l,{position:i.BOTTOM,content:r("div",{style:{width:"150px",padding:"10px"},children:[t("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:["","arrow","triangle"].map(r=>t(y,{type:r,active:e[0][s]===r,onClick:()=>{p(r)},flipped:d},r))}),t("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:["bar","square","circle"].map(r=>t(y,{type:r,active:e[0][s]===r,onClick:()=>{p(r)},flipped:d},r))})]}),children:t(a,{content:m,position:i.BOTTOM,children:t(o,{icon:h,minimal:!0,"aria-label":m})})})});export const LineHeads=n(({elements:n,store:o})=>r(e,{children:[t(BasicHead,{elements:n,store:o,property:"startHead"}),t(BasicHead,{elements:n,store:o,property:"endHead"})]}));const v={LineSettings,LineColor,LineHeads,LineAnimations:h};export const LineToolbar=n(({store:e,components:r})=>{const n=e.selectedElements[0],o=["LineColor","LineSettings","LineHeads",x.animationsEnabled&&"LineAnimations"].filter(e=>Boolean(e)),i=g({type:"line",usedItems:o,components:r});return t(m,{items:i,itemRender:o=>{const i=r[o]||v[o];return t(i,{element:n,store:e,elements:e.selectedElements},o)}})});export default LineToolbar;
|
|
@@ -6,8 +6,8 @@ type Props = {
|
|
|
6
6
|
};
|
|
7
7
|
export declare const NumberInput: ({ value, onValueChange, ...props }: {
|
|
8
8
|
[x: string]: any;
|
|
9
|
-
value: any;
|
|
10
9
|
onValueChange: any;
|
|
10
|
+
value: any;
|
|
11
11
|
}) => React.JSX.Element;
|
|
12
12
|
export declare const PageToolbar: (({ store, components }: Props) => React.JSX.Element) & React.NamedExoticComponent<Props> & {
|
|
13
13
|
readonly type: ({ store, components }: Props) => React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Fragment as e,jsx as t,jsxs as o}from"react/jsx-runtime";import{observer as i}from"mobx-react-lite";import{Button as l,Menu as s,MenuDivider as n,MenuItem as r,Popover as d,Position as c}from"@blueprintjs/core";import{AlignmentBottom as a,AlignmentHorizontalCenter as m,AlignmentLeft as h,AlignmentRight as v,AlignmentTop as p,AlignmentVerticalCenter as u,ChevronDown as x,ChevronUp as E,DoubleChevronDown as y,DoubleChevronUp as b,HorizontalDistribution as g,Layers as f,VerticalDistribution as w}from"@blueprintjs/icons";import{getClientRect as D}from"../../utils/math.js";import{t as P}from"../../utils/l10n.js";import{alignBottom as M,alignCenter as k,alignLeft as C,alignMiddle as j,alignRight as B,alignTop as T}from"../../utils/alignment.js";const F=e=>{if("group"!==e.type){return D(e)}let t=1/0,o=1/0,i=-1/0,l=-1/0;return e.children.forEach(e=>{const s=F(e);t=Math.min(t,s.x),o=Math.min(o,s.y),i=Math.max(i,s.x+s.width),l=Math.max(l,s.y+s.height)}),{x:t,y:o,width:i-t,height:l-o}},O=(e,t,o)=>{if("group"!==e.type){const i=D(e),l=t-i.x,s=o-i.y;e.set({x:e.x+l,y:e.y+s})}else{const i=t-F(e).x,l=o-F(e).y;e.children.forEach(e=>{const t=F(e);O(e,t.x+i,t.y+l)})}};export const PositionPicker=i(({store:i})=>{const D=i.selectedElements.length>0,U=i.selectedElements.every(e=>e.draggable),z=U&&i.selectedElements.length>1;return t(d,{disabled:!D,content:o(s,{style:{width:"280px"},children:[t(n,{title:P("toolbar.layering")}),o("div",{style:{display:"flex"},children:[o("div",{style:{width:"50%"},children:[t(r,{shouldDismissPopover:!1,icon:t(E,{}),text:P("toolbar.up"),disabled:!i.selectedElements.some(e=>{var t;return null===(t=e.parent)||void 0===t?void 0:t.canMoveElementsUp([e.id])}),onClick:()=>i.selectedElements.forEach(e=>e.moveUp())}),t(r,{shouldDismissPopover:!1,icon:t(b,{}),text:P("toolbar.toForward"),disabled:!i.selectedElements.some(e=>{var t;return null===(t=e.parent)||void 0===t?void 0:t.canMoveElementsTop([e.id])}),onClick:()=>i.selectedElements.forEach(e=>e.moveTop())})]}),o("div",{style:{width:"50%"},children:[t(r,{shouldDismissPopover:!1,icon:t(x,{}),text:P("toolbar.down"),disabled:!i.selectedElements.some(e=>{var t;return null===(t=e.parent)||void 0===t?void 0:t.canMoveElementsDown([e.id])}),onClick:()=>i.selectedElements.forEach(e=>e.moveDown())}),t(r,{shouldDismissPopover:!1,icon:t(y,{}),text:P("toolbar.toBottom"),disabled:!i.selectedElements.some(e=>{var t;return null===(t=e.parent)||void 0===t?void 0:t.canMoveElementsBottom([e.id])}),onClick:()=>i.selectedElements.forEach(e=>e.moveBottom())})]})]}),U&&o(e,{children:[t(n,{title:P("toolbar.position")}),o("div",{style:{display:"flex"},children:[o("div",{style:{width:"50%"},children:[t(r,{shouldDismissPopover:!1,icon:t(h,{}),text:P("toolbar.alignLeft"),onClick:()=>{C(i)}}),t(r,{shouldDismissPopover:!1,icon:t(u,{}),text:P("toolbar.alignCenter"),onClick:()=>{k(i)}}),t(r,{shouldDismissPopover:!1,icon:t(v,{}),text:P("toolbar.alignRight"),onClick:()=>{B(i)}})]}),o("div",{style:{width:"50%"},children:[t(r,{shouldDismissPopover:!1,icon:t(p,{}),text:P("toolbar.alignTop"),onClick:()=>{T(i)}}),t(r,{shouldDismissPopover:!1,icon:t(m,{}),text:P("toolbar.alignMiddle"),onClick:()=>{j(i)}}),t(r,{shouldDismissPopover:!1,icon:t(a,{}),text:P("toolbar.alignBottom"),onClick:()=>{M(i)}})]})]})]}),z&&o(e,{children:[t(n,{title:P("toolbar.spaceEvenly")}),o("div",{style:{display:"flex"},children:[t("div",{style:{width:"50%"},children:t(r,{shouldDismissPopover:!1,icon:t(w,{}),text:P("toolbar.verticalDistribution"),onClick:()=>{var e;let t=null===(e=i.activePage)||void 0===e?void 0:e.computedHeight,o=0,l=0;i.selectedElements.forEach(e=>{const i=F(e);t=Math.min(t,i.y),o=Math.max(o,i.y+i.height),l+=i.height});const s=(o-t-l)/(i.selectedElements.length-1),n=i.selectedElements.slice().sort((e,t)=>{const o=F(e),i=F(t);return o.y-i.y});let r=0;n.forEach(e=>{const o=F(e);O(e,o.x,t+r),r+=o.height+s})}})}),t("div",{style:{width:"50%"},children:t(r,{shouldDismissPopover:!1,icon:t(g,{}),text:P("toolbar.horizontalDistribution"),onClick:()=>{var e;let t=null===(e=i.activePage)||void 0===e?void 0:e.computedWidth,o=0,l=0;i.selectedElements.forEach(e=>{const i=F(e);t=Math.min(t,i.x),o=Math.max(o,i.x+i.width),l+=i.width});const s=(o-t-l)/(i.selectedElements.length-1),n=i.selectedElements.slice().sort((e,t)=>{const o=F(e),i=F(t);return o.x-i.x});let r=0;n.forEach(e=>{const o=F(e);O(e,t+r,o.y),r+=o.width+s})}})})]})]})]}),position:c.BOTTOM,children:t(l,{icon:t(f,{}),className:"polotno-position",minimal:!0,text:P("toolbar.position"),disabled:!D})})});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare const Sketch: ({ width, rgb, hex, hsv, hsl, onChange, onSwatchHover, disableAlpha, presetColors, renderers, styles: passedStyles, className, }: {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
className?: string | undefined;
|
|
4
|
+
disableAlpha?: boolean | undefined;
|
|
5
5
|
hex: any;
|
|
6
|
-
hsv: any;
|
|
7
6
|
hsl: any;
|
|
7
|
+
hsv: any;
|
|
8
8
|
onChange: any;
|
|
9
9
|
onSwatchHover: any;
|
|
10
|
-
disableAlpha?: boolean | undefined;
|
|
11
10
|
presetColors?: string[] | undefined;
|
|
12
11
|
renderers: any;
|
|
12
|
+
rgb: any;
|
|
13
13
|
styles?: {} | undefined;
|
|
14
|
-
|
|
14
|
+
width?: number | undefined;
|
|
15
15
|
}) => React.JSX.Element;
|
|
16
16
|
declare const _default: {
|
|
17
17
|
new (props: any): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Fragment as e,jsx as o}from"react/jsx-runtime";import{observer as r}from"mobx-react-lite";import*as t from"../../utils/svg.js";import{ElementContainer as s,extendToolbar as n}from"./element-container.js";import m from"./filters-picker.js";import i from"./color-picker.js";import l from"./flip-button.js";import{AnimationsPicker as a}from"./animations-picker.js";import{flags as c}from"../../utils/flags.js";const p=(e,o)=>Array.from(e.keys()).find(e=>t.sameColors(e,o)),g=(e,o)=>{const r=p(e,o);return e.get(r||"")||o},f={SvgFlip:l,SvgFilters:m,SvgColors:r(({element:r,elements:s,store:n})=>{const m=t.useSvgColors(r.src);return o(e,{children:!r.maskSrc&&m.slice(0,5).map(e=>o(i,{value:g(r.colorsReplace,e),style:{marginLeft:"5px"},onChange:o=>{const t=p(r.colorsReplace,e)||e;r.replaceColor(t,o)},store:n,gradientEnabled:!0},e))})}),SvgAnimations:a};export const SvgToolbar=r(({store:e,hideSvgEffects:r,components:t})=>{const m=e.selectedElements,i=["SvgFlip",!r&&"SvgFilters","SvgColors",c.animationsEnabled&&"SvgAnimations"].filter(e=>!!e),l=n({type:"svg",usedItems:i,components:t});return o(s,{items:l,itemRender:r=>{const s=t[r]||f[r];return o(s,{elements:m,element:m[0],store:e},r)}})});export default SvgToolbar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as t,jsxs as o}from"react/jsx-runtime";import l from"react";import{observer as n}from"mobx-react-lite";import{Button as r,Popover as i,Position as s,Tooltip as a,Menu as c,MenuItem as d,MenuDivider as y,Slider as b}from"@blueprintjs/core";import{Disable as h}from"@blueprintjs/icons";import x from"./color-picker.js";import{NumberInput as g}from"./filters-picker.js";import{ElementContainer as m,extendToolbar as u}from"./element-container.js";import{ZoStrokeWidth as p}from"../../icons/meronex.js";import{TextFontFamily as C,TextFontSize as k,TextFill as f,TextFontVariant as v,TextSpacing as O,VERTICAL_ALIGN_OPTIONS as w,VERTICAL_ALIGN_ICONS as T}from"./text-toolbar.js";import{AnimationsPicker as B}from"./animations-picker.js";import{flags as j}from"../../utils/flags.js";import{t as S}from"../../utils/l10n.js";const M={stroke:"currentColor",strokeWidth:1,strokeOpacity:.25},R={stroke:"currentColor",strokeWidth:2},E=()=>o(t,{children:[e("rect",Object.assign({x:"2",y:"2",width:"16",height:"16",fill:"none"},M)),e("line",Object.assign({x1:"10",y1:"2",x2:"10",y2:"18"},M)),e("line",Object.assign({x1:"2",y1:"10",x2:"18",y2:"10"},M))]}),A=({children:t})=>o("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[e(E,{}),t]}),W=[{key:"all",labelKey:"toolbar.borderModeAll",icon:()=>o("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[e("rect",Object.assign({x:"2",y:"2",width:"16",height:"16",fill:"none"},R)),e("line",Object.assign({x1:"10",y1:"2",x2:"10",y2:"18"},R)),e("line",Object.assign({x1:"2",y1:"10",x2:"18",y2:"10"},R))]})},{key:"outer",labelKey:"toolbar.borderModeOuter",icon:()=>e(A,{children:e("rect",Object.assign({x:"2",y:"2",width:"16",height:"16",fill:"none"},R))})},{key:"inner",labelKey:"toolbar.borderModeInner",icon:()=>o(A,{children:[e("line",Object.assign({x1:"10",y1:"2",x2:"10",y2:"18"},R)),e("line",Object.assign({x1:"2",y1:"10",x2:"18",y2:"10"},R))]})},{key:"topOnly",labelKey:"toolbar.borderModeTopOnly",icon:()=>e(A,{children:e("line",Object.assign({x1:"2",y1:"2",x2:"18",y2:"2"},R))})},{key:"innerHorizontal",labelKey:"toolbar.borderModeInnerHorizontal",icon:()=>e(A,{children:e("line",Object.assign({x1:"2",y1:"10",x2:"18",y2:"10"},R))})},{key:"bottomOnly",labelKey:"toolbar.borderModeBottomOnly",icon:()=>e(A,{children:e("line",Object.assign({x1:"2",y1:"18",x2:"18",y2:"18"},R))})},{key:"leftOnly",labelKey:"toolbar.borderModeLeftOnly",icon:()=>e(A,{children:e("line",Object.assign({x1:"2",y1:"2",x2:"2",y2:"18"},R))})},{key:"innerVertical",labelKey:"toolbar.borderModeInnerVertical",icon:()=>e(A,{children:e("line",Object.assign({x1:"10",y1:"2",x2:"10",y2:"18"},R))})},{key:"rightOnly",labelKey:"toolbar.borderModeRightOnly",icon:()=>e(A,{children:e("line",Object.assign({x1:"18",y1:"2",x2:"18",y2:"18"},R))})}];export const TableBorderSettings=n(({elements:t,store:n})=>{const c=t[0],d="tablecell"===c.type,y=d?n.selectedElements[0]:c,[m,u]=l.useState("all");let C,k;if(d){const e=y.getFocusedCellRange();C=e?e.maxRow-e.minRow+1:1,k=e?e.maxCol-e.minCol+1:1}else{C=y.rows,k=y.cols}const f=C>1,v=k>1,O=e=>"innerHorizontal"===e?!f:("innerVertical"===e||"inner"===e&&!f)&&!v;l.useEffect(()=>{O(m)&&u("all")},[m,f,v]);const w={all:"top",outer:"top",topOnly:"top",topBottom:"top",bottomOnly:"bottom",innerHorizontal:"bottom",inner:"bottom",leftOnly:"left",rightOnly:"right",innerVertical:"right"}[m],T=d?c:"bottomOnly"===m?y.getCell(y.rows-1,0):"rightOnly"===m?y.getCell(0,y.cols-1):y.getCell(0,0),B=(null==T?void 0:T.getEffectiveBorder)?T.getEffectiveBorder(w):{color:y.borderColor,width:y.borderWidth,style:y.borderStyle},j=B.color,M=B.width,R=B.style,E=(e,o={})=>{var l,r;const i=M<=0||"none"===R,s=null!==(l=o.style)&&void 0!==l?l:i?"solid":R,a=void 0!==o.width?o.width:i?1:M,c={color:null!==(r=o.color)&&void 0!==r?r:j,width:a,style:s};n.history.transaction(()=>{y.applyBorderMode(e,c),"all"!==e||d||t.forEach(e=>e.set({borderColor:c.color,borderWidth:c.width,borderStyle:c.style}))})},A=e=>{E(m,{style:e})},F=e=>{E(m,{width:e})};return e(i,{position:s.BOTTOM,content:o("div",{style:{padding:"12px",display:"flex",gap:"12px"},children:[e("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 32px)",gridAutoRows:"32px",gap:"4px"},children:W.map(({key:t,labelKey:o,icon:l})=>{const n=O(t);return e(a,{content:S(o),position:s.TOP,children:e(r,{small:!0,disabled:n,active:!n&&m===t,onClick:()=>{u(t)},icon:e(l,{}),"aria-label":S(o),style:{width:"32px",height:"32px",padding:0}})},t)})}),e("div",{style:{width:"1px",background:"rgba(17,20,24,0.15)"}}),o("div",{style:{display:"flex",flexDirection:"column",gap:"8px",width:"170px"},children:[o("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e("span",{style:{fontSize:"12px"},children:S("toolbar.tableBorderColor")}),e(x,{value:j,onChange:e=>{E(m,{color:e})},store:n})]}),o("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e("span",{style:{fontSize:"12px"},children:S("toolbar.tableBorderWidth")}),e(g,{value:M,onValueChange:F,style:{width:"50px"},min:0,max:20,buttonPosition:"none"})]}),e(b,{value:M,onChange:F,min:0,max:20,labelRenderer:!1}),o("div",{style:{display:"flex",justifyContent:"space-between",gap:"4px"},children:[e(r,{small:!0,onClick:()=>A("none"),active:"none"===R,icon:e(h,{size:16}),style:{flex:1}}),e(r,{small:!0,onClick:()=>A("solid"),active:"solid"===R,style:{flex:1},children:e("svg",{width:"20",height:"14",viewBox:"0 0 20 14",children:e("line",{x2:"20",y1:"7",y2:"7",stroke:"currentColor",strokeWidth:"2"})})}),e(r,{small:!0,onClick:()=>A("dashed"),active:"dashed"===R,style:{flex:1},children:e("svg",{width:"20",height:"14",viewBox:"0 0 20 14",children:e("line",{x2:"20",y1:"7",y2:"7",stroke:"currentColor",strokeDasharray:"4 2",strokeWidth:"2"})})}),e(r,{small:!0,onClick:()=>A("dotted"),active:"dotted"===R,style:{flex:1},children:e("svg",{width:"20",height:"14",viewBox:"0 0 20 14",children:e("line",{x2:"20",y1:"7",y2:"7",stroke:"currentColor",strokeDasharray:"2 2",strokeWidth:"2"})})})]})]})]}),children:e(a,{content:S("toolbar.tableBorderSettings"),position:s.BOTTOM,children:e(r,{minimal:!0,icon:e(p,{}),"aria-label":S("toolbar.tableBorderSettings")})})})});const F=()=>o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[e("rect",{x:"1",y:"1",width:"14",height:"14",rx:"1",stroke:"currentColor",strokeWidth:"1.5",fill:"none"}),e("line",{x1:"5.5",y1:"1",x2:"5.5",y2:"15",stroke:"currentColor",strokeWidth:"1"}),e("line",{x1:"10.5",y1:"1",x2:"10.5",y2:"15",stroke:"currentColor",strokeWidth:"1"}),e("line",{x1:"1",y1:"5.5",x2:"15",y2:"5.5",stroke:"currentColor",strokeWidth:"1"}),e("line",{x1:"1",y1:"10.5",x2:"15",y2:"10.5",stroke:"currentColor",strokeWidth:"1"})]});export const TableStructureMenu=n(({element:l,store:n})=>{const r=l.focusedCells[0],i=null==r?void 0:r.row,s=null==r?void 0:r.col;return o(c,{children:[null!=r&&o(t,{children:[e(y,{title:S("toolbar.tableRows")}),e(d,{text:S("toolbar.insertRowAbove"),onClick:()=>{n.history.transaction(()=>{l.addRow(i)})}}),e(d,{text:S("toolbar.insertRowBelow"),onClick:()=>{n.history.transaction(()=>{l.addRow(i+1)})}}),e(d,{text:S("toolbar.deleteRow"),disabled:l.rows<=1,onClick:()=>{n.history.transaction(()=>{l.removeRow(i)})}}),e(y,{title:S("toolbar.tableColumns")}),e(d,{text:S("toolbar.insertColumnLeft"),onClick:()=>{n.history.transaction(()=>{l.addColumn(s)})}}),e(d,{text:S("toolbar.insertColumnRight"),onClick:()=>{n.history.transaction(()=>{l.addColumn(s+1)})}}),e(d,{text:S("toolbar.deleteColumn"),disabled:l.cols<=1,onClick:()=>{n.history.transaction(()=>{l.removeColumn(s)})}}),e(y,{})]}),e(d,{text:S("toolbar.distributeRowsEvenly"),onClick:()=>{n.history.transaction(()=>{l.distributeRowsEvenly()})}}),e(d,{text:S("toolbar.distributeColumnsEvenly"),onClick:()=>{n.history.transaction(()=>{l.distributeColumnsEvenly()})}})]})});export const TableStructure=n(({elements:t,store:o})=>{const l=t[0];return e(i,{position:s.BOTTOM,content:e(TableStructureMenu,{element:l,store:o}),children:e(a,{content:S("toolbar.tableStructure"),position:s.BOTTOM,children:e(r,{minimal:!0,icon:e(F,{}),"aria-label":S("toolbar.tableStructure")})})})});export const CellPadding=n(({elements:t,store:o})=>e(a,{content:S("toolbar.cellPadding"),position:s.BOTTOM,children:e(g,{value:t[0].cellPadding,onValueChange:e=>o.history.transaction(()=>{t.forEach(t=>t.set({cellPadding:e}))}),style:{width:"50px"},min:0,max:50,buttonPosition:"none"})}));export const CellBackground=n(({elements:t,store:o})=>e(a,{content:S("toolbar.cellBackground"),position:s.BOTTOM,children:e(x,{value:t[0].cellBackground,style:{marginRight:"5px"},onChange:e=>o.history.transaction(()=>{t.forEach(t=>t.set({cellBackground:e}))}),store:o})}));export const CellVerticalAlign=n(({elements:t,store:o})=>{const l=t[0];return e(a,{content:S("toolbar.verticalAlign"),position:s.BOTTOM,children:e(r,{minimal:!0,icon:T[l.verticalAlign],onClick:()=>{const e=(w.indexOf(l.verticalAlign)+1+w.length)%w.length,n=w[e];o.history.transaction(()=>{t.forEach(e=>e.set({verticalAlign:n}))})},"aria-label":S("toolbar.verticalAlign")})})});const V={TableStructure,TableAnimations:B},K={TableBorderSettings,TextFontFamily:C,TextFontSize:k,TextFill:f,CellBackground,TextFontVariant:v,CellVerticalAlign,TextSpacing:O},z=Object.assign(Object.assign({},V),K);export const TableToolbar=n(({store:t,components:o})=>{const l=t.selectedElements[0],n=l.focusedCells,r=n.length>0,i=["TableBorderSettings","CellBackground","TableStructure",...r?["TextFontFamily","TextFontSize","TextFill","TextFontVariant","CellVerticalAlign","TextSpacing"]:[],j.animationsEnabled&&"TableAnimations"],s=u({type:"table",usedItems:i,components:o});return e(m,{items:s,itemRender:i=>{const s=o[i]||z[i],a=!!K[i];if(a&&!r&&"TableBorderSettings"!==i&&"CellBackground"!==i){return null}let c;return c=a?r?n:"TableBorderSettings"===i?t.selectedElements:l.cells.slice():t.selectedElements,e(s,{element:l,store:t,elements:c},i)}})});export default TableToolbar;
|
|
1
|
+
import{Fragment as e,jsx as t,jsxs as o}from"react/jsx-runtime";import l from"react";import{observer as n}from"mobx-react-lite";import{Button as r,Popover as i,Position as s,Tooltip as a,Menu as c,MenuItem as d,MenuDivider as y,Slider as b}from"@blueprintjs/core";import{Disable as h}from"@blueprintjs/icons";import x from"./color-picker.js";import{NumberInput as g}from"./filters-picker.js";import{ElementContainer as m,extendToolbar as u}from"./element-container.js";import{ZoStrokeWidth as p}from"../../icons/meronex.js";import{TextFontFamily as C,TextFontSize as k,TextFill as f,TextFontVariant as v,TextSpacing as O,VERTICAL_ALIGN_OPTIONS as w,VERTICAL_ALIGN_ICONS as T}from"./text-toolbar.js";import{AnimationsPicker as B}from"./animations-picker.js";import{flags as j}from"../../utils/flags.js";import{t as S}from"../../utils/l10n.js";const M={stroke:"currentColor",strokeWidth:1,strokeOpacity:.25},R={stroke:"currentColor",strokeWidth:2},E=()=>o(e,{children:[t("rect",Object.assign({x:"2",y:"2",width:"16",height:"16",fill:"none"},M)),t("line",Object.assign({x1:"10",y1:"2",x2:"10",y2:"18"},M)),t("line",Object.assign({x1:"2",y1:"10",x2:"18",y2:"10"},M))]}),A=({children:e})=>o("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[t(E,{}),e]}),W=[{key:"all",labelKey:"toolbar.borderModeAll",icon:()=>o("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[t("rect",Object.assign({x:"2",y:"2",width:"16",height:"16",fill:"none"},R)),t("line",Object.assign({x1:"10",y1:"2",x2:"10",y2:"18"},R)),t("line",Object.assign({x1:"2",y1:"10",x2:"18",y2:"10"},R))]})},{key:"outer",labelKey:"toolbar.borderModeOuter",icon:()=>t(A,{children:t("rect",Object.assign({x:"2",y:"2",width:"16",height:"16",fill:"none"},R))})},{key:"inner",labelKey:"toolbar.borderModeInner",icon:()=>o(A,{children:[t("line",Object.assign({x1:"10",y1:"2",x2:"10",y2:"18"},R)),t("line",Object.assign({x1:"2",y1:"10",x2:"18",y2:"10"},R))]})},{key:"topOnly",labelKey:"toolbar.borderModeTopOnly",icon:()=>t(A,{children:t("line",Object.assign({x1:"2",y1:"2",x2:"18",y2:"2"},R))})},{key:"innerHorizontal",labelKey:"toolbar.borderModeInnerHorizontal",icon:()=>t(A,{children:t("line",Object.assign({x1:"2",y1:"10",x2:"18",y2:"10"},R))})},{key:"bottomOnly",labelKey:"toolbar.borderModeBottomOnly",icon:()=>t(A,{children:t("line",Object.assign({x1:"2",y1:"18",x2:"18",y2:"18"},R))})},{key:"leftOnly",labelKey:"toolbar.borderModeLeftOnly",icon:()=>t(A,{children:t("line",Object.assign({x1:"2",y1:"2",x2:"2",y2:"18"},R))})},{key:"innerVertical",labelKey:"toolbar.borderModeInnerVertical",icon:()=>t(A,{children:t("line",Object.assign({x1:"10",y1:"2",x2:"10",y2:"18"},R))})},{key:"rightOnly",labelKey:"toolbar.borderModeRightOnly",icon:()=>t(A,{children:t("line",Object.assign({x1:"18",y1:"2",x2:"18",y2:"18"},R))})}];export const TableBorderSettings=n(({elements:e,store:n})=>{const c=e[0],d="tablecell"===c.type,y=d?n.selectedElements[0]:c,[m,u]=l.useState("all");let C,k;if(d){const e=y.getFocusedCellRange();C=e?e.maxRow-e.minRow+1:1,k=e?e.maxCol-e.minCol+1:1}else{C=y.rows,k=y.cols}const f=C>1,v=k>1,O=e=>"innerHorizontal"===e?!f:("innerVertical"===e||"inner"===e&&!f)&&!v;l.useEffect(()=>{O(m)&&u("all")},[m,f,v]);const w={all:"top",outer:"top",topOnly:"top",topBottom:"top",bottomOnly:"bottom",innerHorizontal:"bottom",inner:"bottom",leftOnly:"left",rightOnly:"right",innerVertical:"right"}[m],T=d?c:"bottomOnly"===m?y.getCell(y.rows-1,0):"rightOnly"===m?y.getCell(0,y.cols-1):y.getCell(0,0),B=(null==T?void 0:T.getEffectiveBorder)?T.getEffectiveBorder(w):{color:y.borderColor,width:y.borderWidth,style:y.borderStyle},j=B.color,M=B.width,R=B.style,E=(t,o={})=>{var l,r;const i=M<=0||"none"===R,s=null!==(l=o.style)&&void 0!==l?l:i?"solid":R,a=void 0!==o.width?o.width:i?1:M,c={color:null!==(r=o.color)&&void 0!==r?r:j,width:a,style:s};n.history.transaction(()=>{y.applyBorderMode(t,c),"all"!==t||d||e.forEach(e=>e.set({borderColor:c.color,borderWidth:c.width,borderStyle:c.style}))})},A=e=>{E(m,{style:e})},F=e=>{E(m,{width:e})};return t(i,{position:s.BOTTOM,content:o("div",{style:{padding:"12px",display:"flex",gap:"12px"},children:[t("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 32px)",gridAutoRows:"32px",gap:"4px"},children:W.map(({key:e,labelKey:o,icon:l})=>{const n=O(e);return t(a,{content:S(o),position:s.TOP,children:t(r,{small:!0,disabled:n,active:!n&&m===e,onClick:()=>{u(e)},icon:t(l,{}),"aria-label":S(o),style:{width:"32px",height:"32px",padding:0}})},e)})}),t("div",{style:{width:"1px",background:"rgba(17,20,24,0.15)"}}),o("div",{style:{display:"flex",flexDirection:"column",gap:"8px",width:"170px"},children:[o("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t("span",{style:{fontSize:"12px"},children:S("toolbar.tableBorderColor")}),t(x,{value:j,onChange:e=>{E(m,{color:e})},store:n})]}),o("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t("span",{style:{fontSize:"12px"},children:S("toolbar.tableBorderWidth")}),t(g,{value:M,onValueChange:F,style:{width:"50px"},min:0,max:20,buttonPosition:"none"})]}),t(b,{value:M,onChange:F,min:0,max:20,labelRenderer:!1}),o("div",{style:{display:"flex",justifyContent:"space-between",gap:"4px"},children:[t(r,{small:!0,onClick:()=>A("none"),active:"none"===R,icon:t(h,{size:16}),style:{flex:1}}),t(r,{small:!0,onClick:()=>A("solid"),active:"solid"===R,style:{flex:1},children:t("svg",{width:"20",height:"14",viewBox:"0 0 20 14",children:t("line",{x2:"20",y1:"7",y2:"7",stroke:"currentColor",strokeWidth:"2"})})}),t(r,{small:!0,onClick:()=>A("dashed"),active:"dashed"===R,style:{flex:1},children:t("svg",{width:"20",height:"14",viewBox:"0 0 20 14",children:t("line",{x2:"20",y1:"7",y2:"7",stroke:"currentColor",strokeDasharray:"4 2",strokeWidth:"2"})})}),t(r,{small:!0,onClick:()=>A("dotted"),active:"dotted"===R,style:{flex:1},children:t("svg",{width:"20",height:"14",viewBox:"0 0 20 14",children:t("line",{x2:"20",y1:"7",y2:"7",stroke:"currentColor",strokeDasharray:"2 2",strokeWidth:"2"})})})]})]})]}),children:t(a,{content:S("toolbar.tableBorderSettings"),position:s.BOTTOM,children:t(r,{minimal:!0,icon:t(p,{}),"aria-label":S("toolbar.tableBorderSettings")})})})});const F=()=>o("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[t("rect",{x:"1",y:"1",width:"14",height:"14",rx:"1",stroke:"currentColor",strokeWidth:"1.5",fill:"none"}),t("line",{x1:"5.5",y1:"1",x2:"5.5",y2:"15",stroke:"currentColor",strokeWidth:"1"}),t("line",{x1:"10.5",y1:"1",x2:"10.5",y2:"15",stroke:"currentColor",strokeWidth:"1"}),t("line",{x1:"1",y1:"5.5",x2:"15",y2:"5.5",stroke:"currentColor",strokeWidth:"1"}),t("line",{x1:"1",y1:"10.5",x2:"15",y2:"10.5",stroke:"currentColor",strokeWidth:"1"})]});export const TableStructureMenu=n(({element:l,store:n})=>{const r=l.focusedCells[0],i=null==r?void 0:r.row,s=null==r?void 0:r.col;return o(c,{children:[null!=r&&o(e,{children:[t(y,{title:S("toolbar.tableRows")}),t(d,{text:S("toolbar.insertRowAbove"),onClick:()=>{n.history.transaction(()=>{l.addRow(i)})}}),t(d,{text:S("toolbar.insertRowBelow"),onClick:()=>{n.history.transaction(()=>{l.addRow(i+1)})}}),t(d,{text:S("toolbar.deleteRow"),disabled:l.rows<=1,onClick:()=>{n.history.transaction(()=>{l.removeRow(i)})}}),t(y,{title:S("toolbar.tableColumns")}),t(d,{text:S("toolbar.insertColumnLeft"),onClick:()=>{n.history.transaction(()=>{l.addColumn(s)})}}),t(d,{text:S("toolbar.insertColumnRight"),onClick:()=>{n.history.transaction(()=>{l.addColumn(s+1)})}}),t(d,{text:S("toolbar.deleteColumn"),disabled:l.cols<=1,onClick:()=>{n.history.transaction(()=>{l.removeColumn(s)})}}),t(y,{})]}),t(d,{text:S("toolbar.distributeRowsEvenly"),onClick:()=>{n.history.transaction(()=>{l.distributeRowsEvenly()})}}),t(d,{text:S("toolbar.distributeColumnsEvenly"),onClick:()=>{n.history.transaction(()=>{l.distributeColumnsEvenly()})}})]})});export const TableStructure=n(({elements:e,store:o})=>{const l=e[0];return t(i,{position:s.BOTTOM,content:t(TableStructureMenu,{element:l,store:o}),children:t(a,{content:S("toolbar.tableStructure"),position:s.BOTTOM,children:t(r,{minimal:!0,icon:t(F,{}),"aria-label":S("toolbar.tableStructure")})})})});export const CellPadding=n(({elements:e,store:o})=>t(a,{content:S("toolbar.cellPadding"),position:s.BOTTOM,children:t(g,{value:e[0].cellPadding,onValueChange:t=>o.history.transaction(()=>{e.forEach(e=>e.set({cellPadding:t}))}),style:{width:"50px"},min:0,max:50,buttonPosition:"none"})}));export const CellBackground=n(({elements:e,store:o})=>t(a,{content:S("toolbar.cellBackground"),position:s.BOTTOM,children:t(x,{value:e[0].cellBackground,style:{marginRight:"5px"},onChange:t=>o.history.transaction(()=>{e.forEach(e=>e.set({cellBackground:t}))}),store:o})}));export const CellVerticalAlign=n(({elements:e,store:o})=>{const l=e[0];return t(a,{content:S("toolbar.verticalAlign"),position:s.BOTTOM,children:t(r,{minimal:!0,icon:T[l.verticalAlign],onClick:()=>{const t=(w.indexOf(l.verticalAlign)+1+w.length)%w.length,n=w[t];o.history.transaction(()=>{e.forEach(e=>e.set({verticalAlign:n}))})},"aria-label":S("toolbar.verticalAlign")})})});const V={TableStructure,TableAnimations:B},K={TableBorderSettings,TextFontFamily:C,TextFontSize:k,TextFill:f,CellBackground,TextFontVariant:v,CellVerticalAlign,TextSpacing:O},z=Object.assign(Object.assign({},V),K);export const TableToolbar=n(({store:e,components:o})=>{const l=e.selectedElements[0],n=l.focusedCells,r=n.length>0,i=["TableBorderSettings","CellBackground","TableStructure",...r?["TextFontFamily","TextFontSize","TextFill","TextFontVariant","CellVerticalAlign","TextSpacing"]:[],j.animationsEnabled&&"TableAnimations"],s=u({type:"table",usedItems:i,components:o});return t(m,{items:s,itemRender:i=>{const s=o[i]||z[i],a=!!K[i];if(a&&!r&&"TableBorderSettings"!==i&&"CellBackground"!==i){return null}let c;return c=a?r?n:"TableBorderSettings"===i?e.selectedElements:l.cells.slice():e.selectedElements,t(s,{element:l,store:e,elements:c},i)}})});export default TableToolbar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Fragment as t,jsx as e,jsxs as o}from"react/jsx-runtime";import a from"react";import{observer as i}from"mobx-react-lite";import{Button as n,Position as l,Menu as r,MenuItem as s,MenuDivider as c,TextArea as d}from"@blueprintjs/core";import{Clean as m}from"@blueprintjs/icons";import{Popover as x,Dialog as p}from"@blueprintjs/core";import{t as b}from"../../utils/l10n.js";const u=d;import{URLS as h}from"../../utils/api.js";const f=async({text:t="",command:e,tone:o})=>{try{const a=await fetch(h.aiText(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t,command:e,tone:o})});if(!a.ok){const t=await a.text();throw console.error(t),new Error("Failed to rewrite text")}return(await a.json()).response}catch(a){return console.error(a),t}},g=[{text:"friendly"},{text:"professional"},{text:"humorous"},{text:"formal"}];export const TextAiWrite=i(({store:i})=>{const h=i.selectedElements.length>0,[T,y]=a.useState(!1),[C,k]=a.useState(!1),[v,w]=a.useState(1),[E,j]=a.useState(""),[N,S]=a.useState(""),[O,P]=a.useState(!1),A=a.useRef(null),B=i.selectedElements.some(t=>!t.contentEditable);a.useEffect(()=>{C&&1===v&&setTimeout(()=>{var t;null===(t=A.current)||void 0===t||t.focus()},100)},[C,v]);const I=async(t,e)=>{y(!0);const o=i.selectedElements[0].id,a=i.selectedElements[0].text,n=await f({text:a,command:t,tone:e}),l=i.getElementById(o);l&&(l.set({text:n}),y(!1))},R=async()=>{P(!0);const t=await f({command:"custom",text:i.selectedElements[0].text,tone:E});S(t),P(!1),w(2)};return B?null:T?e(n,{icon:e(m,{}),minimal:!0,text:"AI write",loading:!0}):o(t,{children:[e(x,{disabled:!h,content:o(r,{children:[e(s,{text:b("toolbar.aiText.rewrite"),onClick:()=>{I("rewrite")}}),e(s,{text:b("toolbar.aiText.shorten"),onClick:()=>{I("shorten")}}),e(s,{text:b("toolbar.aiText.continue"),onClick:()=>{I("continue")}}),e(s,{text:b("toolbar.aiText.proofread"),onClick:()=>{I("proofread")}}),e("li",{className:"bp6-menu-header",children:e("h6",{className:"bp6-heading",children:b("toolbar.aiText.tones")})}),g.map(t=>e(s,{text:b(`toolbar.aiText.${t.text}`),onClick:()=>{I("tone",t.text)}},t.text)),e(c,{}),e(s,{text:b("toolbar.aiText.customPrompt"),onClick:t=>{t.preventDefault(),t.stopPropagation(),k(!0)}})]}),position:l.BOTTOM,children:e(n,{icon:e(m,{}),minimal:!0,text:b("toolbar.aiText.aiWrite")})}),e(p,{isOpen:C,onClose:()=>{O||(k(!1),w(1),j(""),S(""))},title:b(1===v?"toolbar.aiText.customPrompt":"toolbar.aiText.generatedResult"),children:o("div",1===v?{className:"bp6-dialog-body",children:[e(d,{inputRef:A,value:E,onChange:t=>j(t.target.value),placeholder:b("toolbar.aiText.promptPlaceholder"),fill:!0,disabled:O,style:{minHeight:100}}),e("div",{className:"bp6-dialog-footer",children:o("div",{className:"bp6-dialog-footer-actions",children:[e(n,{onClick:()=>k(!1),text:b("toolbar.aiText.cancel"),disabled:O}),e(n,{intent:"primary",onClick:R,loading:O,disabled:!E,text:b("toolbar.aiText.generate")})]})})]}:{className:"bp6-dialog-body",children:[e(u,{value:N,onChange:t=>S(t.target.value),fill:!0,growVertically:!0,style:{minHeight:100}}),e("div",{className:"bp6-dialog-footer",children:o("div",{className:"bp6-dialog-footer-actions",children:[e(n,{onClick:()=>w(1),text:b("toolbar.aiText.back"),disabled:O}),e(n,{onClick:R,text:b("toolbar.aiText.tryAgain"),loading:O}),e(n,{intent:"primary",onClick:()=>{const t=i.selectedElements[0].id,e=i.getElementById(t);e&&e.set({text:N}),k(!1),w(1),j(""),S("")},text:b("toolbar.aiText.insert"),disabled:O})]})})]})})]})});
|
|
@@ -43,8 +43,8 @@ export declare const TextFill: (({ elements, store }: InputProps) => React.JSX.E
|
|
|
43
43
|
};
|
|
44
44
|
export declare const NumberInput: ({ value, onValueChange, ...props }: {
|
|
45
45
|
[x: string]: any;
|
|
46
|
-
value: any;
|
|
47
46
|
onValueChange: any;
|
|
47
|
+
value: any;
|
|
48
48
|
}) => React.JSX.Element;
|
|
49
49
|
export declare const TextSpacing: (({ elements, store }: InputProps) => React.JSX.Element) & React.NamedExoticComponent<InputProps> & {
|
|
50
50
|
readonly type: ({ elements, store }: InputProps) => React.JSX.Element;
|