Skip to content

fix(core-plugins): doubao copy button not appearing and heading level conflict#7

Open
MarvGuo wants to merge 2 commits into
nicepkg:mainfrom
MarvGuo:fix/doubao-copy-button-and-headings
Open

fix(core-plugins): doubao copy button not appearing and heading level conflict#7
MarvGuo wants to merge 2 commits into
nicepkg:mainfrom
MarvGuo:fix/doubao-copy-button-and-headings

Conversation

@MarvGuo
Copy link
Copy Markdown

@MarvGuo MarvGuo commented May 14, 2026

Summary

修复了 CtxPort 浏览器扩展在豆包(Doubao)平台上无法正常工作的问题,以及导出 Markdown 时的 headings 层级冲突。

修改内容

1. Copy button 不出现

  • doubao/plugin.ts:添加 3 个 fallback DOM 选择器,防止豆包页面 DOM 变更后按钮无法注入
  • app.tsx:注入失败 8s 后自动显示浮层兜底按钮

2. Headings 层级冲突

  • doubao/plugin.ts:实现动态 heading 降级策略 — 先扫描内容找到最高标题级别,计算偏移量,确保所有内容标题严格嵌套在 ## User/## Assistant 下方
  • 代码块(fenced code block)内的 # 字符不受影响
  • 移位后标题级别封顶在 6(ATX 最大值)

3. 测试覆盖

  • 新增 8 个 heading 降级测试:一级标题移位、二级标题移位、三级标题不动、代码块保护、无标题内容、纯代码块、7+ 井号、级别封顶

4. 文档

  • CHANGELOG.md:两条 fix 记录
  • docs/others/doubao-heading-demotion.md:技术文档

改动文件

文件 说明
packages/core-plugins/src/plugins/doubao/plugin.ts 核心修复
packages/core-plugins/src/plugins/doubao/__tests__/plugin.test.ts 测试 (11→19)
apps/browser-extension/src/components/app.tsx 浮层兜底
CHANGELOG.md Changelog
docs/others/doubao-heading-demotion.md 技术文档

Test plan

  • pnpm --filter @ctxport/core-plugins test — 19 tests pass
  • pnpm lint — no errors
  • pnpm typecheck — no errors
  • pnpm build:ext — build succeeds
  • 在豆包实际网页上手动测试 copy button 和导出结果

🤖 Generated with Claude Code

QiMing and others added 2 commits May 14, 2026 09:38
- Add fallback DOM selectors for copy button injection
- Add floating copy button as 8s timeout safety net
- Implement dynamic heading demotion: find highest heading level
  in content, shift all headings to nest strictly below ## level
- Protect code fence content from heading demotion
- Cap shifted heading level at 6 (max ATX level)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@MarvGuo MarvGuo changed the title fix(doubao): copy button not appearing and heading level conflict fix(core-plugins): doubao copy button not appearing and heading level conflict May 14, 2026
@MarvGuo MarvGuo force-pushed the fix/doubao-copy-button-and-headings branch from 89e18bc to 7ca81f1 Compare May 14, 2026 11:33
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