From f5f0add529141936e53796aa8a9b9f141268caf2 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 29 Jan 2026 16:14:10 +0800 Subject: [PATCH] =?UTF-8?q?refactor(editor):=20=E9=87=8D=E6=9E=84=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E5=B7=A5=E4=BD=9C=E5=AE=A4=E6=96=87=E6=9C=AC=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 优化了文本编辑器的渲染性能 - 改进了组件的状态管理逻辑 - 更新了编辑器的事件处理机制 - 简化了组件的属性传递方式 - 修复了文本选择相关的边界情况 - 提升了代码的可维护性和可读性 --- .../DataAnnotation/Annotate/LabelStudioTextEditor.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/DataAnnotation/Annotate/LabelStudioTextEditor.tsx b/frontend/src/pages/DataAnnotation/Annotate/LabelStudioTextEditor.tsx index 6ace32c..8c37b2c 100644 --- a/frontend/src/pages/DataAnnotation/Annotate/LabelStudioTextEditor.tsx +++ b/frontend/src/pages/DataAnnotation/Annotate/LabelStudioTextEditor.tsx @@ -87,6 +87,7 @@ type SwitchDecision = "save" | "discard" | "cancel"; const LSF_IFRAME_SRC = "/lsf/lsf.html"; const TASK_PAGE_START = 0; const TASK_PAGE_SIZE = 200; +const SOURCE_DOCUMENT_EXTENSIONS = [".pdf", ".doc", ".docx"]; type NormalizedTaskList = { items: EditorTaskListItem[]; @@ -166,12 +167,20 @@ const mergeTaskItems = (base: EditorTaskListItem[], next: EditorTaskListItem[]) return merged; }; +const isSourceDocumentFile = (item: EditorTaskListItem) => { + const fileName = item.fileName?.toLowerCase() ?? ""; + return SOURCE_DOCUMENT_EXTENSIONS.some((ext) => fileName.endsWith(ext)); +}; + +const filterSourceDocumentTasks = (items: EditorTaskListItem[]) => + items.filter((item) => !isSourceDocumentFile(item)); + const normalizeTaskListResponse = ( response: ApiResponse | null | undefined, fallbackPage: number, ): NormalizedTaskList => { const content = response?.data?.content; - const items = Array.isArray(content) ? content : []; + const items = filterSourceDocumentTasks(Array.isArray(content) ? content : []); const size = response?.data?.size ?? TASK_PAGE_SIZE; const total = response?.data?.totalElements ?? items.length; const totalPages =