[PR #22762] [CLOSED] feat: use rich text editor for knowledge file editing #65707

Closed
opened 2026-05-06 11:37:29 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22762
Author: @Classic298
Created: 3/17/2026
Status: Closed

Base: devHead: feat/knowledge-rich-text-editor


📝 Commits (3)

  • 09cb1b3 feat: use rich text editor for knowledge file editing
  • b65acca feat: use rich text editor for knowledge file editing
  • 2ff86d8 feat: use rich text editor for knowledge file editing

📊 Changes

2 files changed (+23 additions, -13 deletions)

View changed files

📝 src/lib/components/common/RichTextInput.svelte (+3 -5)
📝 src/lib/components/workspace/Knowledge/KnowledgeBase.svelte (+20 -8)

📄 Description

Use Rich Text Editor for Knowledge File Editing

Problem

There is an inconsistency in the Knowledge workspace: creating new text content via the "Add Text Content" modal offers a full WYSIWYG editing experience (TipTap-based RichTextInput with formatting toolbar, headings, bold, lists, code blocks, etc.), while editing existing files is limited to a plain, unstyled textarea. Since all knowledge file content is stored as text regardless of the original file type, there is no reason for the editing experience to differ from the creation experience.

Changes

KnowledgeBase.svelte

  • Replace the plain textarea in the file editor drawer with the same RichTextInput component used by the Add Text Content modal
  • Normalize single newlines to paragraph breaks when loading file content, so extracted text from PDFs, DOCXs, and other files preserves its line structure in the rich text editor
  • Set selectedFile after selectedFileContent to avoid a timing issue where the {#key} block would recreate the editor before the content was ready
  • Retain the original aria-label for accessibility on the wrapper element

RichTextInput.svelte (bug fix)

  • Fix a bug in onValueChange where the preserveBreaks code path bypassed markdown parsing entirely, passing raw markdown directly to setContent instead of parsed HTML. This caused all editor content to collapse into a single paragraph whenever a reactive value update triggered setContent. The fix ensures content is always parsed through marked regardless of the preserveBreaks setting.

How it works

  • File content is loaded from selectedFile.data.content
  • Carriage returns are stripped and single newlines are normalized to double newlines (markdown paragraph breaks) — this is idempotent and does not compound on repeated save/reopen cycles
  • The normalized markdown is parsed by RichTextInput's internal marked parser into proper HTML paragraphs
  • Users can format content with headings, bold, italic, lists, code blocks, and tables via the floating toolbar
  • On save, TipTap HTML is converted back to markdown via Turndown and stored via updateFileDataContentById

Contributor License Agreement

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22762 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 3/17/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feat/knowledge-rich-text-editor` --- ### 📝 Commits (3) - [`09cb1b3`](https://github.com/open-webui/open-webui/commit/09cb1b3ba7e84b9f98625a4ebba6b823dc9d0d81) feat: use rich text editor for knowledge file editing - [`b65acca`](https://github.com/open-webui/open-webui/commit/b65accae45ccdfe6a305713bf1e7170111ddb51c) feat: use rich text editor for knowledge file editing - [`2ff86d8`](https://github.com/open-webui/open-webui/commit/2ff86d8c5dc0e2f72647f351257bcd9f20add0a2) feat: use rich text editor for knowledge file editing ### 📊 Changes **2 files changed** (+23 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/common/RichTextInput.svelte` (+3 -5) 📝 `src/lib/components/workspace/Knowledge/KnowledgeBase.svelte` (+20 -8) </details> ### 📄 Description ## Use Rich Text Editor for Knowledge File Editing ### Problem There is an inconsistency in the Knowledge workspace: creating new text content via the "Add Text Content" modal offers a full WYSIWYG editing experience (TipTap-based RichTextInput with formatting toolbar, headings, bold, lists, code blocks, etc.), while editing existing files is limited to a plain, unstyled textarea. Since all knowledge file content is stored as text regardless of the original file type, there is no reason for the editing experience to differ from the creation experience. ### Changes **KnowledgeBase.svelte** - Replace the plain textarea in the file editor drawer with the same RichTextInput component used by the Add Text Content modal - Normalize single newlines to paragraph breaks when loading file content, so extracted text from PDFs, DOCXs, and other files preserves its line structure in the rich text editor - Set selectedFile after selectedFileContent to avoid a timing issue where the {#key} block would recreate the editor before the content was ready - Retain the original aria-label for accessibility on the wrapper element **RichTextInput.svelte (bug fix)** - Fix a bug in onValueChange where the preserveBreaks code path bypassed markdown parsing entirely, passing raw markdown directly to setContent instead of parsed HTML. This caused all editor content to collapse into a single paragraph whenever a reactive value update triggered setContent. The fix ensures content is always parsed through marked regardless of the preserveBreaks setting. ### How it works - File content is loaded from selectedFile.data.content - Carriage returns are stripped and single newlines are normalized to double newlines (markdown paragraph breaks) — this is idempotent and does not compound on repeated save/reopen cycles - The normalized markdown is parsed by RichTextInput's internal marked parser into proper HTML paragraphs - Users can format content with headings, bold, italic, lists, code blocks, and tables via the floating toolbar - On save, TipTap HTML is converted back to markdown via Turndown and stored via updateFileDataContentById ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [X] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 11:37:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#65707