Skip to content

Commit

Permalink
feat: enabel live edit
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 1, 2020
1 parent ce3979a commit e1065f9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/app/presentation/ledge-helper/ledge-helper.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@
.source {
flex: 1;
}

.sample {
height: 100%;
overflow-y: scroll;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { LedgeHelperComponent } from './ledge-helper.component';
import { SharedModule } from '../../shared/shared.module';

describe('LedgeHelperComponent', () => {
let component: LedgeHelperComponent;
let fixture: ComponentFixture<LedgeHelperComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LedgeHelperComponent ]
imports: [SharedModule],
declarations: [LedgeHelperComponent]
})
.compileComponents();
.compileComponents();
}));

beforeEach(() => {
Expand Down
15 changes: 11 additions & 4 deletions src/app/shared/components/ledge-render/ledge-render.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, Component, Input, OnInit } from '@angular/core';
import { AfterViewInit, Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import marked from 'marked/lib/marked';
import { ReporterChartModel } from '../model/reporter-chart.model';
import * as d3 from 'd3';
Expand All @@ -10,7 +10,7 @@ import LedgeMarkdownConverter from '../model/ledge-markdown-converter';
templateUrl: './ledge-render.component.html',
styleUrls: ['./ledge-render.component.scss']
})
export class LedgeRenderComponent implements OnInit, AfterViewInit {
export class LedgeRenderComponent implements OnInit, AfterViewInit, OnChanges {
@Input()
content: string;

Expand All @@ -21,14 +21,21 @@ export class LedgeRenderComponent implements OnInit, AfterViewInit {
}

ngOnInit(): void {
this.buildChartData(this.content);
this.renderContent(this.content);
}

ngAfterViewInit(): void {

}

private buildChartData(content: string) {
ngOnChanges(changes: SimpleChanges): void {
const { content } = changes;
this.content = content.currentValue;
this.renderContent(this.content);
}

private renderContent(content: string) {
this.markdownData = [];
const tokens = marked.lexer(content);
this.buildData(tokens);
}
Expand Down

0 comments on commit e1065f9

Please sign in to comment.