mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
enh: text select copy behaviour
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda126-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda126-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-slim-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-slim-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda126-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-slim-images (push) Blocked by required conditions
Python CI / Format Backend (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda126-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda126-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / build-slim-image (linux/amd64, ubuntu-latest) (push) Waiting to run
Create and publish Docker images with specific build args / build-slim-image (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda126-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-slim-images (push) Blocked by required conditions
Python CI / Format Backend (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
This commit is contained in:
parent
38f45a38cb
commit
2de854fa02
1 changed files with 130 additions and 78 deletions
|
|
@ -2,7 +2,7 @@
|
|||
import { toast } from 'svelte-sonner';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { createEventDispatcher, onDestroy } from 'svelte';
|
||||
import { onMount, tick, getContext } from 'svelte';
|
||||
import type { Writable } from 'svelte/store';
|
||||
import type { i18n as i18nType, t } from 'i18next';
|
||||
|
|
@ -152,6 +152,8 @@
|
|||
export let topPadding = false;
|
||||
|
||||
let citationsElement: HTMLDivElement;
|
||||
|
||||
let contentContainerElement: HTMLDivElement;
|
||||
let buttonsContainerElement: HTMLDivElement;
|
||||
let showDeleteConfirm = false;
|
||||
|
||||
|
|
@ -541,12 +543,8 @@
|
|||
})();
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
// console.log('ResponseMessage mounted');
|
||||
|
||||
await tick();
|
||||
const buttonsWheelHandler = (event: WheelEvent) => {
|
||||
if (buttonsContainerElement) {
|
||||
buttonsContainerElement.addEventListener('wheel', function (event) {
|
||||
if (buttonsContainerElement.scrollWidth <= buttonsContainerElement.clientWidth) {
|
||||
// If the container is not scrollable, horizontal scroll
|
||||
return;
|
||||
|
|
@ -558,7 +556,57 @@
|
|||
buttonsContainerElement.scrollLeft += event.deltaY;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const contentCopyHandler = (e) => {
|
||||
if (contentContainerElement) {
|
||||
e.preventDefault();
|
||||
// Get the selected HTML
|
||||
const selection = window.getSelection();
|
||||
const range = selection.getRangeAt(0);
|
||||
const tempDiv = document.createElement('div');
|
||||
|
||||
// Remove background, color, and font styles
|
||||
tempDiv.appendChild(range.cloneContents());
|
||||
|
||||
tempDiv.querySelectorAll('table').forEach((table) => {
|
||||
table.style.borderCollapse = 'collapse';
|
||||
table.style.width = 'auto';
|
||||
table.style.tableLayout = 'auto';
|
||||
});
|
||||
|
||||
tempDiv.querySelectorAll('th').forEach((th) => {
|
||||
th.style.whiteSpace = 'nowrap';
|
||||
th.style.padding = '4px 8px';
|
||||
});
|
||||
|
||||
// Put cleaned HTML + plain text into clipboard
|
||||
e.clipboardData.setData('text/html', tempDiv.innerHTML);
|
||||
e.clipboardData.setData('text/plain', selection.toString());
|
||||
}
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
// console.log('ResponseMessage mounted');
|
||||
|
||||
await tick();
|
||||
if (buttonsContainerElement) {
|
||||
buttonsContainerElement.addEventListener('wheel', buttonsWheelHandler);
|
||||
}
|
||||
|
||||
if (contentContainerElement) {
|
||||
contentContainerElement.addEventListener('copy', contentCopyHandler);
|
||||
}
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (buttonsContainerElement) {
|
||||
buttonsContainerElement.removeEventListener('wheel', buttonsWheelHandler);
|
||||
}
|
||||
|
||||
if (contentContainerElement) {
|
||||
contentContainerElement.removeEventListener('copy', contentCopyHandler);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
@ -719,8 +767,13 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="w-full flex flex-col relative" id="response-content-container">
|
||||
{/if}
|
||||
|
||||
<div
|
||||
bind:this={contentContainerElement}
|
||||
class="w-full flex flex-col relative {edit ? 'hidden' : ''}"
|
||||
id="response-content-container"
|
||||
>
|
||||
{#if message.content === '' && !message.error && ((model?.info?.meta?.capabilities?.status_updates ?? true) ? (message?.statusHistory ?? [...(message?.status ? [message?.status] : [])]).length === 0 || (message?.statusHistory?.at(-1)?.hidden ?? false) : true)}
|
||||
<Skeleton />
|
||||
{:else if message.content && message.error !== true}
|
||||
|
|
@ -784,7 +837,6 @@
|
|||
<CodeExecutions codeExecutions={message.code_executions} />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue