mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
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)
This commit is contained in:
@ -25,15 +25,12 @@ import {
|
|||||||
replaceThinkToSection,
|
replaceThinkToSection,
|
||||||
showImage,
|
showImage,
|
||||||
} from '@/utils/chat';
|
} from '@/utils/chat';
|
||||||
import { replaceTextByOldReg } from '../utils';
|
import { currentReg, replaceTextByOldReg } from '../utils';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { pipe } from 'lodash/fp';
|
import { pipe } from 'lodash/fp';
|
||||||
import styles from './index.less';
|
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));
|
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.
|
// TODO: The display of the table is inconsistent with the display previously placed in the MessageItem.
|
||||||
const MarkdownContent = ({
|
const MarkdownContent = ({
|
||||||
@ -201,7 +198,7 @@ const MarkdownContent = ({
|
|||||||
|
|
||||||
const renderReference = useCallback(
|
const renderReference = useCallback(
|
||||||
(text: string) => {
|
(text: string) => {
|
||||||
let replacedText = reactStringReplace(text, reg, (match, i) => {
|
let replacedText = reactStringReplace(text, currentReg, (match, i) => {
|
||||||
const chunkIndex = getChunkIndex(match);
|
const chunkIndex = getChunkIndex(match);
|
||||||
|
|
||||||
const { documentUrl, fileExtension, imageId, chunkItem, documentId } =
|
const { documentUrl, fileExtension, imageId, chunkItem, documentId } =
|
||||||
|
|||||||
@ -43,17 +43,15 @@ export const buildMessageItemReference = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const oldReg = /(#{2}\d+\${2})/g;
|
const oldReg = /(#{2}\d+\${2})/g;
|
||||||
const currentReg = /\[ID:(\d+)\]/g;
|
export const currentReg = /\[ID:(\d+)\]/g;
|
||||||
|
|
||||||
function transformReg(substring: string) {
|
|
||||||
return `~~${substring.slice(4, -1)}==`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// To be compatible with the old index matching mode
|
// To be compatible with the old index matching mode
|
||||||
export const replaceTextByOldReg = (text: string) => {
|
export const replaceTextByOldReg = (text: string) => {
|
||||||
return text
|
return (
|
||||||
?.replace(currentReg, transformReg)
|
text
|
||||||
.replace(oldReg, (substring: string) => {
|
// ?.replace(currentReg, transformReg)
|
||||||
return `~~${substring.slice(2, -2)}==`;
|
.replace(oldReg, (substring: string) => {
|
||||||
});
|
return `[ID:${substring.slice(2, -2)}]`;
|
||||||
|
})
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user