-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4314 from serlo/plugin-edusharing-use-open-iframe…
…-resizer fix(plugin-edusharing): use open-iframe-resizer
- Loading branch information
Showing
18 changed files
with
37 additions
and
151 deletions.
There are no files selected for viewing
Binary file removed
BIN
-3.6 KB
.yarn/cache/@babel-helper-annotate-as-pure-npm-7.25.9-a0f89e14a0-41edda10df.zip
Binary file not shown.
Binary file removed
BIN
-102 KB
.yarn/cache/@babel-helper-create-class-features-plugin-npm-7.25.9-1efda825e9-91dd5f203e.zip
Binary file not shown.
Binary file removed
BIN
-15.6 KB
...n/cache/@babel-helper-member-expression-to-functions-npm-7.25.9-761e6fec27-8e2f1979b6.zip
Binary file not shown.
Binary file removed
BIN
-4.16 KB
.yarn/cache/@babel-helper-optimise-call-expression-npm-7.25.9-d8006fbada-f09d0ad60c.zip
Binary file not shown.
Binary file removed
BIN
-10.9 KB
.yarn/cache/@babel-helper-replace-supers-npm-7.25.9-664068b76b-84f40e1252.zip
Binary file not shown.
Binary file removed
BIN
-4.22 KB
...e/@babel-helper-skip-transparent-expression-wrappers-npm-7.25.9-215072fae0-fdbb524893.zip
Binary file not shown.
Binary file removed
BIN
-8.23 KB
...e/@babel-plugin-proposal-private-property-in-object-npm-7.21.11-d474c5e67a-1b880543bc.zip
Binary file not shown.
Binary file added
BIN
+8.63 KB
.yarn/cache/@open-iframe-resizer-core-npm-1.2.1-521060cbad-611919d099.zip
Binary file not shown.
Binary file added
BIN
+7.25 KB
.yarn/cache/@open-iframe-resizer-react-npm-1.2.1-cbd37663b7-a21ea5a890.zip
Binary file not shown.
Binary file removed
BIN
-16.9 KB
.yarn/cache/iframe-resizer-react-npm-1.1.1-bdc4fb4c8f-fd3db2dfd3.zip
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { GetStaticPaths, GetStaticProps } from 'next' | ||
import Script from 'next/script' | ||
|
||
import { LazyIframeResizer } from '@/components/content/lazy-iframe-resizer' | ||
import { Entity } from '@/components/entity/entity' | ||
import { FrontendClientBase } from '@/components/frontend-client-base/frontend-client-base' | ||
import { HeadTags } from '@/components/head-tags' | ||
|
@@ -52,7 +52,10 @@ export default renderedPageNoHooks<SlugProps>(({ pageData }) => { | |
serloEntityData={{ entityId }} | ||
authorization={pageData.authorization} | ||
> | ||
<LazyIframeResizer /> | ||
<Script | ||
src="https://cdn.jsdelivr.net/npm/@open-iframe-resizer/[email protected]/dist/index.min.js" | ||
strategy="lazyOnload" | ||
/> | ||
{pageData.metaData ? ( | ||
<HeadTags | ||
data={pageData.metaData} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import EdusharingIcon from '@editor/editor-ui/assets/edusharing.svg' | ||
import IframeResizer from 'iframe-resizer-react' | ||
import { IframeResizer } from '@open-iframe-resizer/react' | ||
import * as t from 'io-ts' | ||
import { memo, useEffect, useState } from 'react' | ||
|
||
|
@@ -32,7 +32,7 @@ const EmbedJson = t.type({ | |
}) | ||
|
||
const iframeResizerHtml = | ||
'<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.9/iframeResizer.contentWindow.min.js"></script>' | ||
'<script type="module" src="https://cdn.jsdelivr.net/npm/@open-iframe-resizer/[email protected]/dist/index.min.js"></script>' | ||
|
||
const cssReset = 'padding: 0; margin: 0; border: 0;' | ||
|
||
|
@@ -109,12 +109,15 @@ export function EdusharingAssetRenderer(props: { | |
) | ||
|
||
function buildHtml(htmlSnippet: string, defineContainerHeight: boolean) { | ||
// Hack: Some learning apps size themselves to be a little bit too tall and a scroll bar appears -> 97% height to prevent this | ||
// Hack: height: 97% -> Some learning apps size themselves to be a little bit too tall and a scroll bar appears -> 97% height to prevent this | ||
// Hack: overflow-y: hidden -> Sometimes after setting the correct iframe height the vertical scroll bar does not disappear. | ||
return ` | ||
<html style="${cssReset}${defineContainerHeight ? 'height: 97%;' : ''}"> | ||
<html style="${cssReset}${defineContainerHeight ? 'height: 97%;' : 'overflow-y: hidden;'}"> | ||
<head> | ||
${defineContainerHeight ? '' : iframeResizerHtml} | ||
</head> | ||
<body style="${cssReset}${defineContainerHeight ? 'height: 100%;' : ''}"> | ||
${htmlSnippet} | ||
${defineContainerHeight ? '' : iframeResizerHtml} | ||
</body> | ||
</html> | ||
` | ||
|
@@ -311,10 +314,8 @@ export function EdusharingAssetRenderer(props: { | |
if (embedHtml === null) return | ||
|
||
// IframeResizer properties: | ||
// - `heightCalculationMethod="lowestElement"` -> Documentation says its the most accurate (however worse performance than others) | ||
// - `srcDoc` -> Sets the iframe content | ||
// - `checkOrigin={false}` -> Necessary when using srcDoc | ||
// - `style={{ width: '1px', minWidth: '100%' }}` -> Makes Iframe have width 100% and take as much height as it needs. Recommended by documentation. | ||
// - Missing `sandbox` -> Should put no restrictions on what the iframe can do: A) Make iframe send the same cookies as the host. B) Allow it to execute scripts. Both important to be able to fetch video. | ||
return ( | ||
<div | ||
|
@@ -335,13 +336,9 @@ export function EdusharingAssetRenderer(props: { | |
/> | ||
) : ( | ||
<MemoizedIframeResizer | ||
heightCalculationMethod="lowestElement" | ||
checkOrigin={false} | ||
srcDoc={embedHtml} | ||
style={{ | ||
width: '1px', | ||
minWidth: '100%', | ||
}} | ||
style={{ width: '100%' }} | ||
/> | ||
)} | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters