diff --git a/sourcecode/hub/app/View/Components/LtiLaunch.php b/sourcecode/hub/app/View/Components/LtiLaunch.php index d25ff85ee..d9043f48f 100644 --- a/sourcecode/hub/app/View/Components/LtiLaunch.php +++ b/sourcecode/hub/app/View/Components/LtiLaunch.php @@ -7,6 +7,7 @@ use Illuminate\Contracts\Encryption\Encrypter; use Illuminate\Contracts\View\View; use Illuminate\Support\Facades\URL; +use Illuminate\Support\Str; use Illuminate\View\Component; use function view; @@ -15,19 +16,31 @@ class LtiLaunch extends Component { public readonly string $url; + public readonly string $uniqueId; + /** * @param string $logTo * A selector for an element in which to log messages sent by the * iframe. + * @param array $parameters */ public function __construct( private Encrypter $encrypter, public \App\Lti\LtiLaunch $launch, + public string $method = 'GET', + public array $parameters = [], + public string $target = '_self', + public int $width = 640, + public int $height = 480, public string $logTo = '', + public bool $forwardsResizeMessages = false, + public bool $direct = false, ) { $this->url = URL::signedRoute('lti.launch', [ 'launch' => $this->encrypter->encrypt($launch), ]); + + $this->uniqueId = Str::uuid()->toString(); } public function render(): View diff --git a/sourcecode/hub/resources/js/resize.js b/sourcecode/hub/resources/js/resize.js index b2ee64787..d1ed15cab 100644 --- a/sourcecode/hub/resources/js/resize.js +++ b/sourcecode/hub/resources/js/resize.js @@ -37,8 +37,9 @@ addEventListener('message', (event) => { const border = iframe.getBoundingClientRect().height - iframe.scrollHeight; iframe.height = String(event.data.scrollHeight + border); - if (window.parent) { - // forward to parent iframe + if (window.parent && iframe.closest('.forwards-resize-messages')) { + console.debug('Forwarding the resize request'); + parent.postMessage({ action: 'resize', scrollHeight: event.data.scrollHeight, diff --git a/sourcecode/hub/resources/views/components/launch.blade.php b/sourcecode/hub/resources/views/components/launch.blade.php index 893557b9d..a2f6b948f 100644 --- a/sourcecode/hub/resources/views/components/launch.blade.php +++ b/sourcecode/hub/resources/views/components/launch.blade.php @@ -1,25 +1,12 @@ -@php use Illuminate\Support\Str; @endphp - -@props([ - 'url' => 'about:blank', - 'method' => 'GET', - 'parameters' => [], - 'target' => '_self', - 'direct' => false, - 'width' => 640, - 'height' => 480, - 'logTo' => '', - 'uniqueId' => (string) Str::uuid(), -]) - - @if ($direct) diff --git a/sourcecode/hub/resources/views/content/embed.blade.php b/sourcecode/hub/resources/views/content/embed.blade.php index a9ac3b978..169487b85 100644 --- a/sourcecode/hub/resources/views/content/embed.blade.php +++ b/sourcecode/hub/resources/views/content/embed.blade.php @@ -2,5 +2,5 @@ {{ $version->title }} - +