polotno 3.21.0 → 3.22.1

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 (99) hide show
  1. package/THIRD_PARTY_NOTICES.md +4 -4
  2. package/blueprint/side-panel/select-video.d.ts +74 -0
  3. package/blueprint.polotno.css +90 -180
  4. package/canvas/crop-overlay.d.ts +20 -8
  5. package/canvas/crop-overlay.js +1 -1
  6. package/canvas/element.js +1 -1
  7. package/canvas/fade-overlay.js +1 -1
  8. package/canvas/figure-element.js +1 -1
  9. package/canvas/gif-element.js +1 -1
  10. package/canvas/image-element.js +1 -1
  11. package/canvas/lottie-element.js +1 -1
  12. package/canvas/media-resize.js +1 -1
  13. package/canvas/page.js +1 -1
  14. package/canvas/quill-font-formats.d.ts +1 -1
  15. package/canvas/quill-font-formats.js +1 -1
  16. package/canvas/render-tag-element.js +1 -1
  17. package/canvas/rich-editor.js +5 -7
  18. package/canvas/text-element/render-tag-source.d.ts +5 -0
  19. package/canvas/text-element/render-tag-source.js +1 -1
  20. package/canvas/tooltip.js +1 -1
  21. package/canvas/use-mediabunny-video.js +1 -1
  22. package/canvas/video-element.js +1 -1
  23. package/canvas/workspace-canvas.js +1 -1
  24. package/icons/registry.d.ts +7 -0
  25. package/icons/registry.js +1 -1
  26. package/image-tools/host.d.ts +3 -0
  27. package/image-tools/sessions.js +1 -1
  28. package/image-tools/target.d.ts +5 -0
  29. package/image-tools/target.js +1 -1
  30. package/image-tools/types.d.ts +5 -0
  31. package/model/crop-mode.d.ts +3 -0
  32. package/model/crop-mode.js +1 -1
  33. package/model/figure-model.d.ts +29 -0
  34. package/model/gif-model.d.ts +40 -0
  35. package/model/group-model.d.ts +302 -1
  36. package/model/group-model.js +1 -1
  37. package/model/history.js +1 -1
  38. package/model/image-model.d.ts +40 -0
  39. package/model/image-model.js +1 -1
  40. package/model/line-model.d.ts +29 -0
  41. package/model/lottie-model.d.ts +40 -0
  42. package/model/node-model.d.ts +32 -0
  43. package/model/node-model.js +1 -1
  44. package/model/page-model.d.ts +906 -3
  45. package/model/shape-model.d.ts +29 -0
  46. package/model/shape-model.js +1 -1
  47. package/model/store.d.ts +61 -2
  48. package/model/store.js +1 -1
  49. package/model/svg-model.d.ts +27 -0
  50. package/model/table-model.d.ts +37 -1
  51. package/model/table-model.js +1 -1
  52. package/model/text-model.d.ts +27 -0
  53. package/model/video-model.d.ts +40 -0
  54. package/package.json +14 -14
  55. package/polotno.bundle.js +207 -208
  56. package/primitives/autocomplete.d.ts +11 -0
  57. package/primitives/autocomplete.js +1 -0
  58. package/primitives/select.js +1 -1
  59. package/side-panel/index.d.ts +1 -0
  60. package/side-panel/index.js +1 -1
  61. package/side-panel/layers-panel.js +1 -1
  62. package/side-panel/select-image.js +1 -1
  63. package/side-panel/select-video.d.ts +74 -0
  64. package/side-panel/select-video.js +1 -1
  65. package/side-panel/side-panel.d.ts +1 -0
  66. package/side-panel/side-panel.js +1 -1
  67. package/side-panel/variables-panel.d.ts +10 -0
  68. package/side-panel/variables-panel.js +1 -0
  69. package/toolbar/element-container.d.ts +6 -0
  70. package/toolbar/element-container.js +1 -1
  71. package/toolbar/figure-toolbar.d.ts +8 -9
  72. package/toolbar/figure-toolbar.js +1 -1
  73. package/toolbar/gif-toolbar.d.ts +4 -5
  74. package/toolbar/gif-toolbar.js +1 -1
  75. package/toolbar/group-toolbar.d.ts +2 -3
  76. package/toolbar/group-toolbar.js +1 -1
  77. package/toolbar/image-toolbar.d.ts +11 -12
  78. package/toolbar/image-toolbar.js +1 -1
  79. package/toolbar/index.d.ts +1 -0
  80. package/toolbar/index.js +1 -1
  81. package/toolbar/line-toolbar.js +1 -1
  82. package/toolbar/many-toolbar.d.ts +2 -3
  83. package/toolbar/many-toolbar.js +1 -1
  84. package/toolbar/page-toolbar.d.ts +2 -3
  85. package/toolbar/page-toolbar.js +1 -1
  86. package/toolbar/svg-toolbar.d.ts +2 -3
  87. package/toolbar/svg-toolbar.js +1 -1
  88. package/toolbar/text-toolbar.js +1 -1
  89. package/toolbar/text-variables.d.ts +15 -0
  90. package/toolbar/text-variables.js +1 -0
  91. package/toolbar/toolbar.js +1 -1
  92. package/toolbar/video-toolbar.js +1 -1
  93. package/ui.css +1 -1
  94. package/utils/animations.js +1 -1
  95. package/utils/clipboard.d.ts +50 -0
  96. package/utils/l10n.d.ts +32 -0
  97. package/utils/l10n.js +1 -1
  98. package/utils/selection-transform.js +1 -1
  99. package/utils/validate-key.js +1 -1
