Upload folder using huggingface_hub
Browse files
6.20.0/imageeditor/shared/ImageEditor.svelte
CHANGED
|
@@ -102,11 +102,19 @@
|
|
| 102 |
let pixi_target: HTMLDivElement;
|
| 103 |
let pixi_target_crop: HTMLDivElement;
|
| 104 |
|
|
|
|
| 105 |
$effect(() => {
|
| 106 |
-
if (check_if_should_init())
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
});
|
| 111 |
|
| 112 |
function refresh_tools(): void {
|
|
@@ -765,7 +773,8 @@
|
|
| 765 |
on_drag_change: (dragging) => (is_dragging = dragging),
|
| 766 |
on_files: handle_files,
|
| 767 |
accepted_types: "image/*",
|
| 768 |
-
disable_click: disable_click
|
|
|
|
| 769 |
}}
|
| 770 |
aria-label={"Click to upload or drop files"}
|
| 771 |
aria-dropeffect="copy"
|
|
|
|
| 102 |
let pixi_target: HTMLDivElement;
|
| 103 |
let pixi_target_crop: HTMLDivElement;
|
| 104 |
|
| 105 |
+
let layer_options_key: string | undefined | null = null;
|
| 106 |
$effect(() => {
|
| 107 |
+
if (!check_if_should_init()) return;
|
| 108 |
+
|
| 109 |
+
const next_layer_options_key = JSON.stringify(layer_options);
|
| 110 |
+
if (next_layer_options_key === layer_options_key) return;
|
| 111 |
+
|
| 112 |
+
layer_options_key = next_layer_options_key;
|
| 113 |
+
editor.set_layer_options(layer_options);
|
| 114 |
+
});
|
| 115 |
+
|
| 116 |
+
$effect(() => {
|
| 117 |
+
refresh_tools();
|
| 118 |
});
|
| 119 |
|
| 120 |
function refresh_tools(): void {
|
|
|
|
| 773 |
on_drag_change: (dragging) => (is_dragging = dragging),
|
| 774 |
on_files: handle_files,
|
| 775 |
accepted_types: "image/*",
|
| 776 |
+
disable_click: disable_click,
|
| 777 |
+
ignore_click_selector: ".toolbar-wrap"
|
| 778 |
}}
|
| 779 |
aria-label={"Click to upload or drop files"}
|
| 780 |
aria-dropeffect="copy"
|
6.20.0/imageeditor/shared/Toolbar.svelte
CHANGED
|
@@ -16,12 +16,12 @@
|
|
| 16 |
import {
|
| 17 |
Image,
|
| 18 |
Brush,
|
|
|
|
| 19 |
Erase,
|
| 20 |
Crop,
|
| 21 |
Upload,
|
| 22 |
ImagePaste,
|
| 23 |
Webcam,
|
| 24 |
-
Circle,
|
| 25 |
Resize,
|
| 26 |
ColorPickerSolid
|
| 27 |
} from "@gradio/icons";
|
|
@@ -108,7 +108,7 @@
|
|
| 108 |
);
|
| 109 |
</script>
|
| 110 |
|
| 111 |
-
<div class="toolbar-wrap">
|
| 112 |
<div class="half-container">
|
| 113 |
{#if can_edit_image}
|
| 114 |
<IconButton
|
|
@@ -228,7 +228,7 @@
|
|
| 228 |
offset={0}
|
| 229 |
/>
|
| 230 |
<IconButton
|
| 231 |
-
Icon={
|
| 232 |
label="Brush Size"
|
| 233 |
onclick={(e) => handle_subtool_click(e, "size")}
|
| 234 |
highlight={subtool === "size"}
|
|
@@ -263,7 +263,7 @@
|
|
| 263 |
|
| 264 |
{#if tool === "erase" && eraser_options}
|
| 265 |
<IconButton
|
| 266 |
-
Icon={
|
| 267 |
label="Eraser Size"
|
| 268 |
onclick={(e) => handle_subtool_click(e, "size")}
|
| 269 |
highlight={subtool === "size"}
|
|
|
|
| 16 |
import {
|
| 17 |
Image,
|
| 18 |
Brush,
|
| 19 |
+
BrushSize,
|
| 20 |
Erase,
|
| 21 |
Crop,
|
| 22 |
Upload,
|
| 23 |
ImagePaste,
|
| 24 |
Webcam,
|
|
|
|
| 25 |
Resize,
|
| 26 |
ColorPickerSolid
|
| 27 |
} from "@gradio/icons";
|
|
|
|
| 108 |
);
|
| 109 |
</script>
|
| 110 |
|
| 111 |
+
<div class="toolbar-wrap" onclick={(e) => e.stopPropagation()}>
|
| 112 |
<div class="half-container">
|
| 113 |
{#if can_edit_image}
|
| 114 |
<IconButton
|
|
|
|
| 228 |
offset={0}
|
| 229 |
/>
|
| 230 |
<IconButton
|
| 231 |
+
Icon={BrushSize}
|
| 232 |
label="Brush Size"
|
| 233 |
onclick={(e) => handle_subtool_click(e, "size")}
|
| 234 |
highlight={subtool === "size"}
|
|
|
|
| 263 |
|
| 264 |
{#if tool === "erase" && eraser_options}
|
| 265 |
<IconButton
|
| 266 |
+
Icon={BrushSize}
|
| 267 |
label="Eraser Size"
|
| 268 |
onclick={(e) => handle_subtool_click(e, "size")}
|
| 269 |
highlight={subtool === "size"}
|
6.20.0/imageeditor/shared/brush/BrushOptions.svelte
CHANGED
|
@@ -105,8 +105,12 @@
|
|
| 105 |
const debounced_close_preview = debounce(handle_close_preview, 1000);
|
| 106 |
|
| 107 |
$effect(() => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
selected_size;
|
| 109 |
-
selected_color;
|
| 110 |
handle_preview();
|
| 111 |
});
|
| 112 |
|
|
|
|
| 105 |
const debounced_close_preview = debounce(handle_close_preview, 1000);
|
| 106 |
|
| 107 |
$effect(() => {
|
| 108 |
+
if (!show_size) {
|
| 109 |
+
preview = false;
|
| 110 |
+
return;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
selected_size;
|
|
|
|
| 114 |
handle_preview();
|
| 115 |
});
|
| 116 |
|
6.20.0/imageeditor/shared/brush/brush.ts
CHANGED
|
@@ -150,22 +150,23 @@ export class BrushTool implements Tool {
|
|
| 150 |
* @param {Subtool} subtool - The current subtool.
|
| 151 |
*/
|
| 152 |
set_tool(tool: ToolbarTool, subtool: Subtool): void {
|
| 153 |
-
|
| 154 |
-
this.
|
|
|
|
| 155 |
|
| 156 |
-
if (this.
|
| 157 |
this.commit_pending_changes();
|
| 158 |
}
|
| 159 |
|
|
|
|
|
|
|
|
|
|
| 160 |
if (this.brush_cursor) {
|
| 161 |
const should_be_active = tool === "draw" || tool === "erase";
|
| 162 |
|
| 163 |
this.brush_cursor.set_active(should_be_active);
|
| 164 |
}
|
| 165 |
|
| 166 |
-
const new_mode = tool === "erase" ? "erase" : "draw";
|
| 167 |
-
const mode_changed = this.state.mode !== new_mode;
|
| 168 |
-
const needs_brush_tool = tool === "erase" || tool === "draw";
|
| 169 |
const textures_initialized =
|
| 170 |
this.brush_textures?.textures_initialized ?? false;
|
| 171 |
|
|
@@ -179,10 +180,7 @@ export class BrushTool implements Tool {
|
|
| 179 |
Math.round(current_bounds.height) !== Math.round(tex_dims.height);
|
| 180 |
}
|
| 181 |
|
| 182 |
-
if (
|
| 183 |
-
needs_brush_tool &&
|
| 184 |
-
(mode_changed || !textures_initialized || dimensions_changed)
|
| 185 |
-
) {
|
| 186 |
this.brush_textures?.initialize_textures();
|
| 187 |
}
|
| 188 |
|
|
|
|
| 150 |
* @param {Subtool} subtool - The current subtool.
|
| 151 |
*/
|
| 152 |
set_tool(tool: ToolbarTool, subtool: Subtool): void {
|
| 153 |
+
const new_mode = tool === "erase" ? "erase" : "draw";
|
| 154 |
+
const mode_changed = this.state.mode !== new_mode;
|
| 155 |
+
const needs_brush_tool = tool === "erase" || tool === "draw";
|
| 156 |
|
| 157 |
+
if (this.is_drawing && (!needs_brush_tool || mode_changed)) {
|
| 158 |
this.commit_pending_changes();
|
| 159 |
}
|
| 160 |
|
| 161 |
+
this.current_tool = tool;
|
| 162 |
+
this.current_subtool = subtool;
|
| 163 |
+
|
| 164 |
if (this.brush_cursor) {
|
| 165 |
const should_be_active = tool === "draw" || tool === "erase";
|
| 166 |
|
| 167 |
this.brush_cursor.set_active(should_be_active);
|
| 168 |
}
|
| 169 |
|
|
|
|
|
|
|
|
|
|
| 170 |
const textures_initialized =
|
| 171 |
this.brush_textures?.textures_initialized ?? false;
|
| 172 |
|
|
|
|
| 180 |
Math.round(current_bounds.height) !== Math.round(tex_dims.height);
|
| 181 |
}
|
| 182 |
|
| 183 |
+
if (needs_brush_tool && (!textures_initialized || dimensions_changed)) {
|
|
|
|
|
|
|
|
|
|
| 184 |
this.brush_textures?.initialize_textures();
|
| 185 |
}
|
| 186 |
|