polotno 3.6.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE.md +22 -7
  2. package/README.md +1 -1
  3. package/blueprint/side-panel/text-panel.js +3 -3
  4. package/blueprint/toolbar/text-toolbar.js +2 -2
  5. package/blueprint.polotno.css +116 -116
  6. package/canvas/figure-element.js +1 -1
  7. package/canvas/gif-element.js +1 -1
  8. package/canvas/html-element.js +1 -1
  9. package/canvas/image-element.js +1 -1
  10. package/canvas/page.js +1 -1
  11. package/canvas/quill-font-formats.js +1 -1
  12. package/canvas/render-tag-element.js +1 -1
  13. package/canvas/rich-editor.d.ts +0 -4
  14. package/canvas/rich-editor.js +5 -2
  15. package/canvas/text-element.js +1 -1
  16. package/canvas/use-mediabunny-video.js +1 -1
  17. package/canvas/video-element.js +1 -1
  18. package/model/group-model.d.ts +2 -12
  19. package/model/image-model.js +1 -1
  20. package/model/page-model.d.ts +2 -12
  21. package/model/store.d.ts +18 -108
  22. package/model/store.js +1 -1
  23. package/model/table-model.d.ts +2 -12
  24. package/model/table-model.js +1 -1
  25. package/model/text-model.js +1 -1
  26. package/package.json +28 -28
  27. package/pages-timeline/audio-track.js +1 -1
  28. package/pages-timeline/current-time.js +1 -1
  29. package/pages-timeline/element-track.js +1 -1
  30. package/pages-timeline/page-preview.js +1 -1
  31. package/pages-timeline/pages-timeline.js +1 -1
  32. package/pages-timeline/pages.js +1 -1
  33. package/pages-timeline/play-button.js +1 -1
  34. package/pages-timeline/time-ruler.js +1 -1
  35. package/pages-timeline/track-styles.js +1 -1
  36. package/polotno.bundle.js +171 -168
  37. package/primitives/select.d.ts +1 -1
  38. package/side-panel/images-grid.d.ts +2 -1
  39. package/side-panel/images-grid.js +1 -1
  40. package/side-panel/select-svg.js +1 -1
  41. package/side-panel/text-panel.js +1 -1
  42. package/side-panel/text-template.d.ts +12 -0
  43. package/side-panel/text-template.js +1 -0
  44. package/toolbar/text-toolbar.js +1 -1
  45. package/toolbar/video-toolbar.js +1 -1
  46. package/ui.css +2 -2
  47. package/utils/font-metric.js +1 -1
  48. package/utils/fonts.js +1 -1
  49. package/utils/html-to-svg/font-inliner.js +1 -1
  50. package/utils/html2canvas.js +1 -1
  51. package/utils/measure-text.js +1 -1
  52. package/utils/pointer-drag.d.ts +13 -0
  53. package/utils/pointer-drag.js +1 -0
  54. package/utils/px.d.ts +2 -0
  55. package/utils/px.js +1 -1
  56. package/utils/rich-text-html.js +1 -1
  57. package/utils/text-format-state.js +1 -1
  58. package/utils/text-format.js +1 -1
  59. package/utils/validate-key.js +1 -1
package/LICENSE.md CHANGED
@@ -1,9 +1,24 @@
1
- Copyright (C) 2014 - present by Anton Lavrenov
1
+ # Polotno SDK License
2
2
 
3
- Full license (canonical): https://polotno.com/legal/license
3
+ Copyright (c) 2014–present Anton Lavrenov. All rights reserved.
4
4
 
5
- - Free Trial: evaluation, testing, and internal development only. No production use.
6
- - Commercial/production use requires a paid license.
7
- - Do not reverse engineer or decompile the SDK.
8
- - Do not redistribute or sublicense the SDK itself, and do not bypass license checks or technical limits.
9
- - The SDK is provided "as is", without warranties or liability to the maximum extent permitted by law.
5
+ You can use this package for evaluation, development, and testing for 60 days.
6
+ After 60 days, all use requires a valid Polotno subscription.
7
+
8
+ Production use requires a valid Polotno subscription at any time. Production use
9
+ is use of this package in a live product, service, or internal tool, including a
10
+ tool that only your own employees use. Development, testing, continuous
11
+ integration, and evaluation are not production use, wherever they run.
12
+
13
+ An AI agent can use this package for you under the same terms. The agent gets no
14
+ rights of its own.
15
+
16
+ Do not reverse engineer, decompile, or change this package. Do not republish or
17
+ sublicense it. Do not bypass a license check or a technical limit.
18
+
19
+ This package is provided "as is", without warranty. To the maximum limit that
20
+ the law permits, the copyright holder has no liability for a claim or for
21
+ damages.
22
+
23
+ Subscription terms (payment, duration, support):
24
+ https://polotno.com/legal/license
package/README.md CHANGED
@@ -45,4 +45,4 @@ export const App = () => {
45
45
 
46
46
  ## License
47
47
 
48
- See licensing details at [polotno.com](https://polotno.com/).
48
+ See [LICENSE.md](./LICENSE.md).
@@ -1,4 +1,4 @@
1
- var t=this&&this.__rest||function(t,e){var o={};for(var i in t){Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i])}if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(t);n<i.length;n++){e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(o[i[n]]=t[i[n]])}}return o};import{jsx as e,jsxs as o}from"react/jsx-runtime";import i from"react";import{observer as n}from"mobx-react-lite";import{Button as l,Tab as a,Tabs as r}from"@blueprintjs/core";import s from"swr";import{Upload as c,Trash as d}from"@blueprintjs/icons";import{t as f}from"../../utils/l10n.js";import m from"../../utils/styled.js";import{isMobile as p}from"../../utils/screen.js";import{ImagesGrid as h}from"./images-grid.js";import{textTemplateList as g}from"../../utils/api.js";import{fetcher as y}from"../../utils/use-api.js";import{localFileToURL as x}from"../../utils/file.js";import{registerNextDomDrop as u}from"../../canvas/page.js";const b=m("div")`
1
+ var t=this&&this.__rest||function(t,e){var o={};for(var i in t){Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i])}if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(t);n<i.length;n++){e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(o[i[n]]=t[i[n]])}}return o};import{jsx as e,jsxs as o}from"react/jsx-runtime";import i from"react";import{observer as n}from"mobx-react-lite";import{Button as l,Tab as a,Tabs as r}from"@blueprintjs/core";import s from"swr";import{Upload as c,Trash as d}from"@blueprintjs/icons";import{t as f}from"../../utils/l10n.js";import m from"../../utils/styled.js";import{isMobile as p}from"../../utils/screen.js";import{ImagesGrid as h}from"./images-grid.js";import{textTemplateList as g}from"../../utils/api.js";import{fetcher as y}from"../../utils/use-api.js";import{localFileToURL as x}from"../../utils/file.js";import{cssFontFamily as u}from"@polotno/core/fonts";import{registerNextDomDrop as b}from"../../canvas/page.js";const v=m("div")`
2
2
  height: calc(100% - 40px);
