こんにちは ![]()
このトピックは同じだと思います:Force download pdf on IOS
これには、api.decorateCookedElement を使用する必要があります。
次のようなものでうまくいくはずです ![]()
これをコンポーネントのヘッダーセクションに配置します。
<script type="text/discourse-plugin" version="0.8.42">
api.decorateCookedElement(
element => {
const pdfFiles = element.querySelectorAll("a.attachment[href$='.pdf']");
if (!pdfFiles.length) {
return;
}
pdfFiles.forEach((pdf) => {
pdf.setAttribute("download", "");
});
},
{ id: "download-pdf", onlyStream: true }
);
</script>
私のデバイスでテストしたところ、うまくいきましたが、他の属性などを使用したい場合は、簡単に変更できます… お役に立てば幸いです ![]()