-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
placeholder
param to Image and ImageEditor to replace upload im…
…age text (#8930)
- Loading branch information
1 parent
747013b
commit 41d5ab9
Showing
16 changed files
with
147 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@gradio/atoms": minor | ||
"@gradio/image": minor | ||
"@gradio/imageeditor": minor | ||
"@gradio/simpleimage": minor | ||
"gradio": minor | ||
--- | ||
|
||
feat:Add `placeholder` param to Image and ImageEditor to replace upload image text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const RE_HEADING = /^(#\s*)(.+)$/m; | ||
|
||
export function inject(text: string): [string | false, string | false] { | ||
const trimmed_text = text.trim(); | ||
|
||
const heading_match = trimmed_text.match(RE_HEADING); | ||
if (!heading_match) { | ||
return [false, trimmed_text || false]; | ||
} | ||
|
||
const [full_match, , heading_content] = heading_match; | ||
const _heading = heading_content.trim(); | ||
|
||
if (trimmed_text === full_match) { | ||
return [_heading, false]; | ||
} | ||
|
||
const heading_end_index = | ||
heading_match.index !== undefined | ||
? heading_match.index + full_match.length | ||
: 0; | ||
const remaining_text = trimmed_text.substring(heading_end_index).trim(); | ||
|
||
const _paragraph = remaining_text || false; | ||
|
||
return [_heading, _paragraph]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.