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:
Text appears correct in the modal
After clicking "Save" and sending the message, all newlines are stripped
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.
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>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/21518
Author: @eren-karakus0
Created: 2/17/2026
Status: ❌ Closed
Base:
dev← Head:fix/windows-textarea-newlines📝 Commits (1)
130eb1efix: 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:
Root cause: two issues working together:
\r\n) line endings which were not normalizedschema.text()creates plain text nodes that discard newline characters — they need to be represented ashardBreaknodesSolution
InputVariablesModal.svelte: Normalize Windows CRLF (\r\n) to LF (\n) before passing variable values to the editor.RichTextInput.svelte: InreplaceVariables(), split replacement text on newlines and create proper ProseMirrorhardBreaknodes between textsegments instead of inserting raw newline characters.
Closes #21447
Changelog Entry
Description
replaceVariables()andInputVariablesModalFixed
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.