diff --git a/backend/src/Squidex/wwwroot/scripts/editor-context.html b/backend/src/Squidex/wwwroot/scripts/editor-context.html index d478786c6..5713479ae 100644 --- a/backend/src/Squidex/wwwroot/scripts/editor-context.html +++ b/backend/src/Squidex/wwwroot/scripts/editor-context.html @@ -11,7 +11,8 @@ textarea { box-sizing: border-box; resize: none; - overflow: hidden; + overflow-x: hidden; + overflow-y: hidden; width: 100%; } @@ -25,7 +26,7 @@ } - + - + - + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/src/app/features/dashboard/pages/dashboard-config.component.ts b/frontend/src/app/features/dashboard/pages/dashboard-config.component.ts index b580c87a1..f5e57df2e 100644 --- a/frontend/src/app/features/dashboard/pages/dashboard-config.component.ts +++ b/frontend/src/app/features/dashboard/pages/dashboard-config.component.ts @@ -60,7 +60,7 @@ export class DashboardConfigComponent { } if (changes.app) { - this.uiState.getAppUser('dashboard.grid', this.configDefaults).pipe(take(1)) + this.uiState.getAppShared('dashboard.grid', this.configDefaults).pipe(take(1)) .subscribe(dto => { this.setConfig(dto); }); @@ -91,7 +91,6 @@ export class DashboardConfigComponent { public resetConfig() { this.setConfig(Types.clone(this.configDefaults)); - this.saveConfig(); } diff --git a/frontend/src/app/features/dashboard/pages/dashboard-page.component.html b/frontend/src/app/features/dashboard/pages/dashboard-page.component.html index 228a645b6..99e74117f 100644 --- a/frontend/src/app/features/dashboard/pages/dashboard-page.component.html +++ b/frontend/src/app/features/dashboard/pages/dashboard-page.component.html @@ -68,7 +68,7 @@ - + diff --git a/frontend/src/app/features/teams/pages/dashboard/dashboard-page.component.html b/frontend/src/app/features/teams/pages/dashboard/dashboard-page.component.html index 07134dc71..2dc903cab 100644 --- a/frontend/src/app/features/teams/pages/dashboard/dashboard-page.component.html +++ b/frontend/src/app/features/teams/pages/dashboard/dashboard-page.component.html @@ -56,7 +56,7 @@ - + diff --git a/frontend/src/app/shared/components/cards/iframe-card.component.ts b/frontend/src/app/shared/components/cards/iframe-card.component.ts index c76e37800..b1870e221 100644 --- a/frontend/src/app/shared/components/cards/iframe-card.component.ts +++ b/frontend/src/app/shared/components/cards/iframe-card.component.ts @@ -5,7 +5,9 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, Input, ViewChild } from '@angular/core'; +import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, HostListener, Input, ViewChild } from '@angular/core'; +import { ApiUrlConfig, Types } from '@app/framework'; +import { AppDto, AuthService, TeamDto } from '@app/shared/internal'; @Component({ selector: 'sqx-iframe-card', @@ -14,13 +16,67 @@ import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, Input, V changeDetection: ChangeDetectionStrategy.OnPush, }) export class IFrameCardComponent implements AfterViewInit { + private readonly context: any; + private isInitialized = false; + @Input() public options: any; @ViewChild('iframe', { static: false }) public iframe!: ElementRef; + @Input() + public set team(value: TeamDto | undefined | null) { + if (value) { + this.context.teamId = value.id; + this.context.teamName = value.name; + } + } + + @Input() + public set app(value: AppDto | undefined | null) { + if (value) { + this.context.appId = value.id; + this.context.appName = value.name; + } + } + + constructor(apiUrl: ApiUrlConfig, authService: AuthService) { + this.context = { apiUrl: apiUrl.buildUrl('api'), user: authService.user }; + } + public ngAfterViewInit() { this.iframe.nativeElement.src = this.options?.src; } + + @HostListener('window:message', ['$event']) + public onWindowMessage(event: MessageEvent) { + if (event.source === this.iframe.nativeElement.contentWindow) { + const { type } = event.data; + + if (type === 'started') { + this.isInitialized = true; + + this.sendInit(); + } + } + } + + private sendInit() { + this.sendMessage('init', { context: this.context }); + } + + private sendMessage(type: string, payload: any) { + if (!this.iframe) { + return; + } + + const iframe = this.iframe.nativeElement; + + if (this.isInitialized && iframe.contentWindow && Types.isFunction(iframe.contentWindow.postMessage)) { + const message = { type, ...payload }; + + iframe.contentWindow.postMessage(message, '*'); + } + } }