UNPKG

ng-realmark

Version:

Real-time Markdown W/ Markdown three way merge

43 lines 1.85 kB
import { Component, Input, Output, EventEmitter } from '@angular/core'; import { RealMarkService } from '../service/realmark.service'; import { DomSanitizer } from '@angular/platform-browser'; import { ChangeDetectionStrategy } from '@angular/core'; var PreviewerStaticComponent = /** @class */ (function () { function PreviewerStaticComponent(realMarkService, sanitizer) { this.realMarkService = realMarkService; this.sanitizer = sanitizer; this.toc = new EventEmitter(true); } PreviewerStaticComponent.prototype.ngOnInit = function () { this.updateDom(this.content); }; PreviewerStaticComponent.prototype.updateDom = function (innerHTML) { var inputMarkdown = innerHTML; if (this.codeBlock) { inputMarkdown = "```" + this.codeBlock + "\n" + inputMarkdown + "\n```"; } this.outputHTML = this.sanitizer.bypassSecurityTrustHtml(this.realMarkService.fromInput(inputMarkdown)); this.toc.emit(this.realMarkService.getTableOfContents()); }; PreviewerStaticComponent.decorators = [ { type: Component, args: [{ selector: 'realmark-previewer-static', template: '<div [innerHTML]="outputHTML"></div>', styles: [], changeDetection: ChangeDetectionStrategy.OnPush },] }, ]; /** @nocollapse */ PreviewerStaticComponent.ctorParameters = function () { return [ { type: RealMarkService }, { type: DomSanitizer } ]; }; PreviewerStaticComponent.propDecorators = { content: [{ type: Input }], codeBlock: [{ type: Input }], toc: [{ type: Output }] }; return PreviewerStaticComponent; }()); export { PreviewerStaticComponent }; //# sourceMappingURL=previewer-static.component.js.map