diff --git a/backend/open_webui/routers/chats.py b/backend/open_webui/routers/chats.py index 602bdc499b..037e00d224 100644 --- a/backend/open_webui/routers/chats.py +++ b/backend/open_webui/routers/chats.py @@ -1919,7 +1919,7 @@ async def fork_chat_by_id( } # The source chat's folder may no longer be writable by the caller. - folder_id = chat.folder_id if is_owner else None + folder_id = chat.folder_id if folder_id is not None and not await has_folder_write_access(user.id, folder_id, db=db): folder_id = None diff --git a/src/app.css b/src/app.css index d504e42e21..5dda85fa4d 100644 --- a/src/app.css +++ b/src/app.css @@ -716,6 +716,118 @@ html.high-contrast.dark .ProseMirror p.is-editor-empty:first-child::before { @apply dark:border-gray-850 text-xs; } +.document-markdown { + font-size: 0.75rem; + line-height: 1.5; + overflow-wrap: anywhere; +} +.document-markdown h1, +.document-markdown h2, +.document-markdown h3, +.document-markdown h4, +.document-markdown h5, +.document-markdown h6 { + margin: 1rem 0 0.375rem; + font-weight: 600; + line-height: 1.3; +} +.document-markdown h1 { + font-size: 1.125rem; +} +.document-markdown h2 { + font-size: 1rem; +} +.document-markdown h3 { + font-size: 0.875rem; +} +.document-markdown h4, +.document-markdown h5, +.document-markdown h6 { + font-size: 0.75rem; +} +.document-markdown p, +.document-markdown ul, +.document-markdown ol { + margin: 0.5rem 0; +} +.document-markdown li { + margin-block: 0.125rem; +} +.document-markdown blockquote { + font-size: 0.75rem; +} +.document-markdown strong { + font-weight: 600; +} +.document-markdown hr { + margin: 0.75rem 0; +} +.document-markdown img { + margin: 0.5rem 0; +} +.document-markdown table { + font-size: 0.75rem; + margin: 0.5rem 0; +} +.document-markdown th, +.document-markdown td { + padding: 0.375rem 0.5rem !important; +} +.document-markdown pre { + margin: 0.5rem 0; + font-family: var(--font-mono); +} +.document-markdown pre.hljs { + padding: 0.5rem 0.75rem; +} +.document-markdown pre code { + font-size: 0.75rem; +} +.document-markdown .codespan { + font-size: 0.95em; +} +.document-markdown input[type='checkbox']:disabled { + cursor: default; +} +.document-markdown .document-code-block { + border-radius: 0.5rem; +} +.document-markdown .document-code-block > .sticky { + padding: 0.25rem 0.5rem; +} +.document-markdown .document-code-block > .sticky button { + height: 1.5rem; + padding-inline: 0.375rem; + font-size: 0.6875rem; +} +.document-markdown > :first-child, +.document-markdown .tiptap > :first-child { + margin-top: 0; +} +.document-markdown > :last-child, +.document-markdown .tiptap > :last-child { + margin-bottom: 0; +} + +.document-markdown .tiptap th, +.document-markdown .tiptap td { + background: transparent; + border-width: 0 0 1px; +} +.document-markdown .tiptap :is(th, td, li) > p { + margin: 0; +} +.document-markdown .tiptap pre > code { + padding: 0; + background: transparent; +} +.document-markdown .tiptap > div:has(> pre) { + margin: 0.5rem 0; +} +.document-markdown .tiptap img { + max-height: none; +} + .tippy-box[data-theme~='transparent'] { @apply bg-transparent p-0 m-0 text-inherit; } diff --git a/src/lib/components/chat/FileNav.svelte b/src/lib/components/chat/FileNav.svelte index 2678451522..94a9c97be1 100644 --- a/src/lib/components/chat/FileNav.svelte +++ b/src/lib/components/chat/FileNav.svelte @@ -1223,7 +1223,12 @@ session = chatId; const previousView = openedFile?.path === filePath - ? { showRaw, currentSlide, selectedExcelSheet, scroll: viewerRoot?.scrollTop ?? 0 } + ? { + showRaw, + currentSlide, + selectedExcelSheet, + scroll: viewerRoot?.scrollTop ?? 0 + } : null; const current = () => generation === loadGeneration && selector === effectiveTerminalId && session === chatId; @@ -2272,7 +2277,22 @@ onSort={toggleSort} onToggleHidden={toggleHidden} > - {#if (isMarkdown || isCsv || isHtml || isJson || isSvg || isNotebook) && fileContent !== null && !editing} + {#if isMarkdown && fileContent !== null && !editing} + {#each [{ label: 'Editor', icon: 'pencil', raw: false }, { label: 'Source', icon: 'code', raw: true }] as mode} + + + + {/each} + {:else if (isCsv || isHtml || isJson || isSvg || isNotebook) && fileContent !== null && !editing}