# `gradio_highlightedtextbox`
<a href="https://pypi.org/project/gradio_highlightedtextbox/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_highlightedtextbox"></a> <a href="https://huggingface.co/spaces/gsarti/gradio_highlightedtextbox/discussions" target="_blank"><img alt="Static Badge" src="https://img.shields.io/badge/%F0%9F%A4%97%20Discuss-%23097EFF?style=flat&logoColor=black"></a>
Editable Gradio textarea supporting highlighting
## Installation
```bash
pip install gradio_highlightedtextbox
```
## Usage
```python
import gradio as gr
from gradio_highlightedtextbox import HighlightedTextbox
def convert_tagged_text_to_highlighted_text(
tagged_text: str,
tag_id: str | list[str],
tag_open: str | list[str],
tag_close: str | list[str],
) -> list[tuple[str, str | None]]:
return HighlightedTextbox.tagged_text_to_tuples(
tagged_text, tag_id, tag_open, tag_close
)
def convert_highlighted_text_to_tagged_text(
highlighted_text: dict[str, str | list[tuple[str, str | None]]],
tag_id: str | list[str],
tag_open: str | list[str],
tag_close: str | list[str],
) -> str:
return HighlightedTextbox.tuples_to_tagged_text(
highlighted_text["data"], tag_id, tag_open, tag_close
)
def show_info(
highlighted_text: dict[str, str | list[tuple[str, str | None]]],
tag_id: str | list[str],
tag_open: str | list[str],
tag_close: str | list[str],
msg: str,
) -> None:
gr.Info(
f"{msg}: {HighlightedTextbox.tuples_to_tagged_text(highlighted_text['data'], tag_id, tag_open, tag_close)}"
)
initial_text = "It is not something to be ashamed of: it is no different from the <a>personal fears</a> and <b>dislikes</b> of other things that <c>manny peopl</c> have."
with gr.Blocks() as demo:
gr.Markdown("### Parameters to control the highlighted textbox:")
with gr.Row():
tag_id = gr.Dropdown(
choices=["Error A", "Error B", "Error C"],
value=["Error A", "Error B", "Error C"],
multiselect=True,
allow_custom_value=True,
label="Tag ID",
show_label=True,
info="Insert one or more tag IDs to use in the highlighted textbox.",
)
tag_open = gr.Dropdown(
choices=["<a>", "<b>", "<c>"],
value=["<a>", "<b>", "<c>"],
multiselect=True,
allow_custom_value=True,
label="Tag open",
show_label=True,
info="Insert one or more tags to mark the beginning of a highlighted section.",
)
tag_close = gr.Dropdown(
choices=["</a>", "</b>", "</c>"],
value=["</a>", "</b>", "</c>"],
multiselect=True,
allow_custom_value=True,
label="Tag close",
show_label=True,
info="Insert one or more tags to mark the end of a highlighted section.",
)
gr.Markdown(
"""
### Example:
The following text is tagged using the parameters above to mark spans that will be highlighted.
Both the tagged text and the highlighted text are editable, so you can see how the changes in one affect the other.
Highlights will disappear if the highlighted text is edited. Modals will appear upon focus, change, and blur events on the highlighted text.
"""
)
with gr.Row():
tagged = gr.Textbox(
initial_text,
interactive=True,
label="Tagged text",
show_label=True,
info="Tagged text using the format above to mark spans that will be highlighted.",
)
high = HighlightedTextbox(
convert_tagged_text_to_highlighted_text(
tagged.value, tag_id.value, tag_open.value, tag_close.value
),
interactive=True,
label="Highlighted text",
info="Textbox containing editable text with custom highlights.",
show_legend=True,
show_label=True,
legend_label="Legend:",
show_legend_label=True,
show_remove_tags_button=True,
show_copy_button=False,
color_map={"Error A": "blue", "Error B": "red", "Error C": "green"},
)
# Functions
tagged.input(
fn=convert_tagged_text_to_highlighted_text,
inputs=[tagged, tag_id, tag_open, tag_close],
outputs=high,
)
high.input(
fn=convert_highlighted_text_to_tagged_text,
inputs=[high, tag_id, tag_open, tag_close],
outputs=tagged,
)
high.focus(
fn=show_info,
inputs=[high, tag_id, tag_open, tag_close, gr.State("Focus")],
outputs=None,
)
high.blur(
fn=show_info,
inputs=[high, tag_id, tag_open, tag_close, gr.State("Blur")],
outputs=None,
)
high.clear(
fn=show_info,
inputs=[high, tag_id, tag_open, tag_close, gr.State("Remove tags")],
outputs=None,
)
if __name__ == "__main__":
demo.launch()
```
## `HighlightedTextbox`
### Initialization
<table>
<thead>
<tr>
<th align="left">name</th>
<th align="left" style="width: 25%;">type</th>
<th align="left">default</th>
<th align="left">description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><code>value</code></td>
<td align="left" style="width: 25%;">
```python
list[tuple[str, str | None]] | Callable | None
```
</td>
<td align="left"><code>""</code></td>
<td align="left">default text to provide in textbox. If callable, the function will be called whenever the app loads to set the initial value of the component.</td>
</tr>
<tr>
<td align="left"><code>color_map</code></td>
<td align="left" style="width: 25%;">
```python
dict[str, str] | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">dictionary mapping labels to colors.</td>
</tr>
<tr>
<td align="left"><code>show_legend</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>False</code></td>
<td align="left">if True, will display legend.</td>
</tr>
<tr>
<td align="left"><code>show_legend_label</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>False</code></td>
<td align="left">if True, will display legend label.</td>
</tr>
<tr>
<td align="left"><code>legend_label</code></td>
<td align="left" style="width: 25%;">
```python
str
```
</td>
<td align="left"><code>""</code></td>
<td align="left">label to display above legend.</td>
</tr>
<tr>
<td align="left"><code>combine_adjacent</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>False</code></td>
<td align="left">if True, will combine adjacent spans with the same label.</td>
</tr>
<tr>
<td align="left"><code>adjacent_separator</code></td>
<td align="left" style="width: 25%;">
```python
str
```
</td>
<td align="left"><code>""</code></td>
<td align="left">separator to use when combining adjacent spans.</td>
</tr>
<tr>
<td align="left"><code>label</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">component name in interface.</td>
</tr>
<tr>
<td align="left"><code>info</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>every</code></td>
<td align="left" style="width: 25%;">
```python
float | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>
</tr>
<tr>
<td align="left"><code>show_label</code></td>
<td align="left" style="width: 25%;">
```python
bool | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">if True, will display label.</td>
</tr>
<tr>
<td align="left"><code>container</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">If True, will place the component in a container - providing some extra padding around the border.</td>
</tr>
<tr>
<td align="left"><code>scale</code></td>
<td align="left" style="width: 25%;">
```python
int | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.</td>
</tr>
<tr>
<td align="left"><code>min_width</code></td>
<td align="left" style="width: 25%;">
```python
int
```
</td>
<td align="left"><code>160</code></td>
<td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
</tr>
<tr>
<td align="left"><code>visible</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">If False, component will be hidden.</td>
</tr>
<tr>
<td align="left"><code>elem_id</code></td>
<td align="left" style="width: 25%;">
```python
str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
</tr>
<tr>
<td align="left"><code>autofocus</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>False</code></td>
<td align="left">None</td>
</tr>
<tr>
<td align="left"><code>autoscroll</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">If True, will automatically scroll to the bottom of the textbox when the value changes, unless the user scrolls up. If False, will not scroll to the bottom of the textbox when the value changes.</td>
</tr>
<tr>
<td align="left"><code>interactive</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.</td>
</tr>
<tr>
<td align="left"><code>elem_classes</code></td>
<td align="left" style="width: 25%;">
```python
list[str] | str | None
```
</td>
<td align="left"><code>None</code></td>
<td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
</tr>
<tr>
<td align="left"><code>render</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>True</code></td>
<td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
</tr>
<tr>
<td align="left"><code>show_copy_button</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>False</code></td>
<td align="left">If True, includes a copy button to copy the text in the textbox. Only applies if show_label is True.</td>
</tr>
<tr>
<td align="left"><code>show_remove_tags_button</code></td>
<td align="left" style="width: 25%;">
```python
bool
```
</td>
<td align="left"><code>False</code></td>
<td align="left">If True, includes a button to remove all tags from the text.</td>
</tr>
</tbody></table>
### Events
| name | description |
|:-----|:------------|
| `change` | Triggered when the value of the HighlightedTextbox changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
| `input` | This listener is triggered when the user changes the value of the HighlightedTextbox. |
| `select` | Event listener for when the user selects or deselects the HighlightedTextbox. Uses event data gradio.SelectData to carry `value` referring to the label of the HighlightedTextbox, and `selected` to refer to state of the HighlightedTextbox. See EventData documentation on how to use this event data |
| `submit` | This listener is triggered when the user presses the Enter key while the HighlightedTextbox is focused. |
| `focus` | This listener is triggered when the HighlightedTextbox is focused. |
| `blur` | This listener is triggered when the HighlightedTextbox is unfocused/blurred. |
| `clear` | This listener is triggered when the user clears the HighlightedTextbox using the X button for the component. |
### User function
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
- When used as an Input, the component only impacts the input signature of the user function.
- When used as an output, the component only impacts the return signature of the user function.
The code snippet below is accurate in cases where the component is used as both an input and an output.
- **As input:** Should return, list of (word, category) tuples, or a dictionary of two keys: "id", and "data", which is a list of (word, category) tuples.
```python
def predict(
value: dict
) -> list[tuple[str, str | None]] | dict | None:
return value
```
Raw data
{
"_id": null,
"home_page": null,
"name": "gradio-highlightedtextbox",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "color, editing, gradio-custom-component, gradio-template-SimpleTextbox, highlight, textbox",
"author": null,
"author_email": "Gabriele Sarti <gabriele.sarti996@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/52/a8/b8739e69ce742d09f54992be752bd26d281370a23f4fddd062eeab3da026/gradio_highlightedtextbox-0.0.12.tar.gz",
"platform": null,
"description": "\n# `gradio_highlightedtextbox`\n<a href=\"https://pypi.org/project/gradio_highlightedtextbox/\" target=\"_blank\"><img alt=\"PyPI - Version\" src=\"https://img.shields.io/pypi/v/gradio_highlightedtextbox\"></a> <a href=\"https://huggingface.co/spaces/gsarti/gradio_highlightedtextbox/discussions\" target=\"_blank\"><img alt=\"Static Badge\" src=\"https://img.shields.io/badge/%F0%9F%A4%97%20Discuss-%23097EFF?style=flat&logoColor=black\"></a>\n\nEditable Gradio textarea supporting highlighting\n\n## Installation\n \n```bash \npip install gradio_highlightedtextbox\n```\n\n## Usage\n\n```python\nimport gradio as gr\nfrom gradio_highlightedtextbox import HighlightedTextbox\n\n\ndef convert_tagged_text_to_highlighted_text(\n tagged_text: str,\n tag_id: str | list[str],\n tag_open: str | list[str],\n tag_close: str | list[str],\n) -> list[tuple[str, str | None]]:\n return HighlightedTextbox.tagged_text_to_tuples(\n tagged_text, tag_id, tag_open, tag_close\n )\n\n\ndef convert_highlighted_text_to_tagged_text(\n highlighted_text: dict[str, str | list[tuple[str, str | None]]],\n tag_id: str | list[str],\n tag_open: str | list[str],\n tag_close: str | list[str],\n) -> str:\n return HighlightedTextbox.tuples_to_tagged_text(\n highlighted_text[\"data\"], tag_id, tag_open, tag_close\n )\n\n\ndef show_info(\n highlighted_text: dict[str, str | list[tuple[str, str | None]]],\n tag_id: str | list[str],\n tag_open: str | list[str],\n tag_close: str | list[str],\n msg: str,\n) -> None:\n gr.Info(\n f\"{msg}: {HighlightedTextbox.tuples_to_tagged_text(highlighted_text['data'], tag_id, tag_open, tag_close)}\"\n )\n\n\ninitial_text = \"It is not something to be ashamed of: it is no different from the <a>personal fears</a> and <b>dislikes</b> of other things that <c>manny peopl</c> have.\"\n\nwith gr.Blocks() as demo:\n gr.Markdown(\"### Parameters to control the highlighted textbox:\")\n with gr.Row():\n tag_id = gr.Dropdown(\n choices=[\"Error A\", \"Error B\", \"Error C\"],\n value=[\"Error A\", \"Error B\", \"Error C\"],\n multiselect=True,\n allow_custom_value=True,\n label=\"Tag ID\",\n show_label=True,\n info=\"Insert one or more tag IDs to use in the highlighted textbox.\",\n )\n tag_open = gr.Dropdown(\n choices=[\"<a>\", \"<b>\", \"<c>\"],\n value=[\"<a>\", \"<b>\", \"<c>\"],\n multiselect=True,\n allow_custom_value=True,\n label=\"Tag open\",\n show_label=True,\n info=\"Insert one or more tags to mark the beginning of a highlighted section.\",\n )\n tag_close = gr.Dropdown(\n choices=[\"</a>\", \"</b>\", \"</c>\"],\n value=[\"</a>\", \"</b>\", \"</c>\"],\n multiselect=True,\n allow_custom_value=True,\n label=\"Tag close\",\n show_label=True,\n info=\"Insert one or more tags to mark the end of a highlighted section.\",\n )\n gr.Markdown(\n \"\"\"\n### Example:\n\nThe following text is tagged using the parameters above to mark spans that will be highlighted.\n\nBoth the tagged text and the highlighted text are editable, so you can see how the changes in one affect the other.\n\nHighlights will disappear if the highlighted text is edited. Modals will appear upon focus, change, and blur events on the highlighted text.\n\"\"\"\n )\n with gr.Row():\n tagged = gr.Textbox(\n initial_text,\n interactive=True,\n label=\"Tagged text\",\n show_label=True,\n info=\"Tagged text using the format above to mark spans that will be highlighted.\",\n )\n high = HighlightedTextbox(\n convert_tagged_text_to_highlighted_text(\n tagged.value, tag_id.value, tag_open.value, tag_close.value\n ),\n interactive=True,\n label=\"Highlighted text\",\n info=\"Textbox containing editable text with custom highlights.\",\n show_legend=True,\n show_label=True,\n legend_label=\"Legend:\",\n show_legend_label=True,\n show_remove_tags_button=True,\n show_copy_button=False,\n color_map={\"Error A\": \"blue\", \"Error B\": \"red\", \"Error C\": \"green\"},\n )\n\n # Functions\n\n tagged.input(\n fn=convert_tagged_text_to_highlighted_text,\n inputs=[tagged, tag_id, tag_open, tag_close],\n outputs=high,\n )\n high.input(\n fn=convert_highlighted_text_to_tagged_text,\n inputs=[high, tag_id, tag_open, tag_close],\n outputs=tagged,\n )\n high.focus(\n fn=show_info,\n inputs=[high, tag_id, tag_open, tag_close, gr.State(\"Focus\")],\n outputs=None,\n )\n high.blur(\n fn=show_info,\n inputs=[high, tag_id, tag_open, tag_close, gr.State(\"Blur\")],\n outputs=None,\n )\n high.clear(\n fn=show_info,\n inputs=[high, tag_id, tag_open, tag_close, gr.State(\"Remove tags\")],\n outputs=None,\n )\n\nif __name__ == \"__main__\":\n demo.launch()\n\n```\n\n## `HighlightedTextbox`\n\n### Initialization\n\n<table>\n<thead>\n<tr>\n<th align=\"left\">name</th>\n<th align=\"left\" style=\"width: 25%;\">type</th>\n<th align=\"left\">default</th>\n<th align=\"left\">description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align=\"left\"><code>value</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[tuple[str, str | None]] | Callable | None\n```\n\n</td>\n<td align=\"left\"><code>\"\"</code></td>\n<td align=\"left\">default text to provide in textbox. If callable, the function will be called whenever the app loads to set the initial value of the component.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>color_map</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\ndict[str, str] | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">dictionary mapping labels to colors.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>show_legend</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>False</code></td>\n<td align=\"left\">if True, will display legend.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>show_legend_label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>False</code></td>\n<td align=\"left\">if True, will display legend label.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>legend_label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr\n```\n\n</td>\n<td align=\"left\"><code>\"\"</code></td>\n<td align=\"left\">label to display above legend.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>combine_adjacent</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>False</code></td>\n<td align=\"left\">if True, will combine adjacent spans with the same label.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>adjacent_separator</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr\n```\n\n</td>\n<td align=\"left\"><code>\"\"</code></td>\n<td align=\"left\">separator to use when combining adjacent spans.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">component name in interface.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>info</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>every</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nfloat | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>show_label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">if True, will display label.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>container</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If True, will place the component in a container - providing some extra padding around the border.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>scale</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>min_width</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint\n```\n\n</td>\n<td align=\"left\"><code>160</code></td>\n<td align=\"left\">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>visible</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If False, component will be hidden.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_id</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>autofocus</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>False</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>autoscroll</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If True, will automatically scroll to the bottom of the textbox when the value changes, unless the user scrolls up. If False, will not scroll to the bottom of the textbox when the value changes.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>interactive</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_classes</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[str] | str | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>render</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>show_copy_button</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>False</code></td>\n<td align=\"left\">If True, includes a copy button to copy the text in the textbox. Only applies if show_label is True.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>show_remove_tags_button</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>False</code></td>\n<td align=\"left\">If True, includes a button to remove all tags from the text.</td>\n</tr>\n</tbody></table>\n\n\n### Events\n\n| name | description |\n|:-----|:------------|\n| `change` | Triggered when the value of the HighlightedTextbox changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |\n| `input` | This listener is triggered when the user changes the value of the HighlightedTextbox. |\n| `select` | Event listener for when the user selects or deselects the HighlightedTextbox. Uses event data gradio.SelectData to carry `value` referring to the label of the HighlightedTextbox, and `selected` to refer to state of the HighlightedTextbox. See EventData documentation on how to use this event data |\n| `submit` | This listener is triggered when the user presses the Enter key while the HighlightedTextbox is focused. |\n| `focus` | This listener is triggered when the HighlightedTextbox is focused. |\n| `blur` | This listener is triggered when the HighlightedTextbox is unfocused/blurred. |\n| `clear` | This listener is triggered when the user clears the HighlightedTextbox using the X button for the component. |\n\n\n\n### User function\n\nThe impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).\n\n- When used as an Input, the component only impacts the input signature of the user function. \n- When used as an output, the component only impacts the return signature of the user function. \n\nThe code snippet below is accurate in cases where the component is used as both an input and an output.\n\n- **As input:** Should return, list of (word, category) tuples, or a dictionary of two keys: \"id\", and \"data\", which is a list of (word, category) tuples.\n\n ```python\n def predict(\n value: dict\n ) -> list[tuple[str, str | None]] | dict | None:\n return value\n ```\n \n",
"bugtrack_url": null,
"license": null,
"summary": "Editable Gradio textarea supporting highlighting",
"version": "0.0.12",
"project_urls": {
"space": "https://huggingface.co/spaces/gsarti/gradio_highlightedtextbox"
},
"split_keywords": [
"color",
" editing",
" gradio-custom-component",
" gradio-template-simpletextbox",
" highlight",
" textbox"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6865660c199a4fb657459b0d3e1b5a3d34d49c81e3d889fd97cbe93ece4da718",
"md5": "84d49ba8c93d44977708b1a59b4dc85a",
"sha256": "5a2d65aedcb1ab8fb6952604f0e8b78cde95851a923c325a87eb0bd03c7c5702"
},
"downloads": -1,
"filename": "gradio_highlightedtextbox-0.0.12-py3-none-any.whl",
"has_sig": false,
"md5_digest": "84d49ba8c93d44977708b1a59b4dc85a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 34606,
"upload_time": "2024-04-15T13:53:43",
"upload_time_iso_8601": "2024-04-15T13:53:43.593858Z",
"url": "https://files.pythonhosted.org/packages/68/65/660c199a4fb657459b0d3e1b5a3d34d49c81e3d889fd97cbe93ece4da718/gradio_highlightedtextbox-0.0.12-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "52a8b8739e69ce742d09f54992be752bd26d281370a23f4fddd062eeab3da026",
"md5": "ee08074048e646ca5b0b7e51324a7df6",
"sha256": "a178f26d23a2d9f9d91cf2cf364eb61b3720bdcfe555f5cad26f90c5da4acb5a"
},
"downloads": -1,
"filename": "gradio_highlightedtextbox-0.0.12.tar.gz",
"has_sig": false,
"md5_digest": "ee08074048e646ca5b0b7e51324a7df6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 53086,
"upload_time": "2024-04-15T13:53:45",
"upload_time_iso_8601": "2024-04-15T13:53:45.999461Z",
"url": "https://files.pythonhosted.org/packages/52/a8/b8739e69ce742d09f54992be752bd26d281370a23f4fddd062eeab3da026/gradio_highlightedtextbox-0.0.12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-15 13:53:45",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "gradio-highlightedtextbox"
}