Skip to content

空代码块占位提示语与块头重叠修复(重修:实查装饰落点) - #331

Merged
todosdev[bot] merged 4 commits into
mainfrom
tds/conv-01a22ab8-c4d6-79fe-ba82-4d96ac52c6c7
Nov 30, 2026
Merged

todosdev[bot] merged 4 commits into
mainfrom
tds/conv-01a22ab8-c4d6-79fe-ba82-4d96ac52c6c7

Conversation

@todosdev

@todosdev todosdev Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • 重修 fix(page-tree): prevent re-expanding active page ancestors on tree mutations #290:第一轮样式侧修复(.wiki-content .code-block.is-empty::before)落点判断错误——实测 is-empty / data-placeholder 挂在 Tiptap React 渲染器外层 wrapper(div.react-renderer.node-codeBlock)上,而非 CodeBlockView 自己的 .code-block(NodeViewWrapper),生产 v342 复现占位语压住块头。
  • 改走规格允许的扩展侧口径:Placeholder 配置 emptyNodeClass 按节点类型排除 codeBlock,空代码块不再挂 is-empty,浮动占位伪元素彻底不产生;普通空段落(含空文档首段)占位行为零变化。

Changes

  • web/src/editor/extensions.ts
    • Placeholder.configure 增加 emptyNodeClass: ({ node }) => node.type.name === "codeBlock" ? "" : "is-empty",对 codeBlock 返回空类名即不挂 is-empty。
  • web/src/index.css
    • 删除第一轮写错落点的 .wiki-content .code-block.is-empty::before { display: none } 规则(该类组合在实际 DOM 中不存在)。
  • web/src/editor/placeholder.test.tsx(新增)
    • 回归用例:空代码块 NodeView 不挂 is-empty 且块头行仍在;空段落照常挂 is-empty + data-placeholder。

Testing

  • pnpm --filter web test:104 文件 / 1323 用例全绿(含既有 CodeBlockCollapse、EditorToolbar、paste、roundtrip 等)。
  • pnpm --filter worker test:6 文件 / 23 用例全绿。
  • pnpm --filter web typecheck:tsc --noEmit 通过。
  • biome check(改动文件):无新增告警(16 条 noDescendingSpecificity 均为既有主题色段落)。
  • 真实浏览器验收:Chrome headless 挂项目自有 createExtensions 渲染空代码块,修复前后截图与 DOM outerHTML 证据已留 todos 工单——修复前占位语压住「纯文本」块头,修复后块头清晰、空段落占位仍在。

本仓库不跟踪前端构建产物(无 dist/ 需要重建)。

WorkerHub and others added 4 commits November 30, 2026 12:55
## 摘要

- 重修 #290:第一轮样式侧修复(.code-block.is-empty)落点判断错误——实测
  Placeholder 的节点装饰把 is-empty / data-placeholder 挂在 React 渲染器
  外层 wrapper(div.react-renderer.node-codeBlock)上,而非 CodeBlockView
  自己的 .code-block(NodeViewWrapper),生产 v342 复现压住块头行。
- 改走扩展侧口径(规格二选一):Placeholder 配置 emptyNodeClass 按节点类型
  排除 codeBlock(返回空类名 = 不挂 is-empty),浮动伪元素不再落到块头上。
- 普通空段落(含空文档首段)占位行为零变化;is-editor-empty 仍由扩展按
  isEmptyDoc 独立控制,与本次排除互不影响。

## 测试

- 新增 web/src/editor/placeholder.test.tsx:空代码块 NodeView 不挂 is-empty、
  块头仍在;空段落照常挂 is-empty + data-placeholder。
- pnpm --filter web test:104 文件 / 1323 用例全绿(含既有 CodeBlockCollapse、
  EditorToolbar、paste、roundtrip 等)。
- pnpm --filter worker test:6 文件 / 23 用例全绿。
- pnpm --filter web typecheck:tsc --noEmit 通过。
- biome check web/src/editor/extensions.ts web/src/editor/placeholder.test.tsx
  web/src/index.css:无新增告警(现存 16 条 noDescendingSpecificity 均为既有
  主题色段落)。
@todosdev
todosdev Bot merged commit 35c138c into main Nov 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant