polotno 4.15.3 → 4.16.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 (86) hide show
  1. package/blueprint/side-panel/select-video.d.ts +2 -0
  2. package/canvas/element.js +1 -1
  3. package/canvas/figure-element.js +1 -1
  4. package/canvas/gif-element.js +1 -1
  5. package/canvas/html-element.js +1 -1
  6. package/canvas/image-element.js +1 -1
  7. package/canvas/page.js +1 -1
  8. package/canvas/render-tag-element.js +1 -1
  9. package/canvas/rich-editor.d.ts +3 -1
  10. package/canvas/rich-editor.js +2 -2
  11. package/canvas/text-element.js +1 -1
  12. package/canvas/use-color.d.ts +2 -2
  13. package/canvas/video-element.js +1 -1
  14. package/model/figure-model.d.ts +1 -0
  15. package/model/gif-model.d.ts +1 -0
  16. package/model/group-model.d.ts +12 -0
  17. package/model/image-model.d.ts +1 -0
  18. package/model/line-model.d.ts +1 -0
  19. package/model/node-model.d.ts +1 -0
  20. package/model/node-model.js +1 -1
  21. package/model/page-model.d.ts +36 -0
  22. package/model/page-model.js +1 -1
  23. package/model/shape-model.d.ts +1 -0
  24. package/model/store.d.ts +6 -0
  25. package/model/store.js +1 -1
  26. package/model/svg-model.d.ts +1 -0
  27. package/model/table-model.d.ts +1 -0
  28. package/model/text-model.d.ts +5 -0
  29. package/model/text-model.js +1 -1
  30. package/model/video-model.d.ts +1 -0
  31. package/package.json +21 -21
  32. package/polotno.bundle.js +166 -165
  33. package/primitives/numeric-input-delayed.d.ts +12 -0
  34. package/primitives/numeric-input-delayed.js +1 -0
  35. package/primitives/popover.js +1 -1
  36. package/side-panel/effects-panel.js +1 -1
  37. package/side-panel/layer-selection.d.ts +26 -0
  38. package/side-panel/layer-selection.js +1 -0
  39. package/side-panel/layers-panel.js +1 -1
  40. package/side-panel/select-video.d.ts +2 -0
  41. package/side-panel/size-panel.js +1 -1
  42. package/side-panel/text-effect-presets.d.ts +11 -0
  43. package/side-panel/text-effect-presets.js +1 -0
  44. package/toolbar/group-toolbar.js +1 -1
  45. package/toolbar/image-toolbar.d.ts +3 -2
  46. package/toolbar/image-toolbar.js +1 -1
  47. package/toolbar/many-toolbar.js +1 -1
  48. package/toolbar/opacity-picker.d.ts +3 -2
  49. package/toolbar/opacity-picker.js +1 -1
  50. package/toolbar/position-picker.js +1 -1
  51. package/toolbar/selection-colors.d.ts +18 -0
  52. package/toolbar/selection-colors.js +1 -0
  53. package/toolbar/selection-size.d.ts +12 -0
  54. package/toolbar/selection-size.js +1 -0
  55. package/toolbar/svg-toolbar.js +1 -1
  56. package/ui.css +1 -1
  57. package/utils/alignment.d.ts +16 -0
  58. package/utils/alignment.js +1 -1
  59. package/utils/array.d.ts +1 -0
  60. package/utils/array.js +1 -0
  61. package/utils/clipboard.d.ts +10 -0
  62. package/utils/duplicate.d.ts +2 -0
  63. package/utils/duplicate.js +1 -1
  64. package/utils/file.d.ts +1 -1
  65. package/utils/flags.d.ts +1 -1
  66. package/utils/l10n.d.ts +13 -0
  67. package/utils/l10n.js +1 -1
  68. package/utils/measure-text.d.ts +6 -3
  69. package/utils/measure-text.js +1 -1
  70. package/utils/px.d.ts +11 -18
  71. package/utils/px.js +1 -1
  72. package/utils/rich-text-html.d.ts +5 -0
  73. package/utils/rich-text-html.js +1 -1
  74. package/utils/selection-colors.d.ts +15 -0
  75. package/utils/selection-colors.js +1 -0
  76. package/utils/selection-transform.d.ts +19 -0
  77. package/utils/selection-transform.js +1 -0
  78. package/utils/selection.d.ts +3 -0
  79. package/utils/selection.js +1 -0
  80. package/utils/text-sizing.d.ts +5 -0
  81. package/utils/text-sizing.js +1 -0
  82. package/utils/use-svg-colors.d.ts +1 -0
  83. package/utils/use-svg-colors.js +1 -1
  84. package/utils/validate-key.js +1 -1
  85. package/canvas/text-element/fit-font-size.d.ts +0 -5
  86. package/canvas/text-element/fit-font-size.js +0 -1
