This commit is contained in:
Timothy Jaeryang Baek 2025-05-05 01:45:55 +04:00
parent 463ac99e39
commit f24d0085c2

View File

@ -166,6 +166,9 @@
} }
async function aiEnhanceContent(content) { async function aiEnhanceContent(content) {
// fake delay
await new Promise((resolve) => setTimeout(resolve, 2000));
const md = content.md + '_ai'; const md = content.md + '_ai';
const html = marked.parse(md); const html = marked.parse(md);
@ -612,7 +615,13 @@
</div> </div>
</div> </div>
<div class=" flex-1 w-full h-full overflow-auto px-4 pb-14"> <div class=" flex-1 w-full h-full overflow-auto px-4 pb-14 relative">
{#if enhancing}
<div
class="w-full h-full absolute top-0 left-0 backdrop-blur-xs bg-white/10 dark:bg-gray-900/10 flex items-center justify-center z-10"
></div>
{/if}
{#if files && files.length > 0} {#if files && files.length > 0}
<div class="mb-3.5 mt-1.5 w-full flex gap-1 flex-wrap z-40"> <div class="mb-3.5 mt-1.5 w-full flex gap-1 flex-wrap z-40">
{#each files as file, fileIdx} {#each files as file, fileIdx}
@ -653,7 +662,7 @@
placeholder={$i18n.t('Write something...')} placeholder={$i18n.t('Write something...')}
html={note.data?.content?.html} html={note.data?.content?.html}
json={true} json={true}
editable={versionIdx === null} editable={versionIdx === null && !enhancing}
onChange={(content) => { onChange={(content) => {
note.data.content.html = content.html; note.data.content.html = content.html;
note.data.content.md = content.md; note.data.content.md = content.md;
@ -665,7 +674,7 @@
</div> </div>
<div <div
class="absolute bottom-0 right-0 p-5 max-w-full {$showSidebar class="absolute z-30 bottom-0 right-0 p-5 max-w-full {$showSidebar
? 'md:max-w-[calc(100%-260px)]' ? 'md:max-w-[calc(100%-260px)]'
: ''} w-full flex justify-end" : ''} w-full flex justify-end"
> >
@ -769,13 +778,20 @@
<Tooltip content={$i18n.t('Enhance')} placement="top"> <Tooltip content={$i18n.t('Enhance')} placement="top">
<button <button
class="p-2.5 flex justify-center items-center hover:bg-gray-50 dark:hover:bg-gray-800 rounded-full transition shrink-0" class="{enhancing
? 'p-2'
: 'p-2.5'} flex justify-center items-center hover:bg-gray-50 dark:hover:bg-gray-800 rounded-full transition shrink-0"
on:click={() => { on:click={() => {
enhanceNoteHandler(); enhanceNoteHandler();
}} }}
disabled={enhancing}
type="button" type="button"
> >
<SparklesSolid /> {#if enhancing}
<Spinner className="size-5" />
{:else}
<SparklesSolid />
{/if}
</button> </button>
</Tooltip> </Tooltip>
</div> </div>