没错,从那以后情况确实发生了一些变化!下面我提供了一个基于我们目前首选装饰方法的针对性示例。
以下代码需要添加到主题/组件的 <head> 标签中:
<script type="text/discourse-plugin" version="0.8.42">
api.decorateCookedElement(post =>
post.querySelectorAll('div[data-theme-iframe="no-scroll"] iframe').forEach(iframe => {
iframe.setAttribute('scrolling', 'no');
}),
{
id: 'iframe-decorator',
onlyStream: true,
}
);
</script>
有了上述设置,您可以通过如下方式用特定的 div 包裹 iframe,以禁用帖子内的滚动:
<div data-theme-iframe="no-scroll">
<iframe src="https://someallowediframesource.com"></iframe>
</div>
这应该能解决问题,但如果您发现任何问题,请随时告知。