UNPKG

ngx-trumbowyg

Version:

This an Angular wrapper for [Trumbowyg WYSIWYG editor](https://alex-d.github.io/Trumbowyg/).

2 lines 3.63 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/forms")):"function"==typeof define&&define.amd?define("ngx-trumbowyg",["exports","@angular/core","@angular/forms"],e):e(t["ngx-trumbowyg"]={},t.ng.core,t.ng.forms)}(this,function(t,o,e){"use strict";var i=new o.InjectionToken("Trumbowyg options"),n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])};function s(t,e){function o(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var a=Object.assign||function a(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},r=function(){function t(t,e){if(this.editorControl=t,(this._config=e)&&e.events&&(e.events.tbwinit||e.events.tbwchange||e.events.tbwfocus))throw new Error("Forbidden event registration. These events are protected for the Ngx-Trumbowyg library: tbwinit, tbwchange, tbwfocus");t.valueAccessor=this}return t.prototype.ngOnInit=function(){var t=this.editorControl.control;t.setValidators(t.validator),t.updateValueAndValidity()},t.prototype.ngAfterViewInit=function(){var t=this,e=$(this._editor.nativeElement).trumbowyg(a({},this._config,this.options)).on("tbwinit",function(){t.setDisabledState(t._disabled),t.setContent(t._initValue)}).on("tbwchange",function(){t._onChange(t.getContent())}).on("tbwfocus",function(){t._onTouch()});if(this._config&&this._config.events){var o=this._config.events;Object.keys(o).forEach(function(t){e.on(t,o[t]())})}},t.prototype.registerOnChange=function(t){this._onChange=t},t.prototype.registerOnTouched=function(t){this._onTouch=t},t.prototype.writeValue=function(t){this._initValue=t,this._editor&&this._editor.nativeElement&&this.setContent(t)},t.prototype.setDisabledState=function(t){this._disabled=t,this._editor&&$(this._editor.nativeElement).trumbowyg(this._disabled?"disable":"enable")},t.prototype.ngOnDestroy=function(){$(this._editor.nativeElement).trumbowyg("destroy")},t.prototype.setContent=function(t){$(this._editor.nativeElement).trumbowyg("html",t)},t.prototype.getContent=function(){return $(this._editor.nativeElement).trumbowyg("html")},t}(),c=function(r){function t(t,e,o){var n=r.call(this,t,e)||this;return n.editorControl=t,n._config=e,n._editor=o,n}return s(t,r),t.decorators=[{type:o.Directive,args:[{selector:"[ngxTrumbowygEditor]"}]}],t.ctorParameters=function(){return[{type:e.NgControl},{type:undefined,decorators:[{type:o.Inject,args:[i]},{type:o.Optional}]},{type:o.ElementRef}]},t.propDecorators={options:[{type:o.Input}],placeholder:[{type:o.Input}]},t}(r),u=function(n){function t(t,e){var o=n.call(this,t,e)||this;return o.editorControl=t,o._config=e,o}return s(t,n),t.decorators=[{type:o.Component,args:[{selector:"ngx-trumbowyg-editor",template:"<textarea #editor [placeholder]=\"placeholder ? placeholder : ''\"></textarea>\n",styles:[""]}]}],t.ctorParameters=function(){return[{type:e.NgControl},{type:undefined,decorators:[{type:o.Inject,args:[i]},{type:o.Optional}]}]},t.propDecorators={options:[{type:o.Input}],placeholder:[{type:o.Input}],_editor:[{type:o.ViewChild,args:["editor"]}]},t}(r),p=function(){function e(){}return e.withConfig=function(t){return{ngModule:e,providers:[{provide:i,useValue:t}]}},e.decorators=[{type:o.NgModule,args:[{declarations:[c,u],exports:[c,u]}]}],e}();t.NgxTrumbowygModule=p,t.ɵb=r,t.ɵd=u,t.ɵc=i,t.ɵa=c,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=ngx-trumbowyg.umd.min.js.map