Repository navigation
feat(app-kit): 网页端改为消费 app-kit,大纲注入导航实现(#512) - #520
Merged
Merged
Conversation
- apps/web/src 下 12 个源文件的 23 处引用改为直接消费 @md-bundle/app-kit/* (mdpkg、导出七件、byline/download/dataUrl、outline);垫片文件保留 —— Playwright spec 用 `/src/lib/exportPng.ts` 这类 dev-server 路径拿模块,删了会逼 spec 写 /@fs/ 绝对路径; - 新增 app-kit/outline 的 createOutlineNavigator:把「结构化编辑器视图 + 预览容器」 组合成 OutlineNavigator,web 与 Clairis 共用同一份滚动实现; - App.tsx 从 app-kit 引 <OutlineMenu> 并注入 navigator,同时保留 editorView / previewRef (高亮定位与预览滚动仍需要它们); - 注入分支只接管编辑/源码模式:预览标题没有稳定 id(renderer 的净化白名单剥离 id, 全仓也无标题锚点生成器),按 id 寻址无法表达「滚到第 N 个标题」,故预览仍走 组件内置的 DOM 元素路径;scrollToHeading 加空 id 守卫,保证永不抛 SyntaxError; - 测试:outlineMenu 补两条(编辑模式走注入实现并交回焦点 / 预览模式不调用注入实现); save / share-card / App 三处 vi.mock 从垫片路径改指 app-kit 模块 id —— 消费者换了模块, mock 必须跟着换,否则 mock 落空而测试假装通过。 单测:renderer 121 / editor 957 / app-kit 18 / web 419 全绿;typecheck / lint / build 通过; 全量 e2e 598 passed(2 条 render-parity / proto-semantic-modes 失败在干净工作区同样复现, 与本次改动无因果关系)。 refs #512
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更概述
网页端改为直接消费
@md-bundle/app-kit,大纲组件从 app-kit 引入并注入导航实现;用户可见行为与迁移前一致,apps/web/src/lib里只剩再导出。关联 Issue
fixes #512
变更内容
apps/web/src(12 个源文件、23 处 import)、packages/app-kit/src/outline(新增 navigator + 组件边界收紧)、三处测试 mockpackages/app-kit/src/outline/navigator.ts(createOutlineNavigator+OutlineEditorView/OutlineNavigatorSources)packages/app-kit/src/outline/OutlineMenu.tsx:CM6ViewLike上移为共享结构类型;注入分支收紧到编辑/源码模式apps/web/src/App.tsx:从 app-kit 引<OutlineMenu>,注入navigator,保留editorView/previewRefapps/web/src/lib/*、apps/web/src/components/{PreviewView,ShareCard,ValidationPanel}.tsx:改指 app-kit 子路径apps/web/test/outlineMenu.test.tsx:+2 条注入边界用例/src/lib/exportPng.ts这类 dev-server 路径取模块,删掉就得改成/@fs/<绝对路径>。createOutlineNavigator把「结构化编辑器视图 + 预览容器」组合成OutlineNavigator,web 与 Clairis 共用同一份滚动实现,避免各写一套lineBlockAt/scrollIntoView。packages/renderer的 DOMPurify 白名单剥离id,全仓也没有标题锚点生成器,按 id 寻址无法表达「滚到第 N 个标题」。预览态继续走组件内置的_domEl.scrollIntoView;scrollToHeading加空 id 守卫,任何消费方都不会拿到querySelector('#')的 SyntaxError。影响范围
@md-bundle/app-kit/outline新增createOutlineNavigator与两个类型;OutlineMenu行为在未注入时完全不变。验证方式与结果
pnpm -r typecheck— 4 个包全 Donepnpm -r lint— 0 errors(2 + 1 条既有 warning)pnpm -r test— renderer 121 / editor 957 / app-kit 18 / web 419pnpm -r build— 全 Done(web dist 4.65s)pnpm --filter @md-bundle/web test:e2e(全量)— 598 passed,2 passed 之外的两条失败为既有环境问题(见下)playwright test test/v2-outline.spec.ts test/v2-outline-multitab.spec.ts --retries=0— 15 passed.cm-scroller从 0 滚到 9860.45px;预览模式点同一项 → 预览容器从 0 滚到 6540.45px(到底);两边高亮都落在「章节 40」QG-5 验证基于 d4a3db3)关于全量 e2e 的两条失败
既有的 macOS 字体栅格 / 浮点容差问题,与本 diff 无因果关系,已做对照:把本 diff
git stash后在干净工作区重跑这两个 spec,同样这两条失败、同样 11 passed;跑完按备份逐字节核对已恢复。另外这两条的被测对象(计算样式、装饰态 alpha)本 PR 未触及任何相关文件。质量门禁引用
outlineMenu.test.tsx两条边界用例 + 全量 e2e,而不是标no-ui-impact。scrollToLine(4)、焦点交回、预览态不碰注入实现),不是「元素存在」;它们跑之前先红后绿。d4a3db3。pnpm -r build+ 真实浏览器打开。scrollToHeading(id)与 renderer 剥离 id 冲突」已就地裁决并补测试锁死,在 [change=app-kit/6] 网页端改为消费 app-kit(删除重复实现) #512 的 QG-5 评论里完整留痕,不静默改设计。已知缺口
OutlineNavigator.scrollToHeading(id)对未自带锚点的消费方是 no-op。若 Clairis 也需要预览跳转,需要先决定「预览标题是否要有稳定 id」(涉及 renderer 净化白名单),属于产品决策,不在本票拍板。风险评估
risk-lowai-generatedgit revert <merge-commit>即可回滚