package/utils/l10n.js CHANGED
@@ -1 +1 @@
1
- import{observable as e,action as o,toJS as a}from"mobx";const r=e({imageEdit:{title:"AI edit",expand:"Expand",upscale:"Upscale",inpaint:"Generative fill",replace:"Replace",remove:"Remove",prompt:"Your prompt",promptPlaceholder:"Describe what should be there",expandPromptPlaceholder:"Describe the new area (optional)",replaceDescription:"Select an area on the image, then describe what you want to change.",replaceHint:"Describe what should replace the selection, such as “plain wall” or “open sky”.",removeDescription:"Select an object to remove. The surrounding image will fill the selected area.",expandDescription:"Drag the frame beyond the image edges to make room for new content.",cropDescription:"Drag the frame to crop the image.",upscaleDescription:"Increase the image resolution.",removeBackgroundDescription:"Remove the image background.",applyCrop:"Apply crop",generate:"Generate",clear:"Clear selection",resetFrame:"Reset frame",processing:"Generating…",loadingImage:"Loading image…",upscaling:"Upscaling…",removingBackground:"Removing background…",failed:"The image could not be edited. Please try again.",rasterFailed:"This device could not prepare the image. Try a smaller image.",selectRegion:"Drag on the image to select an area."},toolbar:{duration:"Duration",opacity:"Opacity",effects:"Effects",blur:"Blur",curvedText:"Curved text",curvePower:"Power",temperature:"Temperature",saturation:"Saturation",contrast:"Contrast",shadows:"Shadows",white:"White",black:"Black",vibrance:"Vibrance",textBackground:"Background",textBox:"Text box",backgroundCornerRadius:"Corner radius",backgroundOpacity:"Opacity",backgroundPadding:"Padding",brightness:"Brightness",filters:"Filters",sepia:"Sepia",grayscale:"Grayscale",cold:"Cold",natural:"Natural",warm:"Warm",textStroke:"Text Stroke",blendMode:"Blending",blend:{"pass-through":"Pass Through",normal:"Normal",multiply:"Multiply",screen:"Screen",overlay:"Overlay",darken:"Darken",lighten:"Lighten","color-dodge":"Color Dodge","color-burn":"Color Burn","hard-light":"Hard Light","soft-light":"Soft Light",difference:"Difference",exclusion:"Exclusion",hue:"Hue",saturation:"Saturation",color:"Color",luminosity:"Luminosity"},strokeLineJoin:"Corners",joinRound:"Round",joinMiter:"Miter",joinBevel:"Bevel",shadow:"Shadow",border:"Border",cornerRadius:"Corner Radius",copyStyle:"Copy style",uppercase:"Uppercase",position:"Position",layering:"Layering",toForward:"To Front",up:"Forward",down:"Backward",toBottom:"To back",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignTop:"Align top",alignMiddle:"Align middle",alignBottom:"Align bottom",flip:"Flip",flipHorizontally:"Flip horizontally",flipVertically:"Flip vertically",fitToBackground:"Fit to page",removeBackground:"Remove background",removeBackgroundTitle:"Remove background from image",cancelRemoveBackground:"Cancel",confirmRemoveBackground:"Confirm",crop:"Crop",cropDone:"Done",cropCancel:"Cancel",clip:"Apply mask",removeClip:"Remove mask",removeMask:"Remove mask",transparency:"Transparency",lockedDescription:"Object is locked. Unlock it to allow changes from canvas.",unlockedDescription:"Object is unlocked. Lock it to prevent changes from canvas.",removeElements:"Remove elements",duplicateElements:"Duplicate elements",download:"Download",saveAsImage:"Save as image",saveAsPDF:"Save as PDF",lineHeight:"Line height",letterSpacing:"Letter spacing",offsetX:"Offset X",offsetY:"Offset Y",color:"Color",selectable:"Selectable",draggable:"Draggable",removable:"Removable",resizable:"Resizable",contentEditable:"Can change content",styleEditable:"Can change style",alwaysOnTop:"Always on top",showInExport:"Show in export",ungroupElements:"Ungroup",groupElements:"Group",lineSize:"Line size",fade:"Fade",move:"Move",zoom:"Zoom",animate:"Animate",rotate:"Rotate",none:"None",bounce:"Bounce",blink:"Blink",strength:"Strength",spaceEvenly:"Space evenly",horizontalDistribution:"Horizontally",verticalDistribution:"Vertically",strokeWidth:"Stroke Width",strokeSettings:"Stroke settings",spacing:"Spacing",volume:"Volume",speed:"Speed",seconds:"sec",lineStyle:"Line style",lineStartHead:"Line start",lineEndHead:"Line end",textDirection:"Text direction",fontSize:"Font size",fontFamily:"Font family",fontFamilyMixed:"Mixed",fontsInSelection:"Fonts in selection",textAlign:"Text align",verticalAlign:"Vertical align",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",cellBackground:"Cell background",tableBorderSettings:"Border settings",tableBorderColor:"Border color",tableBorderWidth:"Border width",tableBorderStyle:"Border style",borderModeAll:"All borders",borderModeOuter:"Outer borders",borderModeInner:"Inner borders",borderModeBottomOnly:"Bottom only",borderModeTopOnly:"Top only",borderModeLeftOnly:"Left only",borderModeRightOnly:"Right only",borderModeInnerHorizontal:"Inner horizontal",borderModeInnerVertical:"Inner vertical",tableStructure:"Table structure",tableRows:"Rows",tableColumns:"Columns",insertRowAbove:"Insert row above",insertRowBelow:"Insert row below",deleteRow:"Delete row",insertColumnLeft:"Insert column left",insertColumnRight:"Insert column right",deleteColumn:"Delete column",deleteRows:"Delete rows",deleteColumns:"Delete columns",distributeRowsEvenly:"Distribute rows evenly",distributeColumnsEvenly:"Distribute columns evenly",cellPadding:"Cell padding",listFormat:"List",colorPicker:{solid:"Solid",linear:"Linear",angle:"Angle",stops:"Gradient stops",stop:"Stop",addStop:"Add stop",removeStop:"Remove stop",reverse:"Reverse gradient",colors:"Colors",resetColors:"Reset",recolorAll:"Recolor all"},clipFade:{title:"Fade",preparing:"Preparing mask…",shape:"Shape",linear:"Linear",radial:"Radial",stopOpacity:"Stop opacity",stops:"Fade stops",stop:"Stop",start:"Fade start",end:"Fade end",center:"Fade center",radius:"Fade radius",reverse:"Reverse",removeStop:"Remove stop",addStop:"Add stop",reset:"Reset",hint:"Drag the handles on the image to position the fade."},aiText:{aiWrite:"AI write",rewrite:"Rewrite",shorten:"Shorten",continue:"Continue writing",proofread:"Proofread",tones:"Tones",friendly:"Friendly",professional:"Professional",humorous:"Humorous",formal:"Formal",customPrompt:"Custom prompt",generatedResult:"Generated result",cancel:"Cancel",generate:"Generate",back:"Back",tryAgain:"Try Again",insert:"Insert",promptPlaceholder:"Describe what you want to generate"}},workspace:{noPages:"There are no pages yet...",addPage:"Add page",removePage:"Remove page",duplicatePage:"Duplicate page",moveUp:"Move up",moveDown:"Move down",moveLeft:"Move left",moveRight:"Move right"},scale:{reset:"Reset"},error:{removeBackground:"Ops! Something went wrong. Background can not be removed."},sidePanel:{close:"Close",templates:"Templates",searchTemplatesWithSameSize:"Show templates with the same size",searchPlaceholder:"Search...",otherFormats:"Other formats",noResults:"No results",error:"Loading is failed...",text:"Text",uploadFont:"Upload font",myFonts:"My fonts",photos:"Photos",videos:"Videos",animations:"Animations",effects:"Effects",elements:"Elements",shapes:"Shapes",tables:"Tables",lines:"Lines",draw:"Draw",drawTool:"Tool",drawSelection:"Selection",drawBrush:"Brush",drawHighlighter:"Highlighter",upload:"Upload",uploadImage:"Add file",uploadTip:"Upload your assets",uploadUnsupported:"Skipped some files. You can add images, video and audio.",uploadFailed:"Upload failed. Please try again.",background:"Background",resize:"Resize",layers:"Layers",animate:"Animate",layerTypes:{image:"Image",text:"Text",svg:"SVG",line:"Line",figure:"Figure",group:"Group"},layersTip:"Elements on your active page:",noLayers:"No elements on the page...",namePlaceholder:"Type element name...",useMagicResize:"Use magic resize",advanced:"Advanced",bleed:"Bleed",showBleed:"Show bleed",clipImage:"Mask image",width:"Width",height:"Height",units:"Units",magicResizeDescription:"Magic resize will automatically resize and move all elements on the canvas",headerText:"Header",createHeader:"Create header",subHeaderText:"Sub Header",createSubHeader:"Create sub header",bodyText:"Body text",createBody:"Create body text"},pagesTimeline:{pages:"Pages",removePage:"Remove page",addPage:"Add page",duplicatePage:"Duplicate page",removeAudio:"Remove audio",duplicateAudio:"Duplicate audio",renameAudio:"Rename audio",muteAudio:"Mute",unmuteAudio:"Unmute",volume:"Volume",speed:"Speed",rewind:"Rewind to start",editAsVideo:"Edit as video",editAsVideoHint:"On: preview the frame at the playhead — timed elements hide outside their range. Off: show all elements while editing."},contextMenu:{duplicate:"Duplicate",split:"Split at playhead",rename:"Rename",remove:"Remove",lock:"Lock",unlock:"Unlock",copy:"Copy",paste:"Paste",copyStyle:"Copy style",moveUp:"Move up",moveDown:"Move down",moveBack:"Move back",moveForward:"Move forward"}}),n=e=>e&&"object"==typeof e;function i(e,o){Object.keys(o).forEach(a=>{const r=e[a],l=o[a];n(l)&&n(r)?i(r,l):e[a]=l})}function l(e,o,a=""){Object.keys(o).forEach(r=>{const i=o[r],s=a?`${a}.${r}`:r;n(i)?n(e[r])?l(e[r],i,s):console.warn(`Missing nested translation object at '${s}'`):void 0===e[r]&&console.warn(`Missing translation '${s}'`)})}export const setTranslations=o((e,{validate:o=!1}={})=>{o&&l(e,r),i(r,e)});export const getTranslations=()=>a(r);const s={};export const t=e=>{const o=function(e,o){var a,r=o.split("."),n=e;for(a=0;a<r.length;++a){if(null==n[r[a]]){return}n=n[r[a]]}return n}(r,e);if(void 0!==o){return o}s[e]||(s[e]=!0,console.warn(`Missing translation '${e}'`));const a=e.split("."),n=a[a.length-1]||" ";return n.charAt(0).toUpperCase()+n.slice(1)};
1
+ import{observable as e,action as o,toJS as a}from"mobx";const r=e({imageEdit:{title:"AI edit",expand:"Expand",upscale:"Upscale",inpaint:"Generative fill",replace:"Replace",remove:"Remove",prompt:"Your prompt",promptPlaceholder:"Describe what should be there",expandPromptPlaceholder:"Describe the new area (optional)",replaceDescription:"Select an area on the image, then describe what you want to change.",replaceHint:"Describe what should replace the selection, such as “plain wall” or “open sky”.",removeDescription:"Select an object to remove. The surrounding image will fill the selected area.",expandDescription:"Drag the frame beyond the image edges to make room for new content.",cropDescription:"Drag the frame to crop the image.",upscaleDescription:"Increase the image resolution.",removeBackgroundDescription:"Remove the image background.",applyCrop:"Apply crop",generate:"Generate",clear:"Clear selection",resetFrame:"Reset frame",processing:"Generating…",loadingImage:"Loading image…",upscaling:"Upscaling…",removingBackground:"Removing background…",failed:"The image could not be edited. Please try again.",rasterFailed:"This device could not prepare the image. Try a smaller image.",selectRegion:"Drag on the image to select an area."},toolbar:{duration:"Duration",opacity:"Opacity",effects:"Effects",blur:"Blur",curvedText:"Curved text",curvePower:"Power",temperature:"Temperature",saturation:"Saturation",contrast:"Contrast",shadows:"Shadows",white:"White",black:"Black",vibrance:"Vibrance",textBackground:"Background",textBox:"Text box",backgroundCornerRadius:"Corner radius",backgroundOpacity:"Opacity",backgroundPadding:"Padding",brightness:"Brightness",filters:"Filters",sepia:"Sepia",grayscale:"Grayscale",cold:"Cold",natural:"Natural",warm:"Warm",textStroke:"Text Stroke",textEffect:{none:"None",shadow:"Shadow",lift:"Lift",glow:"Glow",outline:"Outline",sticker:"Sticker",pop:"Pop",background:"Background"},blendMode:"Blending",blend:{"pass-through":"Pass Through",normal:"Normal",multiply:"Multiply",screen:"Screen",overlay:"Overlay",darken:"Darken",lighten:"Lighten","color-dodge":"Color Dodge","color-burn":"Color Burn","hard-light":"Hard Light","soft-light":"Soft Light",difference:"Difference",exclusion:"Exclusion",hue:"Hue",saturation:"Saturation",color:"Color",luminosity:"Luminosity"},strokeLineJoin:"Corners",joinRound:"Round",joinMiter:"Miter",joinBevel:"Bevel",shadow:"Shadow",border:"Border",cornerRadius:"Corner Radius",copyStyle:"Copy style",uppercase:"Uppercase",position:"Position",layering:"Layering",toForward:"To Front",up:"Forward",down:"Backward",toBottom:"To back",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignTop:"Align top",alignMiddle:"Align middle",alignBottom:"Align bottom",flip:"Flip",flipHorizontally:"Flip horizontally",flipVertically:"Flip vertically",fitToBackground:"Fill page",fitToPage:"Fit to page",widthShort:"W",heightShort:"H",removeBackground:"Remove background",removeBackgroundTitle:"Remove background from image",cancelRemoveBackground:"Cancel",confirmRemoveBackground:"Confirm",crop:"Crop",cropDone:"Done",cropCancel:"Cancel",clip:"Apply mask",removeClip:"Remove mask",removeMask:"Remove mask",transparency:"Transparency",lockedDescription:"Object is locked. Unlock it to allow changes from canvas.",unlockedDescription:"Object is unlocked. Lock it to prevent changes from canvas.",removeElements:"Remove elements",duplicateElements:"Duplicate elements",download:"Download",saveAsImage:"Save as image",saveAsPDF:"Save as PDF",lineHeight:"Line height",letterSpacing:"Letter spacing",offsetX:"Offset X",offsetY:"Offset Y",color:"Color",selectable:"Selectable",draggable:"Draggable",removable:"Removable",resizable:"Resizable",contentEditable:"Can change content",styleEditable:"Can change style",alwaysOnTop:"Always on top",showInExport:"Show in export",ungroupElements:"Ungroup",groupElements:"Group",lineSize:"Line size",fade:"Fade",move:"Move",zoom:"Zoom",animate:"Animate",rotate:"Rotate",none:"None",bounce:"Bounce",blink:"Blink",strength:"Strength",spaceEvenly:"Space evenly",horizontalDistribution:"Horizontally",verticalDistribution:"Vertically",strokeWidth:"Stroke Width",strokeSettings:"Stroke settings",spacing:"Spacing",volume:"Volume",speed:"Speed",seconds:"sec",lineStyle:"Line style",lineStartHead:"Line start",lineEndHead:"Line end",textDirection:"Text direction",fontSize:"Font size",fontFamily:"Font family",fontFamilyMixed:"Mixed",fontsInSelection:"Fonts in selection",textAlign:"Text align",verticalAlign:"Vertical align",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",cellBackground:"Cell background",tableBorderSettings:"Border settings",tableBorderColor:"Border color",tableBorderWidth:"Border width",tableBorderStyle:"Border style",borderModeAll:"All borders",borderModeOuter:"Outer borders",borderModeInner:"Inner borders",borderModeBottomOnly:"Bottom only",borderModeTopOnly:"Top only",borderModeLeftOnly:"Left only",borderModeRightOnly:"Right only",borderModeInnerHorizontal:"Inner horizontal",borderModeInnerVertical:"Inner vertical",tableStructure:"Table structure",tableRows:"Rows",tableColumns:"Columns",insertRowAbove:"Insert row above",insertRowBelow:"Insert row below",deleteRow:"Delete row",insertColumnLeft:"Insert column left",insertColumnRight:"Insert column right",deleteColumn:"Delete column",deleteRows:"Delete rows",deleteColumns:"Delete columns",distributeRowsEvenly:"Distribute rows evenly",distributeColumnsEvenly:"Distribute columns evenly",cellPadding:"Cell padding",listFormat:"List",colorPicker:{solid:"Solid",linear:"Linear",angle:"Angle",stops:"Gradient stops",stop:"Stop",addStop:"Add stop",removeStop:"Remove stop",reverse:"Reverse gradient",colors:"Colors",resetColors:"Reset",recolorAll:"Recolor all"},clipFade:{title:"Fade",preparing:"Preparing mask…",shape:"Shape",linear:"Linear",radial:"Radial",stopOpacity:"Stop opacity",stops:"Fade stops",stop:"Stop",start:"Fade start",end:"Fade end",center:"Fade center",radius:"Fade radius",reverse:"Reverse",removeStop:"Remove stop",addStop:"Add stop",reset:"Reset",hint:"Drag the handles on the image to position the fade."},aiText:{aiWrite:"AI write",rewrite:"Rewrite",shorten:"Shorten",continue:"Continue writing",proofread:"Proofread",tones:"Tones",friendly:"Friendly",professional:"Professional",humorous:"Humorous",formal:"Formal",customPrompt:"Custom prompt",generatedResult:"Generated result",cancel:"Cancel",generate:"Generate",back:"Back",tryAgain:"Try Again",insert:"Insert",promptPlaceholder:"Describe what you want to generate"}},workspace:{noPages:"There are no pages yet...",addPage:"Add page",removePage:"Remove page",duplicatePage:"Duplicate page",moveUp:"Move up",moveDown:"Move down",moveLeft:"Move left",moveRight:"Move right"},scale:{reset:"Reset"},error:{removeBackground:"Ops! Something went wrong. Background can not be removed."},sidePanel:{close:"Close",templates:"Templates",searchTemplatesWithSameSize:"Show templates with the same size",searchPlaceholder:"Search...",otherFormats:"Other formats",noResults:"No results",error:"Loading is failed...",text:"Text",uploadFont:"Upload font",myFonts:"My fonts",photos:"Photos",videos:"Videos",animations:"Animations",effects:"Effects",elements:"Elements",shapes:"Shapes",tables:"Tables",lines:"Lines",draw:"Draw",drawTool:"Tool",drawSelection:"Selection",drawBrush:"Brush",drawHighlighter:"Highlighter",upload:"Upload",uploadImage:"Add file",uploadTip:"Upload your assets",uploadUnsupported:"Skipped some files. You can add images, video and audio.",uploadFailed:"Upload failed. Please try again.",background:"Background",resize:"Resize",layers:"Layers",animate:"Animate",layerTypes:{image:"Image",text:"Text",svg:"SVG",line:"Line",figure:"Figure",group:"Group"},layersTip:"Elements on your active page:",noLayers:"No elements on the page...",namePlaceholder:"Type element name...",useMagicResize:"Use magic resize",advanced:"Advanced",bleed:"Bleed",showBleed:"Show bleed",clipImage:"Mask image",width:"Width",height:"Height",units:"Units",magicResizeDescription:"Magic resize will automatically resize and move all elements on the canvas",headerText:"Header",createHeader:"Create header",subHeaderText:"Sub Header",createSubHeader:"Create sub header",bodyText:"Body text",createBody:"Create body text"},pagesTimeline:{pages:"Pages",removePage:"Remove page",addPage:"Add page",duplicatePage:"Duplicate page",removeAudio:"Remove audio",duplicateAudio:"Duplicate audio",renameAudio:"Rename audio",muteAudio:"Mute",unmuteAudio:"Unmute",volume:"Volume",speed:"Speed",rewind:"Rewind to start",editAsVideo:"Edit as video",editAsVideoHint:"On: preview the frame at the playhead — timed elements hide outside their range. Off: show all elements while editing."},contextMenu:{duplicate:"Duplicate",split:"Split at playhead",rename:"Rename",remove:"Remove",lock:"Lock",unlock:"Unlock",copy:"Copy",paste:"Paste",copyStyle:"Copy style",moveUp:"Move up",moveDown:"Move down",moveBack:"Move back",moveForward:"Move forward"}}),n=e=>e&&"object"==typeof e;function i(e,o){Object.keys(o).forEach(a=>{const r=e[a],l=o[a];n(l)&&n(r)?i(r,l):e[a]=l})}function l(e,o,a=""){Object.keys(o).forEach(r=>{const i=o[r],s=a?`${a}.${r}`:r;n(i)?n(e[r])?l(e[r],i,s):console.warn(`Missing nested translation object at '${s}'`):void 0===e[r]&&console.warn(`Missing translation '${s}'`)})}export const setTranslations=o((e,{validate:o=!1}={})=>{o&&l(e,r),i(r,e)});export const getTranslations=()=>a(r);const s={};export const t=e=>{const o=function(e,o){var a,r=o.split("."),n=e;for(a=0;a<r.length;++a){if(null==n[r[a]]){return}n=n[r[a]]}return n}(r,e);if(void 0!==o){return o}s[e]||(s[e]=!0,console.warn(`Missing translation '${e}'`));const a=e.split("."),n=a[a.length-1]||" ";return n.charAt(0).toUpperCase()+n.slice(1)};
@@ -1,10 +1,13 @@
1
- export interface TextMeasureResult {
2
- height: number;
3
- }
1
+ import { type TextSizingResult } from '@polotno/core/text-sizing';
2
+ export type TextMeasureResult = Pick<TextSizingResult, 'height' | 'fontSize' | 'lines' | 'lineCount' | 'totalLineCount' | 'truncated'>;
4
3
  export interface MeasureTextOptions {
5
4
  text: string;
6
5
  width: number;
7
6
  height?: number;
7
+ textOverflow?: string;
8
+ maxLines?: number;
9
+ minFontSize?: number;
10
+ maxFontSize?: number;
8
11
  fontSize?: number;
9
12
  fontFamily?: string;
10
13
  fontWeight?: string;
@@ -1 +1 @@
1
- import t from"konva";import{flags as e}from"./flags.js";import{detectSize as n}from"@polotno/core/measure-html";import{removeTags as o}from"@polotno/core/text";import{applyTextDefaults as i}from"@polotno/core/text-types";import{cssFontFamily as r}from"@polotno/core/fonts";import{getHtml as l,getCurvePath as f,getCurveTextHeight as a,resolveLineHeight as h}from"@polotno/core/text-html";export async function measureText(c){var g;return(null!==(g=c.richTextEnabled)&&void 0!==g?g:e.htmlRenderEnabled||e.renderTagTextEnabled)?function(t){const o=i(Object.assign(Object.assign({},t),{text:t.text,width:t.width}));if(o.curveEnabled){return{height:a(o)}}const r=l(o,{fontFamily:o.fontFamily,textOverflow:e.textOverflow}),{height:f}=n(r);return{height:f}}(c):function(e){var n;const l=i(Object.assign(Object.assign({},e),{text:e.text,width:e.width})),a=h({fontFamily:l.fontFamily,fontSize:l.fontSize,lineHeight:l.lineHeight});let c=o(l.text);if("uppercase"===l.textTransform&&(c=c.toUpperCase()),l.curveEnabled){const e=new t.TextPath({data:f(l.width,null!==(n=l.height)&&void 0!==n?n:0,l.curvePower,l.fontSize),align:"center",textBaseline:"middle",text:c,fontSize:l.fontSize,fontFamily:r(l.fontFamily),fontWeight:l.fontWeight,fontStyle:l.fontStyle,letterSpacing:l.letterSpacing*l.fontSize,fill:l.fill}),o=e.getSelfRect();return e.destroy(),{height:o.height||l.fontSize}}const g=new t.Text({text:c,width:l.width,fontSize:l.fontSize,fontFamily:r(l.fontFamily),fontStyle:`${l.fontStyle} ${l.fontWeight}`,lineHeight:a,letterSpacing:l.letterSpacing*l.fontSize,align:l.align}),m=Math.ceil(g.fontSize()*g.lineHeight()*g.textArr.length+1);return g.destroy(),{height:m}}(c)}
1
+ import{removeTags as t}from"@polotno/core/text";import{applyTextDefaults as o}from"@polotno/core/text-types";import{curveLayoutAt as e}from"@polotno/core/curve-glyphs";import{layoutCurvedTextSizing as n,layoutTextSizing as i,renderTagLayoutAt as r}from"@polotno/core/text-sizing";import{editorTextSizing as l}from"./text-sizing.js";export async function measureText(a){var s;const u=o(a),m=Object.assign(Object.assign({},u),{height:null!==(s=a.height)&&void 0!==s?s:0}),c=l(m);if(u.curveEnabled){const{fontSize:o,layout:i,truncated:r}=n({element:m,sizing:c,layoutAt:e(m,{getHtmlOptions:{fontFamily:u.fontFamily}})}),l=i.bounds.height;return{height:l,fontSize:o,lines:[{text:t(u.text),top:0,height:l,paragraph:0}],lineCount:1,totalLineCount:1,truncated:r}}const g=i({element:m,sizing:c,layoutAt:r(m,{getHtmlOptions:{fontFamily:u.fontFamily,forEditor:!0}})});return{height:g.height,fontSize:g.fontSize,lines:g.lines,lineCount:g.lineCount,totalLineCount:g.totalLineCount,truncated:g.truncated}}
package/utils/px.d.ts CHANGED
@@ -9,24 +9,6 @@ export declare const textMinWidthIsMeasured: (element: {
9
9
  letterSpacing?: number;
10
10
  text: string;
11
11
  }) => boolean;
12
- type BoxStyleSource = {
13
- cornerRadius?: number;
14
- shadowBlur: number;
15
- shadowOffsetX: number;
16
- shadowOffsetY: number;
17
- };
18
- export declare const scaledBoxStyleAttrs: (element: BoxStyleSource, scale: number) => {
19
- cornerRadius: number;
20
- shadowBlur: number;
21
- shadowOffsetX: number;
22
- shadowOffsetY: number;
23
- };
24
- export declare const roundedBoxStyleAttrs: (element: BoxStyleSource) => {
25
- cornerRadius: number;
26
- shadowBlur: number;
27
- shadowOffsetX: number;
28
- shadowOffsetY: number;
29
- };
30
12
  type TextStyleSource = {
31
13
  fontSize: number;
32
14
  strokeWidth: number;
@@ -43,6 +25,11 @@ export declare const scaledFontSizeAttrs: (element: TextStyleSource, fontSize: n
43
25
  shadowOffsetX: number;
44
26
  shadowOffsetY: number;
45
27
  };
28
+ type FontSizeBounds = {
29
+ minFontSize?: number;
30
+ maxFontSize?: number;
31
+ };
32
+ export declare const scaledFontSizeBounds: (start: FontSizeBounds, factor: number, round?: boolean) => FontSizeBounds;
46
33
  export declare const roundedGeometryPx: (value: number) => number;
47
34
  export declare const roundedCropFraction: (value: number) => number;
48
35
  export declare const roundedPosition: (node: Konva.Node) => {
@@ -71,6 +58,12 @@ export declare const roundedFontSizeAttrs: (element: TextStyleSource, fontSize:
71
58
  shadowOffsetX: number;
72
59
  shadowOffsetY: number;
73
60
  };
61
+ export declare const scaledStyleAttrs: (element: {
62
+ type: string;
63
+ }, scale: number) => Record<string, number | string>;
64
+ export declare const roundedStyleAttrs: (element: {
65
+ type: string;
66
+ }) => Record<string, number>;
74
67
  export declare const roundedTextDecorationAttrs: (element: TextStyleSource) => {
75
68
  strokeWidth: number;
76
69
  borderSize: number;
package/utils/px.js CHANGED
@@ -1 +1 @@
1
- var t=this&&this.__rest||function(t,e){var o={};for(var r in t){Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r])}if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++){e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]])}}return o};import{htmlInflatesMinContentWidth as e}from"./rich-text-html.js";export const roundEnabledPx=t=>t>0?Math.max(1,Math.round(t)):0;export const MAIN_TRANSFORMER_NAME="main-transformer";export const activeAnchorOf=t=>{var e,o;const r=null===(e=t.getStage())||void 0===e?void 0:e.findOne(".main-transformer");return null!==(o=null==r?void 0:r.getActiveAnchor())&&void 0!==o?o:""};export const isCornerAnchor=t=>!(t.includes("middle")||t.includes("center"));export const textMinResizeWidth=(t,e)=>t<e?1:e;export const textMinWidthIsMeasured=t=>{var o;return!!t.curveEnabled||0!==(null!==(o=t.letterSpacing)&&void 0!==o?o:0)||e(t.text)};export const scaledBoxStyleAttrs=(t,e)=>{var o;return{cornerRadius:(null!==(o=t.cornerRadius)&&void 0!==o?o:0)*e,shadowBlur:t.shadowBlur*e,shadowOffsetX:t.shadowOffsetX*e,shadowOffsetY:t.shadowOffsetY*e}};export const roundedBoxStyleAttrs=t=>{var e;return{cornerRadius:roundEnabledPx(null!==(e=t.cornerRadius)&&void 0!==e?e:0),shadowBlur:Math.round(t.shadowBlur),shadowOffsetX:Math.round(t.shadowOffsetX),shadowOffsetY:Math.round(t.shadowOffsetY)}};export const scaledFontSizeAttrs=(t,e)=>{const o=t.fontSize>0?e/t.fontSize:1;return{fontSize:e,strokeWidth:t.strokeWidth*o,borderSize:t.borderSize*o,shadowBlur:t.shadowBlur*o,shadowOffsetX:t.shadowOffsetX*o,shadowOffsetY:t.shadowOffsetY*o}};export const roundedGeometryPx=t=>Math.round(1e6*t)/1e6+0;export const roundedCropFraction=t=>Math.round(1e9*t)/1e9+0;export const roundedPosition=t=>({x:roundedGeometryPx(t.x()),y:roundedGeometryPx(t.y())});export const roundedGeometryAttrs=t=>({x:roundedGeometryPx(t.x),y:roundedGeometryPx(t.y),width:roundedGeometryPx(t.width),height:roundedGeometryPx(t.height),rotation:roundedGeometryPx(t.rotation)});export const roundedFontSizeAttrs=(t,e)=>{const o=scaledFontSizeAttrs(t,e);return{fontSize:Math.round(o.fontSize),strokeWidth:roundEnabledPx(o.strokeWidth),borderSize:roundEnabledPx(o.borderSize),shadowBlur:Math.round(o.shadowBlur),shadowOffsetX:Math.round(o.shadowOffsetX),shadowOffsetY:Math.round(o.shadowOffsetY)}};export const roundedTextDecorationAttrs=e=>{const o=roundedFontSizeAttrs(e,e.fontSize),{fontSize:r}=o;return t(o,["fontSize"])};
1
+ var t=this&&this.__rest||function(t,e){var o={};for(var r in t){Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r])}if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++){e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(o[r[n]]=t[r[n]])}}return o};import{htmlInflatesMinContentWidth as e,scaleRichTextFontSizesInHtml as o}from"./rich-text-html.js";export const roundEnabledPx=t=>t>0?Math.max(1,Math.round(t)):0;export const MAIN_TRANSFORMER_NAME="main-transformer";export const activeAnchorOf=t=>{var e,o;const r=null===(e=t.getStage())||void 0===e?void 0:e.findOne(".main-transformer");return null!==(o=null==r?void 0:r.getActiveAnchor())&&void 0!==o?o:""};export const isCornerAnchor=t=>!(t.includes("middle")||t.includes("center"));export const textMinResizeWidth=(t,e)=>t<e?1:e;export const textMinWidthIsMeasured=t=>{var o;return!!t.curveEnabled||0!==(null!==(o=t.letterSpacing)&&void 0!==o?o:0)||e(t.text)};const r=(t,e)=>{var o;return{cornerRadius:(null!==(o=t.cornerRadius)&&void 0!==o?o:0)*e,shadowBlur:t.shadowBlur*e,shadowOffsetX:t.shadowOffsetX*e,shadowOffsetY:t.shadowOffsetY*e}},n=t=>{var e;return{cornerRadius:roundEnabledPx(null!==(e=t.cornerRadius)&&void 0!==e?e:0),shadowBlur:Math.round(t.shadowBlur),shadowOffsetX:Math.round(t.shadowOffsetX),shadowOffsetY:Math.round(t.shadowOffsetY)}};export const scaledFontSizeAttrs=(t,e)=>{const o=t.fontSize>0?e/t.fontSize:1;return{fontSize:e,strokeWidth:t.strokeWidth*o,borderSize:t.borderSize*o,shadowBlur:t.shadowBlur*o,shadowOffsetX:t.shadowOffsetX*o,shadowOffsetY:t.shadowOffsetY*o}};export const scaledFontSizeBounds=(t,e,o=!1)=>{const r=t=>{if(1===e){return t}const r=t*e;return o?Math.round(r):r},n={};return void 0!==t.minFontSize&&(n.minFontSize=r(t.minFontSize)),void 0!==t.maxFontSize&&(n.maxFontSize=r(t.maxFontSize)),n};export const roundedGeometryPx=t=>Math.round(1e6*t)/1e6+0;export const roundedCropFraction=t=>Math.round(1e9*t)/1e9+0;export const roundedPosition=t=>({x:roundedGeometryPx(t.x()),y:roundedGeometryPx(t.y())});export const roundedGeometryAttrs=t=>({x:roundedGeometryPx(t.x),y:roundedGeometryPx(t.y),width:roundedGeometryPx(t.width),height:roundedGeometryPx(t.height),rotation:roundedGeometryPx(t.rotation)});export const roundedFontSizeAttrs=(t,e)=>{const o=scaledFontSizeAttrs(t,e);return{fontSize:Math.round(o.fontSize),strokeWidth:roundEnabledPx(o.strokeWidth),borderSize:roundEnabledPx(o.borderSize),shadowBlur:Math.round(o.shadowBlur),shadowOffsetX:Math.round(o.shadowOffsetX),shadowOffsetY:Math.round(o.shadowOffsetY)}};const s=["image","svg","gif","video"];export const scaledStyleAttrs=(t,e)=>{const n=t;return"text"===n.type?Object.assign(Object.assign({},scaledFontSizeAttrs(n,n.fontSize*e)),{text:o(n.text,e)}):"figure"===n.type?Object.assign(Object.assign({},r(n,e)),{strokeWidth:n.strokeWidth*e}):s.includes(n.type)?Object.assign(Object.assign({},r(n,e)),{borderSize:n.borderSize*e}):{}};export const roundedStyleAttrs=t=>{const e=t;return"text"===e.type?roundedFontSizeAttrs(e,e.fontSize):"figure"===e.type?Object.assign(Object.assign({},n(e)),{strokeWidth:roundEnabledPx(e.strokeWidth)}):s.includes(e.type)?Object.assign(Object.assign({},n(e)),{borderSize:roundEnabledPx(e.borderSize)}):{}};export const roundedTextDecorationAttrs=e=>{const o=roundedFontSizeAttrs(e,e.fontSize),{fontSize:r}=o;return t(o,["fontSize"])};
@@ -23,3 +23,8 @@ export declare function stripInlineFontSizes(html: string): string;
23
23
  export declare function stripInlineFontFamilies(html: string): string;
