!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("@angular/forms")):"function"==typeof define&&define.amd?define("ng2-ckeditor",["exports","@angular/core","@angular/common","@angular/forms"],e):e((t=t||self)["ng2-ckeditor"]={},t.ng.core,t.ng.common,t.ng.forms)}(this,(function(t,e,n,o){"use strict";function i(t,e,n,o){var i,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,o);else for(var u=t.length-1;u>=0;u--)(i=t[u])&&(s=(r<3?i(s):r>3?i(e,n,s):i(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s}function r(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var s=function(){function t(){this.click=new e.EventEmitter}return t.prototype.initialize=function(t){var e=this;t.instance.addCommand(this.command,{exec:function(t){e.click.emit(t)}}),t.instance.ui.addButton(this.name,{label:this.label,command:this.command,toolbar:this.toolbar,icon:this.icon})},t.prototype.ngOnInit=function(){if(!this.name)throw new Error('Attribute "name" is required on ');if(!this.command)throw new Error('Attribute "command" is required on ')},i([e.Output(),r("design:type",Object)],t.prototype,"click",void 0),i([e.Input(),r("design:type",String)],t.prototype,"label",void 0),i([e.Input(),r("design:type",String)],t.prototype,"command",void 0),i([e.Input(),r("design:type",String)],t.prototype,"toolbar",void 0),i([e.Input(),r("design:type",String)],t.prototype,"name",void 0),i([e.Input(),r("design:type",String)],t.prototype,"icon",void 0),t=i([e.Directive({selector:"ckbutton"})],t)}(),u=function(){function t(){}return t.prototype.ngAfterContentInit=function(){var t=this;this.toolbarButtons.forEach((function(e){return e.toolbar=t.name}))},t.prototype.initialize=function(t){t.instance.ui.addToolbarGroup(this.name,this.previous,this.subgroupOf),this.toolbarButtons.forEach((function(e){e.initialize(t)}))},i([e.Input(),r("design:type",String)],t.prototype,"name",void 0),i([e.Input(),r("design:type",Object)],t.prototype,"previous",void 0),i([e.Input(),r("design:type",String)],t.prototype,"subgroupOf",void 0),i([e.ContentChildren(s),r("design:type",e.QueryList)],t.prototype,"toolbarButtons",void 0),t=i([e.Directive({selector:"ckgroup"})],t)}(),c=function(){function t(t){this.zone=t,this.change=new e.EventEmitter,this.editorChange=new e.EventEmitter,this.ready=new e.EventEmitter,this.blur=new e.EventEmitter,this.focus=new e.EventEmitter,this.contentDom=new e.EventEmitter,this.fileUploadRequest=new e.EventEmitter,this.fileUploadResponse=new e.EventEmitter,this.paste=new e.EventEmitter,this.drop=new e.EventEmitter,this._value=""}var n;return n=t,Object.defineProperty(t.prototype,"value",{get:function(){return this._value},set:function(t){t!==this._value&&(this._value=t,this.onChange(t))},enumerable:!0,configurable:!0}),t.prototype.ngOnChanges=function(t){t.readonly&&this.instance&&this.instance.setReadOnly(t.readonly.currentValue)},t.prototype.ngOnDestroy=function(){this.instance&&(this.instance.removeAllListeners(),CKEDITOR.instances[this.instance.name].destroy(),this.instance.destroy(),this.instance=null)},t.prototype.ngAfterViewInit=function(){this.ckeditorInit(this.config||{})},t.prototype.ngAfterViewChecked=function(){this.ckeditorInit(this.config||{})},t.prototype.updateValue=function(t){var e=this;this.zone.run((function(){e.value=t,e.onChange(t),e.onTouched(),e.change.emit(t)}))},t.prototype.ckeditorInit=function(t){var e=this;if("undefined"==typeof CKEDITOR)console.warn("CKEditor 4.x is missing (http://ckeditor.com/)");else{if(this.instance||!this.documentContains(this.host.nativeElement))return;this.readonly&&(t.readOnly=this.readonly),this.instance=CKEDITOR.replace(this.host.nativeElement,t),this.instance.setData(this.value),this.instance.on("instanceReady",(function(t){e.instance.getData()!==e.value&&e.instance.setData(e.value),e.ready.emit(t)})),this.instance.on("change",(function(t){e.onTouched();var n=e.instance.getData();e.value!==n&&(e.debounce?(e.debounceTimeout&&clearTimeout(e.debounceTimeout),e.debounceTimeout=setTimeout((function(){e.updateValue(n),e.debounceTimeout=null}),parseInt(e.debounce))):e.updateValue(n)),e.editorChange.emit(t)})),this.instance.on("blur",(function(t){e.blur.emit(t)})),this.instance.on("focus",(function(t){e.focus.emit(t)})),this.instance.on("contentDom",(function(t){e.contentDom.emit(t)})),this.instance.on("fileUploadRequest",(function(t){e.fileUploadRequest.emit(t)})),this.instance.on("fileUploadResponse",(function(t){e.fileUploadResponse.emit(t)})),this.instance.on("paste",(function(t){e.paste.emit(t)})),this.instance.on("drop",(function(t){e.drop.emit(t)})),this.toolbarGroups.forEach((function(t){t.initialize(e)})),this.toolbarButtons.forEach((function(t){t.initialize(e)}))}},t.prototype.writeValue=function(t){this._value=t,this.instance&&this.instance.setData(t)},t.prototype.onChange=function(t){},t.prototype.onTouched=function(){},t.prototype.registerOnChange=function(t){this.onChange=t},t.prototype.registerOnTouched=function(t){this.onTouched=t},t.prototype.documentContains=function(t){return document.contains?document.contains(t):document.body.contains(t)},t.ctorParameters=function(){return[{type:e.NgZone}]},i([e.Input(),r("design:type",Object)],t.prototype,"config",void 0),i([e.Input(),r("design:type",Boolean)],t.prototype,"readonly",void 0),i([e.Input(),r("design:type",String)],t.prototype,"debounce",void 0),i([e.Output(),r("design:type",Object)],t.prototype,"change",void 0),i([e.Output(),r("design:type",Object)],t.prototype,"editorChange",void 0),i([e.Output(),r("design:type",Object)],t.prototype,"ready",void 0),i([e.Output(),r("design:type",Object)],t.prototype,"blur",void 0),i([e.Output(),r("design:type",Object)],t.prototype,"focus",void 0),i([e.Output(),r("design:type",Object)],t.prototype,"contentDom",void 0),i([e.Output(),r("design:type",Object)],t.prototype,"fileUploadRequest",void 0),i([e.Output(),r("design:type",Object)],t.prototype,"fileUploadResponse",void 0),i([e.Output(),r("design:type",Object)],t.prototype,"paste",void 0),i([e.Output(),r("design:type",Object)],t.prototype,"drop",void 0),i([e.ViewChild("host",{static:!1}),r("design:type",Object)],t.prototype,"host",void 0),i([e.ContentChildren(s),r("design:type",e.QueryList)],t.prototype,"toolbarButtons",void 0),i([e.ContentChildren(u),r("design:type",e.QueryList)],t.prototype,"toolbarGroups",void 0),i([e.Input(),r("design:type",Object),r("design:paramtypes",[Object])],t.prototype,"value",null),t=n=i([e.Component({selector:"ckeditor",providers:[{provide:o.NG_VALUE_ACCESSOR,useExisting:e.forwardRef((function(){return n})),multi:!0}],template:"\n \n "}),r("design:paramtypes",[e.NgZone])],t)}(),p=function(){function t(){}return t=i([e.NgModule({imports:[n.CommonModule],declarations:[c,s,u],exports:[c,s,u]})],t)}();t.CKEditorModule=p,t.ɵa=c,t.ɵb=s,t.ɵc=u,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=ng2-ckeditor.umd.min.js.map