mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-02-06 18:45:08 +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 { ReactNode } from 'react';
|
||||||
|
import { VariableRegex } from '../../constant';
|
||||||
|
|
||||||
interface VariableDisplayProps {
|
interface VariableDisplayProps {
|
||||||
content: string;
|
content: string;
|
||||||
@ -7,7 +8,9 @@ interface VariableDisplayProps {
|
|||||||
|
|
||||||
// This component mimics the VariableNode's decorate function from PromptEditor
|
// This component mimics the VariableNode's decorate function from PromptEditor
|
||||||
function VariableNodeDisplay({ label }: { label: ReactNode }) {
|
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>;
|
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;
|
if (!content) return null;
|
||||||
|
|
||||||
// Regular expression to match content within {}
|
// Regular expression to match content within {}
|
||||||
const regex = /{([^}]*)}/g;
|
const regex = VariableRegex;
|
||||||
let match;
|
let match;
|
||||||
let lastIndex = 0;
|
let lastIndex = 0;
|
||||||
const elements: ReactNode[] = [];
|
const elements: ReactNode[] = [];
|
||||||
|
|||||||
@ -1085,3 +1085,5 @@ export const BeginQueryTypeMap = {
|
|||||||
[BeginQueryType.Integer]: TypesWithArray.Number,
|
[BeginQueryType.Integer]: TypesWithArray.Number,
|
||||||
[BeginQueryType.Boolean]: TypesWithArray.Boolean,
|
[BeginQueryType.Boolean]: TypesWithArray.Boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const VariableRegex = /{([^{}]*)}/g;
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import * as ReactDOM from 'react-dom';
|
|||||||
|
|
||||||
import { $createVariableNode } from './variable-node';
|
import { $createVariableNode } from './variable-node';
|
||||||
|
|
||||||
import { JsonSchemaDataType } from '@/pages/agent/constant';
|
import { JsonSchemaDataType, VariableRegex } from '@/pages/agent/constant';
|
||||||
import {
|
import {
|
||||||
useFindAgentStructuredOutputLabel,
|
useFindAgentStructuredOutputLabel,
|
||||||
useShowSecondaryMenu,
|
useShowSecondaryMenu,
|
||||||
@ -299,7 +299,7 @@ export default function VariablePickerMenuPlugin({
|
|||||||
// Handles variable references in the format {variable_name}.
|
// Handles variable references in the format {variable_name}.
|
||||||
const parseLineContent = useCallback(
|
const parseLineContent = useCallback(
|
||||||
(line: string, paragraph: ReturnType<typeof $createParagraphNode>) => {
|
(line: string, paragraph: ReturnType<typeof $createParagraphNode>) => {
|
||||||
const regex = /{([^}]*)}/g;
|
const regex = VariableRegex;
|
||||||
let match;
|
let match;
|
||||||
let lastIndex = 0;
|
let lastIndex = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user