1 | "use strict";
|
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7 | };
|
8 | var __metadata = (this && this.__metadata) || function (k, v) {
|
9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10 | };
|
11 | var core_1 = require('@angular/core');
|
12 | var http_1 = require('@angular/http');
|
13 | var markdown = require('markdown').markdown;
|
14 | var MarkdownFileViewComponent = (function () {
|
15 | function MarkdownFileViewComponent(http) {
|
16 | this.http = http;
|
17 | this.content = '';
|
18 | }
|
19 | MarkdownFileViewComponent.prototype.escapeAngularBindings = function (html) {
|
20 | return html.replace(/<code/g, '<code ngNonBindable');
|
21 | };
|
22 | MarkdownFileViewComponent.prototype.ngOnInit = function () {
|
23 | var _this = this;
|
24 | console.log('Will load MD from: ', this.mdFilePath);
|
25 | this.http.get(this.mdFilePath)
|
26 | .map(function (res) { return res.text(); })
|
27 | .map(function (text) { return markdown.toHTML(text); })
|
28 | .map(this.escapeAngularBindings)
|
29 | .subscribe(function (html) { return _this.content = html; });
|
30 | };
|
31 | __decorate([
|
32 | core_1.Input('template'),
|
33 | __metadata('design:type', String)
|
34 | ], MarkdownFileViewComponent.prototype, "mdFilePath", void 0);
|
35 | MarkdownFileViewComponent = __decorate([
|
36 | core_1.Component({
|
37 | selector: 'markdown-file',
|
38 | template: '<div class="markdown-file-content" [innerHTML]="content"></div>'
|
39 | }),
|
40 | __metadata('design:paramtypes', [http_1.Http])
|
41 | ], MarkdownFileViewComponent);
|
42 | return MarkdownFileViewComponent;
|
43 | }());
|
44 | exports.MarkdownFileViewComponent = MarkdownFileViewComponent;
|
45 |
|
\ | No newline at end of file |