polotno 4.17.0 → 4.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/blueprint/side-panel/select-video.d.ts +18 -16
  2. package/canvas/animated-shadow.d.ts +11 -0
  3. package/canvas/animated-shadow.js +1 -0
  4. package/canvas/apply-filters.d.ts +5 -1
  5. package/canvas/apply-filters.js +1 -1
  6. package/canvas/downscale.js +1 -1
  7. package/canvas/element.js +1 -1
  8. package/canvas/figure-element.js +1 -1
  9. package/canvas/gif-element.js +1 -1
  10. package/canvas/html-element.js +1 -1
  11. package/canvas/image-element.d.ts +1 -0
  12. package/canvas/image-element.js +1 -1
  13. package/canvas/line-element.js +1 -1
  14. package/canvas/page.js +1 -1
  15. package/canvas/render-tag-element.js +1 -1
  16. package/canvas/rich-editor.d.ts +2 -0
  17. package/canvas/rich-editor.js +8 -5
  18. package/canvas/text-element.js +1 -1
  19. package/canvas/use-animated-blur.d.ts +4 -0
  20. package/canvas/use-animated-blur.js +1 -0
  21. package/canvas/use-color.d.ts +1 -1
  22. package/canvas/use-filtered-source.js +1 -1
  23. package/canvas/use-offscreen-canvas.d.ts +2 -0
  24. package/canvas/use-offscreen-canvas.js +1 -0
  25. package/canvas/use-transformer-snap.js +1 -1
  26. package/canvas/video-element.js +1 -1
  27. package/icons/animation-icons.d.ts +30 -7
  28. package/icons/animation-icons.js +1 -1
  29. package/icons/registry.d.ts +22 -0
  30. package/icons/registry.js +1 -1
  31. package/image-tools/raster.js +1 -1
  32. package/model/figure-model.d.ts +10 -9
  33. package/model/gif-model.d.ts +10 -9
  34. package/model/group-model.d.ts +78 -68
  35. package/model/group-model.js +1 -1
  36. package/model/history.d.ts +3 -0
  37. package/model/history.js +1 -1
  38. package/model/image-model.d.ts +10 -9
  39. package/model/line-model.d.ts +10 -9
  40. package/model/node-model.d.ts +8 -8
  41. package/model/page-model.d.ts +228 -204
  42. package/model/shape-model.d.ts +15 -9
  43. package/model/shape-model.js +1 -1
  44. package/model/store.d.ts +31 -17
  45. package/model/store.js +1 -1
  46. package/model/svg-model.d.ts +9 -8
  47. package/model/table-model.d.ts +8 -7
  48. package/model/text-model.d.ts +9 -8
  49. package/model/video-model.d.ts +10 -9
  50. package/package.json +24 -21
  51. package/pages-timeline/element-track.js +1 -1
  52. package/pages-timeline/page-preview.js +1 -1
  53. package/polotno.bundle.js +195 -177
  54. package/side-panel/animations-panel.js +1 -1
  55. package/side-panel/select-video.d.ts +18 -16
  56. package/side-panel/text-panel.js +1 -1
  57. package/side-panel/text-template.js +1 -1
  58. package/toolbar/animations-picker.js +1 -1
  59. package/toolbar/use-copy-style.d.ts +1 -0
  60. package/toolbar/use-copy-style.js +1 -1
  61. package/ui.css +1 -1
  62. package/utils/animations.d.ts +212 -10
  63. package/utils/animations.js +1 -1
  64. package/utils/clipboard.d.ts +17 -15
  65. package/utils/clipboard.js +1 -1
  66. package/utils/duplicate.js +1 -1
  67. package/utils/fonts.js +1 -1
  68. package/utils/from-svg.js +1 -1
  69. package/utils/image-dpi.js +1 -1
  70. package/utils/image-edit.js +1 -1
  71. package/utils/l10n.d.ts +44 -0
  72. package/utils/l10n.js +1 -1
  73. package/utils/px.d.ts +1 -0
  74. package/utils/px.js +1 -1
  75. package/utils/timeline.d.ts +3 -1
  76. package/utils/timeline.js +1 -1
  77. package/utils/validate-key.js +1 -1
