From b65accae45ccdfe6a305713bf1e7170111ddb51c Mon Sep 17 00:00:00 2001 From: DrMelone <27028174+Classic298@users.noreply.github.com> Date: Tue, 17 Mar 2026 17:11:55 +0100 Subject: [PATCH] feat: use rich text editor for knowledge file editing Replace the plain textarea in the knowledge base file editor drawer with the same RichTextInput (TipTap) component already used by the Add Text Content modal. This resolves an inconsistency where creating new text content offered a full WYSIWYG experience with formatting toolbar, headings, bold, lists, and code blocks, while editing existing files was limited to an unstyled textarea. Since the RichTextInput markdown parser collapses single newlines (standard markdown behavior), file content is pre-processed on load to normalize single newlines into paragraph breaks. This ensures extracted text from PDFs, DOCXs, and other files preserves its line structure when displayed in the rich text editor. The wrapper div also retains the original aria-label for accessibility. --- .../workspace/Knowledge/KnowledgeBase.svelte | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte b/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte index e902c21b83..999808690d 100644 --- a/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte +++ b/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte @@ -172,7 +172,13 @@ const fileSelectHandler = async (file) => { try { selectedFile = file; - selectedFileContent = selectedFile?.data?.content || ''; + const rawContent = selectedFile?.data?.content || ''; + + // Normalize single newlines to paragraph breaks (double newlines) so the + // rich text editor's markdown parser preserves them. Without this, single + // newlines get collapsed into spaces during markdown parsing (breaks: false). + // Existing double+ newlines (paragraph breaks) are left unchanged. + selectedFileContent = rawContent.replace(/(? {#key selectedFile.id} -