3
3
  display: flex;
4
4
  flex-direction: column;
@@ -6,7 +6,7 @@ var t=this&&this.__rest||function(t,e){var o={};for(var i in t){Object.prototype
6
6
  .bp6-dark & .polotno-text-preview-plain {
7
7
  filter: invert(1);
8
8
  }
9
- `,v=m("div")`
9
+ `,j=m("div")`
10
10
  height: 100px;
11
11
  cursor: pointer;
12
12
  box-shadow: 0 0 5px rgba(16, 22, 26, 0.3);
@@ -21,4 +21,4 @@ var t=this&&this.__rest||function(t,e){var o={};for(var i in t){Object.prototype
21
21
  text-align: center;
22
22
  color: white;
23
23
  margin-bottom: 10px;
24
- `;let j=async t=>x(t);export function setFontUploadFunc(t){j=t}const w=n(({onSelect:t,onRemove:i,font:n})=>o(v,{style:{fontFamily:n.fontFamily},className:"polotno-font-item",onClick:t,children:[n.fontFamily," text",e(l,{style:{position:"absolute",right:0,bottom:0},minimal:!0,icon:e(d,{}),onClick:t=>{t.stopPropagation(),i()}})]})),F=o=>{var{onSelect:i}=o,n=t(o,["onSelect"]);return e(l,Object.assign({},n,{draggable:!0,className:"polotno-close-panel",onClick:()=>i(),onDragStart:()=>{u(({x:t,y:e})=>{i({x:t,y:e})})},onDragEnd:t=>{u(null)}}))};export const TextPanel=n(({store:t})=>{i.useEffect(()=>{t.loadFont("Roboto")},[]);const n=e=>{var o;const i=e.width||t.width/2,n=((null==e?void 0:e.x)||t.width/2)-i/2,l=((null==e?void 0:e.y)||t.height/2)-e.fontSize/2,a=(t.width+t.height)/2160,r=null===(o=t.activePage)||void 0===o?void 0:o.addElement(Object.assign(Object.assign({type:"text",fontFamily:"Roboto"},e),{x:n,y:l,width:i,fontSize:e.fontSize*a}));p()||null==r||r.toggleEditMode(!0)};i.useEffect(()=>{t.fonts.forEach(e=>t.loadFont(e.fontFamily))},[t.fonts]);const{data:d,error:m}=s(g(),y),[x,u]=i.useState("text");return o("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[o(r,{id:"text-panel-tabs",large:!0,onChange:t=>u(String(t)),children:[e(a,{id:"text",children:f("sidePanel.text")}),e(a,{id:"font",children:f("sidePanel.myFonts")})]}),"text"===x&&o(b,{children:[e(F,{style:{marginBottom:"5px",width:"100%",fontSize:"25px",fontFamily:"Roboto"},minimal:!0,onSelect:t=>{n(Object.assign(Object.assign({},t),{fontSize:76,text:f("sidePanel.headerText"),fontFamily:"Roboto"}))},children:f("sidePanel.createHeader")}),e(F,{style:{marginBottom:"5px",width:"100%",fontSize:"18px",fontFamily:"Roboto"},minimal:!0,onSelect:t=>{n(Object.assign(Object.assign({},t),{fontSize:44,text:f("sidePanel.subHeaderText"),fontFamily:"Roboto"}))},children:f("sidePanel.createSubHeader")}),e(F,{style:{marginBottom:"5px",width:"100%",fontSize:"14px",fontFamily:"Roboto"},minimal:!0,onSelect:t=>{n(Object.assign(Object.assign({},t),{fontSize:30,text:f("sidePanel.bodyText"),fontFamily:"Roboto"}))},children:f("sidePanel.createBody")}),e(h,{shadowEnabled:!1,images:null==d?void 0:d.items,getPreview:t=>t.preview,getImageClassName:t=>t.json.indexOf("plain")>=0?"polotno-text-preview-plain":"",isLoading:!d,error:m,onSelect:async(e,o)=>{const i=await fetch(e.json),n=await i.json();if(!t.activePage){return}const l=(t.width+t.height)/2160,a=o?o.x-n.width/2*l:t.width/2-n.width/2*l,r=o?o.y-n.height/2*l:t.height/2-n.height/2*l;t.history.transaction(()=>{const e=n.pages[0].children,o=[];e.forEach(e=>{delete e.id;const{id:i}=t.activePage.addElement(Object.assign(Object.assign({},e),{fontSize:e.fontSize*l,x:e.x*l+a,y:e.y*l+r,width:e.width*l,height:e.height*l}));o.push(i)}),t.selectElements(o)})}})]}),"font"===x&&o("div",{style:{display:"flex",flexDirection:"column",height:"calc(100% - 50px)"},children:[o("label",{htmlFor:"polotno-font-upload",children:[e(l,{icon:e(c,{}),style:{width:"100%"},onClick:()=>{var t;null===(t=document.querySelector("#polotno-font-upload"))||void 0===t||t.click()},children:f("sidePanel.uploadFont")}),e("input",{type:"file",accept:".ttf, .otf, .woff, .woff2, .eot",id:"polotno-font-upload",style:{display:"none"},onChange:async e=>{const{target:o}=e;for(const i of o.files){const e=await j(i),o=i.name.split(".")[0].replace(/,/g,"");t.addFont({fontFamily:o,url:e})}o.value=null}})]}),e("div",{style:{paddingTop:"20px",overflow:"auto",height:"100%"},children:t.fonts.map((o,i)=>e(w,{font:o,onSelect:()=>{n({fontSize:80,text:"Cool text",fontFamily:o.fontFamily})},onRemove:()=>{t.find(t=>("text"===t.type&&t.fontFamily===o.fontFamily&&t.set({fontFamily:"Roboto"}),!1)),t.removeFont(o.fontFamily)}},i))})]})]})});
24
+ `;let w=async t=>x(t);export function setFontUploadFunc(t){w=t}const F=n(({onSelect:t,onRemove:i,font:n})=>o(j,{style:{fontFamily:u(n.fontFamily)},className:"polotno-font-item",onClick:t,children:[n.fontFamily," text",e(l,{style:{position:"absolute",right:0,bottom:0},minimal:!0,icon:e(d,{}),onClick:t=>{t.stopPropagation(),i()}})]})),S=o=>{var{onSelect:i}=o,n=t(o,["onSelect"]);return e(l,Object.assign({},n,{draggable:!0,className:"polotno-close-panel",onClick:()=>i(),onDragStart:()=>{b(({x:t,y:e})=>{i({x:t,y:e})})},onDragEnd:t=>{b(null)}}))};export const TextPanel=n(({store:t})=>{i.useEffect(()=>{t.loadFont("Roboto")},[]);const n=e=>{var o;const i=e.width||t.width/2,n=((null==e?void 0:e.x)||t.width/2)-i/2,l=((null==e?void 0:e.y)||t.height/2)-e.fontSize/2,a=(t.width+t.height)/2160,r=null===(o=t.activePage)||void 0===o?void 0:o.addElement(Object.assign(Object.assign({type:"text",fontFamily:"Roboto"},e),{x:n,y:l,width:i,fontSize:e.fontSize*a}));p()||null==r||r.toggleEditMode(!0)};i.useEffect(()=>{t.fonts.forEach(e=>t.loadFont(e.fontFamily))},[t.fonts]);const{data:d,error:m}=s(g(),y),[x,u]=i.useState("text");return o("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[o(r,{id:"text-panel-tabs",large:!0,onChange:t=>u(String(t)),children:[e(a,{id:"text",children:f("sidePanel.text")}),e(a,{id:"font",children:f("sidePanel.myFonts")})]}),"text"===x&&o(v,{children:[e(S,{style:{marginBottom:"5px",width:"100%",fontSize:"25px",fontFamily:"Roboto"},minimal:!0,onSelect:t=>{n(Object.assign(Object.assign({},t),{fontSize:76,text:f("sidePanel.headerText"),fontFamily:"Roboto"}))},children:f("sidePanel.createHeader")}),e(S,{style:{marginBottom:"5px",width:"100%",fontSize:"18px",fontFamily:"Roboto"},minimal:!0,onSelect:t=>{n(Object.assign(Object.assign({},t),{fontSize:44,text:f("sidePanel.subHeaderText"),fontFamily:"Roboto"}))},children:f("sidePanel.createSubHeader")}),e(S,{style:{marginBottom:"5px",width:"100%",fontSize:"14px",fontFamily:"Roboto"},minimal:!0,onSelect:t=>{n(Object.assign(Object.assign({},t),{fontSize:30,text:f("sidePanel.bodyText"),fontFamily:"Roboto"}))},children:f("sidePanel.createBody")}),e(h,{shadowEnabled:!1,images:null==d?void 0:d.items,getPreview:t=>t.preview,getImageClassName:t=>t.json.indexOf("plain")>=0?"polotno-text-preview-plain":"",isLoading:!d,error:m,onSelect:async(e,o)=>{const i=await fetch(e.json),n=await i.json();if(!t.activePage){return}const l=(t.width+t.height)/2160,a=o?o.x-n.width/2*l:t.width/2-n.width/2*l,r=o?o.y-n.height/2*l:t.height/2-n.height/2*l;t.history.transaction(()=>{const e=n.pages[0].children,o=[];e.forEach(e=>{delete e.id;const{id:i}=t.activePage.addElement(Object.assign(Object.assign({},e),{fontSize:e.fontSize*l,x:e.x*l+a,y:e.y*l+r,width:e.width*l,height:e.height*l}));o.push(i)}),t.selectElements(o)})}})]}),"font"===x&&o("div",{style:{display:"flex",flexDirection:"column",height:"calc(100% - 50px)"},children:[o("label",{htmlFor:"polotno-font-upload",children:[e(l,{icon:e(c,{}),style:{width:"100%"},onClick:()=>{var t;null===(t=document.querySelector("#polotno-font-upload"))||void 0===t||t.click()},children:f("sidePanel.uploadFont")}),e("input",{type:"file",accept:".ttf, .otf, .woff, .woff2, .eot",id:"polotno-font-upload",style:{display:"none"},onChange:async e=>{const{target:o}=e;for(const i of o.files){const e=await w(i),o=i.name.split(".")[0].replace(/,/g,"");t.addFont({fontFamily:o,url:e})}o.value=null}})]}),e("div",{style:{paddingTop:"20px",overflow:"auto",height:"100%"},children:t.fonts.map((o,i)=>e(F,{font:o,onSelect:()=>{n({fontSize:80,text:"Cool text",fontFamily:o.fontFamily})},onRemove:()=>{t.find(t=>("text"===t.type&&t.fontFamily===o.fontFamily&&t.set({fontFamily:"Roboto"}),!1)),t.removeFont(o.fontFamily)}},i))})]})]})});
@@ -1,7 +1,7 @@
1
- var t=this&&this.__rest||function(t,e){var n={};for(var o in t){Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o])}if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++){e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}}return n};import{jsx as e,jsxs as n}from"react/jsx-runtime";import o from"react";import{observer as i}from"mobx-react-lite";import{Button as r,ButtonGroup as a,Classes as l,InputGroup as s,MenuDivider as c,MenuItem as m,NumericInput as p,Popover as f,Position as d,Slider as h,Tooltip as u}from"@blueprintjs/core";import{List as x}from"react-window";import g from"swr";import{AlignCenter as T,AlignJustify as b,AlignLeft as y,AlignRight as v,Bold as O,CaretDown as F,Italic as S,Search as I,Strikethrough as C,Underline as N}from"@blueprintjs/icons";import{getFontsList as w,globalFonts as A,isGoogleFontChanged as E}from"../../utils/fonts.js";import{getGoogleFontImage as j,getGoogleFontsListAPI as M}from"../../utils/api.js";import L from"./color-picker.js";import _ from"./filters-picker.js";import{AnimationsPicker as V}from"./animations-picker.js";import{ElementContainer as D,extendToolbar as k}from"./element-container.js";import{TextAiWrite as P}from"./text-ai-write.js";import{MdcFormatLineSpacing as R,MdcFormatLetterCase as B,MdcFormatVerticalAlignTop as z,MdcFormatVerticalAlignCenter as G,MdcFormatVerticalAlignBottom as W}from"../../icons/meronex.js";import H from"../../utils/styled.js";import{t as $}from"../../utils/l10n.js";import{flags as U}from"../../utils/flags.js";const q=H("img")`
1
+ var t=this&&this.__rest||function(t,e){var n={};for(var o in t){Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o])}if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++){e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}}return n};import{jsx as e,jsxs as n}from"react/jsx-runtime";import o from"react";import{observer as i}from"mobx-react-lite";import{Button as r,ButtonGroup as a,Classes as l,InputGroup as s,MenuDivider as c,MenuItem as m,NumericInput as p,Popover as f,Position as d,Slider as h,Tooltip as u}from"@blueprintjs/core";import{List as x}from"react-window";import g from"swr";import{AlignCenter as T,AlignJustify as b,AlignLeft as y,AlignRight as v,Bold as O,CaretDown as F,Italic as S,Search as I,Strikethrough as C,Underline as N}from"@blueprintjs/icons";import{getFontsList as w,globalFonts as A,isGoogleFontChanged as E}from"../../utils/fonts.js";import{getGoogleFontImage as j,getGoogleFontsListAPI as M}from"../../utils/api.js";import L from"./color-picker.js";import _ from"./filters-picker.js";import{AnimationsPicker as V}from"./animations-picker.js";import{ElementContainer as D,extendToolbar as k}from"./element-container.js";import{TextAiWrite as P}from"./text-ai-write.js";import{MdcFormatLineSpacing as R,MdcFormatLetterCase as B,MdcFormatVerticalAlignTop as z,MdcFormatVerticalAlignCenter as G,MdcFormatVerticalAlignBottom as W}from"../../icons/meronex.js";import H from"../../utils/styled.js";import{t as $}from"../../utils/l10n.js";import{flags as U}from"../../utils/flags.js";import{cssFontFamily as q}from"@polotno/core/fonts";const J=H("img")`
2
2
  height: 20px;
3
3
 
4
4
  .bp6-dark & {
5
5
  filter: invert(1);
6
6
  }
7
- `,J=w(),K=({fontFamily:t,handleClick:n,modifiers:i,store:r,isCustom:a})=>{const[l,s]=o.useState(!a);if(o.useEffect(()=>{l||r.loadFont(t)},[t,l]),"_divider"===t){return e("div",{style:{paddingTop:"10px"},children:e(c,{})})}const p=l?e(q,{src:j(t),alt:t,onError:()=>{s(!1)}}):t;return e(m,{text:p,active:i.active,disabled:i.disabled,onClick:n,style:{fontFamily:'"'+t+'"'}})},Q=({index:t,style:n,filteredFonts:o,activeFont:i,onFontSelect:r,store:a})=>{const l=o[t];return e("div",{style:n,children:e(K,{fontFamily:l,modifiers:{active:i===l},handleClick:()=>r(l),store:a,isCustom:a.fonts.find(t=>t.fontFamily===l)||A.find(t=>t.fontFamily===l)},l)})},X=({onChange:t,defaultValue:n})=>{const i=o.useRef(null);return o.useEffect(()=>{i.current&&i.current.focus()},[]),e(s,{leftIcon:e(I,{}),inputRef:i,defaultValue:n,onChange:e=>t(e.target.value)})};export const FontMenu=({store:t,fonts:i,activeFont:a,activeFontLabel:s,onFontSelect:c,mixed:m,mixedFonts:p})=>{const[h,g]=o.useState(""),T=i.filter(t=>(null==t?void 0:t.toLowerCase().indexOf(h.toLowerCase()))>=0);return e(f,{content:n("div",{children:[e(X,{onChange:t=>g(t),defaultValue:h}),e("div",{style:{paddingTop:"5px"},children:e(x,{tagName:"ul",className:l.MENU,style:{height:Math.min(400,30*T.length)+10,width:210},rowCount:T.length,rowHeight:30,rowComponent:Q,rowProps:{filteredFonts:T,activeFont:a,onFontSelect:c,store:t}})})]}),children:e(u,{content:m&&p&&p.length>0?`${$("toolbar.fontsInSelection")}: ${p.join(", ")}`:$("toolbar.fontFamily"),position:d.BOTTOM,children:e(r,{text:m?$("toolbar.fontFamilyMixed"):s,rightIcon:e(F,{}),minimal:!0,style:{marginRight:"5px",fontFamily:m?void 0:'"'+a+'"',fontStyle:m?"italic":void 0,color:m?"#5c7080":void 0,overflow:"hidden",whiteSpace:"nowrap",maxHeight:"30px"},"aria-label":$("toolbar.fontFamily")})})})};const Y={};export const fetcher=t=>Y[t]?Promise.resolve(Y[t]):fetch(t).then(t=>t.json()).then(e=>(Y[t]=e,e));export const TextFontFamily=i(({elements:t,store:n})=>{const{data:i,mutate:r}=g(M(),fetcher,{isPaused:()=>E(),fallbackData:[]});o.useEffect(()=>{r()},[E()]);const a=n.fonts.concat(A).map(t=>t.fontFamily).concat((null==i?void 0:i.length)&&!E()?i:J);let l=t[0].fontFamily;l.length>15&&(l=l.slice(0,15)+"...");const s=[];n.find(t=>("text"===t.type&&s.push(t.fontFamily),!1));const c=[...new Set(s.concat("_divider").concat(a))];return e(FontMenu,{fonts:c,activeFont:t[0].fontFamily,activeFontLabel:l,store:n,onFontSelect:e=>{n.history.transaction(()=>{t.forEach(t=>{t.set({fontFamily:e})})})}})});export const TextFontSize=i(({elements:t,store:n})=>{const[i,r]=o.useState(!1);return e(u,{content:$("toolbar.fontSize"),position:d.BOTTOM,openOnTargetFocus:!1,disabled:i,children:e(NumberInput,{"aria-label":$("toolbar.fontSize"),onFocus:()=>r(!0),onBlur:()=>r(!1),onValueChange:e=>{n.history.transaction(()=>{t.forEach(t=>{t.set({fontSize:e,width:Math.max(e,t.width)})})})},value:Math.round(t[0].fontSize),style:{width:"50px"},min:5,max:4*n.height})})});export const ALIGN_OPTIONS=["left","center","right","justify"];export const VERTICAL_ALIGN_OPTIONS=["top","middle","bottom"];export const VERTICAL_ALIGN_ICONS={top:e("span",{className:"bp6-icon",children:e(z,{})}),middle:e("span",{className:"bp6-icon",children:e(G,{})}),bottom:e("span",{className:"bp6-icon",children:e(W,{})})};export const TextFontVariant=i(({elements:t,store:o})=>{const i=t[0];return n(a,{children:[e(u,{content:$("toolbar.textAlign"),position:d.BOTTOM,children:e(r,{minimal:!0,icon:"left"===i.align?e(y,{}):"center"===i.align?e(T,{}):"right"===i.align?e(v,{}):e(b,{}),onMouseDown:t=>{t.preventDefault()},onClick:()=>{const e=(ALIGN_OPTIONS.indexOf(i.align)+1+ALIGN_OPTIONS.length)%ALIGN_OPTIONS.length,n=ALIGN_OPTIONS[e];o.history.transaction(()=>{t.forEach(t=>{t.set({align:n})})})},"aria-label":$("toolbar.textAlign")})}),U.textVerticalResizeEnabled&&e(u,{content:$("toolbar.verticalAlign"),position:d.BOTTOM,children:e(r,{minimal:!0,icon:VERTICAL_ALIGN_ICONS[i.verticalAlign],onMouseDown:t=>{t.preventDefault()},onClick:()=>{const e=(VERTICAL_ALIGN_OPTIONS.indexOf(i.verticalAlign)+1+VERTICAL_ALIGN_OPTIONS.length)%VERTICAL_ALIGN_OPTIONS.length,n=VERTICAL_ALIGN_OPTIONS[e];o.history.transaction(()=>{t.forEach(t=>{t.set({verticalAlign:n})})})},"aria-label":$("toolbar.verticalAlign")})}),e(u,{content:$("toolbar.bold"),position:d.BOTTOM,children:e(r,{minimal:!0,icon:e(O,{}),active:"bold"===i.fontWeight||"700"===i.fontWeight,onMouseDown:t=>{t.preventDefault()},onClick:()=>{const e="bold"===i.fontWeight||"700"===i.fontWeight;o.history.transaction(()=>{t.forEach(t=>{e?t.set({fontWeight:"normal"}):t.set({fontWeight:"bold"})})})},"aria-label":$("toolbar.bold")})}),e(u,{content:$("toolbar.italic"),position:d.BOTTOM,children:e(r,{minimal:!0,icon:e(S,{}),active:"italic"===i.fontStyle,onMouseDown:t=>{t.preventDefault()},onClick:()=>{const e="italic"===i.fontStyle;o.history.transaction(()=>{t.forEach(t=>{e?t.set({fontStyle:"normal"}):t.set({fontStyle:"italic"})})})},"aria-label":$("toolbar.italic")})}),e(u,{content:$("toolbar.underline"),position:d.BOTTOM,children:e(r,{minimal:!0,icon:e(N,{}),active:i.textDecoration.indexOf("underline")>=0,onMouseDown:t=>{t.preventDefault()},onClick:()=>{let e=i.textDecoration.split(" ");e.indexOf("underline")>=0?e=e.filter(t=>"underline"!==t):e.push("underline"),o.history.transaction(()=>{t.forEach(t=>{t.set({textDecoration:e.join(" ")})})})},"aria-label":$("toolbar.underline")})}),e(u,{content:$("toolbar.strikethrough"),position:d.BOTTOM,children:e(r,{minimal:!0,icon:e(C,{}),active:i.textDecoration.indexOf("line-through")>=0,onMouseDown:t=>{t.preventDefault()},onClick:()=>{let e=i.textDecoration.split(" ");e.indexOf("line-through")>=0?e=e.filter(t=>"line-through"!==t):e.push("line-through"),o.history.transaction(()=>{t.forEach(t=>{t.set({textDecoration:e.join(" ")})})})},"aria-label":$("toolbar.strikethrough")})})]})});export const TextTransform=i(({elements:t,store:n})=>e(a,{children:e(u,{content:$("toolbar.uppercase"),children:e(r,{variant:"minimal",active:"uppercase"==t[0].textTransform,icon:e(B,{className:"bp6-icon"}),onMouseDown:t=>{t.preventDefault()},onClick:()=>{n.history.transaction(()=>{t.forEach(t=>{t.set({textTransform:"uppercase"===t.textTransform?"none":"uppercase"})})})}})})}));export const TextFill=i(({elements:t,store:n})=>e(L,{value:t[0].fill,style:{marginRight:"5px"},gradientEnabled:!0,onChange:e=>n.history.transaction(()=>{t.forEach(t=>{t.set({fill:e})})}),store:n}));export const NumberInput=n=>{var{value:i,onValueChange:r}=n,a=t(n,["value","onValueChange"]);const[l,s]=o.useState(i.toString());o.useEffect(()=>{s(i.toString())},[i]);const{min:c,max:m}=a,f="number"==typeof c||"number"==typeof m;return e(p,Object.assign({value:l,onValueChange:(t,e)=>{s(e),Number.isNaN(t)||"number"==typeof c&&t<c||"number"==typeof m&&t>m||r(t)},clampValueOnBlur:f},a))};export const TextSpacing=i(({elements:t,store:o})=>{const i=t[0],a=e=>{o.history.transaction(()=>{t.forEach(t=>{t.set(e)})})},l="number"==typeof i.lineHeight?100*i.lineHeight:120;return e(f,{position:d.BOTTOM,content:n("div",{style:{padding:"15px",width:"230px"},children:[n("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[e("div",{children:$("toolbar.lineHeight")}),e("div",{children:e(NumberInput,{value:Math.round(l),onValueChange:t=>{a({lineHeight:t/100})},style:{width:"50px"},min:50,max:250,buttonPosition:"none"})})]}),e(h,{value:Math.round(l),onChange:t=>{a({lineHeight:t/100})},min:50,max:250,stepSize:1,showTrackFill:!1,labelRenderer:!1}),n("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[e("div",{children:$("toolbar.letterSpacing")}),e("div",{children:e(NumberInput,{value:Math.round(100*i.letterSpacing),onValueChange:t=>{a({letterSpacing:t/100})},style:{width:"50px"},min:-50,max:250,buttonPosition:"none"})})]}),e(h,{value:Math.round(100*i.letterSpacing),onChange:t=>{a({letterSpacing:t/100})},min:-50,max:250,stepSize:1,showTrackFill:!1,labelRenderer:!1})]}),children:e(u,{content:$("toolbar.spacing"),position:d.BOTTOM,children:e(r,{icon:e(R,{className:"bp6-icon",style:{fontSize:"20px"}}),minimal:!0,"aria-label":$("toolbar.spacing")})})})});const Z={TextFontFamily,TextFontSize,TextFontVariant,TextTransform,TextFill,TextSpacing,TextAiWrite:P,TextFilters:_,TextAnimations:V};export const TextToolbar=i(({store:t,components:n})=>{const o=t.selectedElements,i=["TextFill","TextFontFamily","TextFontSize","TextFontVariant","TextSpacing","TextTransform","TextFilters",U.animationsEnabled&&"TextAnimations",U.aiTextEnabled&&"TextAiWrite"],r=k({type:"text",usedItems:i,components:n});return e(D,{items:r,itemRender:i=>{const r=n[i]||Z[i];return e(r,{elements:o,element:o[0],store:t},i)}})});export default TextToolbar;
7
+ `,K=w(),Q=({fontFamily:t,handleClick:n,modifiers:i,store:r,isCustom:a})=>{const[l,s]=o.useState(!a);if(o.useEffect(()=>{l||r.loadFont(t)},[t,l]),"_divider"===t){return e("div",{style:{paddingTop:"10px"},children:e(c,{})})}const p=l?e(J,{src:j(t),alt:t,onError:()=>{s(!1)}}):t;return e(m,{text:p,active:i.active,disabled:i.disabled,onClick:n,style:{fontFamily:q(t)}})},X=({index:t,style:n,filteredFonts:o,activeFont:i,onFontSelect:r,store:a})=>{const l=o[t];return e("div",{style:n,children:e(Q,{fontFamily:l,modifiers:{active:i===l},handleClick:()=>r(l),store:a,isCustom:a.fonts.find(t=>t.fontFamily===l)||A.find(t=>t.fontFamily===l)},l)})},Y=({onChange:t,defaultValue:n})=>{const i=o.useRef(null);return o.useEffect(()=>{i.current&&i.current.focus()},[]),e(s,{leftIcon:e(I,{}),inputRef:i,defaultValue:n,onChange:e=>t(e.target.value)})};export const FontMenu=({store:t,fonts:i,activeFont:a,activeFontLabel:s,onFontSelect:c,mixed:m,mixedFonts:p})=>{const[h,g]=o.useState(""),T=i.filter(t=>(null==t?void 0:t.toLowerCase().indexOf(h.toLowerCase()))>=0);return e(f,{content:n("div",{children:[e(Y,{onChange:t=>g(t),defaultValue:h}),e("div",{style:{paddingTop:"5px"},children:e(x,{tagName:"ul",className:l.MENU,style:{height:Math.min(400,30*T.length)+10,width:210},rowCount:T.length,rowHeight:30,rowComponent:X,rowProps:{filteredFonts:T,activeFont:a,onFontSelect:c,store:t}})})]}),children:e(u,{content:m&&p&&p.length>0?`${$("toolbar.fontsInSelection")}: ${p.join(", ")}`:$("toolbar.fontFamily"),position:d.BOTTOM,children:e(r,{text:m?$("toolbar.fontFamilyMixed"):s,rightIcon:e(F,{}),minimal:!0,style:{marginRight:"5px",fontFamily:m?void 0:q(a),fontStyle:m?"italic":void 0,color:m?"#5c7080":void 0,overflow:"hidden",whiteSpace:"nowrap",maxHeight:"30px"},"aria-label":$("toolbar.fontFamily")})})})};const Z={};export const fetcher=t=>Z[t]?Promise.resolve(Z[t]):fetch(t).then(t=>t.json()).then(e=>(Z[t]=e,e));export const TextFontFamily=i(({elements:t,store:n})=>{const{data:i,mutate:r}=g(M(),fetcher,{isPaused:()=>E(),fallbackData:[]});o.useEffect(()=>{r()},[E()]);const a=n.fonts.concat(A).map(t=>t.fontFamily).concat((null==i?void 0:i.length)&&!E()?i:K);let l=t[0].fontFamily;l.length>15&&(l=l.slice(0,15)+"...");const s=[];n.find(t=>("text"===t.type&&s.push(t.fontFamily),!1));const c=[...new Set(s.concat("_divider").concat(a))];return e(FontMenu,{fonts:c,activeFont:t[0].fontFamily,activeFontLabel:l,store:n,onFontSelect:e=>{n.history.transaction(()=>{t.forEach(t=>{t.set({fontFamily:e})})})}})});export const TextFontSize=i(({elements:t,store:n})=>{const[i,r]=o.useState(!1);return e(u,{content:$("toolbar.fontSize"),position:d.BOTTOM,openOnTargetFocus:!1,disabled:i,children:e(NumberInput,{"aria-label":$("toolbar.fontSize"),onFocus:()=>r(!0),onBlur:()=>r(!1),onValueChange:e=>{n.history.transaction(()=>{t.forEach(t=>{t.set({fontSize:e,width:Math.max(e,t.width)})})})},value:Math.round(t[0].fontSize),style:{width:"50px"},min:5,max:4*n.height})})});export const ALIGN_OPTIONS=["left","center","right","justify"];export const VERTICAL_ALIGN_OPTIONS=["top","middle","bottom"];export const VERTICAL_ALIGN_ICONS={top:e("span",{className:"bp6-icon",children:e(z,{})}),middle:e("span",{className:"bp6-icon",children:e(G,{})}),bottom:e("span",{className:"bp6-icon",children:e(W,{})})};export const TextFontVariant=i(({elements:t,store:o})=>{const i=t[0];return n(a,{children:[e(u,{content:$("toolbar.textAlign"),position:d.BOTTOM,children:e(r,{minimal:!0,icon:"left"===i.align?e(y,{}):"center"===i.align?e(T,{}):"right"===i.align?e(v,{}):e(b,{}),onMouseDown:t=>{t.preventDefault()},onClick:()=>{const e=(ALIGN_OPTIONS.indexOf(i.align)+1+ALIGN_OPTIONS.length)%ALIGN_OPTIONS.length,n=ALIGN_OPTIONS[e];o.history.transaction(()=>{t.forEach(t=>{t.set({align:n})})})},"aria-label":$("toolbar.textAlign")})}),U.textVerticalResizeEnabled&&e(u,{content:$("toolbar.verticalAlign"),position:d.BOTTOM,children:e(r,{minimal:!0,icon:VERTICAL_ALIGN_ICONS[i.verticalAlign],onMouseDown:t=>{t.preventDefault()},onClick:()=>{const e=(VERTICAL_ALIGN_OPTIONS.indexOf(i.verticalAlign)+1+VERTICAL_ALIGN_OPTIONS.length)%VERTICAL_ALIGN_OPTIONS.length,n=VERTICAL_ALIGN_OPTIONS[e];o.history.transaction(()=>{t.forEach(t=>{t.set({verticalAlign:n})})})},"aria-label":$("toolbar.verticalAlign")})}),e(u,{content:$("toolbar.bold"),position:d.BOTTOM,children:e(r,{minimal:!0,icon:e(O,{}),active:"bold"===i.fontWeight||"700"===i.fontWeight,onMouseDown:t=>{t.preventDefault()},onClick:()=>{const e="bold"===i.fontWeight||"700"===i.fontWeight;o.history.transaction(()=>{t.forEach(t=>{e?t.set({fontWeight:"normal"}):t.set({fontWeight:"bold"})})})},"aria-label":$("toolbar.bold")})}),e(u,{content:$("toolbar.italic"),position:d.BOTTOM,children:e(r,{minimal:!0,icon:e(S,{}),active:"italic"===i.fontStyle,onMouseDown:t=>{t.preventDefault()},onClick:()=>{const e="italic"===i.fontStyle;o.history.transaction(()=>{t.forEach(t=>{e?t.set({fontStyle:"normal"}):t.set({fontStyle:"italic"})})})},"aria-label":$("toolbar.italic")})}),e(u,{content:$("toolbar.underline"),position:d.BOTTOM,children:e(r,{minimal:!0,icon:e(N,{}),active:i.textDecoration.indexOf("underline")>=0,onMouseDown:t=>{t.preventDefault()},onClick:()=>{let e=i.textDecoration.split(" ");e.indexOf("underline")>=0?e=e.filter(t=>"underline"!==t):e.push("underline"),o.history.transaction(()=>{t.forEach(t=>{t.set({textDecoration:e.join(" ")})})})},"aria-label":$("toolbar.underline")})}),e(u,{content:$("toolbar.strikethrough"),position:d.BOTTOM,children:e(r,{minimal:!0,icon:e(C,{}),active:i.textDecoration.indexOf("line-through")>=0,onMouseDown:t=>{t.preventDefault()},onClick:()=>{let e=i.textDecoration.split(" ");e.indexOf("line-through")>=0?e=e.filter(t=>"line-through"!==t):e.push("line-through"),o.history.transaction(()=>{t.forEach(t=>{t.set({textDecoration:e.join(" ")})})})},"aria-label":$("toolbar.strikethrough")})})]})});export const TextTransform=i(({elements:t,store:n})=>e(a,{children:e(u,{content:$("toolbar.uppercase"),children:e(r,{variant:"minimal",active:"uppercase"==t[0].textTransform,icon:e(B,{className:"bp6-icon"}),onMouseDown:t=>{t.preventDefault()},onClick:()=>{n.history.transaction(()=>{t.forEach(t=>{t.set({textTransform:"uppercase"===t.textTransform?"none":"uppercase"})})})}})})}));export const TextFill=i(({elements:t,store:n})=>e(L,{value:t[0].fill,style:{marginRight:"5px"},gradientEnabled:!0,onChange:e=>n.history.transaction(()=>{t.forEach(t=>{t.set({fill:e})})}),store:n}));export const NumberInput=n=>{var{value:i,onValueChange:r}=n,a=t(n,["value","onValueChange"]);const[l,s]=o.useState(i.toString());o.useEffect(()=>{s(i.toString())},[i]);const{min:c,max:m}=a,f="number"==typeof c||"number"==typeof m;return e(p,Object.assign({value:l,onValueChange:(t,e)=>{s(e),Number.isNaN(t)||"number"==typeof c&&t<c||"number"==typeof m&&t>m||r(t)},clampValueOnBlur:f},a))};export const TextSpacing=i(({elements:t,store:o})=>{const i=t[0],a=e=>{o.history.transaction(()=>{t.forEach(t=>{t.set(e)})})},l="number"==typeof i.lineHeight?100*i.lineHeight:120;return e(f,{position:d.BOTTOM,content:n("div",{style:{padding:"15px",width:"230px"},children:[n("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[e("div",{children:$("toolbar.lineHeight")}),e("div",{children:e(NumberInput,{value:Math.round(l),onValueChange:t=>{a({lineHeight:t/100})},style:{width:"50px"},min:50,max:250,buttonPosition:"none"})})]}),e(h,{value:Math.round(l),onChange:t=>{a({lineHeight:t/100})},min:50,max:250,stepSize:1,showTrackFill:!1,labelRenderer:!1}),n("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:"5px",paddingBottom:"5px"},children:[e("div",{children:$("toolbar.letterSpacing")}),e("div",{children:e(NumberInput,{value:Math.round(100*i.letterSpacing),onValueChange:t=>{a({letterSpacing:t/100})},style:{width:"50px"},min:-50,max:250,buttonPosition:"none"})})]}),e(h,{value:Math.round(100*i.letterSpacing),onChange:t=>{a({letterSpacing:t/100})},min:-50,max:250,stepSize:1,showTrackFill:!1,labelRenderer:!1})]}),children:e(u,{content:$("toolbar.spacing"),position:d.BOTTOM,children:e(r,{icon:e(R,{className:"bp6-icon",style:{fontSize:"20px"}}),minimal:!0,"aria-label":$("toolbar.spacing")})})})});const tt={TextFontFamily,TextFontSize,TextFontVariant,TextTransform,TextFill,TextSpacing,TextAiWrite:P,TextFilters:_,TextAnimations:V};export const TextToolbar=i(({store:t,components:n})=>{const o=t.selectedElements,i=["TextFill","TextFontFamily","TextFontSize","TextFontVariant","TextSpacing","TextTransform","TextFilters",U.animationsEnabled&&"TextAnimations",U.aiTextEnabled&&"TextAiWrite"],r=k({type:"text",usedItems:i,components:n});return e(D,{items:r,itemRender:i=>{const r=n[i]||tt[i];return e(r,{elements:o,element:o[0],store:t},i)}})});export default TextToolbar;