[PR #21518] [CLOSED] fix: preserve newlines in textarea prompt variables on Windows #26115

Closed
opened 2026-04-20 06:20:22 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21518
Author: @eren-karakus0
Created: 2/17/2026
Status: Closed

Base: devHead: fix/windows-textarea-newlines


📝 Commits (1)

  • 130eb1e fix: preserve newlines in textarea prompt variables on Windows

📊 Changes

2 files changed (+25 additions, -2 deletions)

View changed files

📝 src/lib/components/chat/MessageInput/InputVariablesModal.svelte (+8 -1)
📝 src/lib/components/common/RichTextInput.svelte (+17 -1)

📄 Description

Summary

Fixes textarea input variables losing line breaks after message submission on Windows.

Problem

When users paste or type multi-line text into a textarea prompt variable on Windows:

  1. Text appears correct in the modal
  2. After clicking "Save" and sending the message, all newlines are stripped
  3. Editing the message reveals formatting is lost

Root cause: two issues working together:

  • Windows uses CRLF (\r\n) line endings which were not normalized
  • ProseMirror's schema.text() creates plain text nodes that discard newline characters — they need to be represented as hardBreak nodes

Solution

InputVariablesModal.svelte: Normalize Windows CRLF (\r\n) to LF (\n) before passing variable values to the editor.

RichTextInput.svelte: In replaceVariables(), split replacement text on newlines and create proper ProseMirror hardBreak nodes between text
segments instead of inserting raw newline characters.

Closes #21447

Changelog Entry

Description

  • Fix textarea prompt variables losing newlines on Windows in replaceVariables() and InputVariablesModal

Fixed

  • Textarea prompt variable newlines now preserved on Windows by normalizing CRLF line endings and converting newlines to ProseMirror hardBreak nodes

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement
(CLA)
, and I am providing my contributions under its terms.


🔄 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/21518 **Author:** [@eren-karakus0](https://github.com/eren-karakus0) **Created:** 2/17/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/windows-textarea-newlines` --- ### 📝 Commits (1) - [`130eb1e`](https://github.com/open-webui/open-webui/commit/130eb1e28a190ba6912d6018b052cc9eabc70dc1) fix: preserve newlines in textarea prompt variables on Windows ### 📊 Changes **2 files changed** (+25 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/chat/MessageInput/InputVariablesModal.svelte` (+8 -1) 📝 `src/lib/components/common/RichTextInput.svelte` (+17 -1) </details> ### 📄 Description ## Summary Fixes textarea input variables losing line breaks after message submission on Windows. ## Problem When users paste or type multi-line text into a textarea prompt variable on Windows: 1. Text appears correct in the modal 2. After clicking "Save" and sending the message, all newlines are stripped 3. Editing the message reveals formatting is lost Root cause: two issues working together: - Windows uses CRLF (`\r\n`) line endings which were not normalized - ProseMirror's `schema.text()` creates plain text nodes that discard newline characters — they need to be represented as `hardBreak` nodes ## Solution **`InputVariablesModal.svelte`**: Normalize Windows CRLF (`\r\n`) to LF (`\n`) before passing variable values to the editor. **`RichTextInput.svelte`**: In `replaceVariables()`, split replacement text on newlines and create proper ProseMirror `hardBreak` nodes between text segments instead of inserting raw newline characters. Closes #21447 # Changelog Entry ### Description - Fix textarea prompt variables losing newlines on Windows in `replaceVariables()` and `InputVariablesModal` ### Fixed - Textarea prompt variable newlines now preserved on Windows by normalizing CRLF line endings and converting newlines to ProseMirror hardBreak nodes ### Contributor License Agreement 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. --- <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-04-20 06:20:22 -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#26115