Browse Source

* Iframe fix

* Fix header casing.
pull/387/head
Sebastian Stehle 7 years ago
parent
commit
1316696a66
  1. 3
      src/Squidex.Domain.Apps.Entities/Context.cs
  2. 28
      src/Squidex/app/framework/angular/forms/iframe-editor.component.ts

3
src/Squidex.Domain.Apps.Entities/Context.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Security.Claims; using System.Security.Claims;
using Squidex.Domain.Apps.Entities.Apps; using Squidex.Domain.Apps.Entities.Apps;
@ -16,7 +17,7 @@ namespace Squidex.Domain.Apps.Entities
{ {
public sealed class Context public sealed class Context
{ {
public IDictionary<string, string> Headers { get; } = new Dictionary<string, string>(); public IDictionary<string, string> Headers { get; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
public IAppEntity App { get; set; } public IAppEntity App { get; set; }

28
src/Squidex/app/framework/angular/forms/iframe-editor.component.ts

@ -5,7 +5,7 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/ */
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, forwardRef, Input, OnChanges, OnInit, Renderer2, SimpleChanges, ViewChild } from '@angular/core'; import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, forwardRef, Input, OnChanges, Renderer2, SimpleChanges, ViewChild } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { StatefulControlComponent, Types } from '@app/framework/internal'; import { StatefulControlComponent, Types } from '@app/framework/internal';
@ -21,7 +21,7 @@ export const SQX_IFRAME_EDITOR_CONTROL_VALUE_ACCESSOR: any = {
providers: [SQX_IFRAME_EDITOR_CONTROL_VALUE_ACCESSOR], providers: [SQX_IFRAME_EDITOR_CONTROL_VALUE_ACCESSOR],
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class IFrameEditorComponent extends StatefulControlComponent<any, any> implements OnChanges, OnInit { export class IFrameEditorComponent extends StatefulControlComponent<any, any> implements OnChanges, AfterViewInit {
private value: any; private value: any;
private isDisabled = false; private isDisabled = false;
private isInitialized = false; private isInitialized = false;
@ -45,16 +45,24 @@ export class IFrameEditorComponent extends StatefulControlComponent<any, any> im
} }
public ngOnChanges(changes: SimpleChanges) { public ngOnChanges(changes: SimpleChanges) {
if (changes['url']) { if (this.iframe) {
this.iframe.nativeElement.src = this.url; if (changes['url']) {
this.setupUrl();
}
if (changes['formValue'] && this.formValue) {
this.sendFormValue();
}
} }
}
if (changes['formValue'] && this.formValue) { private setupUrl() {
this.sendFormValue(); this.iframe.nativeElement.src = this.url;
}
} }
public ngOnInit(): void { public ngAfterViewInit() {
this.setupUrl();
this.own( this.own(
this.renderer.listen('window', 'message', (event: MessageEvent) => { this.renderer.listen('window', 'message', (event: MessageEvent) => {
if (event.source === this.iframe.nativeElement.contentWindow) { if (event.source === this.iframe.nativeElement.contentWindow) {
@ -111,6 +119,10 @@ export class IFrameEditorComponent extends StatefulControlComponent<any, any> im
} }
private sendMessage(type: string, payload: any) { private sendMessage(type: string, payload: any) {
if (!this.iframe) {
return;
}
const iframe = this.iframe.nativeElement; const iframe = this.iframe.nativeElement;
if (this.isInitialized && iframe.contentWindow && Types.isFunction(iframe.contentWindow.postMessage)) { if (this.isInitialized && iframe.contentWindow && Types.isFunction(iframe.contentWindow.postMessage)) {

Loading…
Cancel
Save