mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-02-06 10:35:06 +08:00
### What problem does this PR solve? Fix: Variables within multiple parentheses cannot be displayed correctly. #12987 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { VariableRegex } from '../../constant';
|
||||
|
||||
interface VariableDisplayProps {
|
||||
content: string;
|
||||
@ -7,7 +8,9 @@ interface VariableDisplayProps {
|
||||
|
||||
// This component mimics the VariableNode's decorate function from PromptEditor
|
||||
function VariableNodeDisplay({ label }: { label: ReactNode }) {
|
||||
let content: ReactNode = <span className="text-accent-primary">{label}</span>;
|
||||
const content: ReactNode = (
|
||||
<span className="text-accent-primary">{label}</span>
|
||||
);
|
||||
|
||||
return <div className="inline-flex items-center mr-1">{content}</div>;
|
||||
}
|
||||
@ -16,7 +19,7 @@ export function VariableDisplay({ content, getLabel }: VariableDisplayProps) {
|
||||
if (!content) return null;
|
||||
|
||||
// Regular expression to match content within {}
|
||||
const regex = /{([^}]*)}/g;
|
||||
const regex = VariableRegex;
|
||||
let match;
|
||||
let lastIndex = 0;
|
||||
const elements: ReactNode[] = [];
|
||||
|
||||
@ -1085,3 +1085,5 @@ export const BeginQueryTypeMap = {
|
||||
[BeginQueryType.Integer]: TypesWithArray.Number,
|
||||
[BeginQueryType.Boolean]: TypesWithArray.Boolean,
|
||||
};
|
||||
|
||||
export const VariableRegex = /{([^{}]*)}/g;
|
||||
|
||||
@ -31,7 +31,7 @@ import * as ReactDOM from 'react-dom';
|
||||
|
||||
import { $createVariableNode } from './variable-node';
|
||||
|
||||
import { JsonSchemaDataType } from '@/pages/agent/constant';
|
||||
import { JsonSchemaDataType, VariableRegex } from '@/pages/agent/constant';
|
||||
import {
|
||||
useFindAgentStructuredOutputLabel,
|
||||
useShowSecondaryMenu,
|
||||
@ -299,7 +299,7 @@ export default function VariablePickerMenuPlugin({
|
||||
// Handles variable references in the format {variable_name}.
|
||||
const parseLineContent = useCallback(
|
||||
(line: string, paragraph: ReturnType<typeof $createParagraphNode>) => {
|
||||
const regex = /{([^}]*)}/g;
|
||||
const regex = VariableRegex;
|
||||
let match;
|
||||
let lastIndex = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user