polotno 3.12.0 → 3.13.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/README.md +57 -22
- package/blueprint/canvas/context-menu/context-menu.d.ts +2 -2
- package/blueprint/canvas/page-controls.d.ts +14 -2
- package/blueprint/canvas/tooltip.d.ts +24 -2
- package/blueprint/pages-timeline/audio-track.d.ts +12 -2
- package/blueprint/pages-timeline/audios.d.ts +10 -2
- package/blueprint/pages-timeline/current-time.d.ts +2 -2
- package/blueprint/pages-timeline/element-track.d.ts +14 -2
- package/blueprint/pages-timeline/elements.d.ts +2 -2
- package/blueprint/pages-timeline/page-preview.d.ts +8 -2
- package/blueprint/pages-timeline/pages-timeline.d.ts +8 -2
- package/blueprint/pages-timeline/pages.d.ts +8 -2
- package/blueprint/pages-timeline/play-button.d.ts +2 -2
- package/blueprint/pages-timeline/time-ruler.d.ts +10 -2
- package/blueprint/side-panel/ai-images-panel.d.ts +6 -2
- package/blueprint/side-panel/animations-panel.d.ts +6 -2
- package/blueprint/side-panel/background-panel.d.ts +6 -2
- package/blueprint/side-panel/draw-panel.d.ts +6 -2
- package/blueprint/side-panel/effects-panel.d.ts +6 -2
- package/blueprint/side-panel/image-clip-panel.d.ts +6 -2
- package/blueprint/side-panel/layers-panel.d.ts +6 -2
- package/blueprint/side-panel/pages-panel.d.ts +6 -2
- package/blueprint/side-panel/select-video.d.ts +2 -2
- package/blueprint/side-panel/side-panel.d.ts +2 -2
- package/blueprint/side-panel/size-panel.d.ts +6 -2
- package/blueprint/side-panel/templates-panel.d.ts +6 -2
- package/blueprint/side-panel/text-panel.d.ts +6 -2
- package/blueprint/side-panel/videos-panel.d.ts +6 -2
- package/blueprint/toolbar/admin-button.d.ts +6 -2
- package/blueprint/toolbar/animations-picker.d.ts +18 -4
- package/blueprint/toolbar/copy-style.d.ts +6 -2
- package/blueprint/toolbar/download-button.d.ts +6 -2
- package/blueprint/toolbar/duplicate-button.d.ts +6 -2
- package/blueprint/toolbar/figure-toolbar.d.ts +8 -8
- package/blueprint/toolbar/filters-picker.d.ts +26 -6
- package/blueprint/toolbar/gif-toolbar.d.ts +2 -2
- package/blueprint/toolbar/group-button.d.ts +6 -2
- package/blueprint/toolbar/group-toolbar.d.ts +2 -2
- package/blueprint/toolbar/history-buttons.d.ts +6 -2
- package/blueprint/toolbar/html-toolbar.d.ts +10 -10
- package/blueprint/toolbar/image-remove-background-button.d.ts +10 -2
- package/blueprint/toolbar/image-toolbar.d.ts +28 -8
- package/blueprint/toolbar/line-toolbar.d.ts +14 -10
- package/blueprint/toolbar/lock-button.d.ts +6 -2
- package/blueprint/toolbar/many-toolbar.d.ts +2 -2
- package/blueprint/toolbar/opacity-picker.d.ts +6 -2
- package/blueprint/toolbar/page-toolbar.d.ts +2 -2
- package/blueprint/toolbar/position-picker.d.ts +6 -2
- package/blueprint/toolbar/remove-button.d.ts +6 -2
- package/blueprint/toolbar/svg-toolbar.d.ts +2 -2
- package/blueprint/toolbar/table-toolbar.d.ts +44 -14
- package/blueprint/toolbar/text-ai-write.d.ts +6 -2
- package/blueprint/toolbar/text-toolbar.d.ts +14 -14
- package/blueprint/toolbar/toolbar.d.ts +2 -2
- package/blueprint/toolbar/video-toolbar.d.ts +6 -6
- package/blueprint/toolbar/zoom-buttons.d.ts +4 -4
- package/canvas/audio.d.ts +3 -2
- package/canvas/context-menu/context-menu.d.ts +2 -2
- package/canvas/drawing-layer.d.ts +2 -2
- package/canvas/element.d.ts +2 -2
- package/canvas/fade-overlay.d.ts +14 -0
- package/canvas/fade-overlay.js +1 -0
- package/canvas/figure-element.d.ts +2 -2
- package/canvas/gif-element.d.ts +2 -2
- package/canvas/gif-element.js +1 -1
- package/canvas/highlighter.d.ts +6 -2
- package/canvas/html-element.d.ts +2 -2
- package/canvas/image-element.d.ts +5 -3
- package/canvas/image-element.js +1 -1
- package/canvas/line-element.d.ts +2 -2
- package/canvas/page-controls.d.ts +14 -2
- package/canvas/page.d.ts +2 -2
- package/canvas/page.js +1 -1
- package/canvas/render-tag-element.d.ts +2 -2
- package/canvas/render-tag-element.js +1 -1
- package/canvas/rich-editor.js +3 -3
- package/canvas/rules.d.ts +2 -2
- package/canvas/table-element.d.ts +2 -2
- package/canvas/text-element.d.ts +2 -2
- package/canvas/tooltip.d.ts +24 -2
- package/canvas/video-element.d.ts +3 -2
- package/canvas/video-element.js +1 -1
- package/canvas/workspace-canvas.d.ts +2 -2
- package/hooks/use-fade-stop-focus.d.ts +2 -0
- package/hooks/use-fade-stop-focus.js +1 -0
- package/icons/registry.d.ts +106 -102
- package/model/figure-model.d.ts +1 -1
- package/model/gif-model.d.ts +1 -1
- package/model/group-model.d.ts +8 -8
- package/model/image-model.d.ts +1 -1
- package/model/line-model.d.ts +1 -1
- package/model/page-model.d.ts +10 -10
- package/model/shape-model.d.ts +2 -2
- package/model/shape-model.js +1 -1
- package/model/store.d.ts +92 -92
- package/model/svg-model.d.ts +1 -1
- package/model/table-model.d.ts +1 -1
- package/model/text-model.d.ts +1 -1
- package/model/video-model.d.ts +1 -1
- package/package.json +49 -35
- package/pages-timeline/audio-track.d.ts +14 -2
- package/pages-timeline/audio-track.js +1 -1
- package/pages-timeline/audios.d.ts +10 -2
- package/pages-timeline/current-time.d.ts +2 -2
- package/pages-timeline/current-time.js +1 -1
- package/pages-timeline/element-track.d.ts +14 -2
- package/pages-timeline/element-track.js +1 -1
- package/pages-timeline/elements.d.ts +2 -2
- package/pages-timeline/page-preview.d.ts +8 -2
- package/pages-timeline/page-preview.js +1 -1
- package/pages-timeline/pages-timeline.d.ts +8 -2
- package/pages-timeline/pages-timeline.js +1 -1
- package/pages-timeline/pages.d.ts +8 -2
- package/pages-timeline/play-button.d.ts +2 -2
- package/pages-timeline/time-ruler.d.ts +10 -2
- package/pages-timeline/time-ruler.js +1 -1
- package/polotno.bundle.js +167 -166
- package/side-panel/ai-images-panel.d.ts +6 -2
- package/side-panel/animations-panel.d.ts +6 -2
- package/side-panel/background-panel.d.ts +6 -2
- package/side-panel/draw-panel.d.ts +6 -2
- package/side-panel/effects-panel.d.ts +6 -2
- package/side-panel/effects-panel.js +1 -1
- package/side-panel/image-clip-panel.d.ts +6 -2
- package/side-panel/layers-panel.d.ts +6 -2
- package/side-panel/pages-panel.d.ts +6 -2
- package/side-panel/select-video.d.ts +2 -2
- package/side-panel/side-panel.d.ts +2 -2
- package/side-panel/size-panel.d.ts +6 -2
- package/side-panel/templates-panel.d.ts +6 -2
- package/side-panel/text-panel.d.ts +6 -2
- package/side-panel/videos-panel.d.ts +6 -2
- package/toolbar/admin-button.d.ts +6 -2
- package/toolbar/animations-picker.d.ts +18 -4
- package/toolbar/copy-style.d.ts +6 -2
- package/toolbar/download-button.d.ts +6 -2
- package/toolbar/duplicate-button.d.ts +6 -2
- package/toolbar/figure-toolbar.d.ts +8 -8
- package/toolbar/filters-picker.d.ts +26 -6
- package/toolbar/gif-toolbar.d.ts +2 -2
- package/toolbar/group-button.d.ts +6 -2
- package/toolbar/group-toolbar.d.ts +2 -2
- package/toolbar/history-buttons.d.ts +6 -2
- package/toolbar/html-toolbar.d.ts +10 -10
- package/toolbar/image-remove-background-button.d.ts +10 -2
- package/toolbar/image-toolbar.d.ts +32 -10
- package/toolbar/line-toolbar.d.ts +14 -10
- package/toolbar/lock-button.d.ts +6 -2
- package/toolbar/many-toolbar.d.ts +2 -2
- package/toolbar/opacity-picker.d.ts +6 -2
- package/toolbar/page-toolbar.d.ts +2 -2
- package/toolbar/position-picker.d.ts +6 -2
- package/toolbar/remove-button.d.ts +6 -2
- package/toolbar/svg-toolbar.d.ts +2 -2
- package/toolbar/table-toolbar.d.ts +44 -14
- package/toolbar/text-ai-write.d.ts +6 -2
- package/toolbar/text-toolbar.d.ts +30 -18
- package/toolbar/toolbar.d.ts +2 -2
- package/toolbar/video-toolbar.d.ts +12 -6
- package/toolbar/video-toolbar.js +1 -1
- package/toolbar/zoom-buttons.d.ts +4 -4
- package/ui.css +1 -1
- package/utils/clip-fade.d.ts +6 -0
- package/utils/clip-fade.js +1 -0
- package/utils/clipboard.d.ts +2 -2
- package/utils/fade-gradient.d.ts +33 -0
- package/utils/fade-gradient.js +1 -0
- package/utils/fade-overlay.d.ts +9 -0
- package/utils/fade-overlay.js +1 -0
- package/utils/l10n.d.ts +19 -0
- package/utils/l10n.js +1 -1
- package/utils/pointer-drag.d.ts +6 -4
- package/utils/pointer-drag.js +1 -1
- package/utils/rich-text-html.d.ts +0 -10
- package/utils/rich-text-html.js +1 -1
- package/utils/validate-key.js +1 -1
package/model/svg-model.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ export declare const SVGElement: import("mobx-state-tree").IModelType<{
|
|
|
143
143
|
} & {
|
|
144
144
|
readonly locked: boolean;
|
|
145
145
|
readonly a: import("./shape-model.js").AnimatedAttrs;
|
|
146
|
-
animated(attr:
|
|
146
|
+
animated(attr: string): any;
|
|
147
147
|
readonly timeRange: {
|
|
148
148
|
start: number;
|
|
149
149
|
end: number;
|
package/model/table-model.d.ts
CHANGED
|
@@ -427,7 +427,7 @@ export declare const TableElement: import("mobx-state-tree").IModelType<{
|
|
|
427
427
|
} & {
|
|
428
428
|
readonly locked: boolean;
|
|
429
429
|
readonly a: import("./shape-model.js").AnimatedAttrs;
|
|
430
|
-
animated(attr:
|
|
430
|
+
animated(attr: string): any;
|
|
431
431
|
readonly timeRange: {
|
|
432
432
|
start: number;
|
|
433
433
|
end: number;
|
package/model/text-model.d.ts
CHANGED
|
@@ -154,7 +154,7 @@ export declare const TextElement: import("mobx-state-tree").IModelType<{
|
|
|
154
154
|
} & {
|
|
155
155
|
readonly locked: boolean;
|
|
156
156
|
readonly a: import("./shape-model.js").AnimatedAttrs;
|
|
157
|
-
animated(attr:
|
|
157
|
+
animated(attr: string): any;
|
|
158
158
|
readonly timeRange: {
|
|
159
159
|
start: number;
|
|
160
160
|
end: number;
|
package/model/video-model.d.ts
CHANGED
|
@@ -149,7 +149,7 @@ export declare const VideoElement: import("mobx-state-tree").IModelType<{
|
|
|
149
149
|
} & {
|
|
150
150
|
readonly locked: boolean;
|
|
151
151
|
readonly a: import("./shape-model.js").AnimatedAttrs;
|
|
152
|
-
animated(attr:
|
|
152
|
+
animated(attr: string): any;
|
|
153
153
|
readonly timeRange: {
|
|
154
154
|
start: number;
|
|
155
155
|
end: number;
|
package/package.json
CHANGED
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polotno",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Design
|
|
3
|
+
"version": "3.13.0",
|
|
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
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/polotno-project/polotno.git",
|
|
9
|
+
"directory": "packages/polotno"
|
|
10
|
+
},
|
|
6
11
|
"keywords": [
|
|
7
12
|
"polotno",
|
|
13
|
+
"design editor sdk",
|
|
14
|
+
"design editor",
|
|
15
|
+
"canvas editor",
|
|
16
|
+
"canva-like",
|
|
17
|
+
"image editor",
|
|
18
|
+
"video editor",
|
|
19
|
+
"konva",
|
|
20
|
+
"react-konva",
|
|
21
|
+
"react",
|
|
8
22
|
"canvas",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
23
|
+
"templates",
|
|
24
|
+
"pdf",
|
|
25
|
+
"psd",
|
|
26
|
+
"mcp",
|
|
27
|
+
"agent-skills"
|
|
11
28
|
],
|
|
12
29
|
"type": "module",
|
|
13
30
|
"exports": {
|
|
@@ -95,32 +112,32 @@
|
|
|
95
112
|
"./polotno.blueprint.css": "./blueprint.polotno.css"
|
|
96
113
|
},
|
|
97
114
|
"dependencies": {
|
|
98
|
-
"@base-ui/react": "^1.
|
|
99
|
-
"@polotno/core": "0.
|
|
100
|
-
"@polotno/html-export": "0.
|
|
101
|
-
"@polotno/schema": "0.6.
|
|
102
|
-
"@polotno/svg-export": "0.
|
|
115
|
+
"@base-ui/react": "^1.8.0",
|
|
116
|
+
"@polotno/core": "0.12.0",
|
|
117
|
+
"@polotno/html-export": "0.6.0",
|
|
118
|
+
"@polotno/schema": "0.6.2",
|
|
119
|
+
"@polotno/svg-export": "0.7.0",
|
|
103
120
|
"class-variance-authority": "^0.7.1",
|
|
104
121
|
"clsx": "^2.1.1",
|
|
105
122
|
"gifuct-js": "^2.1.2",
|
|
106
|
-
"konva": "^10.
|
|
123
|
+
"konva": "^10.5.0",
|
|
107
124
|
"lodash-es": "^4.18.1",
|
|
108
|
-
"lucide-react": "^1.
|
|
109
|
-
"mediabunny": "^1.
|
|
110
|
-
"mobx": "
|
|
111
|
-
"mobx-react-lite": "^
|
|
112
|
-
"mobx-state-tree": "
|
|
125
|
+
"lucide-react": "^1.46.0",
|
|
126
|
+
"mediabunny": "^1.56.3",
|
|
127
|
+
"mobx": "7.0.3",
|
|
128
|
+
"mobx-react-lite": "^5.0.3",
|
|
129
|
+
"mobx-state-tree": "8.0.0",
|
|
113
130
|
"nanoid": "^6.0.1",
|
|
114
131
|
"quill": "^2.0.3",
|
|
115
132
|
"react-konva": "18.2.16",
|
|
116
|
-
"react-konva-utils": "^2.
|
|
133
|
+
"react-konva-utils": "^2.1.0",
|
|
117
134
|
"react-sortablejs": "6.1.4",
|
|
118
|
-
"react-window": "^2.3.
|
|
119
|
-
"render-tag": "^0.1.
|
|
135
|
+
"react-window": "^2.3.1",
|
|
136
|
+
"render-tag": "^0.1.37",
|
|
120
137
|
"sortablejs": "^1.15.7",
|
|
121
138
|
"svg-round-corners": "^0.4.3",
|
|
122
139
|
"swr": "^2.5.1",
|
|
123
|
-
"tailwind-merge": "^3.
|
|
140
|
+
"tailwind-merge": "^3.7.0",
|
|
124
141
|
"tinycolor2": "^1.6.0"
|
|
125
142
|
},
|
|
126
143
|
"targets": {
|
|
@@ -153,21 +170,19 @@
|
|
|
153
170
|
}
|
|
154
171
|
},
|
|
155
172
|
"devDependencies": {
|
|
156
|
-
"@babel/
|
|
157
|
-
"@babel/
|
|
158
|
-
"@babel/traverse": "^8.0.4",
|
|
173
|
+
"@babel/parser": "^8.0.5",
|
|
174
|
+
"@babel/traverse": "^8.0.5",
|
|
159
175
|
"@blueprintjs/core": "6.18.0",
|
|
160
176
|
"@blueprintjs/icons": "^6.13.0",
|
|
161
177
|
"@blueprintjs/select": "6.3.4",
|
|
162
|
-
"@canvas/image": "^2.0.0",
|
|
163
178
|
"@tailwindcss/cli": "^4.3.3",
|
|
164
179
|
"@tailwindcss/vite": "^4.3.3",
|
|
165
|
-
"@testing-library/dom": "^10.4.
|
|
180
|
+
"@testing-library/dom": "^10.4.2",
|
|
166
181
|
"@testing-library/react": "^16.3.3",
|
|
167
|
-
"@types/react": "^19.
|
|
182
|
+
"@types/react": "^19.3.0",
|
|
168
183
|
"@vitejs/plugin-react": "^6.1.1",
|
|
169
|
-
"@vitest/browser": "^
|
|
170
|
-
"@vitest/browser-playwright": "^
|
|
184
|
+
"@vitest/browser": "^5.0.1",
|
|
185
|
+
"@vitest/browser-playwright": "^5.0.1",
|
|
171
186
|
"assemblyscript": "^0.28.20",
|
|
172
187
|
"assert": "^2.1.0",
|
|
173
188
|
"bippy": "^0.7.3",
|
|
@@ -177,20 +192,19 @@
|
|
|
177
192
|
"glob": "^13.0.6",
|
|
178
193
|
"jest-file-snapshot": "^0.7.0",
|
|
179
194
|
"jsdom": "^30.0.1",
|
|
180
|
-
"
|
|
181
|
-
"
|
|
182
|
-
"postcss": "^
|
|
183
|
-
"postcss-selector-parser": "^7.1.5",
|
|
195
|
+
"playwright": "^1.63.0",
|
|
196
|
+
"postcss": "^8.5.28",
|
|
197
|
+
"postcss-selector-parser": "^7.1.6",
|
|
184
198
|
"pptxgenjs": "^4.0.1",
|
|
185
199
|
"process": "^0.11.10",
|
|
186
|
-
"react": "^19.
|
|
187
|
-
"react-dom": "^19.
|
|
200
|
+
"react": "^19.3.0",
|
|
201
|
+
"react-dom": "^19.3.0",
|
|
188
202
|
"tailwindcss": "^4.3.3",
|
|
189
203
|
"terser": "^5.51.2",
|
|
190
204
|
"tw-animate-css": "^1.4.0",
|
|
191
205
|
"typescript": "~6.0.3",
|
|
192
|
-
"vite": "^8.
|
|
193
|
-
"vitest": "^
|
|
206
|
+
"vite": "^8.3.0",
|
|
207
|
+
"vitest": "^5.0.1"
|
|
194
208
|
},
|
|
195
209
|
"homepage": "https://polotno.com/",
|
|
196
210
|
"scripts": {
|
|
@@ -9,6 +9,18 @@ export declare const AudioTrack: (({ audio, scale, store, label, row, }: {
|
|
|
9
9
|
store: StoreType;
|
|
10
10
|
label: string;
|
|
11
11
|
row: number;
|
|
12
|
-
}) => React.JSX.Element) & {
|
|
13
|
-
|
|
12
|
+
}) => React.JSX.Element) & React.NamedExoticComponent<{
|
|
13
|
+
audio: AudioType;
|
|
14
|
+
scale: number;
|
|
15
|
+
store: StoreType;
|
|
16
|
+
label: string;
|
|
17
|
+
row: number;
|
|
18
|
+
}> & {
|
|
19
|
+
readonly type: ({ audio, scale, store, label, row, }: {
|
|
20
|
+
audio: AudioType;
|
|
21
|
+
scale: number;
|
|
22
|
+
store: StoreType;
|
|
23
|
+
label: string;
|
|
24
|
+
row: number;
|
|
25
|
+
}) => React.JSX.Element;
|
|
14
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=this&&this.__rest||function(e,t){var n={};for(var i in e){Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i])}if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++){t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}}return n};import{jsx as t,jsxs as n}from"react/jsx-runtime";import i from"react";import{observer as o}from"mobx-react-lite";import{PolotnoIcon as a}from"../icons/registry.js";import{t as s}from"../utils/l10n.js";import{firstSliderValue as r}from"../lib/utils.js";import{DRAG_SLOP_PX as l,isPrimaryDrag as m,
|
|
1
|
+
var e=this&&this.__rest||function(e,t){var n={};for(var i in e){Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i])}if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++){t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}}return n};import{jsx as t,jsxs as n}from"react/jsx-runtime";import i from"react";import{observer as o}from"mobx-react-lite";import{PolotnoIcon as a}from"../icons/registry.js";import{t as s}from"../utils/l10n.js";import{firstSliderValue as r}from"../lib/utils.js";import{DRAG_SLOP_PX as l,isPrimaryDrag as m,usePointerDrag as d}from"../utils/pointer-drag.js";import{DropdownMenu as p,DropdownMenuContent as c,DropdownMenuItem as u,DropdownMenuSeparator as h}from"../primitives/dropdown-menu.js";import{Slider as f}from"../primitives/slider.js";import{SpeedControl as x}from"../primitives/speed-control.js";import{Spinner as y}from"./spinner.js";import{useWaveformData as v,useWaveformPath as g}from"./waveform.js";import{TrackWrapper as T,TrackContainer as M,TrackMenu as b,TrackMenuButton as j,TrackHandleLeft as w,TrackHandleRight as I,TrackInlineLabel as O,TrackNameInput as P,WaveformSvg as D}from"./track-styles.js";export const AUDIO_ROW_HEIGHT=28;export const AUDIO_TRACK_HEIGHT=24;const S=({position:e,store:t,scale:n})=>{const i=t.pages;for(const o of i){const t=o.startTime,i=o.startTime+o.duration;if(Math.abs(e-t)<10/n){return t}if(Math.abs(e-i)<10/n){return i}}return null};export const AudioTrack=o(({audio:o,scale:A,store:C,label:N,row:E})=>{const[_,X]=i.useState(1),z=i.useRef(null),[k,H]=i.useState(!1),R=d(),$=0===o.volume,B=()=>{$?o.set({volume:_>0?_:1}):(X(o.volume),o.set({volume:0}))},V=(e=o.startTime,t=o.endTime,n=o.speed)=>Math.max(0,(t-e)*(o.duration||0)/n),Y=e=>Math.max(0,C.duration-e),F=(e,t=V())=>Math.min(Math.max(0,e),Y(t)),G=V(),L=C.duration*A-o.delay*A,U=Math.min(G*A,L),J=o.delay*A,{data:K,isLoading:W}=v(o.src),q=o.visibleDuration*A,Q=g(K,20).path,Z=(e,t)=>{if(!m(e)){return}e.stopPropagation();const n=e.clientX,i=J,a=U,s=o.endTime,r=o.startTime,d=o.delay,p=o.duration||1,c=o.speed;R(e,{slopX:l,node:o,onMove:e=>{const l=(e.clientX-n)/A;if("start"===t){if(l>=0){const e=l*c,t=Math.max(0,s-.1-r)*p,n=Math.min(e,t);if(n<=0){return}let i=r+n/p;const a=(o.endTime-i)*p/c,m=d+n/c,u=Y(a);let h=Math.min(Math.max(0,m),u);const f=S({position:h,store:C,scale:A});h=Math.min(Math.max(0,null!=f?f:h),u);const x=h-m;i=Math.min(o.endTime-.1,Math.max(0,i+x*c/p)),o.set({delay:h,startTime:i})}else{const e=-l*c,t=r*p,n=Math.min(e,t);if(n<=0){return}const i=n/p;let a=Math.max(0,r-i);const s=(o.endTime-a)*p/c,m=d-n/c,u=Y(s);let h=Math.min(Math.max(0,m),u);const f=S({position:h,store:C,scale:A});h=Math.min(Math.max(0,null!=f?f:h),u);const x=h-m;a=Math.max(0,Math.min(o.endTime-.1,a+x*c/p)),o.set({delay:h,startTime:a})}}else{const e=i/A+a/A;let t=e+l;const n=S({position:t,store:C,scale:A});t=null!=n?n:t;const r=(t-e)*c/o.duration,m=Math.min(1,Math.max(o.startTime+.1,s+r));o.set({endTime:m})}},onEnd:({moved:e})=>{e&&(()=>{if("start"===t){const e=S({position:o.delay,store:C,scale:A});if(null!=e&&e!==o.delay){const t=V(o.startTime,o.endTime),n=F(e,t),i=n-o.delay,a=Math.max(0,Math.min(o.endTime-.1,o.startTime+i*c/p));o.set({delay:n,startTime:a})}}})()}})};return t(T,{ref:z,style:{left:`${J}px`,top:28*E+"px",width:`${U}px`,height:"24px"},className:"polotno-audio-container",children:n(M,{style:{width:"100%",height:"100%"},onPointerDown:e=>{if(!m(e)){return}const t=e.clientX,n=J;R(e,{slopX:l,node:o,onMove:e=>{const i=(e.clientX-t)/A;let a=n/A+i;const s=a+G,r=S({position:a,store:C,scale:A}),l=S({position:s,store:C,scale:A}),m=null!==r?Math.abs(a-r):Number.POSITIVE_INFINITY,d=null!==l?Math.abs(s-l):Number.POSITIVE_INFINITY;let p;p=F(null!==r&&m<d?r:null!==l?l-G:a),o.set({delay:F(p)})}})},children:[t("div",{style:{position:"absolute",left:"4px",top:"50%",transform:"translateY(-50%)",zIndex:10,pointerEvents:"auto"},onClick:e=>{e.stopPropagation(),B()},onPointerDown:e=>e.stopPropagation(),children:t(a,$?{name:"action.muted",className:"pn:size-3.5",style:{opacity:.7,cursor:"pointer"}}:{name:"action.unmuted",className:"pn:size-3.5",style:{opacity:.7,cursor:"pointer"}})}),t("div",{style:{position:"absolute",inset:"0 0 0 0",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:n("div",{style:{display:"flex",alignItems:"center",width:"100%",height:"100%",gap:"8px",paddingLeft:"22px"},children:[!k&&t(O,{children:N}),Q&&t("div",{style:{flex:1,height:"14px",overflow:"hidden",opacity:$?.4:1},children:t(D,{width:q,height:"14",viewBox:`0 0 ${q} 20`,preserveAspectRatio:"none",style:{width:q+"px",height:"14px",transform:`translateX(-${o.startTime*q}px)`},children:t("path",{d:Q})})}),W&&t("div",{style:{flex:1,display:"flex",justifyContent:"center",alignItems:"center"},children:t(y,{})})]})}),k&&t(P,{value:o.name,onCommit:e=>{o.set({name:e}),H(!1)},onCancel:()=>H(!1)}),t(w,{onPointerDown:e=>Z(e,"start")}),t(I,{onPointerDown:e=>Z(e,"end")}),t(b,{onClick:e=>{e.stopPropagation()},onPointerDown:e=>e.stopPropagation(),children:n(p,{children:[t(j,{}),n(c,{side:"top",align:"start",anchor:z,style:{width:"220px"},children:[n("div",{style:{padding:"8px 12px"},children:[n("div",{style:{fontSize:"12px",marginBottom:"6px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t("span",{children:s("pagesTimeline.volume")}),n("span",{children:[Math.round(100*o.volume),"%"]})]}),t(f,{value:[o.volume],min:0,max:1,step:.01,onValueChange:e=>(e=>{const t=Math.max(0,Math.min(1,e));t>0&&X(t),o.set({volume:t})})(r(e))})]}),n("div",{style:{padding:"8px 12px"},children:[t("div",{style:{fontSize:"12px",marginBottom:"6px"},children:s("pagesTimeline.speed")}),t(x,{value:o.speed,onChange:e=>{const t=V(o.startTime,o.endTime,e);o.set({speed:e,delay:F(o.delay,t)})}})]}),t(h,{}),n(u,{onSelect:e=>{e.preventDefault(),H(!0)},children:[t(a,{name:"action.rename"}),s("pagesTimeline.renameAudio")]}),n(u,{onSelect:e=>{e.preventDefault(),B()},children:[t(a,$?{name:"action.unmuted"}:{name:"action.muted"}),s($?"pagesTimeline.unmuteAudio":"pagesTimeline.muteAudio")]}),n(u,{onSelect:t=>{t.preventDefault(),(()=>{const t=o.toJSON(),n=o.visibleDuration,i=o.delay+n,a=C.duration-i;let s=o.delay;a>=n?s=i:a>0&&(s=Math.max(0,C.duration-n));const{id:r}=t,l=e(t,["id"]);C.addAudio(Object.assign(Object.assign({},l),{delay:s}))})()},children:[t(a,{name:"action.duplicate"}),s("pagesTimeline.duplicateAudio")]}),t(h,{}),n(u,{onSelect:e=>{e.preventDefault(),C.removeAudio(o.id)},children:[t(a,{name:"action.remove"}),s("pagesTimeline.removeAudio")]})]})]})})]})})});
|
|
@@ -3,6 +3,14 @@ export declare const Audios: (({ store, scale, width, }: {
|
|
|
3
3
|
store: StoreType;
|
|
4
4
|
scale: number;
|
|
5
5
|
width: number;
|
|
6
|
-
}) => import("react").JSX.Element | null) & {
|
|
7
|
-
|
|
6
|
+
}) => import("react").JSX.Element | null) & import("react").NamedExoticComponent<{
|
|
7
|
+
store: StoreType;
|
|
8
|
+
scale: number;
|
|
9
|
+
width: number;
|
|
10
|
+
}> & {
|
|
11
|
+
readonly type: ({ store, scale, width, }: {
|
|
12
|
+
store: StoreType;
|
|
13
|
+
scale: number;
|
|
14
|
+
width: number;
|
|
15
|
+
}) => import("react").JSX.Element | null;
|
|
8
16
|
};
|
|
@@ -7,7 +7,7 @@ interface CurrentTimeProps {
|
|
|
7
7
|
variant?: Variant;
|
|
8
8
|
dragAreaRef?: React.RefObject<HTMLElement | null>;
|
|
9
9
|
}
|
|
10
|
-
export declare const CurrentTime: (({ store, scale, variant, dragAreaRef }: CurrentTimeProps) => React.JSX.Element) & {
|
|
11
|
-
|
|
10
|
+
export declare const CurrentTime: (({ store, scale, variant, dragAreaRef }: CurrentTimeProps) => React.JSX.Element) & React.NamedExoticComponent<CurrentTimeProps> & {
|
|
11
|
+
readonly type: ({ store, scale, variant, dragAreaRef }: CurrentTimeProps) => React.JSX.Element;
|
|
12
12
|
};
|
|
13
13
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import r from"react";import{observer as i}from"mobx-react-lite";import{clamp as o}from"../lib/utils.js";import{isPrimaryDrag as n,
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import r from"react";import{observer as i}from"mobx-react-lite";import{clamp as o}from"../lib/utils.js";import{isPrimaryDrag as n,usePointerDrag as l}from"../utils/pointer-drag.js";const s="rgb(0, 161, 255)";export const CurrentTime=i(({store:i,scale:a,variant:c="timeline",dragAreaRef:p})=>{const d=r.useRef(null),u=l(),m=i.effectiveTime,f=r.useCallback(e=>{var t,r;const n=(null==p?void 0:p.current)||(null===(t=d.current)||void 0===t?void 0:t.parentElement);if(!n){return}const l=n.getBoundingClientRect(),s=n.scrollLeft||0;let c=e-l.left+s;const u=window.getComputedStyle(n);c-=parseFloat(u.paddingLeft)||0,i.setCurrentTime(o(c/a,0,i.duration)),null===(r=i.checkActivePage)||void 0===r||r.call(i)},[p,a,i]),g=r.useCallback(e=>{n(e)&&(e.stopPropagation(),f(e.clientX),u(e,{onMove:e=>f(e.clientX)}))},[u,f]),h=(e=>"ruler"===e?{wrapper:{top:0,width:12,height:"100%",transform:"translateX(-6px)",display:"flex",flexDirection:"column",alignItems:"center"},line:{flex:1}}:{wrapper:{top:0,width:12,height:"100%",transform:"translateX(-6px)"},line:{height:"100%",margin:"0 auto"}})(c);return t("div",{ref:d,onPointerDown:g,className:"polotno-current-time pn:touch-pan-y",style:Object.assign(Object.assign({position:"absolute",left:m*a+"px"},h.wrapper),{cursor:"col-resize"}),children:[e("svg",{width:"12",height:"8",viewBox:"0 0 12 8",style:{display:"block",filter:"drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3))"},children:e("path",{d:"M0 0 H12 L6 8 Z",fill:s,stroke:s,strokeWidth:"2",strokeLinejoin:"round"})}),e("div",{style:Object.assign({width:"2px",backgroundColor:s},h.line)})]})});
|
|
@@ -7,6 +7,18 @@ export declare const ElementTrack: (({ element, page, store, scale, row, }: {
|
|
|
7
7
|
store: StoreType;
|
|
8
8
|
scale: number;
|
|
9
9
|
row: number;
|
|
10
|
-
}) => React.JSX.Element) & {
|
|
11
|
-
|
|
10
|
+
}) => React.JSX.Element) & React.NamedExoticComponent<{
|
|
11
|
+
element: ShapeType;
|
|
12
|
+
page: PageType;
|
|
13
|
+
store: StoreType;
|
|
14
|
+
scale: number;
|
|
15
|
+
row: number;
|
|
16
|
+
}> & {
|
|
17
|
+
readonly type: ({ element, page, store, scale, row, }: {
|
|
18
|
+
element: ShapeType;
|
|
19
|
+
page: PageType;
|
|
20
|
+
store: StoreType;
|
|
21
|
+
scale: number;
|
|
22
|
+
row: number;
|
|
23
|
+
}) => React.JSX.Element;
|
|
12
24
|
};
|
|
@@ -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,
|
|
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")]})]})]})})]})})});
|
|
@@ -4,7 +4,7 @@ interface ElementTimelineProps {
|
|
|
4
4
|
scale: number;
|
|
5
5
|
width: number;
|
|
6
6
|
}
|
|
7
|
-
export declare const ElementsTimeline: (({ store, scale, width }: ElementTimelineProps) => import("react").JSX.Element | null) & {
|
|
8
|
-
|
|
7
|
+
export declare const ElementsTimeline: (({ store, scale, width }: ElementTimelineProps) => import("react").JSX.Element | null) & import("react").NamedExoticComponent<ElementTimelineProps> & {
|
|
8
|
+
readonly type: ({ store, scale, width }: ElementTimelineProps) => import("react").JSX.Element | null;
|
|
9
9
|
};
|
|
10
10
|
export {};
|
|
@@ -8,6 +8,12 @@ export declare const usePagePreview: ({ page, setPreview, groupRef, }: {
|
|
|
8
8
|
export declare const PagePreview: (({ page, scale }: {
|
|
9
9
|
page: PageType;
|
|
10
10
|
scale: number;
|
|
11
|
-
}) => React.JSX.Element) & {
|
|
12
|
-
|
|
11
|
+
}) => React.JSX.Element) & React.NamedExoticComponent<{
|
|
12
|
+
page: PageType;
|
|
13
|
+
scale: number;
|
|
14
|
+
}> & {
|
|
15
|
+
readonly type: ({ page, scale }: {
|
|
16
|
+
page: PageType;
|
|
17
|
+
scale: number;
|
|
18
|
+
}) => React.JSX.Element;
|
|
13
19
|
};
|
|
@@ -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 a}from"mobx-state-tree";import{PolotnoIcon as s}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{DropdownMenu as d,DropdownMenuContent as p,DropdownMenuItem as u}from"../primitives/dropdown-menu.js";import{DRAG_SLOP_PX as g,isPrimaryDrag as m,
|
|
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 a}from"mobx-state-tree";import{PolotnoIcon as s}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{DropdownMenu as d,DropdownMenuContent as p,DropdownMenuItem as u}from"../primitives/dropdown-menu.js";import{DRAG_SLOP_PX as g,isPrimaryDrag as m,usePointerDrag as h}from"../utils/pointer-drag.js";import{Spinner as f}from"./spinner.js";import{TrackHandleRight as v,TrackMenu as x,TrackMenuButton as P}from"./track-styles.js";let b=[],w=!1;const y=async()=>{var e;if(w||0===b.length){return}w=!0;const{page:t,setPreview:o}=b.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{w=!1}y()};export const usePagePreview=({page:e,setPreview:t,groupRef:n})=>{const s=o.useRef(!1);o.useEffect(()=>{const o=()=>{b.push({page:e,setPreview:e=>t(e)}),y()};let r=null,l=null,d=Date.now();const p=()=>{r&&clearTimeout(r),s.current&&(l||(l=setTimeout(()=>{Date.now()-d>=6e3&&(o(),d=Date.now(),l=null)},6e3)),r=setTimeout(()=>{o(),d=Date.now(),r=null,l&&(clearTimeout(l),l=null)},300))};let u=null;const g=a(e,e=>{c(u,e)||(p(),u=e)}),m=i(e,()=>e.children.some(e=>e._editModeEnabled),e=>{e||p()}),h=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting?(s.current=!0,p()):(r&&clearTimeout(r),l&&clearTimeout(l),s.current=!1)})},{threshold:.1});return n.current&&h.observe(n.current),()=>{h.disconnect(),r&&clearTimeout(r),l&&clearTimeout(l),g(),m(),b=b.filter(t=>t.page!==e)}},[n,e,t])};export const PagePreview=n(({page:n,scale:i})=>{const[a,c]=o.useState(null),b=n.store.activePage===n||n.store._selectedPagesIds.includes(n.id),w=o.useRef(null),y=n.store.pages.indexOf(n),j=60/n.computedHeight*n.computedWidth,k=r.animationsEnabled?n.duration*i:j,E=n.store.pages.length>1;o.useLayoutEffect(()=>{w.current&&(w.current.style.width=k+"px")},[y,k]),usePagePreview({page:n,setPreview:c,groupRef:w});const I=h();return t("div",{ref:w,style:{width:k+"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"+(b?" sortable-selected":""),children:[e("div",{style:{width:"100%",height:"100%",borderRadius:"15px",backgroundImage:a?`url("${a}")`:"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),a=e.shiftKey;if(a&&i){const e=o.filter(e=>e!==n.id);t.selectPages(e)}else if(a&&!i){const e=o.concat([n.id]);t.selectPages(e)}else{t.selectPages([n.id])}},children:!a&&e(f,{})}),e("div",{style:{position:"absolute",top:"0",left:"0px",bottom:"0px",right:"0px",borderRadius:"15px",border:b?"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(v,{className:"pn:z-[2] pn:before:h-1/2",onPointerDown:e=>{if(!m(e)){return}const t=e.clientX,o=n.duration;I(e,{slopX:g,node:n,onMove:e=>{const a=(e.clientX-t)/i;n.set({duration:Math.max(1e3,o+a)})}})}}),b&&e(x,{className:"polotno-page-menu pn:top-[5px] pn:right-4 pn:translate-y-0",onClick:e=>{e.stopPropagation()},children:t(d,{children:[e(P,{}),t(p,{side:"top",className:"pn:whitespace-nowrap",children:[t(u,{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 a=new Set(i.map(e=>e.id)),s=t.pages.filter(e=>a.has(e.id)),r=s[s.length-1],l=s.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(s,{name:"action.duplicate",className:"pn:size-4"}),l("pagesTimeline.duplicatePage")]}),t(u,{onSelect:e=>{var t,o,i;e.preventDefault();const a=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"}),s=n.store.pages.indexOf(n);a.setZIndex(s+1)},children:[e(s,{name:"action.add",className:"pn:size-4"}),l("pagesTimeline.addPage")]}),E&&t(u,{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(s,{name:"action.remove",className:"pn:size-4"}),l("pagesTimeline.removePage")]})]})]})})]})});
|
|
@@ -3,6 +3,12 @@ import type { StoreType } from '../ui-types.js';
|
|
|
3
3
|
export declare const PagesTimeline: (({ store, defaultOpened, }: {
|
|
4
4
|
store: StoreType;
|
|
5
5
|
defaultOpened?: boolean;
|
|
6
|
-
}) => React.JSX.Element) & {
|
|
7
|
-
|
|
6
|
+
}) => React.JSX.Element) & React.NamedExoticComponent<{
|
|
7
|
+
store: StoreType;
|
|
8
|
+
defaultOpened?: boolean;
|
|
9
|
+
}> & {
|
|
10
|
+
readonly type: ({ store, defaultOpened, }: {
|
|
11
|
+
store: StoreType;
|
|
12
|
+
defaultOpened?: boolean;
|
|
13
|
+
}) => React.JSX.Element;
|
|
8
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as i,Fragment as t}from"react/jsx-runtime";import n from"react";import{observer as o}from"mobx-react-lite";import{PolotnoIcon as r}from"../icons/registry.js";import{flags as a}from"../utils/flags.js";import{t as s}from"../utils/l10n.js";import{clamp as l,cn as p}from"../lib/utils.js";import{Button as m}from"../primitives/button.js";import{floatingControl as d}from"../primitives/floating-control.js";import{Navbar as c}from"../primitives/navbar.js";import{Pages as h}from"./pages.js";import{CurrentTime as u}from"./current-time.js";import{Audios as g}from"./audios.js";import{ElementsTimeline as f}from"./elements.js";import{PlayButton as v}from"./play-button.js";import{TimeRuler as b}from"./time-ruler.js";import{isPrimaryDrag as x,
|
|
1
|
+
import{jsx as e,jsxs as i,Fragment as t}from"react/jsx-runtime";import n from"react";import{observer as o}from"mobx-react-lite";import{PolotnoIcon as r}from"../icons/registry.js";import{flags as a}from"../utils/flags.js";import{t as s}from"../utils/l10n.js";import{clamp as l,cn as p}from"../lib/utils.js";import{Button as m}from"../primitives/button.js";import{floatingControl as d}from"../primitives/floating-control.js";import{Navbar as c}from"../primitives/navbar.js";import{Pages as h}from"./pages.js";import{CurrentTime as u}from"./current-time.js";import{Audios as g}from"./audios.js";import{ElementsTimeline as f}from"./elements.js";import{PlayButton as v}from"./play-button.js";import{TimeRuler as b}from"./time-ruler.js";import{isPrimaryDrag as x,usePointerDrag as j}from"../utils/pointer-drag.js";export const PagesTimeline=o(({store:o,defaultOpened:y=!1})=>{const E=n.useRef(null),[w,z]=n.useState(y),[N,k]=n.useState(.02),[S,C]=n.useState(()=>(e=>{if(!a.animationsEnabled){return 65}const i=e.pages.reduce((e,i)=>e+i.children.length,0),t=25*e.audios.length+20*i+140;return l(t,140,420)})(o)),[P,T]=n.useState(!1),W=j(),D=o.duration*N;return i(t,{children:[e("div",{style:{position:"relative",height:"0px"},children:i(m,{variant:"ghost",size:"sm",onClick:()=>{z(!w)},className:p(d(),"pn:absolute pn:bottom-[5px] pn:left-[5px] pn:z-[1] pn:dark:hover:bg-accent"),children:[a.animationsEnabled&&!w?e(r,{name:"pagesTimeline.play",className:"pn:size-4"}):null,s("pagesTimeline.pages")]})}),i(c,{attached:"top",style:{padding:"5px",height:"auto",zIndex:1,position:"relative",overflow:"visible",display:w?"block":"none"},className:"polotno-pages-timeline pn:whitespace-normal pn:bg-background",children:[a.animationsEnabled&&e("div",{onPointerDown:e=>{if(!x(e)){return}const i=e.clientY,t=S;T(!0),W(e,{onMove:e=>{const n=t-(e.clientY-i);C(l(n,140,420))},onEnd:()=>T(!1)})},className:"pn:group/pn-resize-handle pn:absolute pn:top-0 pn:left-0 pn:right-0 pn:flex pn:h-[14px] pn:-translate-y-1/2 pn:cursor-ns-resize pn:touch-none pn:items-center pn:justify-center"+(P?" active":""),title:"Drag to adjust timeline height",children:e("div",{className:"pn:h-1 pn:w-full pn:rounded-[2px] pn:transition-colors pn:group-hover/pn-resize-handle:bg-primary"+(P?" pn:bg-primary":" pn:bg-transparent")})}),a.animationsEnabled&&e("div",{style:{display:"flex",justifyContent:"center"},children:e(v,{store:o,scale:N,onScaleChange:k})}),e("div",{dir:"ltr",style:{width:"100%",position:"relative",height:S},children:e("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,overflowX:"auto",padding:"0 24px"},ref:E,children:i("div",{style:{position:"relative",minWidth:a.animationsEnabled?D+"px":void 0},children:[a.animationsEnabled&&e(b,{store:o,scale:N,minWidth:D}),i("div",{style:{position:"relative",display:"flex"},children:[e("div",{style:{position:"relative",minWidth:a.animationsEnabled?D+"px":void 0,height:"60px"},children:e(h,{store:o,scale:N})}),e(m,{variant:"ghost",size:"icon",style:{width:"60px",height:"60px",marginLeft:"12px"},onClick:()=>{var e;o.addPage({bleed:(null===(e=o.activePage)||void 0===e?void 0:e.bleed)||0})},children:e(r,{name:"action.add",className:"pn:size-4"})})]}),a.animationsEnabled&&i(t,{children:[e(f,{store:o,scale:N,width:D}),e(g,{store:o,scale:N,width:D})]}),a.animationsEnabled&&e(u,{store:o,scale:N,dragAreaRef:E,variant:"timeline"})]})})})]})]})});
|
|
@@ -2,6 +2,12 @@ import type { StoreType } from '../ui-types.js';
|
|
|
2
2
|
export declare const Pages: (({ store, scale }: {
|
|
3
3
|
store: StoreType;
|
|
4
4
|
scale: number;
|
|
5
|
-
}) => import("react").JSX.Element) & {
|
|
6
|
-
|
|
5
|
+
}) => import("react").JSX.Element) & import("react").NamedExoticComponent<{
|
|
6
|
+
store: StoreType;
|
|
7
|
+
scale: number;
|
|
8
|
+
}> & {
|
|
9
|
+
readonly type: ({ store, scale }: {
|
|
10
|
+
store: StoreType;
|
|
11
|
+
scale: number;
|
|
12
|
+
}) => import("react").JSX.Element;
|
|
7
13
|
};
|
|
@@ -4,7 +4,7 @@ interface PlayButtonProps {
|
|
|
4
4
|
scale?: number;
|
|
5
5
|
onScaleChange?: (scale: number) => void;
|
|
6
6
|
}
|
|
7
|
-
export declare const PlayButton: (({ store, scale, onScaleChange }: PlayButtonProps) => import("react").JSX.Element) & {
|
|
8
|
-
|
|
7
|
+
export declare const PlayButton: (({ store, scale, onScaleChange }: PlayButtonProps) => import("react").JSX.Element) & import("react").NamedExoticComponent<PlayButtonProps> & {
|
|
8
|
+
readonly type: ({ store, scale, onScaleChange }: PlayButtonProps) => import("react").JSX.Element;
|
|
9
9
|
};
|
|
10
10
|
export {};
|
|
@@ -4,6 +4,14 @@ export declare const TimeRuler: (({ store, scale, minWidth, }: {
|
|
|
4
4
|
store: StoreType;
|
|
5
5
|
scale: number;
|
|
6
6
|
minWidth?: number;
|
|
7
|
-
}) => React.JSX.Element) & {
|
|
8
|
-
|
|
7
|
+
}) => React.JSX.Element) & React.NamedExoticComponent<{
|
|
8
|
+
store: StoreType;
|
|
9
|
+
scale: number;
|
|
10
|
+
minWidth?: number;
|
|
11
|
+
}> & {
|
|
12
|
+
readonly type: ({ store, scale, minWidth, }: {
|
|
13
|
+
store: StoreType;
|
|
14
|
+
scale: number;
|
|
15
|
+
minWidth?: number;
|
|
16
|
+
}) => React.JSX.Element;
|
|
9
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as e}from"react/jsx-runtime";import n from"react";import{observer as r}from"mobx-react-lite";import{clamp as i}from"../lib/utils.js";import{isPrimaryDrag as l,
|
|
1
|
+
import{jsx as t,jsxs as e}from"react/jsx-runtime";import n from"react";import{observer as r}from"mobx-react-lite";import{clamp as i}from"../lib/utils.js";import{isPrimaryDrag as l,usePointerDrag as o}from"../utils/pointer-drag.js";export const TimeRuler=r(({store:r,scale:a,minWidth:s=0})=>{const c=n.useRef(null),p=o(),m=Math.max(r.duration,0),u=Math.max(1,Math.ceil(m/1e3)),h=Math.max(m*a,s,120),d=1e3*a,f=[1,2,5,10,15,30,60,120,300,600],x=f.find(t=>t*d>=70)||f[f.length-1],g=Math.max(1,Math.ceil(20/d)),v=n.useCallback(t=>{var e;if(!c.current){return}const n=c.current.getBoundingClientRect(),l=i(t-n.left,0,n.width);r.setCurrentTime(i(l/a,0,r.duration)),null===(e=r.checkActivePage)||void 0===e||e.call(r)},[a,r]),y=n.useCallback(t=>{l(t)&&(v(t.clientX),p(t,{onMove:t=>v(t.clientX)}))},[p,v]);return t("div",{ref:c,className:"polotno-time-ruler pn:relative pn:h-6 pn:cursor-pointer pn:touch-pan-y pn:select-none pn:text-inherit",onPointerDown:y,style:{minWidth:h+"px",width:h+"px"},children:Array.from({length:u+1},(n,r)=>{const i=r%x===0,l=r%g===0&&!i;return i||l?e("div",{style:{position:"absolute",left:1e3*r*a+"px",top:0,transform:"translateX(-50%)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:4,pointerEvents:"none"},children:[l&&t("div",{className:"pn:size-1 pn:rounded-full pn:bg-current pn:opacity-50"}),i&&t("div",{className:"pn:mt-1 pn:text-center pn:text-[11px] pn:tabular-nums pn:opacity-70",children:r<60?`${r}s`:`${Math.floor(r/60)}m${r%60?r%60+"s":""}`})]},r):null})})});
|