mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
feat: handle unsupported iframes in HTML export by replacing them with a placeholder
This commit is contained in:
@@ -297,7 +297,14 @@ export async function convertCurrentDocument (opts: ConvertOpts): Promise<Blob>
|
||||
|
||||
// export html directly
|
||||
if (opts.fromType === 'html' && opts.toType === 'html') {
|
||||
const html = await wrapExportProcess('html', () => getContentHtml(opts.fromHtmlOptions))
|
||||
const html = await wrapExportProcess('html', () => getContentHtml({
|
||||
...opts.fromHtmlOptions,
|
||||
nodeProcessor: node => {
|
||||
if (node.tagName === 'IFRAME' && !/https?:\/\//.test(node.getAttribute('src') || '')) {
|
||||
node.outerHTML = '<i style="border: 1px solid lightgray">This iframe is not supported in export.</i>'
|
||||
}
|
||||
}
|
||||
}))
|
||||
return new Blob([
|
||||
buildHtml(fileName, html, opts.fromHtmlOptions || { includeStyle: false, includeToc: [] })
|
||||
], { type: 'text/html' })
|
||||
@@ -317,6 +324,11 @@ export async function convertCurrentDocument (opts: ConvertOpts): Promise<Blob>
|
||||
if (node.classList.contains('katex-html')) {
|
||||
node.remove()
|
||||
}
|
||||
|
||||
// remove unsupported iframe
|
||||
if (node.tagName === 'IFRAME' && !/https?:\/\//.test(node.getAttribute('src') || '')) {
|
||||
node.outerHTML = '<i style="border: 1px solid lightgray">This iframe is not supported in export.</i>'
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user