Commit 71758cc1 authored by Mark van den Brink's avatar Mark van den Brink

Fix compiler errors

parent 5dd1b197
Pipeline #81324087 passed with stages
in 5 minutes and 34 seconds
import { CollectorComponent } from './collector/collector.component';
import { Component, ViewChild, OnInit } from '@angular/core';
import { Component, ViewChild, AfterViewInit } from '@angular/core';
import { EditorComponent } from './editor/editor.component';
import { HttpClient } from '@angular/common/http';
import { IDefinition } from 'tripetto';
......@@ -13,14 +13,14 @@ const SNAPSHOT = 'tripetto-example-angular-bootstrap-snapshot';
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
@ViewChild('collector') collector: CollectorComponent;
@ViewChild('editor') editor: EditorComponent;
export class AppComponent implements AfterViewInit {
@ViewChild('collector', { static: false }) collector: CollectorComponent;
@ViewChild('editor', { static: false }) editor: EditorComponent;
demoDefinition: IDefinition;
constructor(private _http: HttpClient) {}
ngOnInit() {
ngAfterViewInit() {
// For this demo we use the local store to save the definition and snapshot.
// Here we try to retrieve that saved data.
this.editor.definition = JSON.parse(localStorage.getItem(DEFINITION) || 'null') || undefined;
......
......@@ -30,6 +30,7 @@ export class MarkdownDirective implements OnInit, OnDestroy, OnChanges {
this.element.nativeElement.appendChild(
markdown.reduce<HTMLElement>((type: MarkdownTypes | undefined, content: string | HTMLElement[], value?: IVariable | string) => {
let el: HTMLElement;
let inner: HTMLElement;
switch (type) {
case 'bold':
......@@ -38,6 +39,12 @@ export class MarkdownDirective implements OnInit, OnDestroy, OnChanges {
case 'italic':
el = document.createElement('i');
break;
case 'bold+italic':
el = document.createElement('b');
inner = document.createElement('i');
el.appendChild(inner);
break;
case 'underline':
el = document.createElement('u');
break;
......@@ -75,9 +82,9 @@ export class MarkdownDirective implements OnInit, OnDestroy, OnChanges {
}
if (typeof content === 'string') {
el.textContent = content;
(inner || el).textContent = content;
} else {
content.forEach((node: HTMLElement) => el.appendChild(node));
content.forEach((node: HTMLElement) => (inner || el).appendChild(node));
}
return el;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment