feat(rich): 备注/工单说明/知识正文支持 Markdown 与图片附件
写一件事的时候,光有纯文本不够:要贴截图、要分段、要标重点。 这次把「正文」这条路补全,思路是**存 Markdown 而不是 HTML**—— 能导出、能全文检索、能直接喂给 LLM,也不必每次渲染都重新清洗一遍 HTML。 后端 - attachment 表 + RLS + 迁移 0005;本地磁盘存储,key 由内容 sha256 决定, 换对象存储只改 services/storage.py 一个文件 - 上传在**读流时**卡 20MB,不先落盘再判断;磁盘名由服务端生成,用户文件名只进库和响应头 - 列表带 attachment_count、详情带 attachments,避免一屏 N 次请求 - raw 直链给 <img src> 用(图片带不了 Authorization 头),只允许本工作区成员, 非成员一律 8001 不区分「不存在」与「没权限」 - 5 个用例:上传下载、超限、跨租户、删除确认与权限、raw 鉴权 前端 - 自研零依赖 Markdown 渲染器:先转义再上标签,链接协议白名单 - RichTextEditor:工具栏 + Ctrl+B/I + 预览,粘贴或拖入图片自动上传并插入引用 - AttachmentPanel:上传/下载/删除,下载走带 Authorization 的 fetch 转 blob - 任务备注、工单说明与验收结论、知识正文、评论全部接入 顺手修的 - TaskDetail.hydrate 漏了 setAttachments,导致附件面板永远是空的(e2e 抓到的) 71 passed;web tsc 0 错、构建 255.07 kB │ gzip 80.85 kB; e2e:richtext 9 项 + smoke 7 + tickets 8 + knowledge 7,全绿。
This commit is contained in:
@@ -23,6 +23,69 @@ export const Check = (p: IconProps) => (
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const Bold = (p: IconProps) => (
|
||||
<svg {...base(p)}>
|
||||
<path d="M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const Italic = (p: IconProps) => (
|
||||
<svg {...base(p)}>
|
||||
<path d="M15 5h-5M14 19H9M14.5 5 10 19" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const Quote = (p: IconProps) => (
|
||||
<svg {...base(p)}>
|
||||
<path d="M7 7h4v4c0 2.2-1.3 3.7-3.5 4.5M15 7h4v4c0 2.2-1.3 3.7-3.5 4.5" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const Code = (p: IconProps) => (
|
||||
<svg {...base(p)}>
|
||||
<path d="m9 8-4 4 4 4M15 8l4 4-4 4" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const ListIcon = (p: IconProps) => (
|
||||
<svg {...base(p)}>
|
||||
<path d="M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const Image = (p: IconProps) => (
|
||||
<svg {...base(p)}>
|
||||
<rect x="3.5" y="4.5" width="17" height="15" rx="2.5" />
|
||||
<circle cx="9" cy="10" r="1.6" />
|
||||
<path d="m4 17 4.5-4.5 3.5 3.5 3-3L20 17" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const Eye = (p: IconProps) => (
|
||||
<svg {...base(p)}>
|
||||
<path d="M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6Z" />
|
||||
<circle cx="12" cy="12" r="2.6" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const Pencil = (p: IconProps) => (
|
||||
<svg {...base(p)}>
|
||||
<path d="M4 20h4l10.5-10.5a2.1 2.1 0 0 0-3-3L5 17z" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const Paperclip = (p: IconProps) => (
|
||||
<svg {...base(p)}>
|
||||
<path d="M20 11.5 12.3 19a4.6 4.6 0 0 1-6.5-6.5l7.4-7.4a3.1 3.1 0 1 1 4.4 4.4l-7.4 7.4a1.5 1.5 0 1 1-2.2-2.2l6.6-6.6" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const Download = (p: IconProps) => (
|
||||
<svg {...base(p)}>
|
||||
<path d="M12 4v11M7.5 10.5 12 15l4.5-4.5M4.5 19h15" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const CheckCircle = (p: IconProps) => (
|
||||
<svg {...base(p)}>
|
||||
<circle cx="12" cy="12" r="9" />
|
||||
|
||||
Reference in New Issue
Block a user