24
24
  export declare function hasMultipleDistinctInlineFontSizes(html: string): boolean;
25
25
  export declare function listEffectiveFontFamilies(html: string, baseFamily: string): string[];
26
+ export declare function listInlineTextColors(html: string): Array<{
27
+ index: number;
28
+ color: string;
29
+ }>;
30
+ export declare function setInlineTextColor(html: string, indices: number[], color: string): string;
@@ -1 +1 @@
1
- export*from"@polotno/core/rich-text-html";import{parseHtmlRoot as t,cleanupInlineWrappers as e,extractFontFamiliesFromHtml as r,normalizeRichTextHtml as o,scaleRichTextFontSizesInHtml as n}from"@polotno/core/rich-text-html";import{containsCmykColor as i,isCmykColor as l,toDisplayColor as s}from"@polotno/core/color";import{buildStyleAttribute as c,parseStyleAttribute as u}from"@polotno/core/style-attribute";import{sameColors as f}from"@polotno/core/svg";import{isGradient as a,parseColor as p}from"@polotno/core/gradient";import{LRUCache as y}from"./lru-cache.js";const m="data-native-";export function nativeColorAttribute(t){return m+t}const d=t=>l(t)||a(t)&&i(t);export function readNativeColor(t,e){var r;const o=t.getAttribute(nativeColorAttribute(e));if(null!==o){const n=null===(r=t.style)||void 0===r?void 0:r.getPropertyValue(e);return d(o)&&n&&function(t,e,r){const o=s(r);if(!a(o)){return f(e,o)}const n=function(t,e){if("undefined"==typeof document){return null}const r=document.createElement("span");return r.style.setProperty(t,e),r.style.getPropertyValue(t)||null}(t,o);if(null!==n){return n===e}if(!a(e)){return!1}const i=p(e),l=p(o);return i.rotation===l.rotation&&i.stops.length===l.stops.length&&i.stops.every((t,e)=>Math.abs(t.offset-l.stops[e].offset)<.001&&f(t.color,l.stops[e].color))}(e,n,o)?o:""}const n=u(t.getAttribute("style"))[e];return n&&d(n)?n:""}export function detachNativeColorsInHtml(e){if(!i(e)){return e}const r=t(e);return r?(function(t){for(const e of Array.from(t.querySelectorAll("[style]"))){const t=e.getAttribute("style");if(!i(t)){continue}const r=u(t);for(const[o,n]of Object.entries(r)){d(n)&&(e.setAttribute(nativeColorAttribute(o),n),r[o]=s(n))}e.setAttribute("style",c(r))}}(r),r.innerHTML):e}export function attachNativeColorsInHtml(r){if(!r||!r.includes(m)){return r}const o=t(r);if(!o){return r}let n=!1;for(const t of Array.from(o.querySelectorAll("*"))){for(const{name:e}of Array.from(t.attributes)){if(!e.startsWith(m)){continue}const r=e.slice(12),o=readNativeColor(t,r);if(t.removeAttribute(e),!o){n=!0;continue}const i=u(t.getAttribute("style"));i[r]=o,t.setAttribute("style",c(i))}}return n&&e(o),o.innerHTML}function b(t,e){if(!i(t)){return e(t)}const r=detachNativeColorsInHtml(t),o=e(r);return o===r?t:attachNativeColorsInHtml(o)}export function scaleRichTextFontSizesInHtml(t,e){return b(t,t=>n(t,e))}const v=new y(500);export function htmlInflatesMinContentWidth(e){if(!e||!e.includes("<")){return!1}let r=v.get(e);if(void 0===r){r=!1;const o=t(e);if(o){if(o.querySelector("ol, ul")){r=!0}else{for(const t of o.querySelectorAll("[style]")){if(t.style.fontSize||t.style.letterSpacing){r=!0;break}}}}v.set(e,r)}return r}export function quillHtmlToModelText(t,e){return attachNativeColorsInHtml(o(function(t){const e=(t||"").trim();if("<p><br></p>"===e||"<p></p>"===e){return""}if(e.startsWith("<p>")&&e.endsWith("</p>")){const t=e.slice(3,-4);if(!/(<\/?(p|div|h[1-6]|ul|ol|li|table|thead|tbody|tr|td|blockquote)\b)/i.test(t)){return t}}return t}(t),e))}export function shrinkParagraphStrutForRaster(e){var r;if(!e||!e.includes("<p")){return e}const o=t(e);if(!o){return e}for(const t of Array.from(o.querySelectorAll("p"))){let e=!1;const n=[],i=o.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT);let l=i.nextNode();for(;l;){if((l.textContent||"").length>0){let o=l.parentElement,i=null;for(;o&&o!==t;){const t=null===(r=o.style)||void 0===r?void 0:r.fontSize;if(t){const e=parseFloat(t);if(!Number.isNaN(e)){i=e;break}}o=o.parentElement}if(null==i){e=!0;break}n.push(i)}l=i.nextNode()}!e&&n.length>0&&(t.style.fontSize=`${Math.min(...n)}px`)}return o.innerHTML}const h={bold:["STRONG","B"],italic:["EM","I"],underline:["U"],strike:["S","DEL"]};export function isClipGradientSpan(t){return!!(null==t?void 0:t.style)&&("text"===(t.style.getPropertyValue("-webkit-background-clip")||t.style.getPropertyValue("background-clip"))&&(t.style.backgroundImage.includes("gradient")||!!readNativeColor(t,"background-image")))}const g={bold:t=>t.style.removeProperty("font-weight"),italic:t=>t.style.removeProperty("font-style"),color:t=>{!function(t){if(isClipGradientSpan(t)){for(const e of["background-image","background-size","-webkit-background-clip","background-clip","-webkit-text-fill-color"]){t.style.removeProperty(e)}}}(t),t.style.removeProperty("color")},underline:t=>{const e=t.style.textDecoration.replace(/\bunderline\b/g,"").trim();e?t.style.textDecoration=e:t.style.removeProperty("text-decoration")},strike:t=>{const e=t.style.textDecoration.replace(/\bline-through\b/g,"").trim();e?t.style.textDecoration=e:t.style.removeProperty("text-decoration")},"text-transform":t=>t.style.removeProperty("text-transform")};export function stripInlineFormat(r,o){return b(r,r=>function(r,o){var n,i;if(!r||!r.includes("<")){return r}const l=t(r);if(!l){return r}const s=h[o]||[],c=g[o];for(const t of s){let e;for(;e=l.querySelector(t);){const t=e.parentNode;c&&c(e);const r=null===(n=e.getAttribute("style"))||void 0===n?void 0:n.trim();if(r){const o=l.ownerDocument.createElement("span");o.setAttribute("style",r);for(const{name:t,value:r}of Array.from(e.attributes)){t.startsWith(m)&&o.setAttribute(t,r)}for(;e.firstChild;){o.appendChild(e.firstChild)}t.insertBefore(o,e)}else{for(;e.firstChild;){t.insertBefore(e.firstChild,e)}}t.removeChild(e)}}if(c){for(const t of Array.from(l.querySelectorAll("[style]"))){c(t),(null===(i=t.getAttribute("style"))||void 0===i?void 0:i.trim())||t.removeAttribute("style")}}return e(l),l.innerHTML}(r,o))}const A=Symbol("unset");export function isQuillFormatMixed(t,e){var r;let o=A;for(const n of t.ops){if("string"!=typeof n.insert||"\n"===n.insert){continue}const t=null===(r=n.attributes)||void 0===r?void 0:r[e];if(o===A){o=t}else if(t!==o){return!0}}return!1}export function stripInlineFontSizes(t){return b(t,x)}function x(r){var o;if(!r||!r.includes("font-size")){return r}const n=t(r);if(!n){return r}const i=n.querySelectorAll("[style]");for(let t=0;t<i.length;t++){const e=i[t];e.style.fontSize&&(e.style.removeProperty("font-size"),(null===(o=e.getAttribute("style"))||void 0===o?void 0:o.trim())||e.removeAttribute("style"))}return e(n),n.innerHTML}export function stripInlineFontFamilies(t){return b(t,S)}function S(r){var o;if(!r||!r.includes("font-family")&&!r.includes("ql-font-")){return r}const n=t(r);if(!n){return r}for(const t of Array.from(n.querySelectorAll("[style]"))){t.style.fontFamily&&(t.style.removeProperty("font-family"),(null===(o=t.getAttribute("style"))||void 0===o?void 0:o.trim())||t.removeAttribute("style"))}for(const t of Array.from(n.querySelectorAll("[class]"))){const e=t.getAttribute("class")||"",r=e.split(/\s+/).filter(t=>t&&!t.startsWith("ql-font-"));r.length!==e.split(/\s+/).filter(Boolean).length&&(r.length?t.setAttribute("class",r.join(" ")):t.removeAttribute("class"))}return e(n),n.innerHTML}export function hasMultipleDistinctInlineFontSizes(e){if(!e||!e.includes("<")){return!1}const r=t(e);if(!r){return!1}const o=new Set;for(const t of r.querySelectorAll("[style]")){const e=t.style.fontSize;if(e){const t=e.match(/^(\d+(?:\.\d+)?)px$/i);if(t&&(o.add(parseFloat(t[1])),o.size>1)){return!0}}}return!1}export function listEffectiveFontFamilies(t,e){const o=[];e&&o.push(e),o.push(...r(t||""));const n=new Set,i=[];for(const r of o){n.has(r)||(n.add(r),i.push(r))}return i.sort((t,e)=>t.localeCompare(e,void 0,{sensitivity:"base"})),i}
1
+ export*from"@polotno/core/rich-text-html";import{parseHtmlRoot as t,cleanupInlineWrappers as e,extractFontFamiliesFromHtml as r,normalizeRichTextHtml as o,scaleRichTextFontSizesInHtml as n}from"@polotno/core/rich-text-html";import{containsCmykColor as i,isCmykColor as l,toDisplayColor as s}from"@polotno/core/color";import{buildStyleAttribute as c,mapStyleAttributes as u,parseStyleAttribute as f,stripPriority as a,styleAttributeRanges as p}from"@polotno/core/style-attribute";import{sameColors as y}from"@polotno/core/svg";import{isGradient as d,parseColor as m}from"@polotno/core/gradient";import{LRUCache as b}from"./lru-cache.js";const v="data-native-";export function nativeColorAttribute(t){return v+t}const h=t=>l(t)||d(t)&&i(t);export function readNativeColor(t,e){var r;const o=t.getAttribute(nativeColorAttribute(e));if(null!==o){const n=null===(r=t.style)||void 0===r?void 0:r.getPropertyValue(e);return h(o)&&n&&function(t,e,r){const o=s(r);if(!d(o)){return y(e,o)}const n=function(t,e){if("undefined"==typeof document){return null}const r=document.createElement("span");return r.style.setProperty(t,e),r.style.getPropertyValue(t)||null}(t,o);if(null!==n){return n===e}if(!d(e)){return!1}const i=m(e),l=m(o);return i.rotation===l.rotation&&i.stops.length===l.stops.length&&i.stops.every((t,e)=>Math.abs(t.offset-l.stops[e].offset)<.001&&y(t.color,l.stops[e].color))}(e,n,o)?o:""}const n=f(t.getAttribute("style"))[e];return n&&h(n)?n:""}export function detachNativeColorsInHtml(e){if(!i(e)){return e}const r=t(e);return r?(function(t){for(const e of Array.from(t.querySelectorAll("[style]"))){const t=e.getAttribute("style");if(!i(t)){continue}const r=f(t);for(const[o,n]of Object.entries(r)){h(n)&&(e.setAttribute(nativeColorAttribute(o),n),r[o]=s(n))}e.setAttribute("style",c(r))}}(r),r.innerHTML):e}export function attachNativeColorsInHtml(r){if(!r||!r.includes(v)){return r}const o=t(r);if(!o){return r}let n=!1;for(const t of Array.from(o.querySelectorAll("*"))){for(const{name:e}of Array.from(t.attributes)){if(!e.startsWith(v)){continue}const r=e.slice(12),o=readNativeColor(t,r);if(t.removeAttribute(e),!o){n=!0;continue}const i=f(t.getAttribute("style"));i[r]=o,t.setAttribute("style",c(i))}}return n&&e(o),o.innerHTML}function g(t,e){if(!i(t)){return e(t)}const r=detachNativeColorsInHtml(t),o=e(r);return o===r?t:attachNativeColorsInHtml(o)}export function scaleRichTextFontSizesInHtml(t,e){return g(t,t=>n(t,e))}const x=new b(500);export function htmlInflatesMinContentWidth(e){if(!e||!e.includes("<")){return!1}let r=x.get(e);if(void 0===r){r=!1;const o=t(e);if(o){if(o.querySelector("ol, ul")){r=!0}else{for(const t of o.querySelectorAll("[style]")){if(t.style.fontSize||t.style.letterSpacing){r=!0;break}}}}x.set(e,r)}return r}export function quillHtmlToModelText(t,e){return attachNativeColorsInHtml(o(function(t){const e=(t||"").trim();if("<p><br></p>"===e||"<p></p>"===e){return""}if(e.startsWith("<p>")&&e.endsWith("</p>")){const t=e.slice(3,-4);if(!/(<\/?(p|div|h[1-6]|ul|ol|li|table|thead|tbody|tr|td|blockquote)\b)/i.test(t)){return t}}return t}(t),e))}export function shrinkParagraphStrutForRaster(e){var r;if(!e||!e.includes("<p")){return e}const o=t(e);if(!o){return e}for(const t of Array.from(o.querySelectorAll("p"))){let e=!1;const n=[],i=o.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT);let l=i.nextNode();for(;l;){if((l.textContent||"").length>0){let o=l.parentElement,i=null;for(;o&&o!==t;){const t=null===(r=o.style)||void 0===r?void 0:r.fontSize;if(t){const e=parseFloat(t);if(!Number.isNaN(e)){i=e;break}}o=o.parentElement}if(null==i){e=!0;break}n.push(i)}l=i.nextNode()}!e&&n.length>0&&(t.style.fontSize=`${Math.min(...n)}px`)}return o.innerHTML}const A={bold:["STRONG","B"],italic:["EM","I"],underline:["U"],strike:["S","DEL"]};export function isClipGradientSpan(t){return!!(null==t?void 0:t.style)&&("text"===(t.style.getPropertyValue("-webkit-background-clip")||t.style.getPropertyValue("background-clip"))&&(t.style.backgroundImage.includes("gradient")||!!readNativeColor(t,"background-image")))}const S={bold:t=>t.style.removeProperty("font-weight"),italic:t=>t.style.removeProperty("font-style"),color:t=>{!function(t){if(isClipGradientSpan(t)){for(const e of["background-image","background-size","-webkit-background-clip","background-clip","-webkit-text-fill-color"]){t.style.removeProperty(e)}}}(t),t.style.removeProperty("color")},underline:t=>{const e=t.style.textDecoration.replace(/\bunderline\b/g,"").trim();e?t.style.textDecoration=e:t.style.removeProperty("text-decoration")},strike:t=>{const e=t.style.textDecoration.replace(/\bline-through\b/g,"").trim();e?t.style.textDecoration=e:t.style.removeProperty("text-decoration")},"text-transform":t=>t.style.removeProperty("text-transform")};export function stripInlineFormat(r,o){return g(r,r=>function(r,o){var n,i;if(!r||!r.includes("<")){return r}const l=t(r);if(!l){return r}const s=A[o]||[],c=S[o];for(const t of s){let e;for(;e=l.querySelector(t);){const t=e.parentNode;c&&c(e);const r=null===(n=e.getAttribute("style"))||void 0===n?void 0:n.trim();if(r){const o=l.ownerDocument.createElement("span");o.setAttribute("style",r);for(const{name:t,value:r}of Array.from(e.attributes)){t.startsWith(v)&&o.setAttribute(t,r)}for(;e.firstChild;){o.appendChild(e.firstChild)}t.insertBefore(o,e)}else{for(;e.firstChild;){t.insertBefore(e.firstChild,e)}}t.removeChild(e)}}if(c){for(const t of Array.from(l.querySelectorAll("[style]"))){c(t),(null===(i=t.getAttribute("style"))||void 0===i?void 0:i.trim())||t.removeAttribute("style")}}return e(l),l.innerHTML}(r,o))}const C=Symbol("unset");export function isQuillFormatMixed(t,e){var r;let o=C;for(const n of t.ops){if("string"!=typeof n.insert||"\n"===n.insert){continue}const t=null===(r=n.attributes)||void 0===r?void 0:r[e];if(o===C){o=t}else if(t!==o){return!0}}return!1}export function stripInlineFontSizes(t){return g(t,k)}function k(r){var o;if(!r||!r.includes("font-size")){return r}const n=t(r);if(!n){return r}const i=n.querySelectorAll("[style]");for(let t=0;t<i.length;t++){const e=i[t];e.style.fontSize&&(e.style.removeProperty("font-size"),(null===(o=e.getAttribute("style"))||void 0===o?void 0:o.trim())||e.removeAttribute("style"))}return e(n),n.innerHTML}export function stripInlineFontFamilies(t){return g(t,I)}function I(r){var o;if(!r||!r.includes("font-family")&&!r.includes("ql-font-")){return r}const n=t(r);if(!n){return r}for(const t of Array.from(n.querySelectorAll("[style]"))){t.style.fontFamily&&(t.style.removeProperty("font-family"),(null===(o=t.getAttribute("style"))||void 0===o?void 0:o.trim())||t.removeAttribute("style"))}for(const t of Array.from(n.querySelectorAll("[class]"))){const e=t.getAttribute("class")||"",r=e.split(/\s+/).filter(t=>t&&!t.startsWith("ql-font-"));r.length!==e.split(/\s+/).filter(Boolean).length&&(r.length?t.setAttribute("class",r.join(" ")):t.removeAttribute("class"))}return e(n),n.innerHTML}export function hasMultipleDistinctInlineFontSizes(e){if(!e||!e.includes("<")){return!1}const r=t(e);if(!r){return!1}const o=new Set;for(const t of r.querySelectorAll("[style]")){const e=t.style.fontSize;if(e){const t=e.match(/^(\d+(?:\.\d+)?)px$/i);if(t&&(o.add(parseFloat(t[1])),o.size>1)){return!0}}}return!1}export function listEffectiveFontFamilies(t,e){const o=[];e&&o.push(e),o.push(...r(t||""));const n=new Set,i=[];for(const r of o){n.has(r)||(n.add(r),i.push(r))}return i.sort((t,e)=>t.localeCompare(e,void 0,{sensitivity:"base"})),i}const N=t=>t.color&&!(t=>"text"===(t["-webkit-background-clip"]||t["background-clip"])&&!!t["background-image"])(t)?a(t.color):null;export function listInlineTextColors(t){const e=[];return p(t||"").forEach(([r,o],n)=>{const i=N(f(t.slice(r,o)));i&&e.push({index:n,color:i})}),e}export function setInlineTextColor(t,e,r){let o=-1;return u(t||"",t=>{o+=1;const n=f(t);return e.includes(o)&&N(n)?(n.color=r,c(n)):t})}
@@ -0,0 +1,15 @@
1
+ import type { ShapeType } from '../model/shape-model.js';
2
+ import type { SVGElementType } from '../model/svg-model.js';
3
+ export declare const getColorsReplace: (element: SVGElementType) => Map<string, string>;
4
+ export declare const getSvgColor: (colorsReplace: Map<string, string>, color: string) => string;
5
+ export declare const replaceSvgColor: (element: SVGElementType, original: string, fill: string) => void;
6
+ export type ColorSlot = {
7
+ apply: (color: string) => void;
8
+ gradient: boolean;
9
+ };
10
+ export type SelectionColor = {
11
+ color: string;
12
+ slots: ColorSlot[];
13
+ };
14
+ export declare const colorKey: (color: string) => string;
15
+ export declare const collectSelectionColors: (shapes: ShapeType[], svgColors: (src: string) => string[] | undefined) => SelectionColor[];
@@ -0,0 +1 @@
1
+ import o from"konva";import*as t from"@polotno/core/svg";import{isGradient as e}from"@polotno/core/gradient";import{containsCmykColor as r,formatCmykColor as l,parseCmykColor as s}from"@polotno/core/color";import{listInlineTextColors as c,setInlineTextColor as n}from"./rich-text-html.js";const p=(o,e)=>Array.from(o.keys()).find(o=>t.sameColors(o,e));export const getColorsReplace=o=>o.colorsReplace;export const getSvgColor=(o,t)=>{const e=p(o,t);return o.get(e||"")||t};export const replaceSvgColor=(o,t,e)=>{const r=p(getColorsReplace(o),t)||t;o.replaceColor(r,e)};export const colorKey=t=>{if(e(t)){return t}if(r(t)){const o=s(t);return o?l(o):t}const c=o.Util.colorToRGBA(t);return c?`${c.r},${c.g},${c.b},${c.a}`:t};const i=["image","svg","gif","video","text"];export const collectSelectionColors=(o,t)=>{const e=new Map,r=(o,t,r=!0)=>{if(!o){return}const l=colorKey(o),s=e.get(l)||{color:o,slots:[]};s.slots.push({apply:t,gradient:r}),e.set(l,s)},l=(o,t,e=!0)=>{r(o[t],e=>o.set({[t]:e}),e)};return o.forEach(o=>{var e;if(o.styleEditable){if("figure"!==o.type&&"text"!==o.type||(l(o,"fill"),o.strokeWidth>0&&l(o,"stroke")),"line"===o.type&&l(o,"color",!1),i.includes(o.type)&&o.borderSize>0&&l(o,"borderColor","text"!==o.type),"text"===o.type){const t=o;t.backgroundEnabled&&l(o,"backgroundColor",!1),c(t.text).forEach(({index:o,color:e})=>{r(e,e=>t.set({text:n(t.text,[o],e)}),!1)})}if("svg"===o.type){const l=o;if(l.maskSrc){return}null===(e=t(l.src))||void 0===e||e.forEach(o=>{r(getSvgColor(getColorsReplace(l),o),t=>replaceSvgColor(l,o,t))})}}}),Array.from(e.values()).sort((o,t)=>t.slots.length-o.slots.length)};
@@ -0,0 +1,19 @@
1
+ import type { StoreType } from '../model/store.js';
2
+ import type { ShapeType } from '../model/shape-model.js';
3
+ export declare const isAxisAligned: (rotation: number) => boolean;
4
+ export declare const canStretchAxis: (element: ShapeType, axis: "x" | "y", boxRotation: number) => boolean;
5
+ export declare const leafMinSize: (element: ShapeType, axis: "x" | "y", isEdgeDrag: boolean, startSize: number) => number;
6
+ type Box = {
7
+ x: number;
8
+ y: number;
9
+ width: number;
10
+ height: number;
11
+ };
12
+ export declare const getSelectionBox: (store: StoreType) => Box | null;
13
+ export declare const canResizeSelection: (store: StoreType) => boolean;
14
+ export declare const canMoveSelection: (store: StoreType) => boolean;
15
+ export declare const resizeSelection: (store: StoreType, axis: "x" | "y", size: number) => void;
16
+ export declare const moveSelection: (store: StoreType, axis: "x" | "y", value: number) => void;
17
+ export declare const canFitSelectionToPage: (store: StoreType) => boolean;
18
+ export declare const fitSelectionToPage: (store: StoreType) => void;
19
+ export {};
@@ -0,0 +1 @@
1
+ var e=this&&this.__rest||function(e,t){var i={};for(var n in e){Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n])}if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++){t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(i[n[o]]=e[n[o]])}}return i};import{getTotalClientRect as t}from"./math.js";import{roundedGeometryAttrs as i,roundedGeometryPx as n,roundedStyleAttrs as o,scaledFontSizeBounds as s,scaledStyleAttrs as r,textMinResizeWidth as c,textMinWidthIsMeasured as h}from"./px.js";import{textResizeFloorFontSize as a}from"./text-sizing.js";export const isAxisAligned=e=>{const t=(e%180+180)%180;return t<.1||180-t<.1};export const canStretchAxis=(e,t,i)=>{if(!isAxisAligned(e.rotation-i)){return!1}switch(e.type){case"text":return"x"===t&&!h(e);case"figure":case"video":case"table":return!0;case"image":case"svg":case"gif":return!e.keepRatio;default:return!1}};export const leafMinSize=(e,t,i,n)=>{if("table"===e.type){const i=e;return"x"===t?i.minWidth:i.minHeight}return"text"===e.type&&"x"===t&&i?c(n,a(e)):1};const l=["image","svg","gif","video"],x=e=>{const[t]=e.selectedElements;return 1===e.selectedElements.length&&"group"!==t.type?t:null};export const getSelectionBox=e=>{const i=x(e);if(i){const{x:e,y:t,width:n,height:o}=i;return{x:e,y:t,width:n,height:o}}const n=e.selectedShapes;return n.length?t(n):null};const g=e=>!e.pendingEdit;export const canResizeSelection=e=>{const t=e.selectedShapes;return t.length>0&&t.every(e=>e.resizable&&g(e))};export const canMoveSelection=e=>{const t=e.selectedShapes;return t.length>0&&t.every(e=>e.draggable&&g(e))};const p=(e,t,i)=>{e.set(t),e.setHeightRedistribute(i),e.set({x:n(e.x),y:n(e.y),width:n(e.width)}),e._resetBaseRowHeights()},d=(e,t,n)=>{const c=n.x+(e.x-n.x)*t,h=n.y+(e.y-n.y)*t;if("table"===e.type){return void p(e,{x:c,y:h,width:e.width*t},e.height*t)}const{fontSize:a,minFontSize:l,maxFontSize:x}=e;e.set(Object.assign({x:c,y:h,width:e.width*t,height:e.height*t},r(e,t))),e.set(Object.assign(Object.assign({},i(e)),o(e))),"text"===e.type&&e.set(s({minFontSize:l,maxFontSize:x},e.fontSize/a,!0))};export const resizeSelection=(t,n,o)=>{const s=getSelectionBox(t),r="x"===n?null==s?void 0:s.width:null==s?void 0:s.height;if(!(s&&r&&o>0&&canResizeSelection(t))){return}const c=t.selectedShapes,h=x(t),a=c.every(e=>!l.includes(e.type))&&(h?((e,t)=>"text"===e.type?"x"===t&&!e.curveEnabled:canStretchAxis(e,t,e.rotation))(h,n):c.every(e=>canStretchAxis(e,n,0))),g=Math.max(...c.flatMap(e=>(a?[n]:["x","y"]).map(t=>{const i="x"===t?e.width:e.height,n=leafMinSize(e,t,a,i);return i>=n?n/i:0}))),y=Math.max(o/r,g),u={x:s.x,y:s.y};t.history.transaction(()=>{c.forEach(t=>{a?((t,n,o,s)=>{const[r,c]="x"===n?["x","width"]:["y","height"],h={[r]:s[r]+(t[r]-s[r])*o,[c]:t[c]*o};if("table"===t.type){const{height:i=t.height}=h,n=e(h,["height"]);return void p(t,n,i)}t.set(h),t.set(i(t))})(t,n,y,u):d(t,y,u)})})};const y=(e,t,i)=>{e.forEach(e=>{e.set({x:n(e.x+t),y:n(e.y+i)})})};export const moveSelection=(e,t,i)=>{const n=getSelectionBox(e);if(!n||!Number.isFinite(i)||!canMoveSelection(e)){return}const o=i-("x"===t?n.x:n.y);e.history.transaction(()=>{y(e.selectedShapes,"x"===t?o:0,"y"===t?o:0)})};export const canFitSelectionToPage=e=>canResizeSelection(e)&&canMoveSelection(e);export const fitSelectionToPage=e=>{var i;const n=e.selectedShapes,o=null===(i=n[0])||void 0===i?void 0:i.page;if(!o||!canFitSelectionToPage(e)){return}const s=t(n);if(!s.width||!s.height){return}const r=Math.min(o.computedWidth/s.width,o.computedHeight/s.height);e.history.transaction(()=>{n.forEach(e=>d(e,r,{x:s.x,y:s.y}));const e=t(n);y(n,(o.computedWidth-e.width)/2-e.x,(o.computedHeight-e.height)/2-e.y)})};
@@ -0,0 +1,3 @@
1
+ import type { StoreType } from '../model/store.js';
2
+ export declare function getParentGroupId(store: Pick<StoreType, 'getElementById'>, id: string): string | null;
3
+ export declare function withoutDescendants(ids: ReadonlyArray<string>, getParentId: (id: string) => string | null): string[];
@@ -0,0 +1 @@
1
+ export function getParentGroupId(t,e){var n;const r=null===(n=t.getElementById(e))||void 0===n?void 0:n.parent;return r&&"group"===r.type?r.id:null}export function withoutDescendants(t,e){const n=new Set(t);return t.filter(t=>{for(let r=e(t);null!==r;r=e(r)){if(n.has(r)){return!1}}return!0})}
@@ -0,0 +1,5 @@
1
+ import { type TextSizing, type TextSizingElement } from '@polotno/core/text-sizing';
2
+ import type { TextOverflow } from '@polotno/core/text-html';
3
+ export declare const textOverflowOf: (element: Pick<TextSizingElement, "textOverflow">) => TextOverflow;
4
+ export declare function editorTextSizing(element: TextSizingElement): TextSizing;
5
+ export declare function textResizeFloorFontSize(element: TextSizingElement): number;
@@ -0,0 +1 @@
1
+ import{resolveTextOverflow as t,resolveTextSizing as e}from"@polotno/core/text-sizing";import{flags as o}from"./flags.js";export const textOverflowOf=e=>t(e,o.textOverflow);export function editorTextSizing(t){return e(t,{textOverflow:o.textOverflow,textSplitAllowed:o.textSplitAllowed})}export function textResizeFloorFontSize(t){const{fit:e}=editorTextSizing(t);return"fit"===textOverflowOf(t)&&"fit"===e.mode?e.min:t.fontSize}
@@ -1 +1,2 @@
1
1
  export declare const useSvgColors: (src: string) => string[];
