import { useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { useDebounceFn } from 'ahooks' import { RiBracesLine, RiEyeLine } from '@remixicon/react' import Textarea from '@/app/components/base/textarea' import { Markdown } from '@/app/components/base/markdown' import SchemaEditor from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/schema-editor' import { FileUploaderInAttachmentWrapper } from '@/app/components/base/file-uploader' import ErrorMessage from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/error-message' import { checkJsonSchemaDepth, getValidationErrorMessage, validateSchemaAgainstDraft7, } from '@/app/components/workflow/nodes/llm/utils' import { validateJSONSchema, } from '@/app/components/workflow/variable-inspect/utils' import { getProcessedFiles, getProcessedFilesFromResponse } from '@/app/components/base/file-uploader/utils' import { SegmentedControl } from '@/app/components/base/segmented-control' import { JSON_SCHEMA_MAX_DEPTH } from '@/config' import { TransferMethod } from '@/types/app' import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants' import { SupportUploadFileTypes } from '@/app/components/workflow/types' import type { VarInInspect } from '@/types/workflow' import { VarInInspectType } from '@/types/workflow' import cn from '@/utils/classnames' import LargeDataAlert from './large-data-alert' import BoolValue from '../panel/chat-variable-panel/components/bool-value' import { useStore } from '@/app/components/workflow/store' import { ChunkCardList } from '@/app/components/rag-pipeline/components/chunk-card-list' import type { ChunkInfo } from '@/app/components/rag-pipeline/components/chunk-card-list/types' import { PreviewMode } from '../../base/features/types' import { ChunkingMode } from '@/models/datasets' enum ViewMode { Code = 'code', Preview = 'preview', } enum ContentType { Markdown = 'markdown', Chunks = 'chunks', } type DisplayContentProps = { type: ContentType mdString?: string jsonString?: string readonly: boolean handleTextChange?: (value: string) => void handleEditorChange?: (value: string) => void } const DisplayContent = (props: DisplayContentProps) => { const { type, mdString, jsonString, readonly, handleTextChange, handleEditorChange } = props const [viewMode, setViewMode] = useState(ViewMode.Code) const [isFocused, setIsFocused] = useState(false) const { t } = useTranslation() return (
{type.toUpperCase()}
{viewMode === ViewMode.Code && ( type === ContentType.Markdown ?