diff --git a/dist/embed/iframe.html b/dist/embed/iframe.html index cefb4d9a9c..71ec029660 100644 --- a/dist/embed/iframe.html +++ b/dist/embed/iframe.html @@ -189,6 +189,8 @@ if (cachedHtml !== html) { root.html(html); cachedHtml = html; + + renderLinks(); }; }; @@ -244,6 +246,8 @@ }; root.html(data.div); + + renderLinks(); resize(); } }); @@ -261,14 +265,18 @@ success: (data) => { root.html(data); - root.find('a').off('click').on('click', function (e) { - e.preventDefault(); - window.parent.postMessage({ type: 'openUrl', url: $(this).attr('href'), blockId }, '*'); - }); + renderLinks(); } }); }; + function renderLinks () { + root.find('a').off('click').on('click', function (e) { + e.preventDefault(); + window.parent.postMessage({ type: 'openUrl', url: $(this).attr('href'), blockId }, '*'); + }); + }; + function getEnvironmentContent (processor) { const libs = []; diff --git a/src/ts/component/block/embed.tsx b/src/ts/component/block/embed.tsx index bb8030e8a2..e93f7737fc 100644 --- a/src/ts/component/block/embed.tsx +++ b/src/ts/component/block/embed.tsx @@ -615,7 +615,7 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component { const iw = (iframe[0] as HTMLIFrameElement).contentWindow; const sanitizeParam: any = { - ADD_TAGS: [ 'iframe' ], + ADD_TAGS: [ 'iframe', 'div', 'a' ], ADD_ATTR: [ 'frameborder', 'title', 'allow', 'allowfullscreen', 'loading', 'referrerpolicy', ], @@ -669,6 +669,8 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component]*/); }; @@ -680,7 +682,7 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component`; + return content.match(/^`; }; getImageHtml (content: string): string { @@ -235,14 +235,17 @@ class UtilEmbed { }; case I.EmbedProcessor.Drawio: { - const u = new URL(url); - const allowedHosts = ['viewer.diagrams.net', 'embed.diagrams.net', 'app.diagrams.net', 'draw.io']; - if (allowedHosts.includes(u.hostname)) { - // Edit mode cannot be opened at this time - u.searchParams.delete('edit'); - url = u.toString(); - }; - + try { + const u = new URL(url); + const allowedHosts = [ 'viewer.diagrams.net', 'embed.diagrams.net', 'app.diagrams.net', 'draw.io' ]; + + + if (allowedHosts.includes(u.hostname)) { + // Edit mode cannot be opened at this time + u.searchParams.delete('edit'); + url = u.toString(); + }; + } catch (e) { /**/ }; break; }; @@ -395,6 +398,7 @@ class UtilEmbed { I.EmbedProcessor.Kroki, I.EmbedProcessor.Chart, I.EmbedProcessor.Image, + I.EmbedProcessor.Drawio, ].includes(p); };