Skip to content

HTML Atelier 2.4.2

Latest

Choose a tag to compare

@384615666 384615666 released this 13 Nov 14:23
· 1 commit to main since this release

修复

  • 适配 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 by workspace.getLeavesOfType(), but leaf.view is a host placeholder without the plugin's refresh / refreshToolbar methods. The plugin called them through a bare type assertion, the placeholder threw a TypeError, and because that happened inside the host notification at the end of onLoadFile, 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 TypeError on the previous implementation).

安装:Obsidian 设置 → 第三方插件 → 浏览 搜索 HTML Atelier;或从下方附件下载 main.js、manifest.json、styles.css 放入 .obsidian/plugins/html-atelier/。需要 Obsidian 1.7.2+。