如题,iframe或custom frames有可能嵌入本地HTML吗?试过iframe+app://local/绝对路径和file:///绝对路径,都是一片空白?或者有无其他可以内嵌本地HTML文件的方法哇?
解决方法:Surfing插件自带嵌入HTML的功能,又自己写了一小段js调整高度,直接用的调整图片宽度的写法 ![[文件名|200]]:
const { Plugin } = require("obsidian");
module.exports = class EmbedHeight extends Plugin {
onload() {
console.log("html height 启动成功");
// 自动给所有HTML嵌入块设置高度
setInterval(() => {
const embeds = document.querySelectorAll(".internal-embed");
embeds.forEach(embed => {
const src = embed.getAttribute("src");
const width = embed.getAttribute("width");
// 只处理 html 文件 + 有数字的情况
if (src?.endsWith(".html") && width) {
embed.style.height = width + "px";
embed.style.overflow = "auto";
embed.style.display = "block";
}
});
}, 200);
}
};