# Plugins 模块指南 ## OVERVIEW Milkdown/ProseMirror 插件,AI 补全核心逻辑。 ## STRUCTURE - copilotPlugin.ts - ProseMirror Mark 系统、ghost text、防抖请求 - docBlockPlugin.ts - 文档块插件 - mermaidPlugin.ts - Mermaid 图表渲染 - index.ts - 插件导出 - types.ts - 类型定义 ## WHERE TO LOOK | 任务 | 文件 | 说明 | |------|------|------| | AI 补全核心 | copilotPlugin.ts | ProseMirror Mark、ghost text | | 文档块处理 | docBlockPlugin.ts | 文档块解析与渲染 | | Mermaid 图表 | mermaidPlugin.ts | 图表渲染集成 | | 插件导出 | index.ts | 统一导出入口 | | 类型定义 | types.ts | 公共类型 | ## 关键函数 - scheduleFetch - 防抖触发补全请求 - insertGhostText - 插入 ghost text - acceptSuggestion - Tab 接受建议 - rejectSuggestion - Esc 取消建议 ## CONVENTIONS - TypeScript 2 空格缩进 - 函数:camelCase - 接口/类型:PascalCase ## ANTI-PATTERNS - 空 catch 块 - 类型错误使用 as any - 硬编码超时值 ## 注意事项 - 防抖时间:1000ms(可配置) - 文档大小限制:32KB 自动禁用 - Tab/Esc 快捷键交互