@gradio/imageeditor 0.18.12 → 0.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/CHANGELOG.md +42 -0
- package/Example.svelte +9 -3
- package/ImageEditor.stories.svelte +0 -74
- package/Index.svelte +34 -35
- package/InteractiveImageEditor.svelte +99 -57
- package/dist/Example.svelte +9 -3
- package/dist/Example.svelte.d.ts +4 -18
- package/dist/Index.svelte +34 -35
- package/dist/Index.svelte.d.ts +2 -19
- package/dist/InteractiveImageEditor.svelte +99 -57
- package/dist/InteractiveImageEditor.svelte.d.ts +20 -37
- package/dist/shared/Anchor.svelte +13 -11
- package/dist/shared/Anchor.svelte.d.ts +4 -19
- package/dist/shared/Controls.svelte +63 -39
- package/dist/shared/Controls.svelte.d.ts +13 -28
- package/dist/shared/IconButton.svelte +39 -18
- package/dist/shared/IconButton.svelte.d.ts +7 -21
- package/dist/shared/ImageEditor.svelte +246 -167
- package/dist/shared/ImageEditor.svelte.d.ts +55 -2
- package/dist/shared/Layers.svelte +43 -29
- package/dist/shared/Layers.svelte.d.ts +10 -25
- package/dist/shared/Resize.svelte +22 -16
- package/dist/shared/Resize.svelte.d.ts +6 -22
- package/dist/shared/SecondaryToolbar.svelte +34 -18
- package/dist/shared/SecondaryToolbar.svelte.d.ts +10 -25
- package/dist/shared/Toolbar.svelte +60 -76
- package/dist/shared/Toolbar.svelte.d.ts +10 -25
- package/dist/shared/brush/BrushOptions.svelte +49 -29
- package/dist/shared/brush/BrushOptions.svelte.d.ts +6 -21
- package/dist/shared/brush/BrushSize.svelte +12 -9
- package/dist/shared/brush/BrushSize.svelte.d.ts +5 -20
- package/dist/shared/brush/ColorField.svelte +21 -16
- package/dist/shared/brush/ColorField.svelte.d.ts +6 -22
- package/dist/shared/brush/ColorPicker.svelte +22 -16
- package/dist/shared/brush/ColorPicker.svelte.d.ts +4 -18
- package/dist/shared/brush/ColorSwatch.svelte +41 -21
- package/dist/shared/brush/ColorSwatch.svelte.d.ts +10 -24
- package/dist/shared/brush/brush.js +7 -8
- package/dist/shared/core/editor.d.ts +5 -0
- package/dist/shared/core/editor.js +43 -2
- package/dist/shared/resize/resize.d.ts +2 -0
- package/dist/shared/resize/resize.js +27 -18
- package/dist/types.d.ts +1 -1
- package/package.json +8 -8
- package/shared/Anchor.svelte +13 -11
- package/shared/Controls.svelte +63 -39
- package/shared/IconButton.svelte +39 -18
- package/shared/ImageEditor.svelte +246 -167
- package/shared/Layers.svelte +43 -29
- package/shared/Resize.svelte +22 -16
- package/shared/SecondaryToolbar.svelte +34 -18
- package/shared/Toolbar.svelte +60 -76
- package/shared/brush/BrushOptions.svelte +49 -29
- package/shared/brush/BrushSize.svelte +12 -9
- package/shared/brush/ColorField.svelte +21 -16
- package/shared/brush/ColorPicker.svelte +22 -16
- package/shared/brush/ColorSwatch.svelte +41 -21
- package/shared/brush/brush.ts +8 -10
- package/shared/core/editor.ts +49 -2
- package/shared/resize/resize.ts +28 -20
- package/types.ts +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { createEventDispatcher } from "svelte";
|
|
3
2
|
import { IconButton, IconButtonWrapper } from "@gradio/atoms";
|
|
4
3
|
import {
|
|
5
4
|
Check,
|
|
@@ -11,30 +10,45 @@
|
|
|
11
10
|
Undo,
|
|
12
11
|
Redo
|
|
13
12
|
} from "@gradio/icons";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
let {
|
|
14
|
+
can_save = false,
|
|
15
|
+
changeable = false,
|
|
16
|
+
current_zoom = 1,
|
|
17
|
+
tool,
|
|
18
|
+
min_zoom = true,
|
|
19
|
+
enable_download = false,
|
|
20
|
+
can_undo,
|
|
21
|
+
can_redo,
|
|
22
|
+
onremove_image,
|
|
23
|
+
onundo,
|
|
24
|
+
onredo,
|
|
25
|
+
onsave,
|
|
26
|
+
onzoom_in,
|
|
27
|
+
onzoom_out,
|
|
28
|
+
onset_zoom,
|
|
29
|
+
onpan,
|
|
30
|
+
ondownload
|
|
31
|
+
}: {
|
|
32
|
+
can_save?: boolean;
|
|
33
|
+
changeable?: boolean;
|
|
34
|
+
current_zoom?: number;
|
|
35
|
+
tool: string;
|
|
36
|
+
min_zoom?: boolean;
|
|
37
|
+
enable_download?: boolean;
|
|
38
|
+
can_undo: boolean;
|
|
39
|
+
can_redo: boolean;
|
|
40
|
+
onremove_image?: () => void;
|
|
41
|
+
onundo?: () => void;
|
|
42
|
+
onredo?: () => void;
|
|
43
|
+
onsave?: () => void;
|
|
44
|
+
onzoom_in?: () => void;
|
|
45
|
+
onzoom_out?: () => void;
|
|
46
|
+
onset_zoom?: (zoom: number | "fit") => void;
|
|
47
|
+
onpan?: () => void;
|
|
48
|
+
ondownload?: () => void;
|
|
49
|
+
} = $props();
|
|
50
|
+
|
|
51
|
+
let show_zoom_popup = $state(false);
|
|
38
52
|
|
|
39
53
|
function handle_zoom_click(e: MouseEvent): void {
|
|
40
54
|
e.stopPropagation();
|
|
@@ -42,7 +56,7 @@
|
|
|
42
56
|
}
|
|
43
57
|
|
|
44
58
|
function handle_zoom_change(zoom: number | "fit"): void {
|
|
45
|
-
|
|
59
|
+
onset_zoom?.(zoom);
|
|
46
60
|
show_zoom_popup = false;
|
|
47
61
|
}
|
|
48
62
|
|
|
@@ -52,7 +66,7 @@
|
|
|
52
66
|
}
|
|
53
67
|
}
|
|
54
68
|
|
|
55
|
-
|
|
69
|
+
let formatted_zoom = $derived(Math.round(current_zoom * 100));
|
|
56
70
|
</script>
|
|
57
71
|
|
|
58
72
|
<IconButtonWrapper>
|
|
@@ -61,7 +75,7 @@
|
|
|
61
75
|
Icon={Download}
|
|
62
76
|
label="Download"
|
|
63
77
|
onclick={(event) => {
|
|
64
|
-
|
|
78
|
+
ondownload?.();
|
|
65
79
|
event.stopPropagation();
|
|
66
80
|
}}
|
|
67
81
|
/>
|
|
@@ -72,7 +86,7 @@
|
|
|
72
86
|
label="Pan"
|
|
73
87
|
onclick={(e) => {
|
|
74
88
|
e.stopPropagation();
|
|
75
|
-
|
|
89
|
+
onpan?.();
|
|
76
90
|
}}
|
|
77
91
|
highlight={tool === "pan"}
|
|
78
92
|
size="small"
|
|
@@ -85,7 +99,7 @@
|
|
|
85
99
|
Icon={ZoomOut}
|
|
86
100
|
label="Zoom out"
|
|
87
101
|
onclick={(event) => {
|
|
88
|
-
|
|
102
|
+
onzoom_out?.();
|
|
89
103
|
event.stopPropagation();
|
|
90
104
|
}}
|
|
91
105
|
/>
|
|
@@ -93,7 +107,7 @@
|
|
|
93
107
|
Icon={ZoomIn}
|
|
94
108
|
label="Zoom in"
|
|
95
109
|
onclick={(event) => {
|
|
96
|
-
|
|
110
|
+
onzoom_in?.();
|
|
97
111
|
event.stopPropagation();
|
|
98
112
|
}}
|
|
99
113
|
/>
|
|
@@ -102,20 +116,30 @@
|
|
|
102
116
|
<span
|
|
103
117
|
role="button"
|
|
104
118
|
tabindex="0"
|
|
105
|
-
|
|
106
|
-
|
|
119
|
+
onclick={handle_zoom_click}
|
|
120
|
+
onkeydown={handle_zoom_keydown}>{formatted_zoom}%</span
|
|
107
121
|
>
|
|
108
122
|
{#if show_zoom_popup}
|
|
109
123
|
<div class="zoom-controls">
|
|
110
124
|
<ul>
|
|
111
125
|
<li>
|
|
112
|
-
<button
|
|
126
|
+
<button
|
|
127
|
+
onclick={(event) => {
|
|
128
|
+
event.stopPropagation();
|
|
129
|
+
handle_zoom_change("fit");
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
113
132
|
Fit to screen
|
|
114
133
|
</button>
|
|
115
134
|
</li>
|
|
116
135
|
{#each [0.25, 0.5, 1, 2, 4] as zoom}
|
|
117
136
|
<li>
|
|
118
|
-
<button
|
|
137
|
+
<button
|
|
138
|
+
onclick={(event) => {
|
|
139
|
+
event.stopPropagation();
|
|
140
|
+
handle_zoom_change(zoom);
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
119
143
|
{zoom * 100}%
|
|
120
144
|
</button>
|
|
121
145
|
</li>
|
|
@@ -130,7 +154,7 @@
|
|
|
130
154
|
Icon={Undo}
|
|
131
155
|
label="Undo"
|
|
132
156
|
onclick={(event) => {
|
|
133
|
-
|
|
157
|
+
onundo?.();
|
|
134
158
|
event.stopPropagation();
|
|
135
159
|
}}
|
|
136
160
|
disabled={!can_undo}
|
|
@@ -140,7 +164,7 @@
|
|
|
140
164
|
Icon={Redo}
|
|
141
165
|
label="Redo"
|
|
142
166
|
onclick={(event) => {
|
|
143
|
-
|
|
167
|
+
onredo?.();
|
|
144
168
|
event.stopPropagation();
|
|
145
169
|
}}
|
|
146
170
|
disabled={!can_redo}
|
|
@@ -152,7 +176,7 @@
|
|
|
152
176
|
Icon={Check}
|
|
153
177
|
label="Save changes"
|
|
154
178
|
onclick={(event) => {
|
|
155
|
-
|
|
179
|
+
onsave?.();
|
|
156
180
|
event.stopPropagation();
|
|
157
181
|
}}
|
|
158
182
|
color="var(--color-accent)"
|
|
@@ -163,7 +187,7 @@
|
|
|
163
187
|
Icon={Trash}
|
|
164
188
|
label="Clear canvas"
|
|
165
189
|
onclick={(event) => {
|
|
166
|
-
|
|
190
|
+
onremove_image?.();
|
|
167
191
|
event.stopPropagation();
|
|
168
192
|
}}
|
|
169
193
|
/>
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: Props & {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const Controls: $$__sveltets_2_IsomorphicComponent<{
|
|
1
|
+
type $$ComponentProps = {
|
|
15
2
|
can_save?: boolean;
|
|
16
3
|
changeable?: boolean;
|
|
17
4
|
current_zoom?: number;
|
|
@@ -20,18 +7,16 @@ declare const Controls: $$__sveltets_2_IsomorphicComponent<{
|
|
|
20
7
|
enable_download?: boolean;
|
|
21
8
|
can_undo: boolean;
|
|
22
9
|
can_redo: boolean;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, {}, {}, string>;
|
|
36
|
-
type Controls = InstanceType<typeof Controls>;
|
|
10
|
+
onremove_image?: () => void;
|
|
11
|
+
onundo?: () => void;
|
|
12
|
+
onredo?: () => void;
|
|
13
|
+
onsave?: () => void;
|
|
14
|
+
onzoom_in?: () => void;
|
|
15
|
+
onzoom_out?: () => void;
|
|
16
|
+
onset_zoom?: (zoom: number | "fit") => void;
|
|
17
|
+
onpan?: () => void;
|
|
18
|
+
ondownload?: () => void;
|
|
19
|
+
};
|
|
20
|
+
declare const Controls: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
21
|
+
type Controls = ReturnType<typeof Controls>;
|
|
37
22
|
export default Controls;
|
|
@@ -1,23 +1,44 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { type
|
|
2
|
+
import { type Component } from "svelte";
|
|
3
3
|
import type { ColorInput } from "tinycolor2";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
Icon,
|
|
7
|
+
label = "",
|
|
8
|
+
show_label = false,
|
|
9
|
+
pending = false,
|
|
10
|
+
size = "small",
|
|
11
|
+
padded = true,
|
|
12
|
+
highlight = false,
|
|
13
|
+
disabled = false,
|
|
14
|
+
hasPopup = false,
|
|
15
|
+
color = "var(--block-label-text-color)",
|
|
16
|
+
transparent = false,
|
|
17
|
+
background = "var(--background-fill-primary)",
|
|
18
|
+
offset = 0,
|
|
19
|
+
label_position = "left",
|
|
20
|
+
roundedness = "quite",
|
|
21
|
+
onclick = undefined
|
|
22
|
+
}: {
|
|
23
|
+
Icon: Component<any>;
|
|
24
|
+
label?: string;
|
|
25
|
+
show_label?: boolean;
|
|
26
|
+
pending?: boolean;
|
|
27
|
+
size?: "small" | "large" | "medium";
|
|
28
|
+
padded?: boolean;
|
|
29
|
+
highlight?: boolean;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
hasPopup?: boolean;
|
|
32
|
+
color?: string | ColorInput;
|
|
33
|
+
transparent?: boolean;
|
|
34
|
+
background?: string;
|
|
35
|
+
offset?: number;
|
|
36
|
+
label_position?: "left" | "right";
|
|
37
|
+
roundedness?: "quite" | "very";
|
|
38
|
+
onclick?: (event: MouseEvent) => void;
|
|
39
|
+
} = $props();
|
|
40
|
+
|
|
41
|
+
let _color = $derived(highlight ? "var(--color-accent)" : color.toString());
|
|
21
42
|
</script>
|
|
22
43
|
|
|
23
44
|
<button
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Component } from "svelte";
|
|
2
2
|
import type { ColorInput } from "tinycolor2";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
$$bindings?: Bindings;
|
|
6
|
-
} & Exports;
|
|
7
|
-
(internal: unknown, props: Props & {
|
|
8
|
-
$$events?: Events;
|
|
9
|
-
$$slots?: Slots;
|
|
10
|
-
}): Exports & {
|
|
11
|
-
$set?: any;
|
|
12
|
-
$on?: any;
|
|
13
|
-
};
|
|
14
|
-
z_$$bindings?: Bindings;
|
|
15
|
-
}
|
|
16
|
-
declare const IconButton: $$__sveltets_2_IsomorphicComponent<{
|
|
17
|
-
Icon: ComponentType;
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
Icon: Component<any>;
|
|
18
5
|
label?: string;
|
|
19
6
|
show_label?: boolean;
|
|
20
7
|
pending?: boolean;
|
|
@@ -29,9 +16,8 @@ declare const IconButton: $$__sveltets_2_IsomorphicComponent<{
|
|
|
29
16
|
offset?: number;
|
|
30
17
|
label_position?: "left" | "right";
|
|
31
18
|
roundedness?: "quite" | "very";
|
|
32
|
-
onclick?: (
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
type IconButton = InstanceType<typeof IconButton>;
|
|
19
|
+
onclick?: (event: MouseEvent) => void;
|
|
20
|
+
};
|
|
21
|
+
declare const IconButton: Component<$$ComponentProps, {}, "">;
|
|
22
|
+
type IconButton = ReturnType<typeof IconButton>;
|
|
37
23
|
export default IconButton;
|