feat: Initial clean release of CHM
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
这个提交包含在:
@@ -0,0 +1,66 @@
|
||||
|
||||
interface Options {
|
||||
bodyHtml: string;
|
||||
headHtml: string;
|
||||
scripts: string[];
|
||||
permissions?: string;
|
||||
allow?: string;
|
||||
}
|
||||
|
||||
// allow-modals: Allows confirm/alert dialogs.
|
||||
const makeSandboxedIframe = ({ bodyHtml, headHtml, scripts, permissions = 'allow-scripts allow-modals', allow = '' }: Options) => {
|
||||
const iframe = document.createElement('iframe');
|
||||
|
||||
iframe.setAttribute('sandbox', permissions);
|
||||
if (allow) {
|
||||
iframe.allow = allow;
|
||||
}
|
||||
|
||||
iframe.addEventListener('load', async () => {
|
||||
iframe.contentWindow.postMessage({
|
||||
kind: 'add-script',
|
||||
scripts,
|
||||
}, '*');
|
||||
}, { once: true });
|
||||
|
||||
iframe.srcdoc = `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>${headHtml}</head>
|
||||
<body>
|
||||
<script>
|
||||
"use strict";
|
||||
window.onmessage = (event) => {
|
||||
if (event.source !== parent) {
|
||||
console.log('Ignoring message: wrong source');
|
||||
return;
|
||||
}
|
||||
if (event.data.kind !== 'add-script') {
|
||||
console.log('Ignoring message: wrong type', event.data.kind);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Adding scripts...');
|
||||
window.onmessage = undefined;
|
||||
for (const scriptText of event.data.scripts) {
|
||||
const scriptElem = document.createElement('script');
|
||||
scriptElem.appendChild(document.createTextNode(scriptText));
|
||||
document.head.appendChild(scriptElem);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
${bodyHtml}
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
|
||||
return {
|
||||
iframe,
|
||||
loadPromise: new Promise<void>(resolve => {
|
||||
iframe.addEventListener('load', () => resolve(), { once: true });
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
||||
export default makeSandboxedIframe;
|
||||
在新工单中引用
屏蔽一个用户