Repository navigation
修复
- 适配 Obsidian 1.15 的延迟创建视图:修复打开 HTML 文件后整页显示「无法读取 HTML 文件。请检查文件是否存在。」。
1.15 起,工作区会按需创建视图——后台标签的叶子仍会出现在workspace.getLeavesOfType()结果里,但leaf.view是宿主的占位对象(只有getViewType(),没有插件视图的refresh/refreshToolbar等方法)。插件在刷新同类视图时按类型断言直接调用,占位对象抛TypeError;该异常发生在onLoadFile末尾的宿主通知里,被加载路径的兜底 catch 捕获后,把已经渲染好的预览整页替换成了错误文案。现在只对真实的视图实例执行刷新,宿主通知失败也不会再毁掉文档视图。 - 修正
activeHtmlView()可能把延迟占位对象当成「当前 HTML 视图」返回的问题。 - 回归测试新增「延迟占位视图」场景(旧实现下会以
TypeError失败)。
Fixed
- Obsidian 1.15 deferred views: opening an HTML file could replace the whole page with "Cannot read the HTML file. Check that the file exists.".
Since 1.15, background tabs get their views created lazily — the leaf is still returned byworkspace.getLeavesOfType(), butleaf.viewis a host placeholder without the plugin'srefresh/refreshToolbarmethods. The plugin called them through a bare type assertion, the placeholder threw aTypeError, and because that happened inside the host notification at the end ofonLoadFile, the load path's catch replaced the already-rendered preview with the error text. The plugin now only refreshes real view instances, and a failing host notification can no longer blank the document. activeHtmlView()no longer returns a deferred placeholder as the active HTML view.- Added a deferred-view regression test (fails with
TypeErroron the previous implementation).
安装:Obsidian 设置 → 第三方插件 → 浏览 搜索 HTML Atelier;或从下方附件下载 main.js、manifest.json、styles.css 放入 .obsidian/plugins/html-atelier/。需要 Obsidian 1.7.2+。