ng-realmark
Version:
Real-time Markdown W/ Markdown three way merge
48 lines • 1.76 kB
JavaScript
import { Directive, Input, ElementRef } from '@angular/core';
import { RealMarkService } from '../service/realmark.service';
/**
* @desperate
*/
var RealMarkDirective = /** @class */ (function () {
function RealMarkDirective(elRef, realMarkService) {
this.elRef = elRef;
this.realMarkService = realMarkService;
// reference to the DOM element
this.ele = this.elRef.nativeElement;
}
RealMarkDirective.prototype.ngOnInit = function () {
var inputMarkdown = this.markdowninput;
if (this.code) {
inputMarkdown = "```" + this.code + "\n" + inputMarkdown + "\n```";
}
this.ele.innerHTML = this.realMarkService.fromInput(inputMarkdown);
this.previousHtml = this.markdowninput;
};
RealMarkDirective.prototype.ngDoCheck = function () {
if (!(this.markdowninput === this.previousHtml)) {
var inputMarkdown = this.markdowninput;
if (this.code) {
inputMarkdown = "```" + this.code + "\n" + inputMarkdown + "\n```";
}
this.ele.innerHTML = this.realMarkService.fromInput(inputMarkdown);
this.previousHtml = this.markdowninput;
}
};
RealMarkDirective.decorators = [
{ type: Directive, args: [{
selector: '[RealMark]',
},] },
];
/** @nocollapse */
RealMarkDirective.ctorParameters = function () { return [
{ type: ElementRef },
{ type: RealMarkService }
]; };
RealMarkDirective.propDecorators = {
markdowninput: [{ type: Input }],
code: [{ type: Input }]
};
return RealMarkDirective;
}());
export { RealMarkDirective };
//# sourceMappingURL=realmark.directive.js.map