@@ -149,7 +149,7 @@ export declare const TableElement: import("mobx-state-tree").IModelType<{
149
149
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
150
150
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
151
151
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
152
- blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
152
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
153
153
  custom: import("mobx-state-tree").IType<any, any, any>;
154
154
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
155
155
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -170,6 +170,7 @@ export declare const TableElement: import("mobx-state-tree").IModelType<{
170
170
  type: import("mobx-state-tree").ISimpleType<"exit" | "enter" | "loop">;
171
171
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
172
172
  data: import("mobx-state-tree").IType<{} | null | undefined, {}, {}>;
173
+ easing: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
173
174
  }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
174
175
  blurEnabled: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
175
176
  blurRadius: import("mobx-state-tree").IType<number | undefined, number, number>;
@@ -359,7 +360,7 @@ export declare const TableElement: import("mobx-state-tree").IModelType<{
359
360
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
360
361
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
361
362
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
362
- blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
363
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
363
364
  custom: import("mobx-state-tree").IType<any, any, any>;
364
365
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
365
366
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -371,7 +372,7 @@ export declare const TableElement: import("mobx-state-tree").IModelType<{
371
372
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
372
373
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
373
374
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
374
- blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
375
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
375
376
  custom: import("mobx-state-tree").IType<any, any, any>;
376
377
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
377
378
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -383,7 +384,7 @@ export declare const TableElement: import("mobx-state-tree").IModelType<{
383
384
  type: string | undefined;
384
385
  name: string | undefined;
385
386
  opacity: number | undefined;
386
- blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
387
+ blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light" | undefined;
387
388
  custom: any;
388
389
  visible: boolean | undefined;
389
390
  selectable: boolean | undefined;
@@ -402,7 +403,7 @@ export declare const TableElement: import("mobx-state-tree").IModelType<{
402
403
  alwaysOnTop: boolean;
403
404
  showInExport: boolean;
404
405
  } | {
405
- blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
406
+ blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
406
407
  id: string;
407
408
  type: string;
408
409
  name: string;
@@ -430,7 +431,7 @@ export declare const TableElement: import("mobx-state-tree").IModelType<{
430
431
  alwaysOnTop: boolean;
431
432
  showInExport: boolean;
432
433
  } | {
433
- blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
434
+ blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
434
435
  id: string;
435
436
  type: string;
436
437
  name: string;
@@ -465,7 +466,7 @@ export declare const TableElement: import("mobx-state-tree").IModelType<{
465
466
  readonly isSelected: boolean;
466
467
  readonly isSelectedDirectly: boolean;
467
468
  } & {
468
- setAnimation(type: any, attrs: any): void;
469
+ setAnimation(type: "enter" | "exit" | "loop", attrs: import("../utils/animations.js").AnimationAttrs): void;
469
470
  setFilter(type: any, value: any): void;
470
471
  } & {
471
472
  _focusedCellIds: string[];
@@ -4,7 +4,7 @@ export declare const TextElement: import("mobx-state-tree").IModelType<{
4
4
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
5
5
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
6
6
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
7
- blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
7
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
8
8
  custom: import("mobx-state-tree").IType<any, any, any>;
9
9
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
10
10
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -25,6 +25,7 @@ export declare const TextElement: import("mobx-state-tree").IModelType<{
25
25
  type: import("mobx-state-tree").ISimpleType<"exit" | "enter" | "loop">;
26
26
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
27
27
  data: import("mobx-state-tree").IType<{} | null | undefined, {}, {}>;
28
+ easing: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
28
29
  }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
29
30
  blurEnabled: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
30
31
  blurRadius: import("mobx-state-tree").IType<number | undefined, number, number>;
@@ -92,7 +93,7 @@ export declare const TextElement: import("mobx-state-tree").IModelType<{
92
93
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
93
94
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
94
95
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
95
- blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
96
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
96
97
  custom: import("mobx-state-tree").IType<any, any, any>;
97
98
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
98
99
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -104,7 +105,7 @@ export declare const TextElement: import("mobx-state-tree").IModelType<{
104
105
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
105
106
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
106
107
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
107
- blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
108
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
108
109
  custom: import("mobx-state-tree").IType<any, any, any>;
109
110
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
110
111
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -116,7 +117,7 @@ export declare const TextElement: import("mobx-state-tree").IModelType<{
116
117
  type: string | undefined;
117
118
  name: string | undefined;
118
119
  opacity: number | undefined;
119
- blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
120
+ blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light" | undefined;
120
121
  custom: any;
121
122
  visible: boolean | undefined;
122
123
  selectable: boolean | undefined;
@@ -135,7 +136,7 @@ export declare const TextElement: import("mobx-state-tree").IModelType<{
135
136
  alwaysOnTop: boolean;
136
137
  showInExport: boolean;
137
138
  } | {
138
- blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
139
+ blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
139
140
  id: string;
140
141
  type: string;
141
142
  name: string;
@@ -163,7 +164,7 @@ export declare const TextElement: import("mobx-state-tree").IModelType<{
163
164
  alwaysOnTop: boolean;
164
165
  showInExport: boolean;
165
166
  } | {
166
- blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
167
+ blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
167
168
  id: string;
168
169
  type: string;
169
170
  name: string;
@@ -198,7 +199,7 @@ export declare const TextElement: import("mobx-state-tree").IModelType<{
198
199
  readonly isSelected: boolean;
199
200
  readonly isSelectedDirectly: boolean;
200
201
  } & {
201
- setAnimation(type: any, attrs: any): void;
202
+ setAnimation(type: "enter" | "exit" | "loop", attrs: import("../utils/animations.js").AnimationAttrs): void;
202
203
  setFilter(type: any, value: any): void;
203
204
  } & {
204
205
  set(attrs: any): void;
@@ -216,7 +217,7 @@ export declare const TextElement: import("mobx-state-tree").IModelType<{
216
217
  alwaysOnTop: boolean;
217
218
  showInExport: boolean;
218
219
  } | {
219
- blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
220
+ blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
220
221
  id: string;
221
222
  type: string;
222
223
  name: string;
@@ -4,7 +4,7 @@ export declare const VideoElement: import("mobx-state-tree").IModelType<{
4
4
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
5
5
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
6
6
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
7
- blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
7
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
8
8
  custom: import("mobx-state-tree").IType<any, any, any>;
9
9
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
10
10
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -25,6 +25,7 @@ export declare const VideoElement: import("mobx-state-tree").IModelType<{
25
25
  type: import("mobx-state-tree").ISimpleType<"exit" | "enter" | "loop">;
26
26
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
27
27
  data: import("mobx-state-tree").IType<{} | null | undefined, {}, {}>;
28
+ easing: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
28
29
  }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
29
30
  blurEnabled: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
30
31
  blurRadius: import("mobx-state-tree").IType<number | undefined, number, number>;
@@ -81,7 +82,7 @@ export declare const VideoElement: import("mobx-state-tree").IModelType<{
81
82
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
82
83
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
83
84
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
84
- blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
85
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
85
86
  custom: import("mobx-state-tree").IType<any, any, any>;
86
87
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
87
88
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -93,7 +94,7 @@ export declare const VideoElement: import("mobx-state-tree").IModelType<{
93
94
  type: import("mobx-state-tree").IType<string | undefined, string, string>;
94
95
  name: import("mobx-state-tree").IType<string | undefined, string, string>;
95
96
  opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
96
- blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
97
+ blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light">, [undefined]>;
97
98
  custom: import("mobx-state-tree").IType<any, any, any>;
98
99
  visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
99
100
  selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
@@ -105,7 +106,7 @@ export declare const VideoElement: import("mobx-state-tree").IModelType<{
105
106
  type: string | undefined;
106
107
  name: string | undefined;
107
108
  opacity: number | undefined;
108
- blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
109
+ blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light" | undefined;
109
110
  custom: any;
110
111
  visible: boolean | undefined;
111
112
  selectable: boolean | undefined;
@@ -124,7 +125,7 @@ export declare const VideoElement: import("mobx-state-tree").IModelType<{
124
125
  alwaysOnTop: boolean;
125
126
  showInExport: boolean;
126
127
  } | {
127
- blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
128
+ blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
128
129
  id: string;
129
130
  type: string;
130
131
  name: string;
@@ -152,7 +153,7 @@ export declare const VideoElement: import("mobx-state-tree").IModelType<{
152
153
  alwaysOnTop: boolean;
153
154
  showInExport: boolean;
154
155
  } | {
155
- blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
156
+ blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
156
157
  id: string;
157
158
  type: string;
158
159
  name: string;
@@ -187,7 +188,7 @@ export declare const VideoElement: import("mobx-state-tree").IModelType<{
187
188
  readonly isSelected: boolean;
188
189
  readonly isSelectedDirectly: boolean;
189
190
  } & {
190
- setAnimation(type: any, attrs: any): void;
191
+ setAnimation(type: "enter" | "exit" | "loop", attrs: import("../utils/animations.js").AnimationAttrs): void;
191
192
  setFilter(type: any, value: any): void;
192
193
  } & {
193
194
  _setSourceSize(size: import("../image-tools/types.js").Size, src: string): void;
@@ -211,7 +212,7 @@ export declare const VideoElement: import("mobx-state-tree").IModelType<{
211
212
  type: string | undefined;
212
213
  name: string | undefined;
213
214
  opacity: number | undefined;
214
- blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
215
+ blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light" | undefined;
215
216
  custom: any;
216
217
  visible: boolean | undefined;
217
218
  selectable: boolean | undefined;
@@ -230,7 +231,7 @@ export declare const VideoElement: import("mobx-state-tree").IModelType<{
230
231
  alwaysOnTop: boolean;
231
232
  showInExport: boolean;
232
233
  } | {
233
- blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
234
+ blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
234
235
  id: string;
235
236
  type: string;
236
237
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polotno",
3
- "version": "4.17.0",
3
+ "version": "4.19.0",
4
4
  "description": "Design editor SDK: embed a Canva-like editor, generate designs from templates and data, export PNG, PDF, and video in the browser or on a server.",
5
5
  "author": "Anton Lavrenov",
6
6
  "repository": {
@@ -113,27 +113,27 @@
113
113
  },
114
114
  "dependencies": {
115
115
  "@base-ui/react": "^1.9.0",
116
- "@polotno/core": "0.18.0",
117
- "@polotno/html-export": "0.9.2",
118
- "@polotno/schema": "0.9.0",
119
- "@polotno/svg-export": "0.10.2",
116
+ "@polotno/core": "0.20.0",
117
+ "@polotno/html-export": "0.10.1",
118
+ "@polotno/schema": "0.10.0",
119
+ "@polotno/svg-export": "0.11.1",
120
120
  "class-variance-authority": "^0.7.1",
121
121
  "clsx": "^2.1.1",
122
122
  "gifuct-js": "^2.1.2",
123
- "konva": "^10.9.0",
123
+ "konva": "^10.9.1",
124
124
  "lodash-es": "^4.18.1",
125
- "lucide-react": "^1.59.0",
126
- "mediabunny": "^1.61.6",
127
- "mobx": "7.0.6",
128
- "mobx-react-lite": "^5.1.0",
129
- "mobx-state-tree": "8.0.0",
125
+ "lucide-react": "^1.66.0",
126
+ "mediabunny": "^1.65.0",
127
+ "mobx": "7.1.4",
128
+ "mobx-react-lite": "^5.1.2",
129
+ "mobx-state-tree": "9.0.0",
130
130
  "nanoid": "^6.0.2",
131
131
  "quill": "^2.0.3",
132
132
  "react-konva": "^19.3.2",
133
133
  "react-konva-utils": "^2.1.0",
134
134
  "react-sortablejs": "6.1.4",
135
- "react-window": "^2.4.1",
136
- "render-tag": "0.3.2",
135
+ "react-window": "^2.5.2",
136
+ "render-tag": "0.4.1",
137
137
  "sortablejs": "^1.15.7",
138
138
  "svg-round-corners": "^0.4.3",
139
139
  "swr": "^2.5.1",
@@ -170,8 +170,8 @@
170
170
  }
171
171
  },
172
172
  "devDependencies": {
173
- "@babel/parser": "^8.0.7",
174
- "@babel/traverse": "^8.0.7",
173
+ "@babel/parser": "^8.0.10",
174
+ "@babel/traverse": "^8.0.10",
175
175
  "@blueprintjs/core": "6.21.0",
176
176
  "@blueprintjs/icons": "^6.14.1",
177
177
  "@blueprintjs/select": "6.4.0",
@@ -189,12 +189,12 @@
189
189
  "buffer": "^6.0.3",
190
190
  "canvas": "^3.2.3",
191
191
  "filehound": "^1.17.6",
192
- "glob": "^13.0.6",
192
+ "glob": "^14.0.3",
193
193
  "jest-file-snapshot": "^0.7.0",
194
194
  "jsdom": "^30.1.3",
195
195
  "playwright": "^1.64.1",
196
- "postcss": "^8.5.31",
197
- "postcss-selector-parser": "^7.1.6",
196
+ "postcss": "^8.5.32",
197
+ "postcss-selector-parser": "^7.1.7",
198
198
  "pptxgenjs": "^4.0.1",
199
199
  "process": "^0.11.10",
200
200
  "react": "^19.3.1",
@@ -203,7 +203,7 @@
203
203
  "terser": "^5.51.2",
204
204
  "tw-animate-css": "^1.4.0",
205
205
  "typescript": "~6.0.3",
206
- "vite": "^8.3.4",
206
+ "vite": "^8.3.5",
207
207
  "vitest": "^5.0.5"
208
208
  },
209
209
  "homepage": "https://polotno.com/",
@@ -212,20 +212,23 @@
212
212
  "clean": "rm -rf ./lib && rm -rf ./.pn-build",
213
213
  "prefix-build": "node build/prefix-build.cjs",
214
214
  "tsc": "tsc --project tsconfig.lib.json --removeComments --sourceMap false",
215
- "typecheck": "tsc --noEmit -p tsconfig.json",
215
+ "typecheck": "node ../../scripts/typecheck.mjs --noEmit -p tsconfig.json",
216
216
  "build:css": "tailwindcss -i ./.pn-build/ui.css -o ./lib/ui.css --minify && node build/rename-keyframes.cjs ./lib/ui.css",
217
217
  "check:css": "node build/check-css-hygiene.cjs ./lib/ui.css",
218
218
  "check:agreement": "node build/check-agreement.cjs ./lib/ui.css ./lib/toolbar ./lib/side-panel ./lib/pages-timeline ./lib/primitives ./lib/canvas",
219
219
  "check:parity": "node build/structural-parity.cjs",
220
220
  "test:parity": "pnpm run check:parity && pnpm run check:agreement && pnpm run check:css",
221
221
  "minify": "node minify.cjs",
222
- "build": "pnpm run check:wasm && pnpm run clean && pnpm run prefix-build && pnpm run tsc && pnpm run add_version && node rename-imports.js && pnpm run minify && pnpm run build:css && pnpm run check:css && pnpm run check:agreement && pnpm run build:bundle && node blueprint-scope.js && cp ./src/fonts.css ./lib/fonts.css && mkdir -p ./lib/themes && cp ./src/themes/blueprint.css ./lib/themes/blueprint.css && cp ./src/themes/carbon.css ./lib/themes/carbon.css && node build/copy-package-json.cjs && cp ./README.md ./lib && cp ./LICENSE.md ./lib && pnpm run remove-test-from-lib",
222
+ "build": "node build/build.mjs",
223
223
  "remove-test-from-lib": "find ./lib -type d -name \"__tests__\" -exec rm -rf {} + && find ./lib \\( -name \"*.test.js\" -o -name \"*.test.d.ts\" \\) -type f -delete",
224
224
  "add_version": "sed -i.bak 's/SDK_VERSION/'$npm_package_version'/' ./lib/utils/validate-key.js && rm -f ./lib/utils/validate-key.js.bak",
225
225
  "build:bundle": "vite build && find ./lib -name '*.js.map' -type f -delete",
226
226
  "test": "node scripts/run-tests-parallel.mjs",
227
+ "test:artifact": "POLOTNO_TEST_SCOPE=artifact node scripts/run-browser.mts",
227
228
  "test:unit": "vitest run --project unit",
228
229
  "test:browser": "node scripts/run-browser.mts",
230
+ "test:firefox": "POLOTNO_BROWSER=firefox node scripts/run-browser.mts",
231
+ "test:webkit": "POLOTNO_BROWSER=webkit node scripts/run-browser.mts",
229
232
  "test:serial": "vitest run",
230
233
  "build:wasm": "node wasm/build.mjs",
231
234
  "check:wasm": "node wasm/build.mjs --check"
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import n from"react";import{observer as o}from"mobx-react-lite";import{PolotnoIcon as i}from"../icons/registry.js";import{duplicateElements as r}from"../utils/duplicate.js";import{clamp as l}from"../lib/utils.js";import{getElementTimeRange as s,MIN_DURATION as a,revealElementAtPlayhead as m}from"../utils/timeline.js";import{canSplitAtPlayhead as c,splitElementAtPlayhead as p}from"../utils/split-element.js";import{t as d}from"../utils/l10n.js";import{DRAG_SLOP_PX as u,isPrimaryDrag as f,usePointerDrag as x}from"../utils/pointer-drag.js";import{DropdownMenu as h,DropdownMenuContent as v,DropdownMenuItem as j}from"../primitives/dropdown-menu.js";import{TrackWrapper as E,TrackContainer as g,TrackMenu as w,TrackMenuButton as y,TrackHandleLeft as D,TrackHandleRight as M,TrackLabel as P,TrackNameInput as b}from"./track-styles.js";export const ELEMENT_ROW_HEIGHT=26;const S=o(({element:n,store:o})=>{var r;const l=o.effectiveTime-((null===(r=n.page)||void 0===r?void 0:r.startTime)||0),s=c(n,l);return t(j,{disabled:!s,onSelect:e=>{e.preventDefault();const t=p(n,l);t&&o.selectElements([t.id])},children:[e(i,{name:"action.split"}),d("contextMenu.split")]})}),T=(e,t)=>{const n=e.animations.find(e=>e.type===t);n&&n.enabled||e.setAnimation(t,{name:"none",enabled:!0})},X=(e,t,n,o)=>{const i=l(n,0,t-a),r=l(o,i+a,t);T(e,"enter"),T(e,"exit"),e.setAnimation("enter",{delay:i}),e.setAnimation("exit",{delay:Math.max(0,t-r)})};export const ElementTrack=o(({element:o,page:c,store:p,scale:T,row:k})=>{const A=c.duration,C=c.startTime,H=C+A,{start:N,end:O}=s(o.animations,A),W=(O-N)*T,$=(C+N)*T,_=o.name||o.type||d("toolbar.element"),[G,I]=n.useState(!1),L=x(),[R,q]=n.useState(null),z=()=>{q(e=>null===e?k:e)},B=()=>{q(null)},F=(e,t)=>{if(!f(e)){return}e.stopPropagation();const n=e.clientX,i=N,r=O;L(e,{slopX:u,node:o,onMove:e=>{z();const s=(e.clientX-n)/T;if("start"===t){const e=l(C+i+s,C,C+r-a);X(o,A,e-C,r)}else{const e=l(C+r+s,C+i+a,H);X(o,A,i,e-C)}},onEnd:B})};return e(E,{style:{left:`${$}px`,top:26*(null!=R?R:k)+"px",width:`${W}px`,minWidth:"6px",height:"22px"},children:t(g,{style:{width:"100%",height:"100%",outline:p.selectedElements.find(e=>e.id===o.id)?"2px solid var(--pn-primary, var(--primary, #137cbd))":"none",outlineOffset:"-1px"},onPointerDown:e=>{if(!f(e)){return}e.stopPropagation();const t=e.clientX,n=N,i=O-n;L(e,{slopX:u,node:o,onMove:e=>{z();const r=(e.clientX-t)/T,s=l(C+n+r,C,H-i)-C;X(o,A,s,s+i)},onEnd:({moved:e,cancelled:t})=>{B(),e||t||(p.selectElements([o.id]),m(o))}})},children:[G?e(b,{value:o.name||"",onCommit:e=>{o.set({name:e}),I(!1)},onCancel:()=>I(!1)}):e(P,{children:_}),e(D,{onPointerDown:e=>F(e,"start")}),e(M,{onPointerDown:e=>F(e,"end")}),e(w,{onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:t(h,{children:[e(y,{}),t(v,{side:"top",className:"pn:whitespace-nowrap",children:[e(S,{element:o,store:p}),t(j,{onSelect:e=>{e.preventDefault(),I(!0)},children:[e(i,{name:"action.rename"}),d("contextMenu.rename")]}),t(j,{onSelect:e=>{e.preventDefault(),r([o],p)},children:[e(i,{name:"action.duplicate"}),d("contextMenu.duplicate")]}),t(j,{onSelect:e=>{e.preventDefault(),p.deleteElements([o.id])},children:[e(i,{name:"action.remove"}),d("contextMenu.remove")]})]})]})})]})})});
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import n from"react";import{observer as o}from"mobx-react-lite";import{PolotnoIcon as i}from"../icons/registry.js";import{duplicateElements as r}from"../utils/duplicate.js";import{clamp as l}from"../lib/utils.js";import{getElementTimeRange as s,MIN_DURATION as a,revealElementAtPlayhead as m,setElementTimeRange as c}from"../utils/timeline.js";import{canSplitAtPlayhead as p,splitElementAtPlayhead as d}from"../utils/split-element.js";import{t as u}from"../utils/l10n.js";import{DRAG_SLOP_PX as f,isPrimaryDrag as h,usePointerDrag as v}from"../utils/pointer-drag.js";import{DropdownMenu as x,DropdownMenuContent as j,DropdownMenuItem as E}from"../primitives/dropdown-menu.js";import{TrackWrapper as g,TrackContainer as w,TrackMenu as y,TrackMenuButton as D,TrackHandleLeft as P,TrackHandleRight as M,TrackLabel as S,TrackNameInput as T}from"./track-styles.js";export const ELEMENT_ROW_HEIGHT=26;const X=o(({element:n,store:o})=>{var r;const l=o.effectiveTime-((null===(r=n.page)||void 0===r?void 0:r.startTime)||0),s=p(n,l);return t(E,{disabled:!s,onSelect:e=>{e.preventDefault();const t=d(n,l);t&&o.selectElements([t.id])},children:[e(i,{name:"action.split"}),u("contextMenu.split")]})});export const ElementTrack=o(({element:o,page:p,store:d,scale:b,row:k})=>{const C=p.duration,H=p.startTime,I=H+C,{start:N,end:O}=s(o.animations,C),W=(O-N)*b,$=(H+N)*b,_=o.name||o.type||u("toolbar.element"),[B,G]=n.useState(!1),L=v(),[R,q]=n.useState(null),z=()=>{q(e=>null===e?k:e)},A=()=>{q(null)},F=(e,t)=>{if(!h(e)){return}e.stopPropagation();const n=e.clientX,i=N,r=O;L(e,{slopX:f,node:o,onMove:e=>{z();const s=(e.clientX-n)/b;if("start"===t){const e=l(H+i+s,H,H+r-a);c(o,C,e-H,r)}else{const e=l(H+r+s,H+i+a,I);c(o,C,i,e-H)}},onEnd:A})};return e(g,{style:{left:`${$}px`,top:26*(null!=R?R:k)+"px",width:`${W}px`,minWidth:"6px",height:"22px"},children:t(w,{style:{width:"100%",height:"100%",outline:d.selectedElements.find(e=>e.id===o.id)?"2px solid var(--pn-primary, var(--primary, #137cbd))":"none",outlineOffset:"-1px"},onPointerDown:e=>{if(!h(e)){return}e.stopPropagation();const t=e.clientX,n=N,i=O-n;L(e,{slopX:f,node:o,onMove:e=>{z();const r=(e.clientX-t)/b,s=l(H+n+r,H,I-i)-H;c(o,C,s,s+i)},onEnd:({moved:e,cancelled:t})=>{A(),e||t||(d.selectElements([o.id]),m(o))}})},children:[B?e(T,{value:o.name||"",onCommit:e=>{o.set({name:e}),G(!1)},onCancel:()=>G(!1)}):e(S,{children:_}),e(P,{onPointerDown:e=>F(e,"start")}),e(M,{onPointerDown:e=>F(e,"end")}),e(y,{onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:t(x,{children:[e(D,{}),t(j,{side:"top",className:"pn:whitespace-nowrap",children:[e(X,{element:o,store:d}),t(E,{onSelect:e=>{e.preventDefault(),G(!0)},children:[e(i,{name:"action.rename"}),u("contextMenu.rename")]}),t(E,{onSelect:e=>{e.preventDefault();const t=d.getElementById(o.id);t&&r([t],d)},children:[e(i,{name:"action.duplicate"}),u("contextMenu.duplicate")]}),t(E,{onSelect:e=>{e.preventDefault(),d.deleteElements([o.id])},children:[e(i,{name:"action.remove"}),u("contextMenu.remove")]})]})]})})]})})});
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import o from"react";import{observer as n}from"mobx-react-lite";import{nodeReaction as i}from"../utils/mobx.js";import{onSnapshot as s}from"mobx-state-tree";import{PolotnoIcon as a}from"../icons/registry.js";import{flags as r}from"../utils/flags.js";import{t as l}from"../utils/l10n.js";import{deepEqual as c}from"../utils/deep-equal.js";import{warnOnceDeprecated as d}from"../utils/deprecation.js";import{DropdownMenu as p,DropdownMenuContent as u,DropdownMenuItem as g}from"../primitives/dropdown-menu.js";import{DRAG_SLOP_PX as m,isPrimaryDrag as f,usePointerDrag as h}from"../utils/pointer-drag.js";import{Spinner as v}from"./spinner.js";import{TrackHandleRight as x,TrackMenu as P,TrackMenuButton as b}from"./track-styles.js";let w=[],y=!1;const R=async()=>{var e;if(y||0===w.length){return}y=!0;const{page:t,setPreview:o}=w.shift();try{o(await t.store.toDataURL({pageId:t.id,pixelRatio:.1,quickMode:!0}))}catch(n){"EXPORT_FAILED"===(null==n?void 0:n.code)&&["workspace-not-mounted","unmounted-during-export"].includes(null===(e=n.details)||void 0===e?void 0:e.reason)||n instanceof Error&&"string"==typeof n.message&&(n.message.includes("Canvas was unmounted.")||n.message.includes("<Workspace /> component is not mounted"))||console.error(n)}finally{y=!1}R()};export function usePagePreview(e){const[t,n]=o.useState(null),a=o.useRef(!1),r="groupRef"in e;r&&d("usePagePreview.setPreview","usePagePreview({ page, setPreview, groupRef }) is deprecated: pass { page, ref } and use the returned data URL instead (https://polotno.com/docs/utils)");const{page:l}=e,p=r?e.groupRef:e.ref,u=r?e.setPreview:n;return o.useEffect(()=>{const e=()=>{w.push({page:l,setPreview:u}),R()};let t=null,o=null,n=Date.now();const r=()=>{t&&clearTimeout(t),a.current&&(o||(o=setTimeout(()=>{Date.now()-n>=6e3&&(e(),n=Date.now(),o=null)},6e3)),t=setTimeout(()=>{e(),n=Date.now(),t=null,o&&(clearTimeout(o),o=null)},300))};let d=null;const g=s(l,e=>{c(d,e)||(r(),d=e)}),m=i(l,()=>l.children.some(e=>e._editModeEnabled),e=>{e||r()}),f=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting?(a.current=!0,r()):(t&&clearTimeout(t),o&&clearTimeout(o),a.current=!1)})},{threshold:.1});return p.current&&f.observe(p.current),()=>{f.disconnect(),t&&clearTimeout(t),o&&clearTimeout(o),g(),m(),w=w.filter(e=>e.page!==l)}},[p,l,u]),t}export const PagePreview=n(({page:n,scale:i})=>{const s=n.store.activePage===n||n.store._selectedPagesIds.includes(n.id),c=o.useRef(null),d=n.store.pages.indexOf(n),w=60/n.computedHeight*n.computedWidth,y=r.animationsEnabled?n.duration*i:w,R=n.store.pages.length>1;o.useLayoutEffect(()=>{c.current&&(c.current.style.width=y+"px")},[d,y]);const j=usePagePreview({page:n,ref:c}),k=h();return t("div",{ref:c,style:{width:y+"px",marginRight:r.animationsEnabled?"0px":"10px",height:"60px",display:"flex",position:"relative",borderRadius:"15px",boxShadow:"0 1px 4px rgba(0, 0, 0, 0.18)"},className:"polotno-page-container pn:[&:hover_.polotno-track-menu]:pointer-events-auto pn:[&:hover_.polotno-track-menu]:opacity-100"+(s?" sortable-selected":""),children:[e("div",{style:{width:"100%",height:"100%",borderRadius:"15px",backgroundImage:j?`url("${j}")`:"none",backgroundRepeat:"repeat-x",backgroundSize:"auto 100%",backgroundColor:"white",display:"flex",justifyContent:"center",alignItems:"center"},onClick:e=>{const{store:t}=n,o=t._selectedPagesIds.length?t._selectedPagesIds:t.activePage?[t.activePage.id]:[],i=o.includes(n.id),s=e.shiftKey;if(s&&i){const e=o.filter(e=>e!==n.id);t.selectPages(e)}else if(s&&!i){const e=o.concat([n.id]);t.selectPages(e)}else{t.selectPages([n.id])}},children:!j&&e(v,{})}),e("div",{style:{position:"absolute",top:"0",left:"0px",bottom:"0px",right:"0px",borderRadius:"15px",border:s?"2px solid rgb(0, 161, 255, 0.9)":"2px solid var(--pn-border)",zIndex:1,pointerEvents:"none"}}),r.animationsEnabled&&t("div",{style:{position:"absolute",zIndex:1,bottom:"5px",left:"5px",backgroundColor:"rgba(0, 0, 0, 0.5)",color:"white",padding:"2px 7px",textAlign:"center",borderRadius:"4rem"},children:[(n.duration/1e3).toFixed(1),"s"]}),r.animationsEnabled&&e(x,{className:"pn:z-[2] pn:before:h-1/2",onPointerDown:e=>{if(!f(e)){return}const t=e.clientX,o=n.duration;k(e,{slopX:m,node:n,onMove:e=>{const s=(e.clientX-t)/i;n.set({duration:Math.max(1e3,o+s)})}})}}),s&&e(P,{className:"polotno-page-menu pn:top-[5px] pn:right-4 pn:translate-y-0",onClick:e=>{e.stopPropagation()},children:t(p,{children:[e(b,{}),t(u,{side:"top",className:"pn:whitespace-nowrap",children:[t(g,{onSelect:e=>{e.preventDefault();const t=n.store,o=(t.selectedPages||[]).filter(Boolean),i=o.length?o:t.activePage?[t.activePage]:[];if(!i.length){return}const s=new Set(i.map(e=>e.id)),a=t.pages.filter(e=>s.has(e.id)),r=a[a.length-1],l=a.map(e=>e.clone()),c=t.pages.indexOf(r);l.forEach((e,t)=>{e.setZIndex(c+1+t)}),t.selectPages(l.map(e=>e.id))},children:[e(a,{name:"action.duplicate",className:"pn:size-4"}),l("pagesTimeline.duplicatePage")]}),t(g,{onSelect:e=>{var t,o,i;e.preventDefault();const s=n.store.addPage({bleed:(null===(t=n.store.activePage)||void 0===t?void 0:t.bleed)||0,width:(null===(o=n.store.activePage)||void 0===o?void 0:o.width)||"auto",height:(null===(i=n.store.activePage)||void 0===i?void 0:i.height)||"auto"}),a=n.store.pages.indexOf(n);s.setZIndex(a+1)},children:[e(a,{name:"action.add",className:"pn:size-4"}),l("pagesTimeline.addPage")]}),R&&t(g,{onSelect:e=>{e.preventDefault();const t=n.store,o=(t.selectedPages||[]).filter(Boolean),i=o.length?o.map(e=>e.id):t.activePage?[t.activePage.id]:[];i.length&&t.deletePages(i)},children:[e(a,{name:"action.remove",className:"pn:size-4"}),l("pagesTimeline.removePage")]})]})]})})]})});
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import o from"react";import{observer as n}from"mobx-react-lite";import{nodeReaction as i}from"../utils/mobx.js";import{getSnapshot as s}from"mobx-state-tree";import{PolotnoIcon as a}from"../icons/registry.js";import{flags as r}from"../utils/flags.js";import{t as l}from"../utils/l10n.js";import{deepEqual as c}from"../utils/deep-equal.js";import{warnOnceDeprecated as d}from"../utils/deprecation.js";import{DropdownMenu as p,DropdownMenuContent as u,DropdownMenuItem as g}from"../primitives/dropdown-menu.js";import{DRAG_SLOP_PX as m,isPrimaryDrag as f,usePointerDrag as h}from"../utils/pointer-drag.js";import{Spinner as v}from"./spinner.js";import{TrackHandleRight as x,TrackMenu as P,TrackMenuButton as b}from"./track-styles.js";let w=[],y=!1;const R=async()=>{var e;if(y||0===w.length){return}y=!0;const{page:t,setPreview:o}=w.shift();try{o(await t.store.toDataURL({pageId:t.id,pixelRatio:.1,quickMode:!0}))}catch(n){"EXPORT_FAILED"===(null==n?void 0:n.code)&&["workspace-not-mounted","unmounted-during-export"].includes(null===(e=n.details)||void 0===e?void 0:e.reason)||n instanceof Error&&"string"==typeof n.message&&(n.message.includes("Canvas was unmounted.")||n.message.includes("<Workspace /> component is not mounted"))||console.error(n)}finally{y=!1}R()};export function usePagePreview(e){const[t,n]=o.useState(null),a=o.useRef(!1),r="groupRef"in e;r&&d("usePagePreview.setPreview","usePagePreview({ page, setPreview, groupRef }) is deprecated: pass { page, ref } and use the returned data URL instead (https://polotno.com/docs/utils)");const{page:l}=e,p=r?e.groupRef:e.ref,u=r?e.setPreview:n;return o.useEffect(()=>{let e=null,t=!1;const o=()=>{const o=s(l);!t&&c(e,o)||(t=!1,e=o,w.push({page:l,setPreview:u}),R())};let n=null,r=null,d=Date.now();const g=(e=!1)=>{t||(t=e),n&&clearTimeout(n),a.current&&(r||(r=setTimeout(()=>{Date.now()-d>=6e3&&(o(),d=Date.now(),r=null)},6e3)),n=setTimeout(()=>{o(),d=Date.now(),n=null,r&&(clearTimeout(r),r=null)},300))},m=l.store.history._onChange(()=>g()),f=i(l,()=>l.children.some(e=>e._editModeEnabled),e=>{e||g(!0)}),h=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting?(a.current=!0,g(!0)):(n&&clearTimeout(n),r&&clearTimeout(r),a.current=!1)})},{threshold:.1});return p.current&&h.observe(p.current),()=>{h.disconnect(),n&&clearTimeout(n),r&&clearTimeout(r),m(),f(),w=w.filter(e=>e.page!==l)}},[p,l,u]),t}export const PagePreview=n(({page:n,scale:i})=>{const s=n.store.activePage===n||n.store._selectedPagesIds.includes(n.id),c=o.useRef(null),d=n.store.pages.indexOf(n),w=60/n.computedHeight*n.computedWidth,y=r.animationsEnabled?n.duration*i:w,R=n.store.pages.length>1;o.useLayoutEffect(()=>{c.current&&(c.current.style.width=y+"px")},[d,y]);const j=usePagePreview({page:n,ref:c}),k=h();return t("div",{ref:c,style:{width:y+"px",marginRight:r.animationsEnabled?"0px":"10px",height:"60px",display:"flex",position:"relative",borderRadius:"15px",boxShadow:"0 1px 4px rgba(0, 0, 0, 0.18)"},className:"polotno-page-container pn:[&:hover_.polotno-track-menu]:pointer-events-auto pn:[&:hover_.polotno-track-menu]:opacity-100"+(s?" sortable-selected":""),children:[e("div",{style:{width:"100%",height:"100%",borderRadius:"15px",backgroundImage:j?`url("${j}")`:"none",backgroundRepeat:"repeat-x",backgroundSize:"auto 100%",backgroundColor:"white",display:"flex",justifyContent:"center",alignItems:"center"},onClick:e=>{const{store:t}=n,o=t._selectedPagesIds.length?t._selectedPagesIds:t.activePage?[t.activePage.id]:[],i=o.includes(n.id),s=e.shiftKey;if(s&&i){const e=o.filter(e=>e!==n.id);t.selectPages(e)}else if(s&&!i){const e=o.concat([n.id]);t.selectPages(e)}else{t.selectPages([n.id])}},children:!j&&e(v,{})}),e("div",{style:{position:"absolute",top:"0",left:"0px",bottom:"0px",right:"0px",borderRadius:"15px",border:s?"2px solid rgb(0, 161, 255, 0.9)":"2px solid var(--pn-border)",zIndex:1,pointerEvents:"none"}}),r.animationsEnabled&&t("div",{style:{position:"absolute",zIndex:1,bottom:"5px",left:"5px",backgroundColor:"rgba(0, 0, 0, 0.5)",color:"white",padding:"2px 7px",textAlign:"center",borderRadius:"4rem"},children:[(n.duration/1e3).toFixed(1),"s"]}),r.animationsEnabled&&e(x,{className:"pn:z-[2] pn:before:h-1/2",onPointerDown:e=>{if(!f(e)){return}const t=e.clientX,o=n.duration;k(e,{slopX:m,node:n,onMove:e=>{const s=(e.clientX-t)/i;n.set({duration:Math.max(1e3,o+s)})}})}}),s&&e(P,{className:"polotno-page-menu pn:top-[5px] pn:right-4 pn:translate-y-0",onClick:e=>{e.stopPropagation()},children:t(p,{children:[e(b,{}),t(u,{side:"top",className:"pn:whitespace-nowrap",children:[t(g,{onSelect:e=>{e.preventDefault();const t=n.store,o=(t.selectedPages||[]).filter(Boolean),i=o.length?o:t.activePage?[t.activePage]:[];if(!i.length){return}const s=new Set(i.map(e=>e.id)),a=t.pages.filter(e=>s.has(e.id)),r=a[a.length-1],l=a.map(e=>e.clone()),c=t.pages.indexOf(r);l.forEach((e,t)=>{e.setZIndex(c+1+t)}),t.selectPages(l.map(e=>e.id))},children:[e(a,{name:"action.duplicate",className:"pn:size-4"}),l("pagesTimeline.duplicatePage")]}),t(g,{onSelect:e=>{var t,o,i;e.preventDefault();const s=n.store.addPage({bleed:(null===(t=n.store.activePage)||void 0===t?void 0:t.bleed)||0,width:(null===(o=n.store.activePage)||void 0===o?void 0:o.width)||"auto",height:(null===(i=n.store.activePage)||void 0===i?void 0:i.height)||"auto"}),a=n.store.pages.indexOf(n);s.setZIndex(a+1)},children:[e(a,{name:"action.add",className:"pn:size-4"}),l("pagesTimeline.addPage")]}),R&&t(g,{onSelect:e=>{e.preventDefault();const t=n.store,o=(t.selectedPages||[]).filter(Boolean),i=o.length?o.map(e=>e.id):t.activePage?[t.activePage.id]:[];i.length&&t.deletePages(i)},children:[e(a,{name:"action.remove",className:"pn:size-4"}),l("pagesTimeline.removePage")]})]})]})})]})});