@@ -14,6 +14,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
14
14
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
15
15
  blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
16
16
  custom: import("mobx-state-tree").IType<any, any, any>;
17
+ bindings: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IType<import("@polotno/schema").Bindings, import("@polotno/schema").Bindings, import("@polotno/schema").Bindings>>;
18
+ href: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
17
19
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
18
20
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
19
21
  removable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -95,6 +97,13 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
95
97
  }> & {
96
98
  readonly page: any;
97
99
  readonly store: any;
100
+ readonly filled: Partial<{
101
+ text?: string;
102
+ placeholder?: string;
103
+ src?: string;
104
+ fill?: string;
105
+ visible?: boolean;
106
+ }>;
98
107
  readonly top: import("mobx-state-tree").ModelInstanceTypeProps<{
99
108
  id: import("mobx-state-tree").ISimpleType<string>;
100
109
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
@@ -102,6 +111,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
102
111
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
103
112
  blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
104
113
  custom: import("mobx-state-tree").IType<any, any, any>;
114
+ bindings: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IType<import("@polotno/schema").Bindings, import("@polotno/schema").Bindings, import("@polotno/schema").Bindings>>;
115
+ href: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
105
116
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
106
117
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
107
118
  removable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -114,6 +125,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
114
125
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
115
126
  blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
116
127
  custom: import("mobx-state-tree").IType<any, any, any>;
128
+ bindings: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IType<import("@polotno/schema").Bindings, import("@polotno/schema").Bindings, import("@polotno/schema").Bindings>>;
129
+ href: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
117
130
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
118
131
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
119
132
  removable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -126,6 +139,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
126
139
  opacity: number | undefined;
127
140
  blendMode: "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
128
141
  custom: any;
142
+ bindings: import("@polotno/schema").Bindings | undefined;
143
+ href: string | undefined;
129
144
  visible: boolean | undefined;
130
145
  selectable: boolean | undefined;
131
146
  removable: boolean | undefined;
@@ -137,6 +152,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
137
152
  name: string;
138
153
  opacity: number;
139
154
  custom: any;
155
+ bindings: import("@polotno/schema").Bindings | undefined;
156
+ href: string | undefined;
140
157
  visible: boolean;
141
158
  selectable: boolean;
142
159
  removable: boolean;
@@ -148,6 +165,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
148
165
  name: string;
149
166
  opacity: number;
150
167
  custom: any;
168
+ bindings: import("@polotno/schema").Bindings | undefined;
169
+ href: string | undefined;
151
170
  visible: boolean;
152
171
  selectable: boolean;
153
172
  removable: boolean;
@@ -165,6 +184,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
165
184
  name: string;
166
185
  opacity: number;
167
186
  custom: any;
187
+ bindings: import("@polotno/schema").Bindings | undefined;
188
+ href: string | undefined;
168
189
  visible: boolean;
169
190
  selectable: boolean;
170
191
  removable: boolean;
@@ -176,6 +197,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
176
197
  name: string;
177
198
  opacity: number;
178
199
  custom: any;
200
+ bindings: import("@polotno/schema").Bindings | undefined;
201
+ href: string | undefined;
179
202
  visible: boolean;
180
203
  selectable: boolean;
181
204
  removable: boolean;
@@ -221,6 +244,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
221
244
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
222
245
  blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
223
246
  custom: import("mobx-state-tree").IType<any, any, any>;
247
+ bindings: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IType<import("@polotno/schema").Bindings, import("@polotno/schema").Bindings, import("@polotno/schema").Bindings>>;
248
+ href: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
224
249
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
225
250
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
226
251
  removable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -302,6 +327,13 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
302
327
  }, {
303
328
  readonly page: any;
304
329
  readonly store: any;
330
+ readonly filled: Partial<{
331
+ text?: string;
332
+ placeholder?: string;
333
+ src?: string;
334
+ fill?: string;
335
+ visible?: boolean;
336
+ }>;
305
337
  readonly top: import("mobx-state-tree").ModelInstanceTypeProps<{
306
338
  id: import("mobx-state-tree").ISimpleType<string>;
307
339
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
@@ -309,6 +341,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
309
341
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
310
342
  blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
311
343
  custom: import("mobx-state-tree").IType<any, any, any>;
344
+ bindings: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IType<import("@polotno/schema").Bindings, import("@polotno/schema").Bindings, import("@polotno/schema").Bindings>>;
345
+ href: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
312
346
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
313
347
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
314
348
  removable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -321,6 +355,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
321
355
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
322
356
  blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
323
357
  custom: import("mobx-state-tree").IType<any, any, any>;
358
+ bindings: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IType<import("@polotno/schema").Bindings, import("@polotno/schema").Bindings, import("@polotno/schema").Bindings>>;
359
+ href: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
324
360
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
325
361
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
326
362
  removable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -333,6 +369,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
333
369
  opacity: number | undefined;
334
370
  blendMode: "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
335
371
  custom: any;
372
+ bindings: import("@polotno/schema").Bindings | undefined;
373
+ href: string | undefined;
336
374
  visible: boolean | undefined;
337
375
  selectable: boolean | undefined;
338
376
  removable: boolean | undefined;
@@ -344,6 +382,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
344
382
  name: string;
345
383
  opacity: number;
346
384
  custom: any;
385
+ bindings: import("@polotno/schema").Bindings | undefined;
386
+ href: string | undefined;
347
387
  visible: boolean;
348
388
  selectable: boolean;
349
389
  removable: boolean;
@@ -355,6 +395,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
355
395
  name: string;
356
396
  opacity: number;
357
397
  custom: any;
398
+ bindings: import("@polotno/schema").Bindings | undefined;
399
+ href: string | undefined;
358
400
  visible: boolean;
359
401
  selectable: boolean;
360
402
  removable: boolean;
@@ -372,6 +414,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
372
414
  name: string;
373
415
  opacity: number;
374
416
  custom: any;
417
+ bindings: import("@polotno/schema").Bindings | undefined;
418
+ href: string | undefined;
375
419
  visible: boolean;
376
420
  selectable: boolean;
377
421
  removable: boolean;
@@ -383,6 +427,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
383
427
  name: string;
384
428
  opacity: number;
385
429
  custom: any;
430
+ bindings: import("@polotno/schema").Bindings | undefined;
431
+ href: string | undefined;
386
432
  visible: boolean;
387
433
  selectable: boolean;
388
434
  removable: boolean;
@@ -427,6 +473,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
427
473
  name: string;
428
474
  opacity: number;
429
475
  custom: any;
476
+ bindings: import("@polotno/schema").Bindings | undefined;
477
+ href: string | undefined;
430
478
  visible: boolean;
431
479
  selectable: boolean;
432
480
  removable: boolean;
@@ -438,6 +486,8 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
438
486
  name: string;
439
487
  opacity: number;
440
488
  custom: any;
489
+ bindings: import("@polotno/schema").Bindings | undefined;
490
+ href: string | undefined;
441
491
  visible: boolean;
442
492
  selectable: boolean;
443
493
  removable: boolean;
package/utils/l10n.d.ts CHANGED
@@ -2,6 +2,38 @@ export declare const setTranslations: (json: any, { validate }?: {
2
2
  validate?: boolean | undefined;
3
3
  }) => void;
4
4
  export declare const getTranslations: () => {
5
+ variables: {
6
+ title: string;
7
+ element: string;
8
+ name: string;
9
+ label: string;
10
+ add: string;
11
+ required: string;
12
+ default: string;
13
+ enterValue: string;
14
+ empty: string;
15
+ settings: string;
16
+ delete: string;
17
+ yes: string;
18
+ no: string;
19
+ insert: string;
20
+ search: string;
21
+ noMatch: string;
22
+ nameRule: string;
23
+ nameTaken: string;
24
+ visible: string;
25
+ src: string;
26
+ fill: string;
27
+ unbound: string;
28
+ always: string;
29
+ fit: string;
30
+ manual: string;
31
+ cover: string;
32
+ contain: string;
33
+ focus: string;
34
+ orphan: string;
35
+ 'mixed-types': string;
36
+ };
5
37
  imageEdit: {
6
38
  title: string;
7
39
  expand: string;
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",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:"Drop 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",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",count:"Count",pop:"Pop",rise:"Rise",flipAnimation:"Flip",growTurn:"Grow & turn",spinAnimation:"Spin",pulse:"Pulse",float:"Float",shake:"Shake",typewriter:"Typewriter",lineRise:"Line rise",wordRise:"Word rise",wordFade:"Word fade",letterPop:"Letter pop",wordBlur:"Word blur",wipe:"Wipe",glow:"Glow",lineWipe:"Line wipe",linePeek:"Line peek",letterWave:"Letter wave",kenBurns:"Ken Burns",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, audio and Lottie animations.",uploadFailed:"Upload failed. Please try again.",background:"Background",resize:"Resize",layers:"Layers",animate:"Animate",animationEnter:"Enter",animationBoth:"Both",animationExit:"Exit",animationLoop:"Loop",animationGeneral:"General",animationTextPresets:"Text",animationDuration:"Duration (s)",animationRepeatEvery:"Repeat every (s)",animationStartAt:"Start at (s)",animationEndAt:"End at (s)",animationDirection:"Direction",animationDirections:{right:"Right",left:"Left",up:"Up",down:"Down","bottom-right":"Bottom right","bottom-left":"Bottom left","top-right":"Top right","top-left":"Top left",none:"None"},zoomIn:"Zoom In",zoomOut:"Zoom Out",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({variables:{title:"Variables",element:"Selected element",name:"Variable name",label:"Label",add:"Add variable",required:"Required",default:"Default",enterValue:"Enter a value",empty:"Add a variable, then insert it into text or link it to a selected element.",settings:"Settings",delete:"Delete variable",yes:"Yes",no:"No",insert:"Insert variable",search:"Search or add a variable",noMatch:"No matching variables",nameRule:"Use letters, digits, _ and dots",nameTaken:"Already exists",visible:"Visible",src:"Source",fill:"Color",unbound:"Not linked",always:"Always",fit:"Scale",manual:"Crop",cover:"Fill",contain:"Fit",focus:"Focus",orphan:"Unused","mixed-types":"Mixed types"},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:"Drop 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",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",count:"Count",pop:"Pop",rise:"Rise",flipAnimation:"Flip",growTurn:"Grow & turn",spinAnimation:"Spin",pulse:"Pulse",float:"Float",shake:"Shake",typewriter:"Typewriter",lineRise:"Line rise",wordRise:"Word rise",wordFade:"Word fade",letterPop:"Letter pop",wordBlur:"Word blur",wipe:"Wipe",glow:"Glow",lineWipe:"Line wipe",linePeek:"Line peek",letterWave:"Letter wave",kenBurns:"Ken Burns",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, audio and Lottie animations.",uploadFailed:"Upload failed. Please try again.",background:"Background",resize:"Resize",layers:"Layers",animate:"Animate",animationEnter:"Enter",animationBoth:"Both",animationExit:"Exit",animationLoop:"Loop",animationGeneral:"General",animationTextPresets:"Text",animationDuration:"Duration (s)",animationRepeatEvery:"Repeat every (s)",animationStartAt:"Start at (s)",animationEndAt:"End at (s)",animationDirection:"Direction",animationDirections:{right:"Right",left:"Left",up:"Up",down:"Down","bottom-right":"Bottom right","bottom-left":"Bottom left","top-right":"Top right","top-left":"Top left",none:"None"},zoomIn:"Zoom In",zoomOut:"Zoom Out",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 +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,isMedia as r,scaledStyleAttrs as c,textMinResizeWidth as a,textMinWidthIsMeasured as h}from"./px.js";import{textResizeFloorFontSize as l}from"./text-sizing.js";import{sideResizeCrop as x}from"../canvas/media-resize.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":case"lottie":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?a(n,l(e)):1};const p=e=>{const[t]=e.selectedElements;return 1===e.selectedElements.length&&"group"!==t.type?t:null};export const getSelectionBox=e=>{const i=p(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 d=e=>!e.pendingEdit;export const canResizeSelection=e=>{const t=e.selectedShapes;return t.length>0&&t.every(e=>e.resizable&&d(e))};export const canMoveSelection=e=>{const t=e.selectedShapes;return t.length>0&&t.every(e=>e.draggable&&d(e))};const g=(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()},y=(e,t,n)=>{const r=n.x+(e.x-n.x)*t,a=n.y+(e.y-n.y)*t;if("table"===e.type){return void g(e,{x:r,y:a,width:e.width*t},e.height*t)}const{fontSize:h,minFontSize:l,maxFontSize:x}=e;e.set(Object.assign({x:r,y:a,width:e.width*t,height:e.height*t},c(e,t))),e.set(Object.assign(Object.assign({},i(e)),o(e))),"text"===e.type&&e.set(s({minFontSize:l,maxFontSize:x},e.fontSize/h,!0))},u=e=>r(e.type)?e._sourceSize:null,S=e=>!r(e.type)||e.stretchEnabled||!!u(e);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,a=p(t),h=c.every(S)&&(a?((e,t)=>"text"===e.type?"x"===t&&!e.curveEnabled:canStretchAxis(e,t,e.rotation))(a,n):c.every(e=>canStretchAxis(e,n,0))),l=Math.max(...c.flatMap(e=>(h?[n]:["x","y"]).map(t=>{const i="x"===t?e.width:e.height,n=leafMinSize(e,t,h,i);return i>=n?n/i:0}))),d=Math.max(o/r,l),f={x:s.x,y:s.y};t.history.transaction(()=>{c.forEach(t=>{h?((t,n,o,s)=>{const[r,c]="x"===n?["x","width"]:["y","height"],a=u(t),h=Object.assign({[r]:s[r]+(t[r]-s[r])*o,[c]:t[c]*o},a&&x(t,a,"x"===n?o:1,"y"===n?o:1));if("table"===t.type){const{height:i=t.height}=h,n=e(h,["height"]);return void g(t,n,i)}t.set(h),t.set(i(t))})(t,n,d,f):y(t,d,f)})})};const f=(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(()=>{f(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=>y(e,r,{x:s.x,y:s.y}));const e=t(n);f(n,(o.computedWidth-e.width)/2-e.x,(o.computedHeight-e.height)/2-e.y)})};
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,isMedia as r,scaledStyleAttrs as c,textMinResizeWidth as a,textMinWidthIsMeasured as h}from"./px.js";import{textResizeFloorFontSize as l}from"./text-sizing.js";import{sideResizeCrop as x}from"../canvas/media-resize.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":case"lottie":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?a(n,l(e)):1};const p=e=>{const[t]=e.selectedElements;return 1===e.selectedElements.length&&"group"!==t.type?t:null};export const getSelectionBox=e=>{const i=p(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 d=e=>!e.pendingEdit;export const canResizeSelection=e=>{const t=e.selectedShapes;return t.length>0&&t.every(e=>e.resizable&&d(e))};export const canMoveSelection=e=>{const t=e.selectedShapes;return t.length>0&&t.every(e=>e.draggable&&d(e))};const g=(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()},y=(e,t,n)=>{const r=n.x+(e.x-n.x)*t,a=n.y+(e.y-n.y)*t;if("table"===e.type){return void g(e,{x:r,y:a,width:e.width*t},e.height*t)}const{fontSize:h,minFontSize:l,maxFontSize:x}=e;e.set(Object.assign({x:r,y:a,width:e.width*t,height:e.height*t},c(e,t))),e.set(Object.assign(Object.assign({},i(e)),o(e))),"text"===e.type&&e.set(s({minFontSize:l,maxFontSize:x},e.fontSize/h,!0))},u=e=>r(e.type)?e._sourceSize:null,f=e=>!r(e.type)||e.stretchEnabled||!!u(e);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,a=p(t),h=c.every(f)&&(a?((e,t)=>"text"===e.type?"x"===t&&!e.curveEnabled:canStretchAxis(e,t,e.rotation))(a,n):c.every(e=>canStretchAxis(e,n,0))),l=Math.max(...c.flatMap(e=>(h?[n]:["x","y"]).map(t=>{const i="x"===t?e.width:e.height,n=leafMinSize(e,t,h,i);return i>=n?n/i:0}))),d=Math.max(o/r,l),S={x:s.x,y:s.y};t.history.transaction(()=>{c.forEach(t=>{h?((t,n,o,s)=>{const[r,c]="x"===n?["x","width"]:["y","height"],a=u(t),h=Object.assign({[r]:s[r]+(t[r]-s[r])*o,[c]:t[c]*o},a&&!t.fit&&x(t,a,"x"===n?o:1,"y"===n?o:1));if("table"===t.type){const{height:i=t.height}=h,n=e(h,["height"]);return void g(t,n,i)}t.set(h),t.set(i(t))})(t,n,d,S):y(t,d,S)})})};const S=(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(()=>{S(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=>y(e,r,{x:s.x,y:s.y}));const e=t(n);S(n,(o.computedWidth-e.width)/2-e.x,(o.computedHeight-e.height)/2-e.y)})};
@@ -1 +1 @@
1
- import*as e from"mobx";import{NO_KEY_MESSAGE as o,NO_VALID_MESSAGE as t,NOT_PAID_MESSAGE as n,NOT_PAID_STYLE as a}from"@polotno/core/validate-key";import{getAPI as i}from"./api.js";import{removeBackgroundState as r}from"./flags.js";const s=e.observable({value:!1}),l=e.observable({value:"v1"});export const ___=()=>l.value;const c=e.observable({value:0});export const ____=()=>c.value;export const isCreditVisible=()=>s.value;const d=e.action(()=>{s.value=!0});let u="";export const getKey=()=>u||"";export const setKey=e=>{u=e||""};let p="undefined"!=typeof window?window.location.origin:"";const v="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,f="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===p&&v&&(p="headless"),"file://"===p&&f&&(p="electron");const m=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${p}" here: https://polotno.com/cabinet`;let g=fetch;export const __=e=>{g=e};export async function isKeyPaid(s){for(let u=0;u<5;u++){try{const d=await g(i()+"/validate-key",{method:"POST",body:JSON.stringify({key:s,sdkVersion:"3.21.0"})});if(e.runInAction(()=>{l.value=d.headers.get("x-api-version")||""}),!s){return console.error(o),e.runInAction(()=>{c.value=1}),!1}if(200!==d.status){await new Promise(e=>setTimeout(e,3e3));continue}const u=await d.json();return u.is_valid||(console.error(t),e.runInAction(()=>{c.value=1})),u.is_paid||(console.log(n,a),e.runInAction(()=>{0===c.value&&(c.value=2)})),u.is_domain_valid||console.log(m,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{r.defaultEnabled=u.remove_background_enabled}),u.is_paid||!1}catch(d){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(u)&&!e||d()}
1
+ import*as e from"mobx";import{NO_KEY_MESSAGE as o,NO_VALID_MESSAGE as t,NOT_PAID_MESSAGE as n,NOT_PAID_STYLE as a}from"@polotno/core/validate-key";import{getAPI as i}from"./api.js";import{removeBackgroundState as r}from"./flags.js";const s=e.observable({value:!1}),l=e.observable({value:"v1"});export const ___=()=>l.value;const c=e.observable({value:0});export const ____=()=>c.value;export const isCreditVisible=()=>s.value;const d=e.action(()=>{s.value=!0});let u="";export const getKey=()=>u||"";export const setKey=e=>{u=e||""};let p="undefined"!=typeof window?window.location.origin:"";const v="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,f="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===p&&v&&(p="headless"),"file://"===p&&f&&(p="electron");const m=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${p}" here: https://polotno.com/cabinet`;let g=fetch;export const __=e=>{g=e};export async function isKeyPaid(s){for(let u=0;u<5;u++){try{const d=await g(i()+"/validate-key",{method:"POST",body:JSON.stringify({key:s,sdkVersion:"3.22.1"})});if(e.runInAction(()=>{l.value=d.headers.get("x-api-version")||""}),!s){return console.error(o),e.runInAction(()=>{c.value=1}),!1}if(200!==d.status){await new Promise(e=>setTimeout(e,3e3));continue}const u=await d.json();return u.is_valid||(console.error(t),e.runInAction(()=>{c.value=1})),u.is_paid||(console.log(n,a),e.runInAction(()=>{0===c.value&&(c.value=2)})),u.is_domain_valid||console.log(m,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{r.defaultEnabled=u.remove_background_enabled}),u.is_paid||!1}catch(d){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(u)&&!e||d()}