mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-02-03 22:35:14 +01:00
Make it optional to paste long pasted content to an attachment
This commit is contained in:
parent
42e7864d62
commit
84f66484c5
|
|
@ -884,7 +884,7 @@ function setupPasteHandler() {
|
|||
textbox.addEventListener("paste", async (event) => {
|
||||
const text = event.clipboardData?.getData("text");
|
||||
|
||||
if (text && text.length > MAX_PLAIN_TEXT_LENGTH) {
|
||||
if (text && text.length > MAX_PLAIN_TEXT_LENGTH && document.querySelector("#paste_to_attachment input[data-testid=\"checkbox\"]")?.checked) {
|
||||
event.preventDefault();
|
||||
|
||||
const file = new File([text], "pasted_text.txt", {
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ settings = {
|
|||
'custom_token_bans': '',
|
||||
'negative_prompt': '',
|
||||
'dark_theme': True,
|
||||
'paste_to_attachment': False,
|
||||
'default_extensions': [],
|
||||
|
||||
# Character settings
|
||||
|
|
|
|||
|
|
@ -268,6 +268,11 @@ def list_interface_input_elements():
|
|||
# Model elements
|
||||
elements += list_model_elements()
|
||||
|
||||
# Other elements
|
||||
elements += [
|
||||
'paste_to_attachment'
|
||||
]
|
||||
|
||||
return elements
|
||||
|
||||
|
||||
|
|
@ -473,6 +478,7 @@ def setup_auto_save():
|
|||
# Session tab (ui_session.py)
|
||||
'show_controls',
|
||||
'theme_state',
|
||||
'paste_to_attachment'
|
||||
]
|
||||
|
||||
for element_name in change_elements:
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ def create_ui():
|
|||
gr.Markdown("## Settings")
|
||||
shared.gradio['save_settings'] = gr.Button('Save settings to user_data/settings.yaml', elem_classes='refresh-button', interactive=not mu)
|
||||
shared.gradio['toggle_dark_mode'] = gr.Button('Toggle light/dark theme 💡', elem_classes='refresh-button')
|
||||
shared.gradio['paste_to_attachment'] = gr.Checkbox(label='Turn long pasted text into attachments in the Chat tab', value=shared.settings['paste_to_attachment'], elem_id='paste_to_attachment')
|
||||
|
||||
with gr.Column():
|
||||
gr.Markdown("## Extensions & flags")
|
||||
|
|
|
|||
Loading…
Reference in a new issue