Feat: The key for the begin operator can only contain alphanumeric characters and underscores. #10427 (#11377)

### What problem does this PR solve?

Feat: The key for the begin operator can only contain alphanumeric
characters and underscores. #10427

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-11-19 16:16:57 +08:00
committed by GitHub
parent 1c201c4d54
commit db5ec89dc5
6 changed files with 25 additions and 14 deletions

View File

@ -1,15 +1,16 @@
import { FileIconMap } from '@/constants/file'; import { FileIconMap } from '@/constants/file';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { getExtension } from '@/utils/document-util'; import { getExtension } from '@/utils/document-util';
import { CSSProperties } from 'react';
type IconFontType = { type IconFontType = {
name: string; name: string;
className?: string; className?: string;
style?: CSSProperties;
}; };
export const IconFont = ({ name, className }: IconFontType) => ( export const IconFont = ({ name, className, style }: IconFontType) => (
<svg className={cn('size-4', className)}> <svg className={cn('size-4', className)} style={style}>
<use xlinkHref={`#icon-${name}`} /> <use xlinkHref={`#icon-${name}`} />
</svg> </svg>
); );

View File

@ -8,7 +8,10 @@ type KeyInputProps = {
} & Omit<InputProps, 'onChange'>; } & Omit<InputProps, 'onChange'>;
export const KeyInput = forwardRef<HTMLInputElement, KeyInputProps>( export const KeyInput = forwardRef<HTMLInputElement, KeyInputProps>(
function KeyInput({ value, onChange, searchValue = /[^a-zA-Z0-9_]/g }, ref) { function KeyInput(
{ value, onChange, searchValue = /[^a-zA-Z0-9_]/g, ...props },
ref,
) {
const handleChange = useCallback( const handleChange = useCallback(
(e: ChangeEvent<HTMLInputElement>) => { (e: ChangeEvent<HTMLInputElement>) => {
const value = e.target.value ?? ''; const value = e.target.value ?? '';
@ -18,6 +21,6 @@ export const KeyInput = forwardRef<HTMLInputElement, KeyInputProps>(
[onChange, searchValue], [onChange, searchValue],
); );
return <Input value={value} onChange={handleChange} ref={ref} />; return <Input {...props} value={value} onChange={handleChange} ref={ref} />;
}, },
); );

View File

@ -12,9 +12,12 @@ export const LogicalOperatorIcon = function OperatorIcon({
return ( return (
<IconFont <IconFont
name={icon} name={icon}
className={cn('size-4', { className={cn('size-4')}
'rotate-180': value === ComparisonOperator.GreatThan, style={
})} value === ComparisonOperator.GreatThan
? { transform: 'rotate(180deg)' }
: undefined
}
></IconFont> ></IconFont>
); );
} }

View File

@ -868,7 +868,7 @@ export enum VariableAssignerLogicalArrayOperator {
} }
export enum ExportFileType { export enum ExportFileType {
PDF = 'pdf', // PDF = 'pdf',
HTML = 'html', HTML = 'html',
Markdown = 'md', Markdown = 'md',
DOCX = 'docx', DOCX = 'docx',

View File

@ -1,3 +1,4 @@
import { KeyInput } from '@/components/key-input';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { import {
Dialog, Dialog,
@ -113,7 +114,6 @@ function ParameterForm({
function onSubmit(data: z.infer<typeof FormSchema>) { function onSubmit(data: z.infer<typeof FormSchema>) {
const values = { ...data, options: data.options?.map((x) => x.value) }; const values = { ...data, options: data.options?.map((x) => x.value) };
console.log('🚀 ~ onSubmit ~ values:', values);
submit(values); submit(values);
} }
@ -153,7 +153,11 @@ function ParameterForm({
<FormItem> <FormItem>
<FormLabel>{t('key')}</FormLabel> <FormLabel>{t('key')}</FormLabel>
<FormControl> <FormControl>
<Input {...field} autoComplete="off" onBlur={handleKeyChange} /> <KeyInput
{...field}
autoComplete="off"
onBlur={handleKeyChange}
/>
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>

View File

@ -1,6 +1,7 @@
'use client'; 'use client';
import { FormContainer } from '@/components/form-container'; import { FormContainer } from '@/components/form-container';
import { KeyInput } from '@/components/key-input';
import { SelectWithSearch } from '@/components/originui/select-with-search'; import { SelectWithSearch } from '@/components/originui/select-with-search';
import { BlockButton, Button } from '@/components/ui/button'; import { BlockButton, Button } from '@/components/ui/button';
import { import {
@ -9,7 +10,6 @@ import {
FormItem, FormItem,
FormMessage, FormMessage,
} from '@/components/ui/form'; } from '@/components/ui/form';
import { Input } from '@/components/ui/input';
import { Separator } from '@/components/ui/separator'; import { Separator } from '@/components/ui/separator';
import { RAGFlowNodeType } from '@/interfaces/database/flow'; import { RAGFlowNodeType } from '@/interfaces/database/flow';
import { t } from 'i18next'; import { t } from 'i18next';
@ -67,10 +67,10 @@ export function DynamicOutputForm({ node }: IProps) {
render={({ field }) => ( render={({ field }) => (
<FormItem className="flex-1"> <FormItem className="flex-1">
<FormControl> <FormControl>
<Input <KeyInput
{...field} {...field}
placeholder={t('common.pleaseInput')} placeholder={t('common.pleaseInput')}
></Input> ></KeyInput>
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>