Merge branch 'open-webui:dev' into dev
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import { onDestroy, onMount, getContext } from 'svelte';
|
||||
import panzoom, { type PanZoom } from 'panzoom';
|
||||
|
||||
import fileSaver from 'file-saver';
|
||||
@@ -11,6 +11,8 @@
|
||||
export let src = '';
|
||||
export let alt = '';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
let mounted = false;
|
||||
|
||||
let previewElement = null;
|
||||
@@ -100,9 +102,10 @@
|
||||
|
||||
const mimeType = blob.type || 'image/png';
|
||||
// create file name based on the MIME type, alt should be a valid file name with extension
|
||||
const fileName = alt
|
||||
? `${alt.replaceAll('.', '')}.${mimeType.split('/')[1]}`
|
||||
: 'download.png';
|
||||
const fileName = `${$i18n
|
||||
.t('Generated Image')
|
||||
.toLowerCase()
|
||||
.replace(/ /g, '_')}.${mimeType.split('/')[1]}`;
|
||||
|
||||
// Use FileSaver to save the blob
|
||||
saveAs(blob, fileName);
|
||||
@@ -119,9 +122,10 @@
|
||||
const blobWithType = new Blob([blob], { type: mimeType });
|
||||
|
||||
// create file name based on the MIME type, alt should be a valid file name with extension
|
||||
const fileName = alt
|
||||
? `${alt.replaceAll('.', '')}.${mimeType.split('/')[1]}`
|
||||
: 'download.png';
|
||||
const fileName = `${$i18n
|
||||
.t('Generated Image')
|
||||
.toLowerCase()
|
||||
.replace(/ /g, '_')}.${mimeType.split('/')[1]}`;
|
||||
|
||||
// Use FileSaver to save the blob
|
||||
saveAs(blobWithType, fileName);
|
||||
@@ -146,9 +150,10 @@
|
||||
const blobWithType = new Blob([blob], { type: mimeType });
|
||||
|
||||
// create file name based on the MIME type, alt should be a valid file name with extension
|
||||
const fileName = alt
|
||||
? `${alt.replaceAll('.', '')}.${mimeType.split('/')[1]}`
|
||||
: 'download.png';
|
||||
const fileName = `${$i18n
|
||||
.t('Generated Image')
|
||||
.toLowerCase()
|
||||
.replace(/ /g, '_')}.${mimeType.split('/')[1]}`;
|
||||
|
||||
// Use FileSaver to save the blob
|
||||
saveAs(blobWithType, fileName);
|
||||
|
||||
@@ -149,10 +149,15 @@
|
||||
export let onChange = (e) => {};
|
||||
|
||||
// create a lowlight instance with all languages loaded
|
||||
const lowlight = createLowlight(hljs.listLanguages().reduce((obj, lang) => {
|
||||
obj[lang] = () => hljs.getLanguage(lang);
|
||||
return obj;
|
||||
}, {} as Record<string, any>));
|
||||
const lowlight = createLowlight(
|
||||
hljs.listLanguages().reduce(
|
||||
(obj, lang) => {
|
||||
obj[lang] = () => hljs.getLanguage(lang);
|
||||
return obj;
|
||||
},
|
||||
{} as Record<string, any>
|
||||
)
|
||||
);
|
||||
|
||||
export let editor: Editor | null = null;
|
||||
|
||||
@@ -163,7 +168,7 @@
|
||||
export let documentId = '';
|
||||
|
||||
export let className = 'input-prose';
|
||||
export let placeholder = 'Type here...';
|
||||
export let placeholder = $i18n.t('Type here...');
|
||||
let _placeholder = placeholder;
|
||||
|
||||
$: if (placeholder !== _placeholder) {
|
||||
@@ -501,9 +506,14 @@
|
||||
|
||||
export const focus = () => {
|
||||
if (editor) {
|
||||
editor.view.focus();
|
||||
// Scroll to the current selection
|
||||
editor.view.dispatch(editor.view.state.tr.scrollIntoView());
|
||||
try {
|
||||
editor.view?.focus();
|
||||
// Scroll to the current selection
|
||||
editor.view?.dispatch(editor.view.state.tr.scrollIntoView());
|
||||
} catch (e) {
|
||||
// sometimes focusing throws an error, ignore
|
||||
console.warn('Error focusing editor', e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -679,7 +689,7 @@
|
||||
link: link
|
||||
}),
|
||||
...(dragHandle ? [ListItemDragHandle] : []),
|
||||
Placeholder.configure({ placeholder: () => _placeholder }),
|
||||
Placeholder.configure({ placeholder: () => _placeholder, showOnlyWhenEditable: false }),
|
||||
SelectionDecoration,
|
||||
|
||||
...(richText
|
||||
@@ -1113,4 +1123,9 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div bind:this={element} class="relative w-full min-w-full h-full min-h-fit {className}" />
|
||||
<div
|
||||
bind:this={element}
|
||||
class="relative w-full min-w-full h-full min-h-fit {className} {!editable
|
||||
? 'cursor-not-allowed'
|
||||
: ''}"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user