mirror of
https://github.com/open-webui/open-webui
synced 2024-11-06 16:59:42 +00:00
refac: unescape rich text input
This commit is contained in:
parent
7d322a7238
commit
f6e7af346e
@ -56,6 +56,16 @@
|
||||
});
|
||||
}
|
||||
|
||||
function unescapeMarkdown(text: string): string {
|
||||
return text
|
||||
.replace(/\\([\\`*{}[\]()#+\-.!_>])/g, '$1') // unescape backslashed characters
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
// Method to convert markdown content to ProseMirror-compatible document
|
||||
function markdownToProseMirrorDoc(markdown: string) {
|
||||
return defaultMarkdownParser.parse(value || '');
|
||||
@ -63,7 +73,8 @@
|
||||
|
||||
// Utility function to convert ProseMirror content back to markdown text
|
||||
function serializeEditorContent(doc) {
|
||||
return defaultMarkdownSerializer.serialize(doc);
|
||||
const markdown = defaultMarkdownSerializer.serialize(doc);
|
||||
return unescapeMarkdown(markdown);
|
||||
}
|
||||
|
||||
// ---- Input Rules ----
|
||||
|
Loading…
Reference in New Issue
Block a user