ng-realmark
Version:
Real-time Markdown W/ Markdown three way merge
47 lines • 1.87 kB
JavaScript
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { RealMarkService } from '../service/realmark.service';
import { DomSanitizer } from '@angular/platform-browser';
var PreviewerComponent = /** @class */ (function () {
function PreviewerComponent(realMarkService, sanitizer) {
this.realMarkService = realMarkService;
this.sanitizer = sanitizer;
this.toc = new EventEmitter(true);
}
PreviewerComponent.prototype.ngOnInit = function () {
this.updateDom(this.content);
};
PreviewerComponent.prototype.ngDoCheck = function () {
if (!(this.content === this.previousHtml)) {
this.updateDom(this.content);
}
};
PreviewerComponent.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());
this.previousHtml = this.content;
};
PreviewerComponent.decorators = [
{ type: Component, args: [{
selector: 'realmark-previewer',
template: '<div [innerHTML]="outputHTML"></div>',
styles: [],
},] },
];
/** @nocollapse */
PreviewerComponent.ctorParameters = function () { return [
{ type: RealMarkService },
{ type: DomSanitizer }
]; };
PreviewerComponent.propDecorators = {
content: [{ type: Input }],
codeBlock: [{ type: Input }],
toc: [{ type: Output }]
};
return PreviewerComponent;
}());
export { PreviewerComponent };
//# sourceMappingURL=previewer.component.js.map