diff --git a/web/src/components/originui/timeline.tsx b/web/src/components/originui/timeline.tsx index 9ed7da005..d1090aeaa 100644 --- a/web/src/components/originui/timeline.tsx +++ b/web/src/components/originui/timeline.tsx @@ -1,6 +1,7 @@ 'use client'; import { cn } from '@/lib/utils'; +import { TimelineNodeType } from '@/pages/dataflow-result/constant'; import { parseColorToRGB } from '@/utils/common-util'; import { Slot } from '@radix-ui/react-slot'; import * as React from 'react'; @@ -220,6 +221,8 @@ interface TimelineNode completed?: boolean; clickable?: boolean; activeStyle?: TimelineIndicatorNodeProps; + detail?: any; + type?: TimelineNodeType; } interface CustomTimelineProps extends React.HTMLAttributes { @@ -252,7 +255,6 @@ const CustomTimeline = ({ const [internalActiveStep, setInternalActiveStep] = React.useState(defaultValue); const _lineColor = `rgb(${parseColorToRGB(lineColor)})`; - console.log(lineColor, _lineColor); const currentActiveStep = activeStep ?? internalActiveStep; const handleStepChange = (step: number, id: string | number) => { @@ -284,8 +286,6 @@ const CustomTimeline = ({ typeof _nodeSizeTemp === 'number' ? `${_nodeSizeTemp}px` : _nodeSizeTemp; - console.log('icon-size', nodeSize, node.nodeSize, _nodeSize); - // const activeStyle = _activeStyle || {}; return ( - - {node.date && {node.date}} + {node.title} + {node.date && {node.date}} {node.content && {node.content}} diff --git a/web/src/components/ui/modal/modal.tsx b/web/src/components/ui/modal/modal.tsx index 177addbaa..fff5216b8 100644 --- a/web/src/components/ui/modal/modal.tsx +++ b/web/src/components/ui/modal/modal.tsx @@ -31,6 +31,7 @@ export interface ModalProps { export interface ModalType extends FC { show: typeof modalIns.show; hide: typeof modalIns.hide; + destroy: typeof modalIns.destroy; } const Modal: ModalType = ({ @@ -75,13 +76,13 @@ const Modal: ModalType = ({ const handleCancel = useCallback(() => { onOpenChange?.(false); - // onCancel?.(); - }, [onOpenChange]); + onCancel?.(); + }, [onCancel, onOpenChange]); const handleOk = useCallback(() => { onOpenChange?.(true); - // onOk?.(); - }, [onOpenChange]); + onOk?.(); + }, [onOk, onOpenChange]); const handleChange = (open: boolean) => { onOpenChange?.(open); console.log('open', open, onOpenChange); @@ -208,5 +209,6 @@ Modal.show = modalIns return modalIns.show; }; Modal.hide = modalIns.hide; +Modal.destroy = modalIns.destroy; export { Modal }; diff --git a/web/src/hooks/logic-hooks/navigate-hooks.ts b/web/src/hooks/logic-hooks/navigate-hooks.ts index 17c6004c2..8ca2ab5b6 100644 --- a/web/src/hooks/logic-hooks/navigate-hooks.ts +++ b/web/src/hooks/logic-hooks/navigate-hooks.ts @@ -133,10 +133,10 @@ export const useNavigatePage = () => { ); const navigateToDataflowResult = useCallback( - (id: string, knowledgeId?: string) => () => { + (id: string, knowledgeId: string, doc_id?: string) => () => { navigate( // `${Routes.ParsedResult}/${id}?${QueryStringMap.KnowledgeId}=${knowledgeId}`, - `${Routes.DataflowResult}?id=${id}&type=dataflow`, + `${Routes.DataflowResult}?id=${id}&doc_id=${doc_id}&${QueryStringMap.KnowledgeId}=${knowledgeId}&type=dataflow`, ); }, [navigate], diff --git a/web/src/pages/dataflow-result/chunker.tsx b/web/src/pages/dataflow-result/chunker.tsx index 70f606d2d..1c194f76a 100644 --- a/web/src/pages/dataflow-result/chunker.tsx +++ b/web/src/pages/dataflow-result/chunker.tsx @@ -154,12 +154,7 @@ const ChunkerContainer = (props: IProps) => { )} -
+
diff --git a/web/src/pages/dataflow-result/components/chunk-result-bar/checkbox-sets.tsx b/web/src/pages/dataflow-result/components/chunk-result-bar/checkbox-sets.tsx index 68bafeeb7..bf98299a2 100644 --- a/web/src/pages/dataflow-result/components/chunk-result-bar/checkbox-sets.tsx +++ b/web/src/pages/dataflow-result/components/chunk-result-bar/checkbox-sets.tsx @@ -1,24 +1,17 @@ import { Checkbox } from '@/components/ui/checkbox'; import { Label } from '@/components/ui/label'; -import { Ban, CircleCheck, Trash2 } from 'lucide-react'; +import { Trash2 } from 'lucide-react'; import { useCallback, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; type ICheckboxSetProps = { selectAllChunk: (e: any) => void; removeChunk: (e?: any) => void; - switchChunk: (available: number) => void; checked: boolean; selectedChunkIds: string[]; }; export default (props: ICheckboxSetProps) => { - const { - selectAllChunk, - removeChunk, - switchChunk, - checked, - selectedChunkIds, - } = props; + const { selectAllChunk, removeChunk, checked, selectedChunkIds } = props; const { t } = useTranslation(); const handleSelectAllCheck = useCallback( (e: any) => { @@ -32,14 +25,6 @@ export default (props: ICheckboxSetProps) => { removeChunk(); }, [removeChunk]); - const handleEnabledClick = useCallback(() => { - switchChunk(1); - }, [switchChunk]); - - const handleDisabledClick = useCallback(() => { - switchChunk(0); - }, [switchChunk]); - const isSelected = useMemo(() => { return selectedChunkIds?.length > 0; }, [selectedChunkIds]); @@ -57,20 +42,6 @@ export default (props: ICheckboxSetProps) => {
{isSelected && ( <> -
- - {t('chunk.enable')} -
-
- - {t('chunk.disable')} -
void; + initialValue: { + key: string; + type: string; + value: Array<{ [key: string]: string }>; + }; + onSave: (value: any) => void; className?: string; + isSelect?: boolean; + isDelete?: boolean; + isChunck?: boolean; + handleCheckboxClick?: (id: string | number, checked: boolean) => void; + selectedChunkIds?: string[]; } const FormatPreserveEditor = ({ initialValue, onSave, className, + isChunck, + handleCheckboxClick, + selectedChunkIds, }: FormatPreserveEditorProps) => { const [content, setContent] = useState(initialValue); - const [isEditing, setIsEditing] = useState(false); - - const handleEdit = () => setIsEditing(true); - - const handleSave = () => { - onSave(content); - setIsEditing(false); + // const [isEditing, setIsEditing] = useState(false); + const [activeEditIndex, setActiveEditIndex] = useState( + undefined, + ); + console.log('initialValue', initialValue); + const handleEdit = (e?: any, index?: number) => { + console.log(e, index, content); + if (content.key === 'json') { + console.log(e, e.target.innerText); + setContent((pre) => ({ + ...pre, + value: pre.value.map((item, i) => { + if (i === index) { + return { + ...item, + [Object.keys(item)[0]]: e.target.innerText, + }; + } + return item; + }), + })); + setActiveEditIndex(index); + } }; + const handleChange = (e: any) => { + if (content.key === 'json') { + setContent((pre) => ({ + ...pre, + value: pre.value.map((item, i) => { + if (i === activeEditIndex) { + return { + ...item, + [Object.keys(item)[0]]: e.target.value, + }; + } + return item; + }), + })); + } else { + setContent(e.target.value); + } + }; + + const escapeNewlines = (text: string) => { + return text.replace(/\n/g, '\\n'); + }; + const unescapeNewlines = (text: string) => { + return text.replace(/\\n/g, '\n'); + }; + + const handleSave = () => { + const saveData = { + ...content, + value: content.value?.map((item) => { + return { ...item, text: unescapeNewlines(item.text) }; + }), + }; + onSave(saveData); + setActiveEditIndex(undefined); + }; + const handleCheck = (e: CheckedState, id: string | number) => { + handleCheckboxClick?.(id, e === 'indeterminate' ? false : e); + }; return (
- {isEditing ? ( + {/* {isEditing && content.key === 'json' ? (