Skip to content

fix: spoiler隐藏文本失效 #3429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025
Merged

Conversation

LooseLi
Copy link
Contributor

@LooseLi LooseLi commented Jun 4, 2025

尽量按此模板PR内容,或粘贴相关的ISSUE链接。

fix #3285

已知问题

原有的 spoiler 文本功能只能处理单个文本节点内的 spoiler 标签,无法处理跨越多个 DOM 节点的情况。所以,当文本内容包含复杂格式(如加粗、斜体、公式等)时,隐藏效果失效。

解决方案

增加跨节点处理功能:

  • 添加 processCrossNodeSpoilers 函数,使用 innerHTML 和正则表达式处理跨节点的 spoiler 标签
  • 处理已转义的 spoiler 标签,确保与 /NotionPage.js 中的调用方式兼容
  • 保留原有的单节点处理逻辑,确保向后兼容

改动收益

  1. (示例)更规范的版本管理
    • 统一从 package.json 读取
    • 保持与 npm 生态一致
    • 减少人为错误

具体改动

/public/js/spoilerText.js

测试确认

  • 本地开发环境测试通过
  • 生产环境构建测试通过
  • 版本号正确显示
  • 环境变量配置正常工作

Copy link

vercel bot commented Jun 4, 2025

@LooseLi is attempting to deploy a commit to the tangly1024's projects Team on Vercel.

A member of the Team first needs to authorize it.

@tangly1024 tangly1024 merged commit c9ddcdb into tangly1024:main Jun 5, 2025
3 of 6 checks passed
@LooseLi LooseLi deleted the fix-spoiler-text branch June 5, 2025 05:55
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.

隐藏文本失效
2 participants