30 ? `${note?.title.slice(0, 30)}...` : note?.title} / ${$WEBUI_NAME}` : `${$WEBUI_NAME}`} /> {#if note && activePage} { if (id) { try { const saved = await updateNoteAccessGrants( localStorage.token, id, note.access_grants ?? [] ); savedAccessGrants = structuredClone(saved.access_grants); toast.success($i18n.t('Saved')); } catch (error) { note.access_grants = structuredClone(savedAccessGrants); toast.error(`${error}`); } } }} /> {/if} { deleteNoteHandler(note.id); showDeleteConfirm = false; }} >
{$i18n.t('This will delete')} {note?.title}.
{#if loading}
{:else if note && activePage}
{#if $mobile && !pageTab} {/if} { titleInputFocused = true; }} on:blur={(e) => { // check if target is generate button if (ignoreBlur) { ignoreBlur = false; return; } if ( e.relatedTarget instanceof HTMLElement && e.relatedTarget.id === 'generate-title-button' ) { return; } titleInputFocused = false; changeDebounceHandler(); }} /> {#if titleInputFocused && !titleGenerating}
{/if}
{#if note?.write_access} {#if editor}
{/if} {/if} (currentNoteComments = request)} resource={{ resource_type: 'note', resource_id: note.id }} /> {#if note?.write_access} { 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; }} 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 inputFileHandler(files[0]); } }; }} > {/if} { downloadHandler(type); }} onCopyLink={async () => { const baseUrl = window.location.origin; const res = await copyToClipboard(`${baseUrl}/notes/${note.id}`); if (res) { toast.success($i18n.t('Copied link to clipboard')); } else { toast.error($i18n.t('Failed to copy link')); } }} onCopyToClipboard={async () => { const res = await copyToClipboard( activePage.content.md, activePage.content.html, true ).catch((error) => { toast.error(`${error}`); return null; }); if (res) { toast.success($i18n.t('Copied to clipboard')); } }} onDelete={() => { showDeleteConfirm = true; }} isPinned={$pinnedNotes.some((n) => n.id === note.id)} onPin={async () => { await toggleNotePinnedStatusById(localStorage.token, note.id); note.is_pinned = !note.is_pinned; pinnedNotes.set(await getPinnedNoteList(localStorage.token).catch(() => [])); }} > {#if liveParticipants.length > 0}
{/if} {#if note?.write_access} {#if $user?.permissions?.sharing?.notes || $user?.role === 'admin'}
{ savedAccessGrants = structuredClone(note.access_grants ?? []); showAccessControlModal = true; }} disabled={note?.user_id !== $user?.id && $user?.role !== 'admin'} />
{/if} {:else}
{$i18n.t('Read-Only Access')}
{/if}
{ if (e.deltaY !== 0) { e.preventDefault(); e.currentTarget.scrollLeft += e.deltaY; } }} >
{#if dayjs(note.created_at / 1000000) .locale($i18n.language) .isSame(dayjs().locale($i18n.language), 'day')} {dayjs(note.created_at / 1000000) .locale($i18n.language) .format($i18n.t('[Today at] h:mm A'))} {:else if dayjs(note.created_at / 1000000) .locale($i18n.language) .isSame(dayjs().locale($i18n.language).subtract(1, 'day'), 'day')} {dayjs(note.created_at / 1000000) .locale($i18n.language) .format($i18n.t('[Yesterday at] h:mm A'))} {:else if dayjs(note.created_at / 1000000) .locale($i18n.language) .isSame(dayjs().locale($i18n.language).subtract(1, 'week'), 'week')} {dayjs(note.created_at / 1000000) .locale($i18n.language) .format($i18n.t('[Last] dddd [at] h:mm A'))} {:else} {dayjs(note.created_at / 1000000) .locale($i18n.language) .format($i18n.t('DD/MM/YYYY'))} {/if}
{#if editor}
{$i18n.t('{{COUNT}} words', { COUNT: wordCount })}
{$i18n.t('{{COUNT}} characters', { COUNT: charCount })}
{/if}
{#if previousPage}
{$i18n.t( 'A page changed elsewhere. Your previous text is available to download.' )}
{/if}
{ showNoteTabs = false; await tick(); pagesToggleElement?.focus(); }} pages={note.data.pages.map((page) => page.id === 'main' && page.inherit_note_title !== false ? { ...page, title: note.title || $i18n.t('Untitled') } : page )} activeId={activePageId} editable={note.write_access} busy={pageBusy} onSelect={async (pageId) => { await selectPage(pageId); if ($mobile) showNoteTabs = false; }} onAction={pageAction} onCopyLink={async (pageId) => { await copyToClipboard( `${window.location.origin}/notes/${id}?page=${encodeURIComponent(pageId)}` ); toast.success($i18n.t('Copied link to clipboard')); }} onDownload={(pageId, format) => downloadHandler(format, pageId)} />
(currentNoteComments = { resource_type: 'note', resource_id: note.id, ...target }) }} > {#each [activePage] as renderedPage (`${note.id}:${renderedPage.id}:${renderedPage.generation}:${autoFormat}`)} (editor = event.detail)} id={`note-${note.id}-${renderedPage.id}`} className="input-prose-sm ps-4 pe-0.5 pt-2 flex-1 min-h-[12rem]" json={true} bind:value={renderedPage.content.json} html={editorHtml} documentId={activeDocumentId} bind:cursorTarget collaboration={true} socket={$socket} user={$user} dragHandle={true} link={true} image={true} attachments={true} placeholder={$i18n.t('Write something...')} editable={versionIdx === null && note?.write_access} onComment={selectionCommentsEnabled ? commentOnSelection : null} onSelectionUpdate={({ editor }) => { const { from, to } = editor.state.selection; const selectedText = editor.state.doc.textBetween(from, to, ' '); if (selectedText.length === 0) { selectedContent = null; } else { selectedContent = { text: selectedText, from: from, to: to }; } }} onChange={(content) => { renderedPage.content.json = content.json; renderedPage.content.html = content.html; renderedPage.content.md = content.md; }} fileHandler={true} onFileDrop={(currentEditor, files, pos) => inputFilesHandler(files, currentEditor, pos)} onFilePaste={() => {}} on:paste={(event) => { const e = event.detail.event || event; const pasted = Array.from(e.clipboardData?.files ?? []); if (pasted.length) { e.preventDefault(); inputFilesHandler(pasted); } }} /> {/each}
{/if}
{#if recording}
{ recording = false; displayMediaRecord = false; }} onConfirm={(data) => { if (data?.file) { inputFileHandler(data?.file); } recording = false; displayMediaRecord = false; }} />
{/if}
{#each commentsEnabled ? ['Chat', 'Comments'] : ['Chat'] as tab} {/each}
{#if currentNoteComments}
{#key `${$user.id}:${note.id}:${currentNoteComments.comment_id ?? ''}`} (noteCommentCount = count)} /> {/key}
{/if}
{#if noteChatLoading}
{:else if note && (noteChatId || noteChatDraftKey)} { if (!chatId || chatId === noteChatId) return; noteChatId = chatId; noteChatDraftKey = ''; }} onDeleteEmbeddedChat={deleteNoteChat} onEmbeddedChatTitle={(chatId, title) => { noteChats = noteChats.map((chat) => chat.id === chatId ? { ...chat, title, chat: { ...(chat.chat ?? {}), title } } : chat ); }} /> {/if}