@gradio/imageeditor 0.8.1 → 0.10.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 +33 -0
- package/ImageEditor.stories.svelte +1 -0
- package/Index.svelte +4 -0
- package/package.json +15 -10
- package/shared/InteractiveImageEditor.svelte +26 -4
- package/shared/utils/parse_placeholder.ts +27 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @gradio/imageeditor
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#8930](https://github.com/gradio-app/gradio/pull/8930) [`41d5ab9`](https://github.com/gradio-app/gradio/commit/41d5ab987ba9728753be4509490c79041655809b) - Add `placeholder` param to Image and ImageEditor to replace upload image text. Thanks @hannahblair!
|
|
8
|
+
- [#9118](https://github.com/gradio-app/gradio/pull/9118) [`e1c404d`](https://github.com/gradio-app/gradio/commit/e1c404da1143fb52b659d03e028bdba1badf443d) - setup npm-previews of all packages. Thanks @pngwn!
|
|
9
|
+
|
|
10
|
+
### Dependency updates
|
|
11
|
+
|
|
12
|
+
- @gradio/utils@0.6.0
|
|
13
|
+
- @gradio/upload@0.12.3
|
|
14
|
+
- @gradio/atoms@0.8.0
|
|
15
|
+
- @gradio/client@1.5.1
|
|
16
|
+
- @gradio/statustracker@0.7.5
|
|
17
|
+
- @gradio/wasm@0.13.0
|
|
18
|
+
- @gradio/icons@0.7.1
|
|
19
|
+
- @gradio/image@0.15.0
|
|
20
|
+
|
|
21
|
+
## 0.9.0
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
- [#8964](https://github.com/gradio-app/gradio/pull/8964) [`bf6bbd9`](https://github.com/gradio-app/gradio/commit/bf6bbd971acddbf78f03bea431ed7d1e0003ccf9) - Add min/max-imize button to gr.Image and gr.Gallery. Thanks @hannahblair!
|
|
26
|
+
|
|
27
|
+
### Dependency updates
|
|
28
|
+
|
|
29
|
+
- @gradio/atoms@0.7.9
|
|
30
|
+
- @gradio/statustracker@0.7.4
|
|
31
|
+
- @gradio/client@1.5.0
|
|
32
|
+
- @gradio/icons@0.7.0
|
|
33
|
+
- @gradio/upload@0.12.2
|
|
34
|
+
- @gradio/image@0.14.0
|
|
35
|
+
|
|
3
36
|
## 0.8.1
|
|
4
37
|
|
|
5
38
|
### Dependency updates
|
package/Index.svelte
CHANGED
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"webcam"
|
|
45
45
|
];
|
|
46
46
|
export let interactive: boolean;
|
|
47
|
+
export let placeholder: string | undefined;
|
|
47
48
|
|
|
48
49
|
export let brush: Brush;
|
|
49
50
|
export let eraser: Eraser;
|
|
@@ -55,6 +56,7 @@
|
|
|
55
56
|
accept_blobs: (a: any) => void;
|
|
56
57
|
};
|
|
57
58
|
export let canvas_size: [number, number] | undefined;
|
|
59
|
+
export let show_fullscreen_button = true;
|
|
58
60
|
|
|
59
61
|
export let gradio: Gradio<{
|
|
60
62
|
change: never;
|
|
@@ -153,6 +155,7 @@
|
|
|
153
155
|
selectable={_selectable}
|
|
154
156
|
{show_share_button}
|
|
155
157
|
i18n={gradio.i18n}
|
|
158
|
+
{show_fullscreen_button}
|
|
156
159
|
/>
|
|
157
160
|
</Block>
|
|
158
161
|
{:else}
|
|
@@ -212,6 +215,7 @@
|
|
|
212
215
|
status={loading_status?.status}
|
|
213
216
|
upload={gradio.client.upload}
|
|
214
217
|
stream_handler={gradio.client.stream}
|
|
218
|
+
{placeholder}
|
|
215
219
|
></InteractiveImageEditor>
|
|
216
220
|
</Block>
|
|
217
221
|
{/if}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/imageeditor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
"@types/tinycolor2": "^1.4.6",
|
|
11
11
|
"pixi.js": "^7.3.2",
|
|
12
12
|
"tinycolor2": "^1.6.0",
|
|
13
|
-
"@gradio/atoms": "^0.
|
|
14
|
-
"@gradio/client": "^1.
|
|
15
|
-
"@gradio/icons": "^0.
|
|
16
|
-
"@gradio/
|
|
17
|
-
"@gradio/
|
|
18
|
-
"@gradio/
|
|
19
|
-
"@gradio/
|
|
20
|
-
"@gradio/
|
|
13
|
+
"@gradio/atoms": "^0.8.0",
|
|
14
|
+
"@gradio/client": "^1.5.1",
|
|
15
|
+
"@gradio/icons": "^0.7.1",
|
|
16
|
+
"@gradio/image": "^0.15.0",
|
|
17
|
+
"@gradio/utils": "^0.6.0",
|
|
18
|
+
"@gradio/upload": "^0.12.3",
|
|
19
|
+
"@gradio/statustracker": "^0.7.5",
|
|
20
|
+
"@gradio/wasm": "^0.13.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@gradio/preview": "^0.
|
|
23
|
+
"@gradio/preview": "^0.11.0"
|
|
24
24
|
},
|
|
25
25
|
"main_changeset": true,
|
|
26
26
|
"main": "./Index.svelte",
|
|
@@ -28,5 +28,10 @@
|
|
|
28
28
|
".": "./Index.svelte",
|
|
29
29
|
"./example": "./Example.svelte",
|
|
30
30
|
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
|
35
|
+
"directory": "js/imageeditor"
|
|
31
36
|
}
|
|
32
37
|
}
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import { Tools, Crop, Brush, Sources } from "./tools";
|
|
26
26
|
import { BlockLabel } from "@gradio/atoms";
|
|
27
27
|
import { Image as ImageIcon } from "@gradio/icons";
|
|
28
|
+
import { inject } from "./utils/parse_placeholder";
|
|
28
29
|
|
|
29
30
|
export let brush: IBrush | null;
|
|
30
31
|
export let eraser: Eraser | null;
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
export let upload: Client["upload"];
|
|
50
51
|
export let stream_handler: Client["stream"];
|
|
51
52
|
export let dragging: boolean;
|
|
53
|
+
export let placeholder: string | undefined = undefined;
|
|
52
54
|
|
|
53
55
|
const dispatch = createEventDispatcher<{
|
|
54
56
|
clear?: never;
|
|
@@ -197,6 +199,8 @@
|
|
|
197
199
|
|
|
198
200
|
let active_mode: "webcam" | "color" | null = null;
|
|
199
201
|
let editor_height = 0;
|
|
202
|
+
|
|
203
|
+
$: [heading, paragraph] = placeholder ? inject(placeholder) : [false, false];
|
|
200
204
|
</script>
|
|
201
205
|
|
|
202
206
|
<BlockLabel
|
|
@@ -254,13 +258,22 @@
|
|
|
254
258
|
{#if !bg && !history && active_mode !== "webcam" && status !== "error"}
|
|
255
259
|
<div class="empty wrap" style:height={`${editor_height}px`}>
|
|
256
260
|
{#if sources && sources.length}
|
|
257
|
-
|
|
261
|
+
{#if heading || paragraph}
|
|
262
|
+
{#if heading}
|
|
263
|
+
<h2>{heading}</h2>
|
|
264
|
+
{/if}
|
|
265
|
+
{#if paragraph}
|
|
266
|
+
<p>{paragraph}</p>
|
|
267
|
+
{/if}
|
|
268
|
+
{:else}
|
|
269
|
+
<div>Upload an image</div>
|
|
270
|
+
{/if}
|
|
258
271
|
{/if}
|
|
259
272
|
|
|
260
|
-
{#if sources && sources.length && brush}
|
|
273
|
+
{#if sources && sources.length && brush && !placeholder}
|
|
261
274
|
<div class="or">or</div>
|
|
262
275
|
{/if}
|
|
263
|
-
{#if brush}
|
|
276
|
+
{#if brush && !placeholder}
|
|
264
277
|
<div>select the draw tool to start</div>
|
|
265
278
|
{/if}
|
|
266
279
|
</div>
|
|
@@ -268,6 +281,15 @@
|
|
|
268
281
|
</ImageEditor>
|
|
269
282
|
|
|
270
283
|
<style>
|
|
284
|
+
h2 {
|
|
285
|
+
font-size: var(--text-xl);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
p,
|
|
289
|
+
h2 {
|
|
290
|
+
white-space: pre-line;
|
|
291
|
+
}
|
|
292
|
+
|
|
271
293
|
.empty {
|
|
272
294
|
display: flex;
|
|
273
295
|
flex-direction: column;
|
|
@@ -292,7 +314,7 @@
|
|
|
292
314
|
align-items: center;
|
|
293
315
|
color: var(--block-label-text-color);
|
|
294
316
|
line-height: var(--line-md);
|
|
295
|
-
font-size: var(--text-
|
|
317
|
+
font-size: var(--text-md);
|
|
296
318
|
pointer-events: none;
|
|
297
319
|
}
|
|
298
320
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const RE_HEADING = /^(#\s*)(.+)$/m;
|
|
2
|
+
|
|
3
|
+
export function inject(text: string): [string | false, string | false] {
|
|
4
|
+
const trimmed_text = text.trim();
|
|
5
|
+
|
|
6
|
+
const heading_match = trimmed_text.match(RE_HEADING);
|
|
7
|
+
if (!heading_match) {
|
|
8
|
+
return [false, trimmed_text || false];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const [full_match, , heading_content] = heading_match;
|
|
12
|
+
const _heading = heading_content.trim();
|
|
13
|
+
|
|
14
|
+
if (trimmed_text === full_match) {
|
|
15
|
+
return [_heading, false];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const heading_end_index =
|
|
19
|
+
heading_match.index !== undefined
|
|
20
|
+
? heading_match.index + full_match.length
|
|
21
|
+
: 0;
|
|
22
|
+
const remaining_text = trimmed_text.substring(heading_end_index).trim();
|
|
23
|
+
|
|
24
|
+
const _paragraph = remaining_text || false;
|
|
25
|
+
|
|
26
|
+
return [_heading, _paragraph];
|
|
27
|
+
}
|