@gradio/imageeditor 0.12.13 → 0.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/CHANGELOG.md +23 -0
- package/Example.svelte +1 -1
- package/IMAGE_EDITOR_OVERVIEW.md +224 -0
- package/ImageEditor.stories.svelte +4 -4
- package/Index.svelte +35 -46
- package/{shared/InteractiveImageEditor.svelte → InteractiveImageEditor.svelte} +56 -103
- package/dist/Example.svelte.d.ts +1 -1
- package/dist/Index.svelte +29 -33
- package/dist/Index.svelte.d.ts +17 -16
- package/dist/{shared/InteractiveImageEditor.svelte → InteractiveImageEditor.svelte} +47 -88
- package/dist/{shared/InteractiveImageEditor.svelte.d.ts → InteractiveImageEditor.svelte.d.ts} +13 -15
- package/dist/shared/Anchor.svelte +311 -0
- package/dist/shared/Anchor.svelte.d.ts +18 -0
- package/dist/shared/Controls.svelte +162 -23
- package/dist/shared/Controls.svelte.d.ts +7 -2
- package/dist/shared/{tools/IconButton.svelte → IconButton.svelte} +19 -3
- package/dist/shared/{tools/IconButton.svelte.d.ts → IconButton.svelte.d.ts} +4 -1
- package/dist/shared/ImageEditor.svelte +546 -289
- package/dist/shared/ImageEditor.svelte.d.ts +51 -56
- package/dist/shared/Layers.svelte +233 -0
- package/dist/shared/Layers.svelte.d.ts +35 -0
- package/dist/shared/Resize.svelte +218 -0
- package/dist/shared/Resize.svelte.d.ts +29 -0
- package/dist/shared/SecondaryToolbar.svelte +54 -0
- package/dist/shared/SecondaryToolbar.svelte.d.ts +35 -0
- package/dist/shared/Toolbar.svelte +337 -0
- package/dist/shared/Toolbar.svelte.d.ts +42 -0
- package/dist/shared/{tools → brush}/BrushOptions.svelte +68 -64
- package/dist/shared/{tools → brush}/BrushOptions.svelte.d.ts +9 -9
- package/dist/shared/{tools → brush}/BrushSize.svelte +2 -27
- package/dist/shared/{tools → brush}/ColorField.svelte +2 -1
- package/dist/shared/{tools → brush}/ColorField.svelte.d.ts +1 -0
- package/dist/shared/{tools → brush}/ColorPicker.svelte +81 -9
- package/dist/shared/{tools → brush}/ColorPicker.svelte.d.ts +1 -0
- package/dist/shared/{tools → brush}/ColorSwatch.svelte +78 -38
- package/dist/shared/{tools → brush}/ColorSwatch.svelte.d.ts +6 -2
- package/dist/shared/brush/brush-cursor.d.ts +101 -0
- package/dist/shared/brush/brush-cursor.js +327 -0
- package/dist/shared/brush/brush-textures.d.ts +71 -0
- package/dist/shared/brush/brush-textures.js +404 -0
- package/dist/shared/brush/brush-utils.d.ts +32 -0
- package/dist/shared/brush/brush-utils.js +59 -0
- package/dist/shared/brush/brush.d.ts +152 -0
- package/dist/shared/brush/brush.js +396 -0
- package/dist/shared/brush/types.d.ts +37 -0
- package/dist/shared/brush/types.js +1 -0
- package/dist/shared/core/editor.d.ts +252 -0
- package/dist/shared/core/editor.js +1221 -0
- package/dist/shared/crop/crop.d.ts +201 -0
- package/dist/shared/crop/crop.js +727 -0
- package/dist/shared/image/image.d.ts +89 -0
- package/dist/shared/image/image.js +185 -0
- package/dist/shared/resize/resize.d.ts +270 -0
- package/dist/shared/resize/resize.js +1413 -0
- package/dist/shared/types.d.ts +12 -0
- package/dist/shared/utils/pixi.d.ts +16 -57
- package/dist/shared/utils/pixi.js +15 -113
- package/dist/shared/zoom/zoom.d.ts +136 -0
- package/dist/shared/zoom/zoom.js +548 -0
- package/package.json +11 -10
- package/shared/Anchor.svelte +384 -0
- package/shared/Controls.svelte +194 -27
- package/shared/{tools/IconButton.svelte → IconButton.svelte} +21 -4
- package/shared/ImageEditor.svelte +682 -349
- package/shared/Layers.svelte +249 -0
- package/shared/Resize.svelte +239 -0
- package/shared/SecondaryToolbar.svelte +61 -0
- package/shared/Toolbar.svelte +386 -0
- package/shared/brush/BRUSH_TOOL.md +134 -0
- package/shared/brush/BrushOptions.svelte +200 -0
- package/shared/{tools → brush}/BrushSize.svelte +2 -30
- package/shared/{tools → brush}/ColorField.svelte +3 -1
- package/shared/{tools → brush}/ColorPicker.svelte +86 -9
- package/shared/{tools → brush}/ColorSwatch.svelte +95 -42
- package/shared/brush/brush-cursor.ts +408 -0
- package/shared/brush/brush-textures.ts +508 -0
- package/shared/brush/brush-utils.ts +76 -0
- package/shared/brush/brush.ts +506 -0
- package/shared/brush/types.ts +41 -0
- package/shared/core/EDITOR.md +182 -0
- package/shared/core/editor.ts +1730 -0
- package/shared/crop/CROP.md +139 -0
- package/shared/crop/crop.ts +1027 -0
- package/shared/image/IMAGE.md +135 -0
- package/shared/image/image.ts +300 -0
- package/shared/resize/resize.ts +1894 -0
- package/shared/types.ts +14 -0
- package/shared/utils/pixi.ts +19 -246
- package/shared/zoom/zoom.ts +729 -0
- package/dist/shared/layers/Layers.svelte +0 -231
- package/dist/shared/layers/Layers.svelte.d.ts +0 -18
- package/dist/shared/layers/utils.d.ts +0 -73
- package/dist/shared/layers/utils.js +0 -156
- package/dist/shared/tools/Brush.svelte +0 -215
- package/dist/shared/tools/Brush.svelte.d.ts +0 -29
- package/dist/shared/tools/Crop.svelte +0 -155
- package/dist/shared/tools/Crop.svelte.d.ts +0 -16
- package/dist/shared/tools/Cropper.svelte +0 -271
- package/dist/shared/tools/Cropper.svelte.d.ts +0 -41
- package/dist/shared/tools/Handle.svelte +0 -260
- package/dist/shared/tools/Handle.svelte.d.ts +0 -29
- package/dist/shared/tools/Sources.svelte +0 -257
- package/dist/shared/tools/Sources.svelte.d.ts +0 -34
- package/dist/shared/tools/Tools.svelte +0 -102
- package/dist/shared/tools/Tools.svelte.d.ts +0 -48
- package/dist/shared/tools/brush.d.ts +0 -62
- package/dist/shared/tools/brush.js +0 -133
- package/dist/shared/tools/crop.d.ts +0 -15
- package/dist/shared/tools/crop.js +0 -154
- package/dist/shared/tools/index.d.ts +0 -5
- package/dist/shared/tools/index.js +0 -5
- package/dist/shared/tools/sources.d.ts +0 -46
- package/dist/shared/tools/sources.js +0 -121
- package/dist/shared/tools/types.d.ts +0 -1
- package/shared/layers/Layers.svelte +0 -250
- package/shared/layers/utils.ts +0 -294
- package/shared/tools/Brush.svelte +0 -280
- package/shared/tools/BrushOptions.svelte +0 -180
- package/shared/tools/Crop.svelte +0 -189
- package/shared/tools/Cropper.svelte +0 -346
- package/shared/tools/Handle.svelte +0 -289
- package/shared/tools/Sources.svelte +0 -283
- package/shared/tools/Tools.svelte +0 -162
- package/shared/tools/brush.ts +0 -247
- package/shared/tools/crop.ts +0 -213
- package/shared/tools/index.ts +0 -5
- package/shared/tools/sources.ts +0 -195
- package/shared/tools/types.ts +0 -1
- /package/dist/shared/{tools → brush}/BrushSize.svelte.d.ts +0 -0
- /package/dist/shared/{tools/types.js → types.js} +0 -0
|
@@ -16,49 +16,47 @@
|
|
|
16
16
|
import { createEventDispatcher } from "svelte";
|
|
17
17
|
import { type I18nFormatter } from "@gradio/utils";
|
|
18
18
|
import { prepare_files, type FileData, type Client } from "@gradio/client";
|
|
19
|
-
import { type CommandNode } from "./utils/commands";
|
|
20
|
-
import ImageEditor from "./ImageEditor.svelte";
|
|
21
|
-
import Layers from "./layers/Layers.svelte";
|
|
22
|
-
import { type Brush as IBrush } from "./
|
|
23
|
-
import { type Eraser } from "./tools/Brush.svelte";
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
import { type CommandNode } from "./shared/utils/commands";
|
|
20
|
+
import ImageEditor from "./shared/ImageEditor.svelte";
|
|
21
|
+
// import Layers from "./layers/Layers.svelte";
|
|
22
|
+
import { type Brush as IBrush, type Eraser } from "./shared/brush/types";
|
|
23
|
+
// import { type Eraser } from "./tools/Brush.svelte";
|
|
24
|
+
import { type Tool as ToolbarTool } from "./shared/Toolbar.svelte";
|
|
25
|
+
|
|
26
|
+
// import { Tools, Crop, Brush, Sources } from "./tools";
|
|
26
27
|
import { BlockLabel } from "@gradio/atoms";
|
|
27
28
|
import { Image as ImageIcon } from "@gradio/icons";
|
|
28
|
-
import { inject } from "./utils/parse_placeholder";
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
import { inject } from "./shared/utils/parse_placeholder";
|
|
30
|
+
// import Sources from "./shared/image/Sources.svelte";
|
|
31
|
+
import {
|
|
32
|
+
type LayerOptions,
|
|
33
|
+
type Transform,
|
|
34
|
+
type Source
|
|
35
|
+
} from "./shared/types";
|
|
36
|
+
export let brush: IBrush;
|
|
37
|
+
export let eraser: Eraser;
|
|
38
|
+
export let sources: Source[];
|
|
34
39
|
export let i18n: I18nFormatter;
|
|
35
40
|
export let root: string;
|
|
36
41
|
export let label: string | undefined = undefined;
|
|
37
42
|
export let show_label: boolean;
|
|
38
43
|
export let changeable = false;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export let
|
|
45
|
-
export let
|
|
44
|
+
|
|
45
|
+
export let layers: FileData[];
|
|
46
|
+
export let composite: FileData | null;
|
|
47
|
+
export let background: FileData | null;
|
|
48
|
+
|
|
49
|
+
export let layer_options: LayerOptions;
|
|
50
|
+
export let transforms: Transform[];
|
|
46
51
|
export let accept_blobs: (a: any) => void;
|
|
47
|
-
|
|
48
|
-
| "pending"
|
|
49
|
-
| "complete"
|
|
50
|
-
| "error"
|
|
51
|
-
| "generating"
|
|
52
|
-
| "streaming" = "complete";
|
|
52
|
+
|
|
53
53
|
export let canvas_size: [number, number];
|
|
54
54
|
export let fixed_canvas = false;
|
|
55
55
|
export let realtime: boolean;
|
|
56
56
|
export let upload: Client["upload"];
|
|
57
|
-
export let
|
|
58
|
-
export let dragging: boolean;
|
|
57
|
+
export let is_dragging: boolean;
|
|
59
58
|
export let placeholder: string | undefined = undefined;
|
|
60
|
-
export let
|
|
61
|
-
export let height;
|
|
59
|
+
export let border_region: number;
|
|
62
60
|
export let full_history: CommandNode | null = null;
|
|
63
61
|
|
|
64
62
|
const dispatch = createEventDispatcher<{
|
|
@@ -69,6 +67,7 @@
|
|
|
69
67
|
}>();
|
|
70
68
|
|
|
71
69
|
let editor: ImageEditor;
|
|
70
|
+
let has_drawn = false;
|
|
72
71
|
|
|
73
72
|
function is_not_null(o: Blob | null): o is Blob {
|
|
74
73
|
return !!o;
|
|
@@ -78,7 +77,7 @@
|
|
|
78
77
|
return !!o;
|
|
79
78
|
}
|
|
80
79
|
|
|
81
|
-
$: if (
|
|
80
|
+
$: if (background_image) dispatch("upload");
|
|
82
81
|
|
|
83
82
|
export async function get_data(): Promise<ImageBlobs> {
|
|
84
83
|
let blobs;
|
|
@@ -131,19 +130,13 @@
|
|
|
131
130
|
}
|
|
132
131
|
}
|
|
133
132
|
|
|
134
|
-
$: handle_value(
|
|
135
|
-
|
|
136
|
-
let
|
|
133
|
+
$: handle_value({ layers, composite, background });
|
|
134
|
+
|
|
135
|
+
let background_image = false;
|
|
137
136
|
let history = false;
|
|
138
137
|
|
|
139
138
|
export let image_id: null | string = null;
|
|
140
139
|
|
|
141
|
-
$: editor &&
|
|
142
|
-
editor.set_tool &&
|
|
143
|
-
(sources && sources.length
|
|
144
|
-
? editor.set_tool("bg")
|
|
145
|
-
: editor.set_tool("draw"));
|
|
146
|
-
|
|
147
140
|
type BinaryImages = [string, string, File, number | null][];
|
|
148
141
|
|
|
149
142
|
function nextframe(): Promise<void> {
|
|
@@ -158,16 +151,11 @@
|
|
|
158
151
|
pending = true;
|
|
159
152
|
return;
|
|
160
153
|
}
|
|
161
|
-
|
|
162
154
|
uploading = true;
|
|
163
|
-
|
|
164
155
|
await nextframe();
|
|
165
156
|
const blobs = await editor.get_blobs();
|
|
166
|
-
|
|
167
157
|
const images: BinaryImages = [];
|
|
168
|
-
|
|
169
158
|
let id = Math.random().toString(36).substring(2);
|
|
170
|
-
|
|
171
159
|
if (blobs.background)
|
|
172
160
|
images.push([
|
|
173
161
|
id,
|
|
@@ -191,7 +179,6 @@
|
|
|
191
179
|
i
|
|
192
180
|
]);
|
|
193
181
|
});
|
|
194
|
-
|
|
195
182
|
await Promise.all(
|
|
196
183
|
images.map(async ([image_id, type, data, index]) => {
|
|
197
184
|
return accept_blobs({
|
|
@@ -202,7 +189,6 @@
|
|
|
202
189
|
);
|
|
203
190
|
image_id = id;
|
|
204
191
|
dispatch("change");
|
|
205
|
-
|
|
206
192
|
await nextframe();
|
|
207
193
|
uploading = false;
|
|
208
194
|
if (pending) {
|
|
@@ -212,14 +198,9 @@
|
|
|
212
198
|
}
|
|
213
199
|
}
|
|
214
200
|
|
|
215
|
-
let active_mode: "webcam" | "color" | null = null;
|
|
216
|
-
let editor_height = height - 100;
|
|
217
|
-
|
|
218
|
-
let _dynamic_height: number;
|
|
219
|
-
|
|
220
|
-
$: dynamic_height = _dynamic_height;
|
|
221
|
-
|
|
222
201
|
$: [heading, paragraph] = placeholder ? inject(placeholder) : [false, false];
|
|
202
|
+
|
|
203
|
+
let current_tool: ToolbarTool;
|
|
223
204
|
</script>
|
|
224
205
|
|
|
225
206
|
<BlockLabel
|
|
@@ -228,60 +209,34 @@
|
|
|
228
209
|
label={label || i18n("image.image")}
|
|
229
210
|
/>
|
|
230
211
|
<ImageEditor
|
|
212
|
+
{transforms}
|
|
213
|
+
{composite}
|
|
214
|
+
{layers}
|
|
215
|
+
{background}
|
|
231
216
|
on:history
|
|
232
217
|
{canvas_size}
|
|
233
|
-
crop_size={Array.isArray(crop_size) ? crop_size : undefined}
|
|
234
218
|
bind:this={editor}
|
|
235
|
-
bind:height={editor_height}
|
|
236
|
-
bind:canvas_height={_dynamic_height}
|
|
237
|
-
parent_height={height}
|
|
238
219
|
{changeable}
|
|
239
220
|
on:save
|
|
240
221
|
on:change={handle_change}
|
|
241
222
|
on:clear={() => dispatch("clear")}
|
|
242
|
-
bind:history
|
|
243
|
-
bind:bg
|
|
244
223
|
{sources}
|
|
245
|
-
crop_constraint={!!crop_constraint}
|
|
246
224
|
{full_history}
|
|
225
|
+
bind:background_image
|
|
226
|
+
bind:current_tool
|
|
227
|
+
brush_options={brush}
|
|
228
|
+
eraser_options={eraser}
|
|
229
|
+
{fixed_canvas}
|
|
230
|
+
{border_region}
|
|
231
|
+
{layer_options}
|
|
232
|
+
{i18n}
|
|
233
|
+
{root}
|
|
234
|
+
{upload}
|
|
235
|
+
bind:is_dragging
|
|
236
|
+
bind:has_drawn
|
|
247
237
|
>
|
|
248
|
-
|
|
249
|
-
<
|
|
250
|
-
|
|
251
|
-
<Sources
|
|
252
|
-
bind:dragging
|
|
253
|
-
{i18n}
|
|
254
|
-
{root}
|
|
255
|
-
{sources}
|
|
256
|
-
{upload}
|
|
257
|
-
{stream_handler}
|
|
258
|
-
{canvas_size}
|
|
259
|
-
bind:bg
|
|
260
|
-
bind:active_mode
|
|
261
|
-
background_file={value?.background || value?.composite || null}
|
|
262
|
-
{fixed_canvas}
|
|
263
|
-
></Sources>
|
|
264
|
-
|
|
265
|
-
{#if transforms.includes("crop")}
|
|
266
|
-
<Crop {crop_constraint} />
|
|
267
|
-
{/if}
|
|
268
|
-
{#if brush}
|
|
269
|
-
<Brush
|
|
270
|
-
color_mode={brush.color_mode}
|
|
271
|
-
default_color={brush.default_color}
|
|
272
|
-
default_size={brush.default_size}
|
|
273
|
-
colors={brush.colors}
|
|
274
|
-
mode="draw"
|
|
275
|
-
/>
|
|
276
|
-
{/if}
|
|
277
|
-
|
|
278
|
-
{#if brush && eraser}
|
|
279
|
-
<Brush default_size={eraser.default_size} mode="erase" />
|
|
280
|
-
{/if}
|
|
281
|
-
</Tools>
|
|
282
|
-
|
|
283
|
-
{#if !bg && !history && active_mode !== "webcam" && status !== "error"}
|
|
284
|
-
<div class="empty wrap" style:height={`${editor_height}px`}>
|
|
238
|
+
{#if !background_image && current_tool === "image" && !has_drawn}
|
|
239
|
+
<div class="empty wrap">
|
|
285
240
|
{#if sources && sources.length}
|
|
286
241
|
{#if heading || paragraph}
|
|
287
242
|
{#if heading}
|
|
@@ -326,10 +281,10 @@
|
|
|
326
281
|
left: 0;
|
|
327
282
|
right: 0;
|
|
328
283
|
margin: auto;
|
|
329
|
-
z-index: var(--layer-
|
|
284
|
+
z-index: var(--layer-1);
|
|
330
285
|
text-align: center;
|
|
331
|
-
color: var(--
|
|
332
|
-
|
|
286
|
+
color: var(--color-grey-500) !important;
|
|
287
|
+
cursor: pointer;
|
|
333
288
|
}
|
|
334
289
|
|
|
335
290
|
.wrap {
|
|
@@ -337,10 +292,8 @@
|
|
|
337
292
|
flex-direction: column;
|
|
338
293
|
justify-content: center;
|
|
339
294
|
align-items: center;
|
|
340
|
-
color: var(--block-label-text-color);
|
|
341
295
|
line-height: var(--line-md);
|
|
342
296
|
font-size: var(--text-md);
|
|
343
|
-
pointer-events: none;
|
|
344
297
|
}
|
|
345
298
|
|
|
346
299
|
.or {
|
package/dist/Example.svelte.d.ts
CHANGED
package/dist/Index.svelte
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<svelte:options accessors={true} immutable={true} />
|
|
2
2
|
|
|
3
|
-
<script>import {
|
|
4
|
-
import
|
|
3
|
+
<script>import { FileData } from "@gradio/client";
|
|
4
|
+
import { BaseStaticImage as StaticImage } from "@gradio/image";
|
|
5
|
+
import InteractiveImageEditor from "./InteractiveImageEditor.svelte";
|
|
5
6
|
import { Block } from "@gradio/atoms";
|
|
6
7
|
import { StatusTracker } from "@gradio/statustracker";
|
|
7
8
|
import { tick } from "svelte";
|
|
@@ -18,7 +19,7 @@ export let show_label;
|
|
|
18
19
|
export let show_download_button;
|
|
19
20
|
export let root;
|
|
20
21
|
export let value_is_output = false;
|
|
21
|
-
export let height;
|
|
22
|
+
export let height = 350;
|
|
22
23
|
export let width;
|
|
23
24
|
export let _selectable = false;
|
|
24
25
|
export let container = true;
|
|
@@ -26,18 +27,13 @@ export let scale = null;
|
|
|
26
27
|
export let min_width = void 0;
|
|
27
28
|
export let loading_status;
|
|
28
29
|
export let show_share_button = false;
|
|
29
|
-
export let sources = [
|
|
30
|
-
"upload",
|
|
31
|
-
"clipboard",
|
|
32
|
-
"webcam"
|
|
33
|
-
];
|
|
30
|
+
export let sources = [];
|
|
34
31
|
export let interactive;
|
|
35
32
|
export let placeholder;
|
|
36
33
|
export let brush;
|
|
37
34
|
export let eraser;
|
|
38
|
-
export let
|
|
39
|
-
export let
|
|
40
|
-
export let layers = true;
|
|
35
|
+
export let transforms = [];
|
|
36
|
+
export let layers;
|
|
41
37
|
export let attached_events = [];
|
|
42
38
|
export let server;
|
|
43
39
|
export let canvas_size;
|
|
@@ -45,6 +41,7 @@ export let fixed_canvas = false;
|
|
|
45
41
|
export let show_fullscreen_button = true;
|
|
46
42
|
export let full_history = null;
|
|
47
43
|
export let gradio;
|
|
44
|
+
export let border_region = 0;
|
|
48
45
|
let editor_instance;
|
|
49
46
|
let image_id = null;
|
|
50
47
|
export async function get_value() {
|
|
@@ -56,7 +53,7 @@ export async function get_value() {
|
|
|
56
53
|
const blobs = await editor_instance.get_data();
|
|
57
54
|
return blobs;
|
|
58
55
|
}
|
|
59
|
-
let
|
|
56
|
+
let is_dragging;
|
|
60
57
|
$:
|
|
61
58
|
value && handle_change();
|
|
62
59
|
const is_browser = typeof window !== "undefined";
|
|
@@ -82,28 +79,28 @@ function handle_history_change() {
|
|
|
82
79
|
tick().then((_) => value_is_output = false);
|
|
83
80
|
}
|
|
84
81
|
}
|
|
85
|
-
let dynamic_height = void 0;
|
|
86
|
-
let safe_height_initial = Math.max(
|
|
87
|
-
canvas_size[1] / (is_browser ? window.devicePixelRatio : 1),
|
|
88
|
-
250
|
|
89
|
-
);
|
|
90
|
-
$:
|
|
91
|
-
safe_height = Math.max((dynamic_height ?? safe_height_initial) + 100, 250);
|
|
92
82
|
$:
|
|
93
83
|
has_value = value?.background || value?.layers?.length || value?.composite;
|
|
84
|
+
$:
|
|
85
|
+
normalised_background = value?.background ? new FileData(value.background) : null;
|
|
86
|
+
$:
|
|
87
|
+
normalised_composite = value?.composite ? new FileData(value.composite) : null;
|
|
88
|
+
$:
|
|
89
|
+
normalised_layers = value?.layers?.map((layer) => new FileData(layer)) || [];
|
|
94
90
|
</script>
|
|
95
91
|
|
|
96
92
|
{#if !interactive}
|
|
97
93
|
<Block
|
|
98
94
|
{visible}
|
|
99
95
|
variant={"solid"}
|
|
100
|
-
border_mode={
|
|
96
|
+
border_mode={is_dragging ? "focus" : "base"}
|
|
101
97
|
padding={false}
|
|
102
98
|
{elem_id}
|
|
103
99
|
{elem_classes}
|
|
104
100
|
{height}
|
|
105
101
|
{width}
|
|
106
|
-
allow_overflow={
|
|
102
|
+
allow_overflow={true}
|
|
103
|
+
overflow_behavior="visible"
|
|
107
104
|
{container}
|
|
108
105
|
{scale}
|
|
109
106
|
{min_width}
|
|
@@ -132,13 +129,14 @@ $:
|
|
|
132
129
|
<Block
|
|
133
130
|
{visible}
|
|
134
131
|
variant={has_value ? "solid" : "dashed"}
|
|
135
|
-
border_mode={
|
|
132
|
+
border_mode={is_dragging ? "focus" : "base"}
|
|
136
133
|
padding={false}
|
|
137
134
|
{elem_id}
|
|
138
135
|
{elem_classes}
|
|
139
|
-
|
|
136
|
+
{height}
|
|
140
137
|
{width}
|
|
141
|
-
allow_overflow={
|
|
138
|
+
allow_overflow={true}
|
|
139
|
+
overflow_behavior="visible"
|
|
142
140
|
{container}
|
|
143
141
|
{scale}
|
|
144
142
|
{min_width}
|
|
@@ -151,25 +149,25 @@ $:
|
|
|
151
149
|
/>
|
|
152
150
|
|
|
153
151
|
<InteractiveImageEditor
|
|
152
|
+
{border_region}
|
|
154
153
|
on:history={(e) => (full_history = e.detail)}
|
|
155
|
-
bind:
|
|
154
|
+
bind:is_dragging
|
|
156
155
|
{canvas_size}
|
|
157
156
|
on:change={() => handle_history_change()}
|
|
158
157
|
bind:image_id
|
|
159
|
-
{
|
|
160
|
-
{
|
|
158
|
+
layers={normalised_layers}
|
|
159
|
+
composite={normalised_composite}
|
|
160
|
+
background={normalised_background}
|
|
161
161
|
bind:this={editor_instance}
|
|
162
|
-
bind:dynamic_height
|
|
163
162
|
{root}
|
|
164
163
|
{sources}
|
|
165
164
|
{label}
|
|
166
165
|
{show_label}
|
|
167
|
-
{height}
|
|
168
166
|
{fixed_canvas}
|
|
169
167
|
on:save={(e) => handle_save()}
|
|
170
168
|
on:edit={() => gradio.dispatch("edit")}
|
|
171
169
|
on:clear={() => gradio.dispatch("clear")}
|
|
172
|
-
on:drag={({ detail }) => (
|
|
170
|
+
on:drag={({ detail }) => (is_dragging = detail)}
|
|
173
171
|
on:upload={() => gradio.dispatch("upload")}
|
|
174
172
|
on:share={({ detail }) => gradio.dispatch("share", detail)}
|
|
175
173
|
on:error={({ detail }) => {
|
|
@@ -192,10 +190,8 @@ $:
|
|
|
192
190
|
i18n={gradio.i18n}
|
|
193
191
|
{transforms}
|
|
194
192
|
accept_blobs={server.accept_blobs}
|
|
195
|
-
{layers}
|
|
196
|
-
status={loading_status?.status}
|
|
193
|
+
layer_options={layers}
|
|
197
194
|
upload={(...args) => gradio.client.upload(...args)}
|
|
198
|
-
stream_handler={(...args) => gradio.client.stream(...args)}
|
|
199
195
|
{placeholder}
|
|
200
196
|
{full_history}
|
|
201
197
|
></InteractiveImageEditor>
|
package/dist/Index.svelte.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { Brush, Eraser } from "./shared/
|
|
3
|
-
import type { EditorData, ImageBlobs } from "./
|
|
2
|
+
import type { Brush, Eraser } from "./shared/brush/types";
|
|
3
|
+
import type { EditorData, ImageBlobs } from "./InteractiveImageEditor.svelte";
|
|
4
4
|
import type { Gradio, SelectData } from "@gradio/utils";
|
|
5
5
|
import type { LoadingStatus } from "@gradio/statustracker";
|
|
6
|
+
import type { LayerOptions, Transform, Source } from "./shared/types";
|
|
6
7
|
declare const __propDef: {
|
|
7
8
|
props: {
|
|
8
9
|
elem_id?: string | undefined;
|
|
@@ -14,7 +15,7 @@ declare const __propDef: {
|
|
|
14
15
|
show_download_button: boolean;
|
|
15
16
|
root: string;
|
|
16
17
|
value_is_output?: boolean | undefined;
|
|
17
|
-
height
|
|
18
|
+
height?: number | undefined;
|
|
18
19
|
width: number | undefined;
|
|
19
20
|
_selectable?: boolean | undefined;
|
|
20
21
|
container?: boolean | undefined;
|
|
@@ -22,14 +23,13 @@ declare const __propDef: {
|
|
|
22
23
|
min_width?: number | undefined;
|
|
23
24
|
loading_status: LoadingStatus;
|
|
24
25
|
show_share_button?: boolean | undefined;
|
|
25
|
-
sources?:
|
|
26
|
+
sources?: Source[] | undefined;
|
|
26
27
|
interactive: boolean;
|
|
27
28
|
placeholder: string | undefined;
|
|
28
29
|
brush: Brush;
|
|
29
30
|
eraser: Eraser;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
layers?: boolean | undefined;
|
|
31
|
+
transforms?: Transform[] | undefined;
|
|
32
|
+
layers: LayerOptions;
|
|
33
33
|
attached_events?: string[] | undefined;
|
|
34
34
|
server: {
|
|
35
35
|
accept_blobs: (a: any) => void;
|
|
@@ -51,6 +51,7 @@ declare const __propDef: {
|
|
|
51
51
|
share: ShareData;
|
|
52
52
|
clear_status: LoadingStatus;
|
|
53
53
|
}>;
|
|
54
|
+
border_region?: number | undefined;
|
|
54
55
|
get_value?: (() => Promise<ImageBlobs | {
|
|
55
56
|
id: string;
|
|
56
57
|
}>) | undefined;
|
|
@@ -120,9 +121,9 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
|
|
|
120
121
|
get show_share_button(): boolean | undefined;
|
|
121
122
|
/**accessor*/
|
|
122
123
|
set show_share_button(_: boolean | undefined);
|
|
123
|
-
get sources():
|
|
124
|
+
get sources(): Source[] | undefined;
|
|
124
125
|
/**accessor*/
|
|
125
|
-
set sources(_:
|
|
126
|
+
set sources(_: Source[] | undefined);
|
|
126
127
|
get interactive(): boolean;
|
|
127
128
|
/**accessor*/
|
|
128
129
|
set interactive(_: boolean);
|
|
@@ -135,15 +136,12 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
|
|
|
135
136
|
get eraser(): Eraser;
|
|
136
137
|
/**accessor*/
|
|
137
138
|
set eraser(_: Eraser);
|
|
138
|
-
get
|
|
139
|
+
get transforms(): Transform[] | undefined;
|
|
139
140
|
/**accessor*/
|
|
140
|
-
set
|
|
141
|
-
get
|
|
141
|
+
set transforms(_: Transform[] | undefined);
|
|
142
|
+
get layers(): LayerOptions;
|
|
142
143
|
/**accessor*/
|
|
143
|
-
set
|
|
144
|
-
get layers(): boolean | undefined;
|
|
145
|
-
/**accessor*/
|
|
146
|
-
set layers(_: boolean | undefined);
|
|
144
|
+
set layers(_: LayerOptions);
|
|
147
145
|
get attached_events(): string[] | undefined;
|
|
148
146
|
/**accessor*/
|
|
149
147
|
set attached_events(_: string[] | undefined);
|
|
@@ -193,6 +191,9 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
|
|
|
193
191
|
share: ShareData;
|
|
194
192
|
clear_status: LoadingStatus;
|
|
195
193
|
}>);
|
|
194
|
+
get border_region(): number | undefined;
|
|
195
|
+
/**accessor*/
|
|
196
|
+
set border_region(_: number | undefined);
|
|
196
197
|
get undefined(): any;
|
|
197
198
|
/**accessor*/
|
|
198
199
|
set undefined(_: any);
|