Browse Source

Code editor improvements.

pull/383/head
Sebastian Stehle 7 years ago
parent
commit
bd526355f2
  1. 6
      src/Squidex/app/framework/angular/forms/code-editor.component.ts
  2. 2
      src/Squidex/app/framework/angular/forms/json-editor.component.ts
  3. 6
      src/Squidex/app/framework/angular/stateful.component.ts

6
src/Squidex/app/framework/angular/forms/code-editor.component.ts

@ -29,7 +29,7 @@ export const SQX_CODE_EDITOR_CONTROL_VALUE_ACCESSOR: any = {
providers: [SQX_CODE_EDITOR_CONTROL_VALUE_ACCESSOR],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class CodeEditorComponent extends StatefulControlComponent<any, any> implements AfterViewInit {
export class CodeEditorComponent extends StatefulControlComponent<any, string> implements AfterViewInit {
private valueChanged = new Subject();
private aceEditor: any;
private value: string;
@ -47,7 +47,7 @@ export class CodeEditorComponent extends StatefulControlComponent<any, any> impl
super(changeDetector, {});
}
public writeValue(obj: any) {
public writeValue(obj: string) {
this.value = Types.isString(obj) ? obj : '';
if (this.aceEditor) {
@ -87,6 +87,8 @@ export class CodeEditorComponent extends StatefulControlComponent<any, any> impl
this.aceEditor.on('change', () => {
this.valueChanged.next();
});
this.detach();
});
}

2
src/Squidex/app/framework/angular/forms/json-editor.component.ts

@ -87,6 +87,8 @@ export class JsonEditorComponent extends StatefulControlComponent<{}, string> im
this.aceEditor.on('change', () => {
this.valueChanged.next();
});
this.detach();
});
}

6
src/Squidex/app/framework/angular/stateful.component.ts

@ -52,7 +52,7 @@ export class ResourceOwner implements OnDestroy {
export abstract class StatefulComponent<T = any> extends State<T> implements OnDestroy {
private readonly subscriptions = new ResourceOwner();
private subscription: Subscription;
private readonly subscription: Subscription;
constructor(
private readonly changeDetector: ChangeDetectorRef,
@ -76,6 +76,10 @@ export abstract class StatefulComponent<T = any> extends State<T> implements OnD
this.subscriptions.unsubscribeAll();
}
protected detach() {
this.changeDetector.detach();
}
protected detectChanges() {
this.changeDetector.detectChanges();
}

Loading…
Cancel
Save