From e1c41a93c35d219b91157243e0fe786745360fe6 Mon Sep 17 00:00:00 2001
From: Jerry Yan <792602257@qq.com>
Date: Fri, 9 Jan 2026 18:52:52 +0800
Subject: [PATCH] =?UTF-8?q?refactor(annotation):=20=E4=BC=98=E5=8C=96?=
=?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91=E7=A7=BB?=
=?UTF-8?q?=E9=99=A4=E6=96=87=E6=9C=AC=E7=B1=BB=E5=9E=8B=E7=89=B9=E6=AE=8A?=
=?UTF-8?q?=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 移除了 text_object_types 变量定义
- 删除了 is_text_template 判断逻辑
- 移除了长文本优化的双栏布局实现
- 添加了关于 Label Studio 默认侧栏控件行为的说明
- 简化了 XML 结构生成逻辑
---
.../app/module/annotation/service/template.py | 20 +++----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/runtime/datamate-python/app/module/annotation/service/template.py b/runtime/datamate-python/app/module/annotation/service/template.py
index 9e36950..ed7dce8 100644
--- a/runtime/datamate-python/app/module/annotation/service/template.py
+++ b/runtime/datamate-python/app/module/annotation/service/template.py
@@ -36,7 +36,6 @@ class AnnotationTemplateService:
"""
tag_config = LabelStudioTagConfig()
control_types = tag_config.get_control_types()
- text_object_types = {"Text", "Paragraphs", "ParagraphLabels", "HyperText", "Markdown"}
def normalize_control_type(raw: Optional[str]) -> str:
if not raw:
@@ -49,8 +48,6 @@ class AnnotationTemplateService:
return ct
return raw
- is_text_template = any((obj.type in text_object_types) for obj in config.objects)
-
# 生成对象定义
object_parts: List[str] = []
for obj in config.objects:
@@ -92,21 +89,10 @@ class AnnotationTemplateService:
else:
# 处理简单标签类型(不需要子元素)
control_parts.append(f' <{tag_type} {" ".join(label_attrs)}/>')
-
- if is_text_template:
- # 长文本优化:将标签控件固定在右侧(sticky),避免需要滚动到页面底部才能看到控件
- xml_parts = [
- '',
- ' ',
- *object_parts,
- ' ',
- ' ',
- *control_parts,
- ' ',
- '',
- ]
- return '\n'.join(xml_parts)
+ # 说明:
+ # - Label Studio Frontend 默认会将控件(control tags)渲染到右侧侧栏(side-column/controls)。
+ # - 如果在 XML 中手工做“双栏布局”,会导致控件出现在主区域,从而与侧栏的结果面板重复,影响体验。
xml_parts = ['']
xml_parts.extend(object_parts)
xml_parts.extend(control_parts)