mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 23:21:44 -05:00
[PR #22214] [CLOSED] fix: prevent preceding character deletion when typing inline code backticks #26555
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22214
Author: @MJ16MJ
Created: 3/4/2026
Status: ❌ Closed
Base:
dev← Head:fix/inline-code-preceding-char-deleted📝 Commits (1)
bec19cafix: prevent preceding character deletion when typing inline code backticks📊 Changes
2 files changed (+22 additions, -1 deletions)
View changed files
📝
package.json(+1 -0)📝
src/lib/components/common/RichTextInput.svelte(+21 -1)📄 Description
Pull Request Checklist
Before submitting, make sure you've checked the following:
dev@tiptap/extension-codeas explicit dependency (already a transitive dep via@tiptap/starter-kit, same version^3.0.7).markInputRulelogic with the default regex vs the fixed regex. The fix changes only the input rule regex pattern — all other Code mark behavior (keyboard shortcut, paste rules, rendering) remains unchanged.fix:Changelog Entry
Description
When "Rich Text Input for Chat" is enabled and a user types inline code using backticks immediately after text (e.g.
Hello\123`), the character preceding the opening backtick is incorrectly deleted, resulting inHell+123instead ofHello+123`.Root cause: TipTap's default Code mark input rule uses the regex
/(^|[^\x60])\x60([^\x60]+)\x60(?!\x60)$/. The first capture group[^\x60]captures the character before the opening backtick. WhenmarkInputRuleprocesses the match, it callstr.delete(range.from + startSpaces, textStart)which deletes everything from the match start to the code content — including that captured preceding character.Fix: Override the Code extension from StarterKit with a custom extension (
FixedCode) that uses a lookbehind assertion/(?<=[^\x60]|^)\x60([^\x60]+)\x60(?!\x60)$/instead of a capture group, so the preceding character is never part of the match range.Added
@tiptap/extension-codeas explicit dependency (was already transitive via starter-kit)FixedCodeextension inRichTextInput.sveltethat extends TipTap's Code mark with a corrected input ruleChanged
code: falseto disable the default (buggy) Code markFixedCodeadded to the editor extensions listFixed
Hello\123`` now correctly produces "Hello" + code("123"))Security
Breaking Changes
Additional Information
devwith "Rich Text Input for Chat" toggled on(?<=...)is supported in all modern browsers (Chrome 62+, Firefox 78+, Safari 16.4+)Screenshots or Videos
Before (bug): Typing
Hello\123`` produces "Hell" + code("123") — the "o" is deletedAfter (fix): Typing
Hello\123`` correctly produces "Hello" + code("123")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.