mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 12:25:20 +00:00
refac/fix: insert prompt as rich text
This commit is contained in:
parent
9942de8011
commit
eb9c4c0e35
1 changed files with 10 additions and 6 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { marked } from 'marked';
|
import { marked } from 'marked';
|
||||||
|
import DOMPurify from 'dompurify';
|
||||||
|
|
||||||
marked.use({
|
marked.use({
|
||||||
breaks: true,
|
breaks: true,
|
||||||
gfm: true,
|
gfm: true,
|
||||||
|
|
@ -336,12 +338,14 @@
|
||||||
let tr = state.tr;
|
let tr = state.tr;
|
||||||
|
|
||||||
if (insertPromptAsRichText) {
|
if (insertPromptAsRichText) {
|
||||||
const htmlContent = marked
|
const htmlContent = DOMPurify.sanitize(
|
||||||
.parse(text, {
|
marked
|
||||||
breaks: true,
|
.parse(text, {
|
||||||
gfm: true
|
breaks: true,
|
||||||
})
|
gfm: true
|
||||||
.trim();
|
})
|
||||||
|
.trim()
|
||||||
|
);
|
||||||
|
|
||||||
// Create a temporary div to parse HTML
|
// Create a temporary div to parse HTML
|
||||||
const tempDiv = document.createElement('div');
|
const tempDiv = document.createElement('div');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue