open-webui/src/lib/components/notes/NoteEditor.svelte

785 lines
20 KiB
Svelte
Raw Normal View History

2025-05-04 01:18:19 +08:00
<script lang="ts">
2025-05-04 03:29:19 +08:00
import { getContext, onDestroy, onMount, tick } from 'svelte';
import { v4 as uuidv4 } from 'uuid';
2025-05-04 22:32:21 +08:00
import fileSaver from 'file-saver';
const { saveAs } = fileSaver;
import jsPDF from 'jspdf';
import html2canvas from 'html2canvas-pro';
2025-05-04 03:29:19 +08:00
2025-05-04 01:18:19 +08:00
const i18n = getContext('i18n');
2025-05-05 05:35:43 +08:00
import { marked } from 'marked';
2025-05-04 01:18:19 +08:00
import { toast } from 'svelte-sonner';
2025-05-04 02:53:23 +08:00
2025-05-04 03:29:19 +08:00
import { config, settings, showSidebar } from '$lib/stores';
2025-05-04 02:53:23 +08:00
import { goto } from '$app/navigation';
2025-05-05 04:05:06 +08:00
import { compressImage, copyToClipboard } from '$lib/utils';
2025-05-04 22:32:21 +08:00
import { WEBUI_API_BASE_URL } from '$lib/constants';
import { uploadFile } from '$lib/apis/files';
2025-05-04 03:29:19 +08:00
2025-05-04 02:53:23 +08:00
import dayjs from '$lib/dayjs';
import calendar from 'dayjs/plugin/calendar';
import duration from 'dayjs/plugin/duration';
import relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(calendar);
dayjs.extend(duration);
dayjs.extend(relativeTime);
async function loadLocale(locales) {
for (const locale of locales) {
try {
dayjs.locale(locale);
break; // Stop after successfully loading the first available locale
} catch (error) {
console.error(`Could not load locale '${locale}':`, error);
}
}
}
// Assuming $i18n.languages is an array of language codes
$: loadLocale($i18n.languages);
2025-05-04 22:32:21 +08:00
import { deleteNoteById, getNoteById, updateNoteById } from '$lib/apis/notes';
2025-05-04 01:18:19 +08:00
import RichTextInput from '../common/RichTextInput.svelte';
import Spinner from '../common/Spinner.svelte';
2025-05-04 04:14:19 +08:00
import MicSolid from '../icons/MicSolid.svelte';
2025-05-04 01:18:19 +08:00
import VoiceRecording from '../chat/MessageInput/VoiceRecording.svelte';
2025-05-04 22:32:21 +08:00
import DeleteConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
2025-05-04 02:53:23 +08:00
import Calendar from '../icons/Calendar.svelte';
import Users from '../icons/Users.svelte';
2025-05-04 22:32:21 +08:00
2025-05-04 03:29:19 +08:00
import Image from '../common/Image.svelte';
import FileItem from '../common/FileItem.svelte';
2025-05-04 03:47:41 +08:00
import FilesOverlay from '../chat/MessageInput/FilesOverlay.svelte';
2025-05-04 04:14:19 +08:00
import RecordMenu from './RecordMenu.svelte';
2025-05-04 22:32:21 +08:00
import NoteMenu from './Notes/NoteMenu.svelte';
import EllipsisHorizontal from '../icons/EllipsisHorizontal.svelte';
2025-05-05 04:05:06 +08:00
import Sparkles from '../icons/Sparkles.svelte';
import SparklesSolid from '../icons/SparklesSolid.svelte';
import Tooltip from '../common/Tooltip.svelte';
import Bars3BottomLeft from '../icons/Bars3BottomLeft.svelte';
2025-05-05 05:35:43 +08:00
import ArrowUturnLeft from '../icons/ArrowUturnLeft.svelte';
import ArrowUturnRight from '../icons/ArrowUturnRight.svelte';
2025-05-04 01:18:19 +08:00
export let id: null | string = null;
2025-05-04 21:22:51 +08:00
let note = null;
const newNote = {
2025-05-04 02:53:23 +08:00
title: '',
data: {
content: {
json: null,
html: '',
md: ''
2025-05-04 03:29:19 +08:00
},
2025-05-05 05:35:43 +08:00
versions: [],
2025-05-04 03:29:19 +08:00
files: null
2025-05-04 02:53:23 +08:00
},
meta: null,
access_control: null
2025-05-04 01:18:19 +08:00
};
2025-05-04 03:29:19 +08:00
let files = [];
2025-05-04 22:32:21 +08:00
2025-05-05 05:35:43 +08:00
let versionIdx = null;
2025-05-04 04:14:19 +08:00
let recording = false;
let displayMediaRecord = false;
2025-05-04 03:29:19 +08:00
2025-05-04 22:32:21 +08:00
let showDeleteConfirm = false;
2025-05-04 03:29:19 +08:00
let dragged = false;
2025-05-05 05:35:43 +08:00
2025-05-04 01:18:19 +08:00
let loading = false;
2025-05-05 05:35:43 +08:00
let enhancing = false;
2025-05-04 01:18:19 +08:00
const init = async () => {
loading = true;
const res = await getNoteById(localStorage.token, id).catch((error) => {
toast.error(`${error}`);
return null;
});
if (res) {
2025-05-04 02:53:23 +08:00
note = res;
2025-05-04 03:29:19 +08:00
files = res.data.files || [];
2025-05-04 02:53:23 +08:00
} else {
2025-05-04 21:22:51 +08:00
goto('/');
2025-05-04 02:53:23 +08:00
return;
2025-05-04 01:18:19 +08:00
}
loading = false;
};
2025-05-04 02:53:23 +08:00
let debounceTimeout: NodeJS.Timeout | null = null;
const changeDebounceHandler = () => {
if (debounceTimeout) {
clearTimeout(debounceTimeout);
}
debounceTimeout = setTimeout(async () => {
2025-05-05 05:35:43 +08:00
if (!note || enhancing || versionIdx !== null) {
2025-05-04 21:22:51 +08:00
return;
}
console.log('Saving note:', note);
2025-05-04 02:53:23 +08:00
const res = await updateNoteById(localStorage.token, id, {
...note,
title: note.title === '' ? $i18n.t('Untitled') : note.title
}).catch((e) => {
toast.error(`${e}`);
});
}, 200);
};
$: if (note) {
changeDebounceHandler();
}
2025-05-04 01:18:19 +08:00
$: if (id) {
init();
}
2025-05-04 03:29:19 +08:00
2025-05-05 05:35:43 +08:00
function areContentsEqual(a, b) {
return JSON.stringify(a) === JSON.stringify(b);
}
function insertNoteVersion(note) {
const current = {
json: note.data.content.json,
html: note.data.content.html,
md: note.data.content.md
};
const lastVersion = note.data.versions?.at(-1);
if (!lastVersion || !areContentsEqual(lastVersion, current)) {
note.data.versions = (note.data.versions ?? []).concat(current);
return true;
}
return false;
}
async function aiEnhanceContent(content) {
const md = content.md + '_ai';
const html = marked.parse(md);
return {
json: null,
html: html,
md: md
};
}
async function enhanceNoteHandler() {
insertNoteVersion(note);
enhancing = true;
const aiResult = await aiEnhanceContent(note.data.content);
note.data.content.json = aiResult.json;
note.data.content.html = aiResult.html;
note.data.content.md = aiResult.md;
enhancing = false;
versionIdx = null;
}
function setContentByVersion(versionIdx) {
if (!note.data.versions?.length) return;
let idx = versionIdx;
if (idx === null) idx = note.data.versions.length - 1; // latest
const v = note.data.versions[idx];
note.data.content.json = v.json;
note.data.content.html = v.html;
note.data.content.md = v.md;
if (versionIdx === null) {
const lastVersion = note.data.versions.at(-1);
const currentContent = note.data.content;
if (areContentsEqual(lastVersion, currentContent)) {
// remove the last version
note.data.versions = note.data.versions.slice(0, -1);
}
}
}
// Navigation
function versionNavigateHandler(direction) {
if (!note.data.versions || note.data.versions.length === 0) return;
if (versionIdx === null) {
// Get latest snapshots
const lastVersion = note.data.versions.at(-1);
const currentContent = note.data.content;
if (!areContentsEqual(lastVersion, currentContent)) {
// If the current content is different from the last version, insert a new version
insertNoteVersion(note);
versionIdx = note.data.versions.length - 1;
} else {
versionIdx = note.data.versions.length;
}
}
if (direction === 'prev') {
if (versionIdx > 0) versionIdx -= 1;
} else if (direction === 'next') {
if (versionIdx < note.data.versions.length - 1) versionIdx += 1;
else versionIdx = null; // Reset to latest
if (versionIdx === note.data.versions.length - 1) {
// If we reach the latest version, reset to null
versionIdx = null;
}
}
setContentByVersion(versionIdx);
}
2025-05-05 04:05:06 +08:00
2025-05-04 03:29:19 +08:00
const uploadFileHandler = async (file) => {
const tempItemId = uuidv4();
const fileItem = {
type: 'file',
file: '',
id: null,
url: '',
name: file.name,
collection_name: '',
status: 'uploading',
size: file.size,
error: '',
itemId: tempItemId
};
if (fileItem.size == 0) {
toast.error($i18n.t('You cannot upload an empty file.'));
return null;
}
files = [...files, fileItem];
try {
// During the file upload, file content is automatically extracted.
const uploadedFile = await uploadFile(localStorage.token, file);
if (uploadedFile) {
console.log('File upload completed:', {
id: uploadedFile.id,
name: fileItem.name,
collection: uploadedFile?.meta?.collection_name
});
if (uploadedFile.error) {
console.warn('File upload warning:', uploadedFile.error);
toast.warning(uploadedFile.error);
}
fileItem.status = 'uploaded';
fileItem.file = uploadedFile;
fileItem.id = uploadedFile.id;
fileItem.collection_name =
uploadedFile?.meta?.collection_name || uploadedFile?.collection_name;
fileItem.url = `${WEBUI_API_BASE_URL}/files/${uploadedFile.id}`;
files = files;
} else {
files = files.filter((item) => item?.itemId !== tempItemId);
}
} catch (e) {
toast.error(`${e}`);
files = files.filter((item) => item?.itemId !== tempItemId);
}
if (files.length > 0) {
note.data.files = files;
} else {
note.data.files = null;
}
};
const inputFilesHandler = async (inputFiles) => {
console.log('Input files handler called with:', inputFiles);
inputFiles.forEach((file) => {
console.log('Processing file:', {
name: file.name,
type: file.type,
size: file.size,
extension: file.name.split('.').at(-1)
});
if (
($config?.file?.max_size ?? null) !== null &&
file.size > ($config?.file?.max_size ?? 0) * 1024 * 1024
) {
console.log('File exceeds max size limit:', {
fileSize: file.size,
maxSize: ($config?.file?.max_size ?? 0) * 1024 * 1024
});
toast.error(
$i18n.t(`File size should not exceed {{maxSize}} MB.`, {
maxSize: $config?.file?.max_size
})
);
return;
}
if (
['image/gif', 'image/webp', 'image/jpeg', 'image/png', 'image/avif'].includes(file['type'])
) {
let reader = new FileReader();
reader.onload = async (event) => {
let imageUrl = event.target.result;
if ($settings?.imageCompression ?? false) {
const width = $settings?.imageCompressionSize?.width ?? null;
const height = $settings?.imageCompressionSize?.height ?? null;
if (width || height) {
imageUrl = await compressImage(imageUrl, width, height);
}
}
files = [
...files,
{
type: 'image',
url: `${imageUrl}`
}
];
note.data.files = files;
};
reader.readAsDataURL(file);
} else {
uploadFileHandler(file);
}
});
};
2025-05-04 22:32:21 +08:00
const downloadHandler = async (type) => {
console.log('downloadHandler', type);
if (type === 'md') {
const blob = new Blob([note.data.content.md], { type: 'text/markdown' });
saveAs(blob, `${note.title}.md`);
} else if (type === 'pdf') {
await downloadPdf(note);
}
};
const downloadPdf = async (note) => {
try {
// Define a fixed virtual screen size
const virtualWidth = 1024; // Fixed width (adjust as needed)
const virtualHeight = 1400; // Fixed height (adjust as needed)
// STEP 1. Get a DOM node to render
const html = note.data?.content?.html ?? '';
let node;
if (html instanceof HTMLElement) {
node = html;
} else {
// If it's HTML string, render to a temporary hidden element
node = document.createElement('div');
node.innerHTML = html;
document.body.appendChild(node);
}
// Render to canvas with predefined width
const canvas = await html2canvas(node, {
useCORS: true,
scale: 2, // Keep at 1x to avoid unexpected enlargements
width: virtualWidth, // Set fixed virtual screen width
windowWidth: virtualWidth, // Ensure consistent rendering
windowHeight: virtualHeight
});
// Remove hidden node if needed
if (!(html instanceof HTMLElement)) {
document.body.removeChild(node);
}
const imgData = canvas.toDataURL('image/png');
// A4 page settings
const pdf = new jsPDF('p', 'mm', 'a4');
const imgWidth = 210; // A4 width in mm
const pageHeight = 297; // A4 height in mm
// Maintain aspect ratio
const imgHeight = (canvas.height * imgWidth) / canvas.width;
let heightLeft = imgHeight;
let position = 0;
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
heightLeft -= pageHeight;
// Handle additional pages
while (heightLeft > 0) {
position -= pageHeight;
pdf.addPage();
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
heightLeft -= pageHeight;
}
pdf.save(`${note.title}.pdf`);
} catch (error) {
console.error('Error generating PDF', error);
toast.error(`${error}`);
}
};
const deleteNoteHandler = async (id) => {
const res = await deleteNoteById(localStorage.token, id).catch((error) => {
toast.error(`${error}`);
return null;
});
if (res) {
toast.success($i18n.t('Note deleted successfully'));
goto('/notes');
} else {
toast.error($i18n.t('Failed to delete note'));
}
};
2025-05-04 03:29:19 +08:00
const onDragOver = (e) => {
e.preventDefault();
// Check if a file is being dragged.
if (e.dataTransfer?.types?.includes('Files')) {
dragged = true;
} else {
dragged = false;
}
};
const onDragLeave = () => {
dragged = false;
};
const onDrop = async (e) => {
e.preventDefault();
console.log(e);
if (e.dataTransfer?.files) {
const inputFiles = Array.from(e.dataTransfer?.files);
if (inputFiles && inputFiles.length > 0) {
console.log(inputFiles);
inputFilesHandler(inputFiles);
}
}
dragged = false;
};
onMount(async () => {
await tick();
const dropzoneElement = document.getElementById('note-editor');
dropzoneElement?.addEventListener('dragover', onDragOver);
dropzoneElement?.addEventListener('drop', onDrop);
dropzoneElement?.addEventListener('dragleave', onDragLeave);
});
onDestroy(() => {
console.log('destroy');
const dropzoneElement = document.getElementById('note-editor');
if (dropzoneElement) {
dropzoneElement?.removeEventListener('dragover', onDragOver);
dropzoneElement?.removeEventListener('drop', onDrop);
dropzoneElement?.removeEventListener('dragleave', onDragLeave);
}
});
2025-05-04 01:18:19 +08:00
</script>
2025-05-04 03:47:41 +08:00
<FilesOverlay show={dragged} />
2025-05-04 22:32:21 +08:00
<DeleteConfirmDialog
bind:show={showDeleteConfirm}
title={$i18n.t('Delete note?')}
on:confirm={() => {
deleteNoteHandler(note.id);
showDeleteConfirm = false;
}}
>
<div class=" text-sm text-gray-500">
{$i18n.t('This will delete')} <span class=" font-semibold">{note.title}</span>.
</div>
</DeleteConfirmDialog>
2025-05-04 03:29:19 +08:00
<div class="relative flex-1 w-full h-full flex justify-center" id="note-editor">
2025-05-04 01:18:19 +08:00
{#if loading}
<div class=" absolute top-0 bottom-0 left-0 right-0 flex">
<div class="m-auto">
<Spinner />
</div>
</div>
2025-05-04 02:53:23 +08:00
{:else}
<div class=" w-full flex flex-col {loading ? 'opacity-20' : ''}">
2025-05-04 03:47:41 +08:00
<div class="shrink-0 w-full flex justify-between items-center px-4.5 pt-1 mb-1.5">
2025-05-05 05:35:43 +08:00
<div class="w-full flex items-center">
2025-05-04 02:53:23 +08:00
<input
class="w-full text-2xl font-medium bg-transparent outline-hidden"
type="text"
bind:value={note.title}
placeholder={$i18n.t('Title')}
required
/>
2025-05-04 22:32:21 +08:00
2025-05-05 05:35:43 +08:00
<div class="flex items-center gap-2">
{#if note.data?.versions?.length > 0}
<div>
<div class="flex items-center gap-0.5 self-center min-w-fit" dir="ltr">
<button
class="self-center p-1 hover:enabled:bg-black/5 dark:hover:enabled:bg-white/5 dark:hover:enabled:text-white hover:enabled:text-black rounded-md transition disabled:cursor-not-allowed disabled:text-gray-500 disabled:hover:text-gray-500"
on:click={() => {
versionNavigateHandler('prev');
}}
disabled={(versionIdx === null && note.data.versions.length === 0) ||
versionIdx === 0}
>
<ArrowUturnLeft className="size-4" />
</button>
<button
class="self-center p-1 hover:enabled:bg-black/5 dark:hover:enabled:bg-white/5 dark:hover:enabled:text-white hover:enabled:text-black rounded-md transition disabled:cursor-not-allowed disabled:text-gray-500 disabled:hover:text-gray-500"
on:click={() => {
versionNavigateHandler('next');
}}
disabled={versionIdx >= note.data.versions.length || versionIdx === null}
>
<ArrowUturnRight className="size-4" />
</button>
</div>
</div>
{/if}
2025-05-04 22:32:21 +08:00
<NoteMenu
onDownload={(type) => {
downloadHandler(type);
}}
2025-05-05 04:05:06 +08:00
onCopyToClipboard={async () => {
const res = await copyToClipboard(note.data.content.md).catch((error) => {
toast.error(`${error}`);
return null;
});
if (res) {
toast.success($i18n.t('Copied to clipboard'));
}
}}
2025-05-04 22:32:21 +08:00
onDelete={() => {
showDeleteConfirm = true;
}}
>
<button
class="self-center w-fit text-sm p-1 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
type="button"
>
<EllipsisHorizontal className="size-5" />
</button>
</NoteMenu>
</div>
2025-05-04 02:53:23 +08:00
</div>
</div>
2025-05-04 01:18:19 +08:00
2025-05-04 03:47:41 +08:00
<div class=" mb-2.5 px-3.5">
2025-05-04 03:29:19 +08:00
<div class="flex gap-1 items-center text-xs font-medium text-gray-500 dark:text-gray-500">
<button class=" flex items-center gap-1 w-fit py-1 px-1.5 rounded-lg">
<Calendar className="size-3.5" strokeWidth="2" />
<span>{dayjs(note.created_at / 1000000).calendar()}</span>
</button>
2025-05-04 02:53:23 +08:00
2025-05-04 03:29:19 +08:00
<button class=" flex items-center gap-1 w-fit py-1 px-1.5 rounded-lg">
<Users className="size-3.5" strokeWidth="2" />
2025-05-04 02:53:23 +08:00
2025-05-04 03:29:19 +08:00
<span> You </span>
</button>
</div>
2025-05-04 03:47:41 +08:00
</div>
2025-05-04 02:53:23 +08:00
2025-05-05 04:05:06 +08:00
<div class=" flex-1 w-full h-full overflow-auto px-4 pb-14">
2025-05-04 21:23:42 +08:00
{#if files && files.length > 0}
2025-05-04 03:47:41 +08:00
<div class="mb-3.5 mt-1.5 w-full flex gap-1 flex-wrap z-40">
2025-05-04 04:20:30 +08:00
{#each files as file, fileIdx}
2025-05-04 03:47:41 +08:00
<div class="w-fit">
2025-05-04 03:29:19 +08:00
{#if file.type === 'image'}
<Image
src={file.url}
imageClassName=" max-h-96 rounded-lg"
dismissible={true}
onDismiss={() => {
2025-05-04 03:47:41 +08:00
files = files.filter((item, idx) => idx !== fileIdx);
2025-05-04 03:29:19 +08:00
note.data.files = files.length > 0 ? files : null;
}}
/>
{:else}
<FileItem
item={file}
dismissible={true}
url={file.url}
name={file.name}
type={file.type}
size={file?.size}
2025-05-04 04:20:30 +08:00
loading={file.status === 'uploading'}
2025-05-04 03:29:19 +08:00
on:dismiss={() => {
files = files.filter((item) => item?.id !== file.id);
note.data.files = files.length > 0 ? files : null;
}}
/>
{/if}
</div>
{/each}
</div>
{/if}
2025-05-04 01:18:19 +08:00
2025-05-04 02:53:23 +08:00
<RichTextInput
2025-05-04 03:47:41 +08:00
className="input-prose-sm px-0.5"
2025-05-04 02:53:23 +08:00
bind:value={note.data.content.json}
placeholder={$i18n.t('Write something...')}
2025-05-05 03:04:15 +08:00
html={note.data?.content?.html}
2025-05-04 02:53:23 +08:00
json={true}
2025-05-05 05:35:43 +08:00
editable={versionIdx === null}
2025-05-04 02:53:23 +08:00
onChange={(content) => {
2025-05-04 20:53:48 +08:00
note.data.content.html = content.html;
note.data.content.md = content.md;
2025-05-04 02:53:23 +08:00
}}
/>
</div>
2025-05-04 01:18:19 +08:00
</div>
2025-05-04 02:53:23 +08:00
{/if}
2025-05-04 01:18:19 +08:00
</div>
2025-05-05 04:05:06 +08:00
<div
class="absolute bottom-0 right-0 p-5 max-w-full {$showSidebar
? 'md:max-w-[calc(100%-260px)]'
: ''} w-full flex justify-end"
>
<div class="flex gap-1 justify-between w-full max-w-full">
2025-05-04 04:14:19 +08:00
{#if recording}
2025-05-04 01:18:19 +08:00
<div class="flex-1 w-full">
<VoiceRecording
2025-05-04 04:14:19 +08:00
bind:recording
2025-05-04 01:18:19 +08:00
className="p-1 w-full max-w-full"
2025-05-04 02:53:23 +08:00
transcribe={false}
2025-05-04 04:14:19 +08:00
displayMedia={displayMediaRecord}
2025-05-04 02:53:23 +08:00
onCancel={() => {
2025-05-04 04:14:19 +08:00
recording = false;
displayMediaRecord = false;
2025-05-04 01:18:19 +08:00
}}
2025-05-04 02:53:23 +08:00
onConfirm={(data) => {
2025-05-04 03:29:19 +08:00
if (data?.file) {
uploadFileHandler(data?.file);
}
2025-05-04 04:14:19 +08:00
recording = false;
displayMediaRecord = false;
2025-05-04 01:18:19 +08:00
}}
/>
</div>
{:else}
2025-05-04 04:14:19 +08:00
<RecordMenu
onRecord={async () => {
displayMediaRecord = false;
try {
let stream = await navigator.mediaDevices
.getUserMedia({ audio: true })
.catch(function (err) {
toast.error(
$i18n.t(`Permission denied when accessing microphone: {{error}}`, {
error: err
})
);
return null;
});
if (stream) {
recording = true;
const tracks = stream.getTracks();
tracks.forEach((track) => track.stop());
}
stream = null;
} catch {
toast.error($i18n.t('Permission denied when accessing microphone'));
}
}}
onCaptureAudio={async () => {
displayMediaRecord = true;
recording = true;
}}
2025-05-04 22:26:33 +08:00
onUpload={async () => {
const input = document.createElement('input');
input.type = 'file';
input.accept = 'audio/*';
input.multiple = false;
input.click();
input.onchange = async (e) => {
const files = e.target.files;
if (files && files.length > 0) {
await uploadFileHandler(files[0]);
}
};
}}
2025-05-04 04:14:19 +08:00
>
2025-05-05 05:35:43 +08:00
<Tooltip content={$i18n.t('Record')} placement="top">
<button
class="cursor-pointer p-2.5 flex rounded-full border border-gray-50 bg-white dark:border-none dark:bg-gray-850 hover:bg-gray-50 dark:hover:bg-gray-800 transition shadow-xl"
type="button"
>
<MicSolid className="size-4.5" />
</button>
</Tooltip>
2025-05-04 04:14:19 +08:00
</RecordMenu>
2025-05-05 04:05:06 +08:00
<div
2025-05-05 05:35:43 +08:00
class="cursor-pointer flex gap-0.5 rounded-full border border-gray-50 dark:border-gray-850 dark:bg-gray-850 transition shadow-xl"
2025-05-05 04:05:06 +08:00
>
2025-05-05 05:35:43 +08:00
<!-- <Tooltip content={$i18n.t('My Notes')} placement="top">
2025-05-05 04:05:06 +08:00
<button
class="p-2 size-8.5 flex justify-center items-center {selectedVersion === 'note'
? 'bg-gray-100 dark:bg-gray-800 '
: ' hover:bg-gray-50 dark:hover:bg-gray-800'} rounded-full transition shrink-0"
type="button"
on:click={() => {
selectedVersion = 'note';
versionToggleHandler();
}}
>
<Bars3BottomLeft />
</button>
2025-05-05 05:35:43 +08:00
</Tooltip> -->
2025-05-05 04:05:06 +08:00
2025-05-05 05:35:43 +08:00
<Tooltip content={$i18n.t('Enhance')} placement="top">
2025-05-05 04:05:06 +08:00
<button
2025-05-05 05:35:43 +08:00
class="p-2.5 flex justify-center items-center hover:bg-gray-50 dark:hover:bg-gray-800 rounded-full transition shrink-0"
2025-05-05 04:05:06 +08:00
on:click={() => {
2025-05-05 05:35:43 +08:00
enhanceNoteHandler();
2025-05-05 04:05:06 +08:00
}}
type="button"
>
<SparklesSolid />
</button>
</Tooltip>
</div>
2025-05-04 01:18:19 +08:00
{/if}
</div>
</div>