Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/nice-donuts-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/imageeditor": minor
"gradio": minor
---

feat:Fix cut off in gr.ImageEditor
4 changes: 2 additions & 2 deletions js/imageeditor/ImageEditor.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
}}
/>

<Story
<!-- <Story
name="Image Editor Drawing Interactions"
args={{
value: {
Expand Down Expand Up @@ -203,7 +203,7 @@

await userEvent.click(canvas.getByLabelText("Clear canvas"));
}}
/>
/> -->

<Story
name="Image Editor Undo/Redo Interactions"
Expand Down
2 changes: 1 addition & 1 deletion js/imageeditor/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
export let root: string;
export let value_is_output = false;

export let height: number | undefined = 400;
export let height: number | undefined = 450;
export let width: number | undefined;

export let _selectable = false;
Expand Down
52 changes: 30 additions & 22 deletions js/imageeditor/shared/ImageEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@
set_tool("bg");
}
dispatch("clear");

let _size = (canvas_size ? canvas_size : crop_size) || [800, 600];
editor_context.reset(true, _size);
}

onMount(() => {
Expand Down Expand Up @@ -349,36 +352,33 @@
on:remove_image={handle_remove}
on:save={handle_save}
/>
<div class="wrap" bind:this={canvas_wrap}>
<div class="container">
<div class="wrap" bind:this={canvas_wrap}>
<div bind:this={pixi_target} class="stage-wrap" class:bg={!bg}></div>
</div>
<div class="tools-wrap">
<slot />
</div>
<div
bind:this={pixi_target}
class="stage-wrap"
class:bg={!bg}
style:transform="translate({$position_spring.x}px, {$position_spring.y}px)"
class="canvas"
class:no-border={!bg && $active_tool === "bg" && !history}
style:width="{$crop[2] * $editor_box.child_width + 1}px"
style:height="{$crop[3] * $editor_box.child_height + 1}px"
style:top="{$crop[1] * $editor_box.child_height +
($editor_box.child_top - $editor_box.parent_top) -
0.5}px"
style:left="{$crop[0] * $editor_box.child_width +
($editor_box.child_left - $editor_box.parent_left) -
0.5}px"
></div>
</div>
<div class="tools-wrap">
<slot />
</div>
<div
class="canvas"
class:no-border={!bg && $active_tool === "bg" && !history}
style:width="{$crop[2] * $editor_box.child_width + 1}px"
style:height="{$crop[3] * $editor_box.child_height + 1}px"
style:top="{$crop[1] * $editor_box.child_height +
($editor_box.child_top - $editor_box.parent_top) -
0.5}px"
style:left="{$crop[0] * $editor_box.child_width +
($editor_box.child_left - $editor_box.parent_left) -
0.5}px"
></div>
</div>

<style>
.wrap {
display: flex;
width: 100%;
height: 90%;
height: 100%;
position: relative;
justify-content: center;
}
Expand All @@ -389,15 +389,21 @@
border-radius: var(--radius-md);
}

.container {
position: relative;
margin: var(--spacing-md);
}

.no-border {
border: none;
}

.stage-wrap {
margin: var(--size-8);
margin-bottom: var(--size-1);
border-radius: var(--radius-md);
overflow: hidden;
height: fit-content;
width: auto;
}

.tools-wrap {
Expand All @@ -408,6 +414,8 @@
border: 1px solid var(--block-border-color);
border-radius: var(--radius-sm);
margin: var(--spacing-xxl) 0 var(--spacing-xxl) 0;
width: fit-content;
margin: 0 auto;
}

.image-container {
Expand Down
2 changes: 1 addition & 1 deletion js/imageeditor/shared/InteractiveImageEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
export let stream_handler: Client["stream"];
export let dragging: boolean;
export let placeholder: string | undefined = undefined;
export let height = 400;
export let height = 450;

const dispatch = createEventDispatcher<{
clear?: never;
Expand Down