8.1.20260212 Obsidian Insider 版 Notice 不显示

obsidian Insider 版 Notice 不显示

#debug记录 #obsidian

Obsidian Insider 版 v1.12.1(安装程序版本 1.9.12)存在一个 bug:内置的 enhance.js 在启动时重建 body DOM,会把 notice-container 从文档树中移除,但 Obsidian 内部仍持有旧引用,导致所有插件的 Notice 通知都不显示。

排查过程:

  1. 在控制台执行 new Notice() 返回对象但不显示
  2. document.querySelector(".notice-container") 为 null
  3. 通过 Notice 对象的 containerEl.parentElement 发现容器存在但 document.body.contains() 为 false(脱离 DOM)
  4. 用 MutationObserver 监控 body childList 变化,捕获到 enhance.js → app.js 的调用栈移除了容器

修复方案: 在插件 onload 中延迟检测 notice-container 是否脱离 DOM,若脱离则用 document.body.appendChild 重新挂载,并通过 MutationObserver 持续监控自动修复。此修复已加入 tasks-calendar-wrapper-custom 插件 v0.8.7。

滚动至顶部
酷口家数字花园 粤ICP备17140089号-1