Skip to content

feat(desktop): 代码块添加语言标签和固定头部栏#4254

Closed
whale-fall-ouo wants to merge 1 commit into
esengine:main-v2from
whale-fall-ouo:feat/code-block-header
Closed

feat(desktop): 代码块添加语言标签和固定头部栏#4254
whale-fall-ouo wants to merge 1 commit into
esengine:main-v2from
whale-fall-ouo:feat/code-block-header

Conversation

@whale-fall-ouo

Copy link
Copy Markdown
Contributor

功能说明

为代码块添加固定的头部栏,包含语言标签和复制按钮。

改动内容

  • HljsCode.tsx — 在 <pre> 外部新增 code-block__header 容器,包含语言标签和复制按钮
  • styles.css — 新增 .code-block__header(sticky 顶部栏)、.code-block__lang(语言标签)、.code-block__header + .code(去掉顶部圆角和 margin)

效果

  • 有语言标签的代码块:顶部显示语言名称和复制按钮
  • 无语言标签的代码块:保持原样
  • 复制按钮不受代码滚动影响,始终可见

- 代码块顶部新增 header,显示语言标签和复制按钮
- header 在 pre 外部,不受代码滚动影响,始终可见
- 无语言标签时保持原样,有语言标签时显示 header
@github-actions github-actions Bot added desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development labels Jun 13, 2026
@SivanCola

Copy link
Copy Markdown
Collaborator

这样的改动可以附一张截图吗?

@whale-fall-ouo

Copy link
Copy Markdown
Contributor Author
1 2

@SivanCola

Copy link
Copy Markdown
Collaborator

Thanks @whale-fall-ouo for the thoughtful code-block UX improvement here. The fixed header, visible language label, and keeping copy controls available for long snippets are useful contributions.

I carried that direction into #3120 in a4244ee, where the final design now uses one shared CodeViewer header toolbar with the language label, plain Copy, and Copy as Markdown. That also avoids the no-language copy-button regression that this PR could introduce if merged directly.

I am closing this as superseded by #3120 so we keep one code-block implementation path. Your contribution is credited there as part of the final repository change.

@SivanCola SivanCola closed this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants