From 070d9036b708dfc805c230facea5efc7b7b90790 Mon Sep 17 00:00:00 2001 From: yujiangping Date: Tue, 6 Jan 2026 19:22:08 +0800 Subject: [PATCH 1/3] feat(i18n): add graph translation key for knowledge graph feature - Add 'graph' translation key to English locale (en.ts) - Add 'graph' translation key to Chinese locale (zh.ts) - Support for graph display label in knowledge graph UI components --- web/src/i18n/en.ts | 1 + web/src/i18n/zh.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts index e679bcee..b53ff2bc 100644 --- a/web/src/i18n/en.ts +++ b/web/src/i18n/en.ts @@ -695,6 +695,7 @@ export const en = { fileDurationLimitError: 'The duration of the media file exceeds the limit. The maximum supported duration is 150 seconds. Current duration', unableReadFile:'Unable to read the information of the media file. Please check the file format.', // Knowledge Graph related + graph: 'Graph', knowledgeGraph: 'Knowledge Graph', basicConfig: 'Basic Configuration', enableKnowledgeGraph: 'Enable Knowledge Graph', diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.ts index abb95a79..141d4600 100644 --- a/web/src/i18n/zh.ts +++ b/web/src/i18n/zh.ts @@ -305,6 +305,7 @@ export const zh = { fileDurationLimitError: '媒体文件时长超过限制,最大支持150秒,当前时长', unableReadFile:'无法读取媒体文件信息,请检查文件格式', // 知识图谱相关 + graph: '图谱', knowledgeGraph: '知识图谱', basicConfig: '基础配置', enableKnowledgeGraph: '启用知识图谱', From 6cc54a25768be819ca4736df31b92da36ffa7da6 Mon Sep 17 00:00:00 2001 From: yujiangping Date: Tue, 6 Jan 2026 19:24:28 +0800 Subject: [PATCH 2/3] feat(i18n): add graph translation key for knowledge graph feature - Add 'graph' translation key to English locale (en.ts) - Add 'graph' translation key to Chinese locale (zh.ts) - Support new graph label in knowledge graph related UI components --- web/src/i18n/en.ts | 1 + web/src/i18n/zh.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts index e679bcee..b53ff2bc 100644 --- a/web/src/i18n/en.ts +++ b/web/src/i18n/en.ts @@ -695,6 +695,7 @@ export const en = { fileDurationLimitError: 'The duration of the media file exceeds the limit. The maximum supported duration is 150 seconds. Current duration', unableReadFile:'Unable to read the information of the media file. Please check the file format.', // Knowledge Graph related + graph: 'Graph', knowledgeGraph: 'Knowledge Graph', basicConfig: 'Basic Configuration', enableKnowledgeGraph: 'Enable Knowledge Graph', diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.ts index abb95a79..141d4600 100644 --- a/web/src/i18n/zh.ts +++ b/web/src/i18n/zh.ts @@ -305,6 +305,7 @@ export const zh = { fileDurationLimitError: '媒体文件时长超过限制,最大支持150秒,当前时长', unableReadFile:'无法读取媒体文件信息,请检查文件格式', // 知识图谱相关 + graph: '图谱', knowledgeGraph: '知识图谱', basicConfig: '基础配置', enableKnowledgeGraph: '启用知识图谱', From d6b1c2effb7dfdb4e139aee54dc6daa673331d83 Mon Sep 17 00:00:00 2001 From: yujiangping Date: Tue, 6 Jan 2026 19:46:38 +0800 Subject: [PATCH 3/3] refactor(markdown): simplify editing logic and remove unused components - Remove unused imports (Button, EditOutlined, SaveOutlined, CloseOutlined) - Remove onSave callback prop and related save/cancel handlers - Simplify editing state management by using editable prop directly instead of isEditing state - Remove edit toolbar with save/cancel buttons from edit mode - Remove edit button that appeared on hover in preview mode - Remove unused props spread in button component renderer - Simplify textarea rows to always use 10 rows instead of conditional logic - Remove group hover styling from preview container - Streamline component to rely solely on editable prop for mode switching --- web/src/components/Markdown/index.tsx | 92 ++------------------------- 1 file changed, 7 insertions(+), 85 deletions(-) diff --git a/web/src/components/Markdown/index.tsx b/web/src/components/Markdown/index.tsx index fdaec143..d16b72e4 100644 --- a/web/src/components/Markdown/index.tsx +++ b/web/src/components/Markdown/index.tsx @@ -1,5 +1,4 @@ -import { Image, Input, Select, Form, Checkbox, Radio, ColorPicker, DatePicker, TimePicker, InputNumber, Slider, Button } from 'antd' -import { EditOutlined, SaveOutlined, CloseOutlined } from '@ant-design/icons' +import { Image, Input, Select, Form, Checkbox, Radio, ColorPicker, DatePicker, TimePicker, InputNumber, Slider } from 'antd' import ReactMarkdown from 'react-markdown' import RemarkGfm from 'remark-gfm' import RemarkMath from 'remark-math' @@ -20,7 +19,6 @@ interface RbMarkdownProps { showHtmlComments?: boolean; // 是否显示 HTML 注释,默认为 false(隐藏) editable?: boolean; // 是否可编辑,默认为 false onContentChange?: (content: string) => void; // 内容变化回调 - onSave?: (content: string) => void; // 保存回调 } const components = { @@ -51,7 +49,7 @@ const components = { video: ({ src, ...props }: any) => , audio: ({ src, ...props }: any) => , a: ({ href, children, ...props }: any) => {children}, - button: ({ children, ...props }: any) => {[children]}, + button: ({ children }: any) => {[children]}, table: ({ children, ...props }: any) => {children}
, tr: ({ children, ...props }: any) => {children}, th: ({ children, ...props }: any) => {children}, @@ -100,9 +98,7 @@ const RbMarkdown: FC = ({ showHtmlComments = false, editable = false, onContentChange, - onSave, }) => { - const [isEditing, setIsEditing] = useState(editable) // 如果可编辑,默认进入编辑模式 const [editContent, setEditContent] = useState(content) const textareaRef = useRef(null) @@ -111,44 +107,6 @@ const RbMarkdown: FC = ({ setEditContent(content) }, [content]) - // 当editable变化时,自动切换编辑状态 - useEffect(() => { - if (editable) { - setIsEditing(true) - // 延迟聚焦,确保 textarea 已渲染 - setTimeout(() => { - textareaRef.current?.focus() - }, 100) - } - }, [editable]) - - // 进入编辑模式 - const handleEdit = () => { - setIsEditing(true) - setEditContent(content) - // 延迟聚焦,确保 textarea 已渲染 - setTimeout(() => { - textareaRef.current?.focus() - }, 100) - } - - // 保存编辑 - const handleSave = () => { - onContentChange?.(editContent) - onSave?.(editContent) - if (!editable) { - setIsEditing(false) // 只有在非强制编辑模式下才退出编辑 - } - } - - // 取消编辑 - const handleCancel = () => { - setEditContent(content) // 恢复原内容 - if (!editable) { - setIsEditing(false) // 只有在非强制编辑模式下才退出编辑 - } - } - // 处理 textarea 内容变化 const handleTextareaChange = (e: React.ChangeEvent) => { const newContent = e.target.value @@ -160,15 +118,15 @@ const RbMarkdown: FC = ({ // 根据参数决定是否将 HTML 注释转换为可见文本 // 使用特殊的 markdown 语法来显示注释,避免被 rehype-raw 过滤 const processedContent = showHtmlComments - ? (isEditing ? editContent : content).replace(//g, (_match, commentContent) => { + ? (editable ? editContent : content).replace(//g, (_match, commentContent) => { // 转换为带样式的文本,使用 标记 const escaped = commentContent.trim().replace(//g, '>') return `<!-- ${escaped} -->` }) - : (isEditing ? editContent : content) + : (editable ? editContent : content) // 如果是编辑模式,显示 textarea - if (isEditing) { + if (editable) { return (
- - {/* 编辑工具栏 - 只在非强制编辑模式下显示 */} - {!editable && ( -
- - -
- )} {/* 编辑区域 */} = ({ // 预览模式 return ( -
+
- - {/* 编辑按钮 - 只在非强制编辑模式且鼠标悬停时显示 */} - {!editable && ( -
- -
- )}