From 841291dda00c7e69b6180a35e5373f3833396cac Mon Sep 17 00:00:00 2001 From: balibabu Date: Thu, 5 Jun 2025 17:43:28 +0800 Subject: [PATCH] Fix: Fixed an issue where using the new quote markers would cause dialogue output to have delete symbols #7623 (#8083) ### What problem does this PR solve? Fix: Fixed an issue where using the new quote markers would cause dialogue output to have delete symbols #7623 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- web/src/pages/chat/markdown-content/index.tsx | 7 ++----- web/src/pages/chat/utils.ts | 18 ++++++++---------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/web/src/pages/chat/markdown-content/index.tsx b/web/src/pages/chat/markdown-content/index.tsx index 4b8cfe5bc..61b27347d 100644 --- a/web/src/pages/chat/markdown-content/index.tsx +++ b/web/src/pages/chat/markdown-content/index.tsx @@ -25,15 +25,12 @@ import { replaceThinkToSection, showImage, } from '@/utils/chat'; -import { replaceTextByOldReg } from '../utils'; +import { currentReg, replaceTextByOldReg } from '../utils'; import classNames from 'classnames'; import { pipe } from 'lodash/fp'; import styles from './index.less'; -const reg = /(~{2}\d+={2})/g; -// const curReg = /(~{2}\d+\${2})/g; - const getChunkIndex = (match: string) => Number(match.slice(2, -2)); // TODO: The display of the table is inconsistent with the display previously placed in the MessageItem. const MarkdownContent = ({ @@ -201,7 +198,7 @@ const MarkdownContent = ({ const renderReference = useCallback( (text: string) => { - let replacedText = reactStringReplace(text, reg, (match, i) => { + let replacedText = reactStringReplace(text, currentReg, (match, i) => { const chunkIndex = getChunkIndex(match); const { documentUrl, fileExtension, imageId, chunkItem, documentId } = diff --git a/web/src/pages/chat/utils.ts b/web/src/pages/chat/utils.ts index 2a21e6937..ba44e3c6f 100644 --- a/web/src/pages/chat/utils.ts +++ b/web/src/pages/chat/utils.ts @@ -43,17 +43,15 @@ export const buildMessageItemReference = ( }; const oldReg = /(#{2}\d+\${2})/g; -const currentReg = /\[ID:(\d+)\]/g; - -function transformReg(substring: string) { - return `~~${substring.slice(4, -1)}==`; -} +export const currentReg = /\[ID:(\d+)\]/g; // To be compatible with the old index matching mode export const replaceTextByOldReg = (text: string) => { - return text - ?.replace(currentReg, transformReg) - .replace(oldReg, (substring: string) => { - return `~~${substring.slice(2, -2)}==`; - }); + return ( + text + // ?.replace(currentReg, transformReg) + .replace(oldReg, (substring: string) => { + return `[ID:${substring.slice(2, -2)}]`; + }) + ); };