2
+ export declare const useSvgColorsMap: (srcs: string[]) => Map<string, string[]>;
@@ -1 +1 @@
1
- import t from"react";import{urlToString as o,getColors as r}from"@polotno/core/svg";export const useSvgColors=e=>{const[s,c]=t.useState([]);return t.useEffect(()=>{let t=!1;return(async()=>{c([]);const s=await o(e),n=r(s);t||c(n)})(),()=>{t=!0}},[e]),s};
1
+ import o from"react";import{urlToString as r,getColors as t}from"@polotno/core/svg";const e=[];export const useSvgColors=o=>{var r;return null!==(r=useSvgColorsMap([o]).get(o))&&void 0!==r?r:e};export const useSvgColorsMap=e=>{const[n,s]=o.useState(new Map),l=Array.from(new Set(e)).sort().join("\n");return o.useEffect(()=>{let o=!1;const e=l?l.split("\n"):[];return Promise.all(e.map(async o=>{try{return[o,t(await r(o))]}catch(e){return console.warn("polotno: failed to read the colors of an SVG",e),null}})).then(r=>{o||s(new Map(r.filter(o=>null!==o)))}),()=>{o=!0}},[l]),n};
@@ -1 +1 @@
1
- import*as e from"mobx";import{getAPI as o}from"./api.js";import{removeBackgroundState as t}from"./flags.js";const n=e.observable({value:!1}),a=e.observable({value:"v1"});export const ___=()=>a.value;const i=e.observable({value:0});export const ____=()=>i.value;export const isCreditVisible=()=>n.value;const r=e.action(()=>{n.value=!0});let s="";export const getKey=()=>s||"";export const setKey=e=>{s=e||""};let l="undefined"!=typeof window?window.location.origin:"";const c="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,d="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===l&&c&&(l="headless"),"file://"===l&&d&&(l="electron");const u=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${l}" here: https://polotno.com/cabinet`;let p=fetch;export const __=e=>{p=e};export async function isKeyPaid(n){for(let s=0;s<5;s++){try{const r=await p(o()+"/validate-key",{method:"POST",body:JSON.stringify({key:n,site:location.host,skdVersion:"4.15.3"})});if(e.runInAction(()=>{a.value=r.headers.get("x-api-version")||""}),!n){return console.error("Polotno API is initialized without API key. It may lead to unexpected behavior and stop working. Please create API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1}),!1}if(200!==r.status){await new Promise(e=>setTimeout(e,3e3));continue}const s=await r.json();return s.is_valid||(console.error("Polotno API key is not valid. Please get new API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1})),s.is_paid||(console.log("%cPolotno Free Version. For development usage only. https://polotno.com/","background: rgb(0, 161, 255); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{0===i.value&&(i.value=2)})),s.is_domain_valid||console.log(u,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{t.defaultEnabled=s.remove_background_enabled}),s.is_paid||!1}catch(r){await new Promise(e=>setTimeout(e,3e3))}}return console.error("Can not validate Polotno API key. Please report to anton@polotno.com immediately."),!0}export async function validateKey(e){await isKeyPaid(s)&&!e||r()}
1
+ import*as e from"mobx";import{getAPI as o}from"./api.js";import{removeBackgroundState as t}from"./flags.js";const n=e.observable({value:!1}),a=e.observable({value:"v1"});export const ___=()=>a.value;const i=e.observable({value:0});export const ____=()=>i.value;export const isCreditVisible=()=>n.value;const r=e.action(()=>{n.value=!0});let s="";export const getKey=()=>s||"";export const setKey=e=>{s=e||""};let l="undefined"!=typeof window?window.location.origin:"";const c="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,d="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===l&&c&&(l="headless"),"file://"===l&&d&&(l="electron");const u=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${l}" here: https://polotno.com/cabinet`;let p=fetch;export const __=e=>{p=e};export async function isKeyPaid(n){for(let s=0;s<5;s++){try{const r=await p(o()+"/validate-key",{method:"POST",body:JSON.stringify({key:n,site:location.host,skdVersion:"4.16.0"})});if(e.runInAction(()=>{a.value=r.headers.get("x-api-version")||""}),!n){return console.error("Polotno API is initialized without API key. It may lead to unexpected behavior and stop working. Please create API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1}),!1}if(200!==r.status){await new Promise(e=>setTimeout(e,3e3));continue}const s=await r.json();return s.is_valid||(console.error("Polotno API key is not valid. Please get new API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1})),s.is_paid||(console.log("%cPolotno Free Version. For development usage only. https://polotno.com/","background: rgb(0, 161, 255); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{0===i.value&&(i.value=2)})),s.is_domain_valid||console.log(u,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{t.defaultEnabled=s.remove_background_enabled}),s.is_paid||!1}catch(r){await new Promise(e=>setTimeout(e,3e3))}}return console.error("Can not validate Polotno API key. Please report to anton@polotno.com immediately."),!0}export async function validateKey(e){await isKeyPaid(s)&&!e||r()}
@@ -1,5 +0,0 @@
1
- import { TextElementType } from '../../model/text-model.js';
2
- import { GetHtmlOptions } from '@polotno/core/text-html';
3
- import { type FitResult, type MeasureHeight } from '@polotno/core/fit-text';
4
- export type { FitResult, MeasureHeight };
5
- export declare function findFitFontSize(element: TextElementType, getHtmlOptions: GetHtmlOptions, measureHeight?: MeasureHeight): FitResult;
@@ -1 +0,0 @@
1
- import{findFitFontSize as t}from"@polotno/core/fit-text";import{flags as e}from"../../utils/flags.js";export function findFitFontSize(o,i,l){return t(o.toJSON(),{getHtmlOptions:Object.assign({textOverflow:e.textOverflow},i),measureHeight:l,textSplitAllowed:e.textSplitAllowed})}