polotno 3.19.1 → 3.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +8 -2
- package/THIRD_PARTY_NOTICES.md +2871 -0
- package/blueprint/canvas/context-menu/context-menu.js +1 -1
- package/blueprint/canvas/page-controls.d.ts +3 -3
- package/blueprint/pages-timeline/pages-timeline.js +2 -2
- package/blueprint/pages-timeline/play-button.js +2 -2
- package/blueprint/side-panel/animations-panel.d.ts +1 -1
- package/blueprint/side-panel/draw-panel.js +2 -2
- package/blueprint/side-panel/effect-card.js +3 -3
- package/blueprint/side-panel/effects-panel.d.ts +1 -1
- package/blueprint/side-panel/effects-panel.js +1 -1
- package/blueprint/side-panel/elements-panel.d.ts +1 -1
- package/blueprint/side-panel/select-video.d.ts +19 -19
- package/blueprint/side-panel/videos-grid.d.ts +4 -4
- package/blueprint/toolbar/animations-picker.d.ts +1 -1
- package/blueprint/toolbar/element-container.d.ts +1 -1
- package/blueprint/toolbar/figure-toolbar.js +1 -1
- package/blueprint/toolbar/filters-picker.d.ts +1 -1
- package/blueprint/toolbar/filters-picker.js +1 -1
- package/blueprint/toolbar/group-button.js +1 -1
- package/blueprint/toolbar/image-remove-background-button.js +1 -1
- package/blueprint/toolbar/image-toolbar.js +1 -1
- package/blueprint/toolbar/line-toolbar.js +1 -1
- package/blueprint/toolbar/page-toolbar.d.ts +1 -1
- package/blueprint/toolbar/position-picker.js +1 -1
- package/blueprint/toolbar/sketch.d.ts +5 -5
- package/blueprint/toolbar/svg-toolbar.js +1 -1
- package/blueprint/toolbar/table-toolbar.js +1 -1
- package/blueprint/toolbar/text-ai-write.js +1 -1
- package/blueprint/toolbar/text-toolbar.d.ts +1 -1
- package/blueprint.polotno.css +164 -153
- package/canvas/apply-filters.d.ts +2 -6
- package/canvas/apply-filters.js +1 -1
- package/canvas/context-menu/context-menu.js +1 -1
- package/canvas/crop-overlay.d.ts +1 -1
- package/canvas/crop-overlay.js +1 -1
- package/canvas/downscale.d.ts +1 -24
- package/canvas/downscale.js +1 -1
- package/canvas/element.d.ts +3 -1
- package/canvas/element.js +1 -1
- package/canvas/fade-overlay.js +1 -1
- package/canvas/figure-element.js +1 -1
- package/canvas/gif-element.d.ts +32 -0
- package/canvas/gif-element.js +1 -1
- package/canvas/hotkeys.d.ts +1 -1
- package/canvas/hotkeys.js +1 -1
- package/canvas/html-element.js +1 -1
- package/canvas/image-element.d.ts +4 -48
- package/canvas/image-element.js +1 -1
- package/canvas/image-tool-controls.js +1 -1
- package/canvas/line-element.js +1 -1
- package/canvas/lottie-element.d.ts +11 -0
- package/canvas/lottie-element.js +1 -0
- package/canvas/lottie-player.d.ts +2 -0
- package/canvas/lottie-player.js +1 -0
- package/canvas/lottie-player.wasm.d.ts +1 -0
- package/canvas/lottie-player.wasm.js +1 -0
- package/canvas/media-placeholders.d.ts +23 -0
- package/canvas/media-placeholders.js +1 -0
- package/canvas/page-controls.d.ts +3 -3
- package/canvas/page.js +1 -1
- package/canvas/quill-font-formats.d.ts +2 -2
- package/canvas/rect-control.js +1 -1
- package/canvas/render-tag-element.js +1 -1
- package/canvas/rich-editor.d.ts +7 -4
- package/canvas/rich-editor.js +5 -5
- package/canvas/rules.js +2 -2
- package/canvas/table-cell-text.d.ts +18 -0
- package/canvas/table-cell-text.js +1 -0
- package/canvas/table-element.js +1 -1
- package/canvas/text-element/caret-color.d.ts +3 -1
- package/canvas/text-element/render-tag-source.d.ts +33 -0
- package/canvas/text-element/render-tag-source.js +1 -0
- package/canvas/text-element.d.ts +1 -1
- package/canvas/text-element.js +1 -1
- package/canvas/use-color.d.ts +5 -5
- package/canvas/use-filtered-source.js +1 -1
- package/canvas/use-mediabunny-video.js +1 -1
- package/canvas/use-transformer-snap.d.ts +2 -2
- package/canvas/video-element.d.ts +4 -2
- package/canvas/video-element.js +1 -1
- package/icons/animation-icons.d.ts +1 -0
- package/icons/animation-icons.js +1 -1
- package/icons/registry.d.ts +35 -32
- package/icons/registry.js +1 -1
- package/image-tools/geometry.d.ts +2 -2
- package/image-tools/target.d.ts +6 -6
- package/image-tools/target.js +1 -1
- package/lib/utils.d.ts +1 -1
- package/model/figure-model.d.ts +10 -10
- package/model/gif-model.d.ts +10 -10
- package/model/group-model.d.ts +393 -84
- package/model/group-model.js +1 -1
- package/model/image-model.d.ts +10 -10
- package/model/image-tools.d.ts +1 -1
- package/model/line-model.d.ts +10 -10
- package/model/lottie-model.d.ts +242 -0
- package/model/lottie-model.js +5 -0
- package/model/node-model.d.ts +8 -8
- package/model/page-model.d.ts +1186 -297
- package/model/page-model.js +1 -1
- package/model/shape-model.d.ts +11 -11
- package/model/shape-model.js +1 -1
- package/model/store.d.ts +30 -26
- package/model/store.js +1 -1
- package/model/svg-model.d.ts +9 -9
- package/model/table-model.d.ts +127 -20
- package/model/table-model.js +1 -1
- package/model/text-model.d.ts +9 -9
- package/model/video-model.d.ts +10 -10
- package/package.json +36 -55
- package/pages-timeline/pages-timeline.js +1 -1
- package/pages-timeline/track-styles.d.ts +12 -12
- package/polotno-app.d.ts +1 -1
- package/polotno.bundle.js +183 -179
- package/primitives/button.d.ts +4 -4
- package/primitives/dialog.d.ts +4 -4
- package/primitives/dropdown-menu.d.ts +18 -18
- package/primitives/input-group.d.ts +1 -1
- package/primitives/popover.d.ts +4 -4
- package/primitives/select.d.ts +5 -5
- package/primitives/tooltip.d.ts +3 -3
- package/side-panel/animations-panel.js +1 -1
- package/side-panel/background-panel.js +1 -1
- package/side-panel/draw-panel.js +1 -1
- package/side-panel/effect-card.js +1 -1
- package/side-panel/effects-panel.js +1 -1
- package/side-panel/photos-panel.js +1 -1
- package/side-panel/select-lottie.d.ts +11 -0
- package/side-panel/select-lottie.js +1 -0
- package/side-panel/select-video.d.ts +19 -19
- package/side-panel/size-panel.js +1 -1
- package/side-panel/unsplash-credit.d.ts +4 -1
- package/side-panel/unsplash-credit.js +1 -1
- package/side-panel/upload-panel.js +1 -1
- package/themes/carbon.css +1 -1
- package/toolbar/gif-toolbar.d.ts +3 -0
- package/toolbar/gif-toolbar.js +1 -1
- package/toolbar/group-button.js +1 -1
- package/toolbar/html-toolbar.d.ts +1 -0
- package/toolbar/html-toolbar.js +3 -3
- package/toolbar/image-remove-background-button.js +1 -1
- package/toolbar/index.d.ts +1 -1
- package/toolbar/index.js +1 -1
- package/toolbar/line-toolbar.js +1 -1
- package/toolbar/position-picker.js +1 -1
- package/toolbar/table-toolbar.js +1 -1
- package/toolbar/text-ai-write.js +1 -1
- package/toolbar/text-toolbar.js +1 -1
- package/toolbar/toolbar-shared.d.ts +15 -4
- package/toolbar/toolbar-shared.js +1 -1
- package/toolbar/toolbar.js +1 -1
- package/ui.css +2 -2
- package/utils/animations.d.ts +47 -44
- package/utils/animations.js +1 -1
- package/utils/base64.d.ts +1 -2
- package/utils/base64.js +1 -1
- package/utils/clipboard.d.ts +19 -18
- package/utils/clipboard.js +1 -1
- package/utils/fade-gradient.d.ts +1 -1
- package/utils/file.d.ts +4 -3
- package/utils/file.js +1 -1
- package/utils/font-metric.d.ts +29 -28
- package/utils/fonts.js +1 -1
- package/utils/gif-lib.d.ts +1 -1
- package/utils/html2canvas.js +1 -1
- package/utils/image-dpi.d.ts +1 -1
- package/utils/image-dpi.js +1 -1
- package/utils/insert-file.js +1 -1
- package/utils/l10n.d.ts +1 -0
- package/utils/l10n.js +1 -1
- package/utils/lottie.d.ts +12 -0
- package/utils/lottie.js +1 -0
- package/utils/math.d.ts +4 -4
- package/utils/px.d.ts +3 -0
- package/utils/px.js +1 -1
- package/utils/react-color/components/common/Checkboard.d.ts +12 -12
- package/utils/react-color/components/common/Swatch.d.ts +6 -6
- package/utils/react-color/helpers/interaction.d.ts +6 -6
- package/utils/reactcss/components/active.d.ts +6 -6
- package/utils/reactcss/components/hover.d.ts +6 -6
- package/utils/rich-text-html.js +1 -1
- package/utils/selection-colors.js +1 -1
- package/utils/selection-transform.d.ts +4 -4
- package/utils/selection-transform.js +1 -1
- package/utils/split-element.js +1 -1
- package/utils/text-format-state.d.ts +1 -0
- package/utils/text-format-state.js +1 -1
- package/utils/text-format.d.ts +2 -2
- package/utils/text-sizing.d.ts +1 -1
- package/utils/timeline.d.ts +30 -2
- package/utils/timeline.js +1 -1
- package/utils/to-html.js +1 -1
- package/utils/to-svg.js +1 -1
- package/utils/validate-key.js +1 -1
- package/canvas/downscale-bands.d.ts +0 -10
- package/canvas/downscale-bands.js +0 -1
- package/canvas/downscale-kernel.d.ts +0 -7
- package/canvas/downscale-kernel.js +0 -1
- package/canvas/downscale-kernel.wasm.d.ts +0 -1
- package/canvas/downscale-kernel.wasm.js +0 -1
- package/canvas/downscale-passes.d.ts +0 -7
- package/canvas/downscale-passes.js +0 -1
package/utils/animations.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IMSTArray, SnapshotIn, SnapshotOut } from 'mobx-state-tree';
|
|
2
|
-
import { type TextPresetName } from '@polotno/core/animation-presets';
|
|
2
|
+
import { type TextPresetName, type WipeDirection } from '@polotno/core/animation-presets';
|
|
3
3
|
import type { Animation } from '../model/shape-model.js';
|
|
4
4
|
export type WipeBand = {
|
|
5
5
|
axis: 'x' | 'y';
|
|
@@ -20,150 +20,135 @@ export declare const glowColor: (element: {
|
|
|
20
20
|
}) => string;
|
|
21
21
|
export declare const hasNumber: (html: string) => boolean;
|
|
22
22
|
export declare const animations: {
|
|
23
|
-
kenBurns: ({ dTime, element, animation }: {
|
|
24
|
-
dTime: any;
|
|
25
|
-
element: any;
|
|
26
|
-
animation: any;
|
|
27
|
-
}) => {
|
|
28
|
-
cropX: any;
|
|
29
|
-
cropY: any;
|
|
30
|
-
cropWidth: number;
|
|
31
|
-
cropHeight: number;
|
|
32
|
-
};
|
|
33
|
-
cameraZoom: ({ dTime, element, animation }: {
|
|
34
|
-
dTime: any;
|
|
35
|
-
element: any;
|
|
36
|
-
animation: any;
|
|
37
|
-
}) => any;
|
|
38
23
|
none: () => {};
|
|
39
24
|
fade: ({ dTime, element, animation }: {
|
|
25
|
+
animation: any;
|
|
40
26
|
dTime: any;
|
|
41
27
|
element: any;
|
|
42
|
-
animation: any;
|
|
43
28
|
}) => {
|
|
44
29
|
opacity: number;
|
|
45
30
|
};
|
|
46
31
|
rotate: ({ dTime, element, animation }: {
|
|
32
|
+
animation: any;
|
|
47
33
|
dTime: any;
|
|
48
34
|
element: any;
|
|
49
|
-
animation: any;
|
|
50
35
|
}) => {
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
51
38
|
rotation: number;
|
|
52
39
|
x: number;
|
|
53
40
|
y: number;
|
|
54
|
-
width: number;
|
|
55
|
-
height: number;
|
|
56
41
|
};
|
|
57
42
|
blink: ({ dTime, element, animation }: {
|
|
43
|
+
animation: any;
|
|
58
44
|
dTime: any;
|
|
59
45
|
element: any;
|
|
60
|
-
animation: any;
|
|
61
46
|
}) => {
|
|
62
47
|
opacity: number;
|
|
63
48
|
};
|
|
64
49
|
bounce: ({ dTime, element, animation }: {
|
|
50
|
+
animation: any;
|
|
65
51
|
dTime: any;
|
|
66
52
|
element: any;
|
|
67
|
-
animation: any;
|
|
68
53
|
}) => {
|
|
69
|
-
fontSize?: number | undefined;
|
|
70
54
|
x: number;
|
|
71
55
|
y: number;
|
|
72
56
|
width: number;
|
|
73
57
|
height: number;
|
|
58
|
+
fontSize?: number | undefined;
|
|
74
59
|
};
|
|
75
60
|
move: ({ dTime, element, animation }: {
|
|
61
|
+
animation: any;
|
|
76
62
|
dTime: any;
|
|
77
63
|
element: any;
|
|
78
|
-
animation: any;
|
|
79
64
|
}) => {
|
|
80
65
|
x: any;
|
|
81
66
|
y: any;
|
|
82
67
|
};
|
|
83
68
|
zoom: ({ dTime, element, animation }: {
|
|
69
|
+
animation: any;
|
|
84
70
|
dTime: any;
|
|
85
71
|
element: any;
|
|
86
|
-
animation: any;
|
|
87
72
|
}) => {
|
|
88
|
-
fontSize?: number | undefined;
|
|
89
73
|
x: number;
|
|
90
74
|
y: number;
|
|
91
75
|
width: number;
|
|
92
76
|
height: number;
|
|
77
|
+
fontSize?: number | undefined;
|
|
93
78
|
};
|
|
94
79
|
pop: ({ dTime, element, animation }: {
|
|
80
|
+
animation: any;
|
|
95
81
|
dTime: any;
|
|
96
82
|
element: any;
|
|
97
|
-
animation: any;
|
|
98
83
|
}) => {
|
|
99
|
-
opacity: number;
|
|
100
|
-
fontSize?: number | undefined;
|
|
101
84
|
x: number;
|
|
102
85
|
y: number;
|
|
103
86
|
width: number;
|
|
104
87
|
height: number;
|
|
88
|
+
fontSize?: number | undefined;
|
|
89
|
+
opacity: number;
|
|
105
90
|
};
|
|
106
91
|
rise: ({ dTime, element, animation }: {
|
|
92
|
+
animation: any;
|
|
107
93
|
dTime: any;
|
|
108
94
|
element: any;
|
|
109
|
-
animation: any;
|
|
110
95
|
}) => {
|
|
111
96
|
y: any;
|
|
112
97
|
opacity: number;
|
|
113
98
|
};
|
|
114
99
|
flip: ({ dTime, animation }: {
|
|
115
|
-
dTime: any;
|
|
116
100
|
animation: any;
|
|
101
|
+
dTime: any;
|
|
117
102
|
}) => {
|
|
118
103
|
flipScale: number;
|
|
119
104
|
};
|
|
120
105
|
growTurn: ({ dTime, element, animation }: {
|
|
106
|
+
animation: any;
|
|
121
107
|
dTime: any;
|
|
122
108
|
element: any;
|
|
123
|
-
animation: any;
|
|
124
109
|
}) => {
|
|
125
|
-
|
|
110
|
+
width: number;
|
|
111
|
+
height: number;
|
|
126
112
|
rotation: number;
|
|
127
113
|
x: number;
|
|
128
114
|
y: number;
|
|
129
|
-
|
|
130
|
-
height: number;
|
|
115
|
+
opacity: number;
|
|
131
116
|
};
|
|
132
117
|
pulse: ({ dTime, element, animation }: {
|
|
118
|
+
animation: any;
|
|
133
119
|
dTime: any;
|
|
134
120
|
element: any;
|
|
135
|
-
animation: any;
|
|
136
121
|
}) => {
|
|
137
|
-
fontSize?: number | undefined;
|
|
138
122
|
x: number;
|
|
139
123
|
y: number;
|
|
140
124
|
width: number;
|
|
141
125
|
height: number;
|
|
126
|
+
fontSize?: number | undefined;
|
|
142
127
|
};
|
|
143
128
|
float: ({ dTime, element, animation }: {
|
|
129
|
+
animation: any;
|
|
144
130
|
dTime: any;
|
|
145
131
|
element: any;
|
|
146
|
-
animation: any;
|
|
147
132
|
}) => {
|
|
148
133
|
y: number;
|
|
149
134
|
};
|
|
150
135
|
shake: ({ dTime, element, animation }: {
|
|
136
|
+
animation: any;
|
|
151
137
|
dTime: any;
|
|
152
138
|
element: any;
|
|
153
|
-
animation: any;
|
|
154
139
|
}) => {
|
|
155
140
|
x: any;
|
|
156
141
|
};
|
|
157
142
|
wipe: ({ dTime, animation }: {
|
|
158
|
-
dTime: any;
|
|
159
143
|
animation: any;
|
|
144
|
+
dTime: any;
|
|
160
145
|
}) => {
|
|
161
146
|
wipe: WipeBand;
|
|
162
147
|
};
|
|
163
148
|
glow: ({ dTime, element, animation }: {
|
|
149
|
+
animation: any;
|
|
164
150
|
dTime: any;
|
|
165
151
|
element: any;
|
|
166
|
-
animation: any;
|
|
167
152
|
}) => {
|
|
168
153
|
shadowEnabled: boolean;
|
|
169
154
|
shadowColor: string;
|
|
@@ -173,23 +158,38 @@ export declare const animations: {
|
|
|
173
158
|
shadowOpacity: number;
|
|
174
159
|
};
|
|
175
160
|
blur: ({ dTime, element, animation }: {
|
|
161
|
+
animation: any;
|
|
176
162
|
dTime: any;
|
|
177
163
|
element: any;
|
|
178
|
-
animation: any;
|
|
179
164
|
}) => {
|
|
180
165
|
blurEnabled: boolean;
|
|
181
166
|
blurRadius: any;
|
|
182
167
|
opacity: number;
|
|
183
168
|
};
|
|
184
169
|
count: ({ dTime, element, animation }: {
|
|
170
|
+
animation: any;
|
|
185
171
|
dTime: any;
|
|
186
172
|
element: any;
|
|
187
|
-
animation: any;
|
|
188
173
|
}) => {
|
|
189
174
|
text?: undefined;
|
|
190
175
|
} | {
|
|
191
176
|
text: string;
|
|
192
177
|
};
|
|
178
|
+
kenBurns: ({ dTime, element, animation }: {
|
|
179
|
+
animation: any;
|
|
180
|
+
dTime: any;
|
|
181
|
+
element: any;
|
|
182
|
+
}) => {
|
|
183
|
+
cropX: any;
|
|
184
|
+
cropY: any;
|
|
185
|
+
cropWidth: number;
|
|
186
|
+
cropHeight: number;
|
|
187
|
+
};
|
|
188
|
+
cameraZoom: ({ dTime, element, animation }: {
|
|
189
|
+
animation: any;
|
|
190
|
+
dTime: any;
|
|
191
|
+
element: any;
|
|
192
|
+
}) => any;
|
|
193
193
|
};
|
|
194
194
|
export declare const isBuiltIn: (name: string) => boolean;
|
|
195
195
|
type TimedAnimation = {
|
|
@@ -208,6 +208,7 @@ export type TextUnitsFrame = {
|
|
|
208
208
|
name: TextPresetName;
|
|
209
209
|
data?: {
|
|
210
210
|
strength?: number;
|
|
211
|
+
direction?: string;
|
|
211
212
|
};
|
|
212
213
|
};
|
|
213
214
|
dTime: number;
|
|
@@ -223,6 +224,8 @@ export declare const textUnitState: ({ animation, dTime }: TextUnitsFrame, index
|
|
|
223
224
|
blur: number;
|
|
224
225
|
from: number;
|
|
225
226
|
to: number;
|
|
227
|
+
direction: WipeDirection | undefined;
|
|
228
|
+
shift: number;
|
|
226
229
|
};
|
|
227
230
|
export type AnimationAttrs = Omit<SnapshotIn<typeof Animation>, 'type'>;
|
|
228
231
|
export declare function setAnimationOf(animations: IMSTArray<typeof Animation>, type: 'enter' | 'exit' | 'loop', attrs: AnimationAttrs): void;
|
|
@@ -245,7 +248,7 @@ export declare const loopWindow: (element: PlayedElement, loop: PreviewedAnimati
|
|
|
245
248
|
duration: number;
|
|
246
249
|
delay: number;
|
|
247
250
|
enabled: boolean;
|
|
248
|
-
type: "
|
|
251
|
+
type: "enter" | "exit" | "loop";
|
|
249
252
|
name: string;
|
|
250
253
|
data: {};
|
|
251
254
|
easing: string | undefined;
|
package/utils/animations.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EASINGS as t,recommendedEasing as n,resolveEasing as e}from"@polotno/core/easing";import{bounceScale as
|
|
1
|
+
import{EASINGS as t,recommendedEasing as n,resolveEasing as e}from"@polotno/core/easing";import{bounceScale as i,MOVE_OFFSETS as o,zoomStart as a,POP_FADE as r,PULSE_AMOUNT as s,GROW_TURN_ANGLE as l,GROW_TURN_SCALE as d,TEXT_BLUR as c,TEXT_PRESETS as m,TEXT_RISE as p,TEXT_WAVE as u,TRAVEL as h,isTextPreset as g,shakeSwing as v,textLoopStart as x,textUnitTiming as y,WIPE_DIRECTION as f,wipeDirection as b}from"@polotno/core/animation-presets";import{firstStopColor as w}from"@polotno/core/gradient";import{getCropRect as M}from"@polotno/core/image";import{flags as T}from"./flags.js";import{degToRad as O,rotateAroundCenter as j}from"./math.js";import{getElementTimeRange as S}from"./timeline.js";const B=t=>{var n,e,i,o;const a=null!==(i=null===(n=t.page)||void 0===n?void 0:n.computedWidth)&&void 0!==i?i:0,r=null!==(o=null===(e=t.page)||void 0===e?void 0:e.computedHeight)&&void 0!==o?o:0;return a>0&&r>0?Math.min(a,r):Math.max(t.width,t.height)};export const KEN_BURNS_ZOOM=.15;export const KEN_BURNS_PAN={right:{x:1,y:0},left:{x:-1,y:0},up:{x:0,y:-1},down:{x:0,y:1}};export const glowColor=t=>{if(t.shadowEnabled||"black"!==t.shadowColor){return t.shadowColor}const n="line"===t.type?t.color:t.fill;return"string"==typeof n?w(n):"#000000"};const E=(t,n)=>(1-Math.cos(2*Math.PI*t/n))/2,X=(t,n)=>{const e=t%n/(n/2);return e<=1?e:2-e},Y=(t,{type:n,duration:e})=>"exit"===n?1-t/e:t/e,k=t=>Math.min(1,Math.max(0,t)),N=(t,n)=>{const e=O(t.rotation),i=Math.cos(e),o=Math.sin(e),a=t.width*(1-n),r=t.height*(1-n);return Object.assign({x:t.x+(a*i-r*o)/2,y:t.y+(a*o+r*i)/2,width:t.width*n,height:t.height*n},void 0===t.fontSize?{}:{fontSize:t.fontSize*n})},W=/\d+(?:[.,]\d+)*/,I=t=>{var n,e;const i=[...new Set(null!==(n=t.match(/[.,]/g))&&void 0!==n?n:[])],o=Math.max(t.lastIndexOf("."),t.lastIndexOf(",")),a=t.length-o-1,r=o>=0&&(i.length>1||3!==a),s=r?t[o]:"",l=null!==(e=i.find(t=>t!==s))&&void 0!==e?e:"",d=r?a:0,c=(l?t.split(l).join(""):t).replace(s||".",".");return{value:parseFloat(c),write:t=>{const[n,e]=t.toFixed(d).split("."),i=l?n.replace(/\B(?=(\d{3})+(?!\d))/g,l):n;return e?i+s+e:i}}},U=(t,n)=>{const e=t.split(/(<[^>]*>|&[#\w]+;)/);for(let i=0;i<e.length;i++){if(e[i].startsWith("<")||e[i].startsWith("&")){continue}const t=W.exec(e[i]);if(!t){continue}const{value:o,write:a}=I(t[0]);return e[i]=e[i].slice(0,t.index)+a(n(o))+e[i].slice(t.index+t[0].length),e.join("")}return null};export const hasNumber=t=>null!==U(t,t=>t);const _={right:{cropX:-1},left:{cropX:1},up:{cropY:1},down:{cropY:-1}},z=Object.fromEntries(Object.entries(m).map(([t,{like:n}])=>[t,t=>animations[n](t)]));export const animations=Object.assign(Object.assign({none:()=>({}),fade:({dTime:t,element:n,animation:e})=>{const i=t/e.duration;return"enter"===e.type?{opacity:i*n.opacity}:{opacity:(1-i)*n.opacity}},rotate:({dTime:t,element:n,animation:e})=>{const i=t/e.duration*360;return j({x:n.x,y:n.y,width:n.width,height:n.height,rotation:n.rotation},i)},blink:({dTime:t,element:n,animation:e})=>({opacity:n.opacity*(1-X(t,e.duration))}),bounce:({dTime:t,element:n,animation:e})=>{var o;const a=i(null!==(o=e.data.strength)&&void 0!==o?o:1);return N(n,1-(1-a)*X(t,e.duration))},move:({dTime:t,element:n,animation:e})=>{var i;const a=o[e.data.direction]||o.right,r=null!==(i=e.data.strength)&&void 0!==i?i:1,s=("exit"===e.type?-1:1)*B(n)*h.move*r*(1-Y(t,e));return{x:n.x+a.x*s,y:n.y+a.y*s}},zoom:({dTime:t,element:n,animation:e})=>{var i;const o=a(e.data.direction,null!==(i=e.data.strength)&&void 0!==i?i:1),r=Y(t,e);return N(n,o+(1-o)*r)},pop:({dTime:t,element:n,animation:e})=>{var i;const o=null!==(i=e.data.strength)&&void 0!==i?i:1,a=Math.max(0,1-o),s=Y(t,e);return Object.assign(Object.assign({},N(n,a+(1-a)*s)),{opacity:n.opacity*k(s/r)})},rise:({dTime:t,element:n,animation:e})=>{var i;const o=null!==(i=e.data.strength)&&void 0!==i?i:1,a=B(n)*h.rise*o,r=Y(t,e),s="exit"===e.type?-1:1;return{y:n.y+s*a*(1-r),opacity:n.opacity*r}},flip:({dTime:t,animation:n})=>({flipScale:Math.cos(Math.PI*(1-Y(t,n)))}),growTurn:({dTime:t,element:n,animation:e})=>{var i;const o=null!==(i=e.data.strength)&&void 0!==i?i:1,a="exit"===e.type,r=Y(t,e),s=N(n,d+(1-d)*r),c=(a?1:-1)*l*o*(1-r);return Object.assign(Object.assign({},j(Object.assign(Object.assign({},s),{rotation:n.rotation}),c)),{opacity:n.opacity*r})},pulse:({dTime:t,element:n,animation:e})=>{var i;const o=null!==(i=e.data.strength)&&void 0!==i?i:1,a=s*o*E(t,e.duration);return N(n,1+a)},float:({dTime:t,element:n,animation:e})=>{var i;const o=null!==(i=e.data.strength)&&void 0!==i?i:1,a=B(n)*h.float*o;return{y:n.y-a*E(t,e.duration)}},shake:({dTime:t,element:n,animation:e})=>{var i;const o=null!==(i=e.data.strength)&&void 0!==i?i:1,a=t/e.duration%1,r=v(a);return{x:n.x+B(n)*h.shake*o*r}},wipe:({dTime:t,animation:n})=>{var e;const{axis:i,forward:o}=f[null!==(e=b(n.name,n.data))&&void 0!==e?e:"right"],a=k(t/n.duration),r=o?a:1-a;return{wipe:o===("exit"===n.type)?{axis:i,from:r,to:1}:{axis:i,from:0,to:r}}},glow:({dTime:t,element:n,animation:e})=>{var i;const o=null!==(i=e.data.strength)&&void 0!==i?i:1;return{shadowEnabled:!0,shadowColor:glowColor(n),shadowOffsetX:0,shadowOffsetY:0,shadowBlur:.02*B(n)*o,shadowOpacity:E(t,e.duration)}},blur:({dTime:t,element:n,animation:e})=>{var i;const o=null!==(i=e.data.strength)&&void 0!==i?i:1,a=n.blurEnabled?n.blurRadius:0,r=Y(t,e);return{blurEnabled:!0,blurRadius:a+20*o*(1-r),opacity:n.opacity*r}},count:({dTime:t,element:n,animation:e})=>{var i;if("string"!=typeof n.text){return{}}const o=Number(null!==(i=e.data.from)&&void 0!==i?i:0),a=Y(t,e),r=U(n.text,t=>o+(t-o)*a);return null===r?{}:{text:r}}},z),{kenBurns:({dTime:t,element:n,animation:e})=>{var i,o;const a="out"===e.data.zoom,r=k(t/e.duration),s=.15*(null!==(i=e.data.strength)&&void 0!==i?i:1)*(a?1-r:r),l=Math.max(.05,1-s),d=null!==(o=KEN_BURNS_PAN[e.data.direction])&&void 0!==o?o:{x:0,y:0},c=a?-1:1,m=n._sourceSize,p=m&&M(n,m),[u,h]=p?[p.width/m.width,p.height/m.height]:[n.cropWidth,n.cropHeight],g=u*l,v=h*l;return{cropX:n.cropX+(u-g)*(1+d.x*c)/2,cropY:n.cropY+(h-v)*(1+d.y*c)/2,cropWidth:g,cropHeight:v}},cameraZoom:({dTime:t,element:n,animation:e})=>{var i,o,a;const r={},s=e.data.direction||"right",l=_[s]||_.right,d=null!==(i=e.data.movementStrength)&&void 0!==i?i:.1,c=null!==(o=e.data.shakeStrength)&&void 0!==o?o:.015;let m=null!==(a=e.data.zoomStrength)&&void 0!==a?a:.6;const p=t/e.duration,u=c*(1-p),h=Math.sin(12*p)*u*.7+Math.sin(8*p)*u*.3;if("exit"===e.type){const t=Math.max(n.cropWidth||1,n.cropHeight||1);m=Math.min(m,1-t)}e.type;const g=1-Math.pow(1-p,2),v=n.cropX||0,x=n.cropY||0,y=n.cropWidth||1,f=n.cropHeight||1,b=y,w=f;let M,T,O=0,j=0;if(l.cropX){const t=l.cropX>0?1-(v+y):v;O=Math.min(t,Math.abs(d))*l.cropX}if(l.cropY){const t=l.cropY>0?1-(x+f):x;j=Math.min(t,Math.abs(d))*l.cropY}return"enter"===e.type?(M=l.cropX?v+O*(1-g):v,T=l.cropY?x+j*(1-g):x):(M=l.cropX?v+O*g:v,T=l.cropY?x+j*g:x),r.cropX=Math.max(0,Math.min(1-b,M+h*b)),r.cropY=Math.max(0,Math.min(1-w,T+h*w)),r.cropWidth=b,r.cropHeight=w,r}});const A=new Map(Object.entries(animations));export const isBuiltIn=t=>A.has(t)&&A.get(t)===animations[t];const C=new Set(["blink","bounce"]),H=(n,i)=>{const o=e(i),a=i.duration;if("linear"===o||!(a>0)){return n}const r=t[o];if("loop"!==i.type){return r(k(n/a))*a}const s=C.has(i.name)?a/2:a,l=Math.floor(n/s)*s;return l+r((n-l)/s)*s};export const playsTextUnits=(t,n)=>{if(!g(n.name)||!isBuiltIn(n.name)){return!1}const e="loop"in m[n.name];return"loop"===n.type===e&&"type"in t&&"text"===t.type&&!("curveEnabled"in t&&t.curveEnabled)&&T.renderTagTextEnabled};export const textUnitState=({animation:n,dTime:i},o,a)=>{var s,l;const{like:d}=m[n.name],h="loop"===n.type,g="exit"===n.type,v=n.duration,x=g?a-1-o:o,{step:f,span:w}=y(n.name,v,a),M=x*f,T=h&&v>0?i%v:i,O=w>0?k((T-M)/w):T>=M?1:0,j={opacity:1,y:0,scale:1,blur:0,from:0,to:1,direction:void 0,shift:0};if(h){const t=null!==(l=null===(s=n.data)||void 0===s?void 0:s.strength)&&void 0!==l?l:1;return j.y=-u*t*E(O,1),j}const S=t[e(n)](O),B=g?1-S:S;return j.opacity=k(B),"wipe"===d?(j.opacity=1,j.direction=b(n.name,n.data),"slide"in m[n.name]?j.shift=g?1-B:B-1:g?j.from=1-k(B):j.to=k(B)):"rise"===d?j.y=(g?-1:1)*p*(1-B):"pop"===d?(j.scale=Math.max(0,B),j.opacity=k(B/r)):"blur"===d&&(j.blur=c*Math.max(0,1-B)),j};export function setAnimationOf(t,e,i){const o=t.find(t=>t.type===e),a=void 0===i.name||i.name===(null==o?void 0:o.name)||"easing"in i?i:Object.assign(Object.assign({},i),{easing:n(e,i.name)});o?Object.assign(o,a):t.push(Object.assign({type:e},a))}export const playedAnimations=t=>{var n,e,i;return null!==(i=null===(e=null===(n=t.store)||void 0===n?void 0:n._animationPreview)||void 0===e?void 0:e[t.id])&&void 0!==i?i:t.animations};export const spansElementTime=t=>"kenBurns"===t&&isBuiltIn(t);export const loopWindow=(t,n,e)=>{if("kenBurns"===(i=n.name)&&isBuiltIn(i)){const{start:i,end:o}=S(e,t.page.duration);return{start:i,animation:Object.assign(Object.assign({},n),{duration:Math.max(1,o-i)})}}var i;return{start:playsTextUnits(t,n)?x(n,e,t.page.duration):n.delay,animation:n}};export const animate=({element:t,dTime:n,animation:e})=>{if(playsTextUnits(t,e)){return{textUnits:{animation:e,dTime:n}}}const i=animations[e.name];return i?i({element:t,dTime:H(n,e),animation:e}):(console.error("Can not find animation type: "+e.name),{})};export const registerAnimation=(t,n)=>{animations[t]&&console.warn(`Animation "${t}" already exists and will be overridden`),animations[t]=n};
|
package/utils/base64.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare const encodeBase64: (bytes: Uint8Array) => string;
|
|
1
|
+
export { base64ToBytes as decodeBase64, bytesToBase64 as encodeBase64, } from '@polotno/core/image-bytes';
|
package/utils/base64.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { base64ToBytes as decodeBase64, bytesToBase64 as encodeBase64, } from '@polotno/core/image-bytes';
|
package/utils/clipboard.d.ts
CHANGED
|
@@ -6,12 +6,13 @@ export declare const isClipboardEmpty: () => boolean;
|
|
|
6
6
|
export declare const resetClipboard: () => void;
|
|
7
7
|
export declare const copyToEvent: (store: StoreType, e: ClipboardEvent) => boolean;
|
|
8
8
|
export declare const cutToEvent: (store: StoreType, e: ClipboardEvent) => boolean;
|
|
9
|
+
export declare const escapeText: (text: string) => string;
|
|
9
10
|
export declare const insertTextElement: (store: StoreType, text: string, extra?: Record<string, any>) => (import("mobx-state-tree").ModelInstanceTypeProps<{
|
|
10
11
|
id: import("mobx-state-tree").ISimpleType<string>;
|
|
11
12
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
12
13
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
13
14
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
14
|
-
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"
|
|
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]>;
|
|
15
16
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
16
17
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
17
18
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -29,7 +30,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
29
30
|
delay: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
30
31
|
duration: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
31
32
|
enabled: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
32
|
-
type: import("mobx-state-tree").ISimpleType<"
|
|
33
|
+
type: import("mobx-state-tree").ISimpleType<"enter" | "exit" | "loop">;
|
|
33
34
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
34
35
|
data: import("mobx-state-tree").IType<{} | null | undefined, {}, {}>;
|
|
35
36
|
easing: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
|
|
@@ -100,7 +101,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
100
101
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
101
102
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
102
103
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
103
|
-
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"
|
|
104
|
+
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
105
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
105
106
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
106
107
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -112,7 +113,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
112
113
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
113
114
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
114
115
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
115
|
-
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"
|
|
116
|
+
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
117
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
117
118
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
118
119
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -124,7 +125,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
124
125
|
type: string | undefined;
|
|
125
126
|
name: string | undefined;
|
|
126
127
|
opacity: number | undefined;
|
|
127
|
-
blendMode: "
|
|
128
|
+
blendMode: "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
|
|
128
129
|
custom: any;
|
|
129
130
|
visible: boolean | undefined;
|
|
130
131
|
selectable: boolean | undefined;
|
|
@@ -143,7 +144,6 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
143
144
|
alwaysOnTop: boolean;
|
|
144
145
|
showInExport: boolean;
|
|
145
146
|
} | {
|
|
146
|
-
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
|
|
147
147
|
id: string;
|
|
148
148
|
type: string;
|
|
149
149
|
name: string;
|
|
@@ -154,6 +154,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
154
154
|
removable: boolean;
|
|
155
155
|
alwaysOnTop: boolean;
|
|
156
156
|
showInExport: boolean;
|
|
157
|
+
blendMode: "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
157
158
|
}>>;
|
|
158
159
|
readonly parent: any;
|
|
159
160
|
readonly isHighlighted: boolean;
|
|
@@ -171,7 +172,6 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
171
172
|
alwaysOnTop: boolean;
|
|
172
173
|
showInExport: boolean;
|
|
173
174
|
} | {
|
|
174
|
-
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
|
|
175
175
|
id: string;
|
|
176
176
|
type: string;
|
|
177
177
|
name: string;
|
|
@@ -182,6 +182,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
182
182
|
removable: boolean;
|
|
183
183
|
alwaysOnTop: boolean;
|
|
184
184
|
showInExport: boolean;
|
|
185
|
+
blendMode: "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
185
186
|
};
|
|
186
187
|
} & {
|
|
187
188
|
clone(attrs?: any, { skipSelect }?: {
|
|
@@ -206,7 +207,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
206
207
|
readonly isSelected: boolean;
|
|
207
208
|
readonly isSelectedDirectly: boolean;
|
|
208
209
|
} & {
|
|
209
|
-
setAnimation(type:
|
|
210
|
+
setAnimation(type: 'enter' | 'exit' | 'loop', attrs: import("./animations.js").AnimationAttrs): void;
|
|
210
211
|
setFilter(type: any, value: any): void;
|
|
211
212
|
} & {
|
|
212
213
|
set(attrs: any): void;
|
|
@@ -217,7 +218,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
217
218
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
218
219
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
219
220
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
220
|
-
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"
|
|
221
|
+
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]>;
|
|
221
222
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
222
223
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
223
224
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -235,7 +236,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
235
236
|
delay: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
236
237
|
duration: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
237
238
|
enabled: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
238
|
-
type: import("mobx-state-tree").ISimpleType<"
|
|
239
|
+
type: import("mobx-state-tree").ISimpleType<"enter" | "exit" | "loop">;
|
|
239
240
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
240
241
|
data: import("mobx-state-tree").IType<{} | null | undefined, {}, {}>;
|
|
241
242
|
easing: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
|
|
@@ -306,7 +307,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
306
307
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
307
308
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
308
309
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
309
|
-
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"
|
|
310
|
+
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]>;
|
|
310
311
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
311
312
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
312
313
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -318,7 +319,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
318
319
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
319
320
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
320
321
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
321
|
-
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"
|
|
322
|
+
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]>;
|
|
322
323
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
323
324
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
324
325
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -330,7 +331,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
330
331
|
type: string | undefined;
|
|
331
332
|
name: string | undefined;
|
|
332
333
|
opacity: number | undefined;
|
|
333
|
-
blendMode: "
|
|
334
|
+
blendMode: "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
|
|
334
335
|
custom: any;
|
|
335
336
|
visible: boolean | undefined;
|
|
336
337
|
selectable: boolean | undefined;
|
|
@@ -349,7 +350,6 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
349
350
|
alwaysOnTop: boolean;
|
|
350
351
|
showInExport: boolean;
|
|
351
352
|
} | {
|
|
352
|
-
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
|
|
353
353
|
id: string;
|
|
354
354
|
type: string;
|
|
355
355
|
name: string;
|
|
@@ -360,6 +360,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
360
360
|
removable: boolean;
|
|
361
361
|
alwaysOnTop: boolean;
|
|
362
362
|
showInExport: boolean;
|
|
363
|
+
blendMode: "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
363
364
|
}>>;
|
|
364
365
|
readonly parent: any;
|
|
365
366
|
readonly isHighlighted: boolean;
|
|
@@ -377,7 +378,6 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
377
378
|
alwaysOnTop: boolean;
|
|
378
379
|
showInExport: boolean;
|
|
379
380
|
} | {
|
|
380
|
-
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
|
|
381
381
|
id: string;
|
|
382
382
|
type: string;
|
|
383
383
|
name: string;
|
|
@@ -388,6 +388,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
388
388
|
removable: boolean;
|
|
389
389
|
alwaysOnTop: boolean;
|
|
390
390
|
showInExport: boolean;
|
|
391
|
+
blendMode: "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
391
392
|
};
|
|
392
393
|
} & {
|
|
393
394
|
clone(attrs?: any, { skipSelect }?: {
|
|
@@ -412,7 +413,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
412
413
|
readonly isSelected: boolean;
|
|
413
414
|
readonly isSelectedDirectly: boolean;
|
|
414
415
|
} & {
|
|
415
|
-
setAnimation(type:
|
|
416
|
+
setAnimation(type: 'enter' | 'exit' | 'loop', attrs: import("./animations.js").AnimationAttrs): void;
|
|
416
417
|
setFilter(type: any, value: any): void;
|
|
417
418
|
} & {
|
|
418
419
|
set(attrs: any): void;
|
|
@@ -430,7 +431,6 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
430
431
|
alwaysOnTop: boolean;
|
|
431
432
|
showInExport: boolean;
|
|
432
433
|
} | {
|
|
433
|
-
blendMode: "normal" | "color" | "overlay" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "saturation" | "screen" | "soft-light";
|
|
434
434
|
id: string;
|
|
435
435
|
type: string;
|
|
436
436
|
name: string;
|
|
@@ -441,8 +441,9 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
441
441
|
removable: boolean;
|
|
442
442
|
alwaysOnTop: boolean;
|
|
443
443
|
showInExport: boolean;
|
|
444
|
+
blendMode: "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "normal" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
444
445
|
}>> & {
|
|
445
|
-
type:
|
|
446
|
+
type: 'text';
|
|
446
447
|
}) | undefined;
|
|
447
448
|
export declare const pasteFromEvent: (store: StoreType, e: ClipboardEvent, opts?: {
|
|
448
449
|
onText?: (text: string) => void;
|
package/utils/clipboard.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{forEveryChild as e}from"../model/group-model.js";import{nanoid as t}from"nanoid";import{getTotalClientRect as a}from"./math.js";import{
|
|
1
|
+
import{forEveryChild as e}from"../model/group-model.js";import{nanoid as t}from"nanoid";import{getTotalClientRect as a}from"./math.js";import{richTextToPlainText as o}from"@polotno/core/text";import{insertFileIntoPage as r}from"./insert-file.js";import{decodeBase64 as l,encodeBase64 as n}from"./base64.js";let i={data:[],pageId:"",payloadId:""};const s="polotno_clipboard",d=(e,t,a)=>{i={data:JSON.parse(JSON.stringify(e)),pageId:t||"",payloadId:a||""};try{localStorage.setItem(s,JSON.stringify(e)),localStorage.setItem(s+"_page",t||""),localStorage.setItem(s+"_payload",a||"")}catch(o){}},c=()=>{try{const e=localStorage.getItem(s),t=localStorage.getItem(s+"_page"),a=localStorage.getItem(s+"_payload");if(e){return{data:JSON.parse(e),pageId:t,payloadId:a}}}catch(e){}return i},p="data-polotno-clipboard";export const copy=e=>{var t;0!==e.selectedElements.length&&d(e.selectedElements.map(e=>e.toJSON()),null===(t=e.activePage)||void 0===t?void 0:t.id)};export const cut=e=>{if(0===e.selectedElements.length){return}copy(e);const t=e.selectedElements.filter(e=>e.removable).map(e=>e.id);e.deleteElements(t)};const m=(t,o)=>{t.history.transaction(()=>{var r,l;let n=0,i=0;const{data:s,pageId:c,payloadId:p}=o;if(c===(null===(r=t.activePage)||void 0===r?void 0:r.id)){n=t.width/20,i=t.height/20}else{const o=[];e({children:s},e=>{"group"!==e.type&&o.push(e)});const r=a(o);r.maxX>t.width&&(n=-r.minX),r.maxY>t.height&&(i=-r.minY)}const m=[];e({children:s},e=>{delete e.id,"group"!==e.type&&(e.x+=n,e.y+=i)}),s.forEach(e=>{var a;const o=null===(a=t.activePage)||void 0===a?void 0:a.addElement(e);o&&m.push(o.id)}),d(s,null===(l=t.activePage)||void 0===l?void 0:l.id,p),t.selectElements(m)})};export const paste=e=>{m(e,c())};export const isClipboardEmpty=()=>0===c().data.length;export const resetClipboard=()=>{i={data:[],pageId:"",payloadId:""};try{localStorage.removeItem(s),localStorage.removeItem(s+"_page"),localStorage.removeItem(s+"_payload")}catch(e){}};export const copyToEvent=(a,r)=>{var l,i;if(!r.clipboardData||0===a.selectedElements.length){return!1}const s=a.selectedElements.map(e=>e.toJSON()),c=t(),m={v:1,id:c,pageId:(null===(l=a.activePage)||void 0===l?void 0:l.id)||"",elements:s};r.clipboardData.setData("text/html",`<div ${p}="${(e=>n((new TextEncoder).encode(JSON.stringify(e))))(m)}"></div>`);const g=[];return e({children:s},e=>{"text"===e.type&&g.push(o(e.text))}),r.clipboardData.setData("text/plain",g.join("\n")||" "),r.preventDefault(),d(s,null===(i=a.activePage)||void 0===i?void 0:i.id,c),!0};export const cutToEvent=(e,t)=>{const a=copyToEvent(e,t);if(a){const t=e.selectedElements.filter(e=>e.removable).map(e=>e.id);e.deleteElements(t)}return a};export const escapeText=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");export const insertTextElement=(e,t,a={})=>{var o;const r=e.width/2,l=(e.width+e.height)/2160;return null===(o=e.activePage)||void 0===o?void 0:o.addElement(Object.assign({type:"text",x:e.width/2-r/2,y:e.height/2-15,width:r,fontSize:30*l,text:t},a))};export const pasteFromEvent=(e,t,a={})=>{const o=t.clipboardData;if(!o){return!1}const n=o.getData("text/html");if(n&&n.includes(p)){const a=(e=>{var a;try{const t=null===(a=(new DOMParser).parseFromString(e,"text/html").querySelector(`[${p}]`))||void 0===a?void 0:a.getAttribute(p);if(!t){return null}const o=JSON.parse((new TextDecoder).decode(l(t)));return Array.isArray(o.elements)?o:null}catch(t){return null}})(n);if(a){t.preventDefault();const o=c();return a.id&&a.id===o.payloadId?m(e,o):m(e,{data:a.elements,pageId:a.pageId,payloadId:a.id}),!0}}const i=o.getData("text/plain"),s=o.files?Array.from(o.files):[];if(0===s.length&&(e=>{if(!/<svg[\s>]/i.test(e)){return!1}const t=(new DOMParser).parseFromString(e.trim(),"image/svg+xml");return"svg"===t.documentElement.localName&&0===t.getElementsByTagName("parsererror").length})(i)&&s.push(new File([i.trim()],"pasted.svg",{type:"image/svg+xml"})),s.length>0){return t.preventDefault(),(async()=>{for(const a of s){try{await r({file:a,store:e})}catch(t){console.error("polotno: failed to insert pasted file",t)}}})(),!0}if(i&&i.trim()){if(t.preventDefault(),a.onText){a.onText(i)}else{const t=insertTextElement(e,escapeText(i));t&&e.selectElements([t.id])}return!0}return 0===o.types.length&&0!==c().data.length&&(t.preventDefault(),paste(e),!0)};
|
package/utils/fade-gradient.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type FadeGradient = {
|
|
|
18
18
|
center: FadePoint;
|
|
19
19
|
radius: FadePoint;
|
|
20
20
|
});
|
|
21
|
-
export declare const defaultFade: (shape?: FadeGradient[
|
|
21
|
+
export declare const defaultFade: (shape?: FadeGradient['shape']) => FadeGradient;
|
|
22
22
|
export declare const insertFadeStop: (stops: FadeStop[], position: number) => {
|
|
23
23
|
stops: {
|
|
24
24
|
id: string;
|
package/utils/file.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export declare function localFileToURL(file: Blob): Promise<string>;
|
|
2
|
-
export type MediaType = 'image' | 'svg' | 'video' | 'audio' | 'gif';
|
|
3
|
-
export declare const MEDIA_ACCEPT = "image/*,video/*,audio
|
|
2
|
+
export type MediaType = 'image' | 'svg' | 'video' | 'audio' | 'gif' | 'lottie';
|
|
3
|
+
export declare const MEDIA_ACCEPT = "image/*,video/*,audio/*,.json,.lottie";
|
|
4
4
|
export declare function getMediaType(file: File): MediaType | null;
|
|
5
|
+
export declare function detectMediaType(file: File): Promise<MediaType | null>;
|
|
5
6
|
export declare function getType(file: File): MediaType;
|
|
6
7
|
export declare function stripExtension(fileName: string): string;
|
|
7
8
|
declare let uploadFunc: (file: File) => Promise<string>;
|
|
8
9
|
export declare function setUploadFunc(func: typeof uploadFunc): void;
|
|
9
|
-
export declare function getUploadFunc():
|
|
10
|
+
export declare function getUploadFunc(): typeof uploadFunc;
|
|
10
11
|
export {};
|
package/utils/file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function localFileToURL(e){return new Promise((o,i)=>{const
|
|
1
|
+
export async function localFileToURL(e){return new Promise((o,i)=>{const t=new FileReader;t.readAsDataURL(e),t.onload=()=>o(t.result),t.onerror=e=>i(e)})}export const MEDIA_ACCEPT="image/*,video/*,audio/*,.json,.lottie";const e={svg:"svg",gif:"gif",lottie:"lottie",png:"image",jpg:"image",jpeg:"image",webp:"image",avif:"image",bmp:"image",heic:"image",mp4:"video",webm:"video",mov:"video",m4v:"video",mp3:"audio",wav:"audio",ogg:"audio",m4a:"audio"};export function getMediaType(o){var i,t,n;const{type:r}=o;if(r.indexOf("svg")>=0){return"svg"}if(r.indexOf("gif")>=0){return"gif"}if(r.indexOf("image")>=0){return"image"}if(r.indexOf("video")>=0){return"video"}if(r.indexOf("audio")>=0){return"audio"}const a=null!==(t=null===(i=o.name.split(".").pop())||void 0===i?void 0:i.toLowerCase())&&void 0!==t?t:"";return null!==(n=e[a])&&void 0!==n?n:null}export async function detectMediaType(e){const o=getMediaType(e);if(o||!/\.json$/i.test(e.name)){return o}try{const o=JSON.parse(await e.text());return"string"==typeof(null==o?void 0:o.v)&&Array.isArray(o.layers)?"lottie":null}catch(i){return null}}export function getType(e){var o;return null!==(o=getMediaType(e))&&void 0!==o?o:"image"}export function stripExtension(e){return e.replace(/\.[^./\\]+$/,"")}let o=async e=>(console.warn("Polotno: using data URL for file embeding. This is not recommended for production. Set upload function https://polotno.com/docs/editor-configuration#how-to-change-image-upload-behavior"),localFileToURL(e));export function setUploadFunc(e){o=e}export function getUploadFunc(){return o}
|