UNPKG

ng-ace

Version:

An ace editor directive for angular.

3 lines (2 loc) 2.1 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core")):"function"==typeof define&&define.amd?define(["exports","@angular/core"],t):t(e["ng-ace"]={},e.ng.core)}(this,function(e,t){"use strict";var o=require("brace"),r=function(){function e(e){var r=this;this.elementRef=e,this.textChanged=new t.EventEmitter,this.editorRef=new t.EventEmitter;var i=e.nativeElement;i.classList.add("editor"),this.editor=o.edit(i),setTimeout(function(){r.editorRef.emit(r.editor)}),this.editor.on("change",function(){var e=r.editor.getValue();e!==r.oldVal&&("undefined"!=typeof r.oldVal&&r.textChanged.emit(e),r.oldVal=e)})}return Object.defineProperty(e.prototype,"options",{set:function(e){this.editor.setOptions(e||{enableBasicAutocompletion:!0,enableLiveAutocompletion:!0})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readOnly",{set:function(e){this._readOnly=e,this.editor.setReadOnly(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"theme",{set:function(e){this._theme=e||"chrome",this.editor.setTheme("ace/theme/"+e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mode",{set:function(e){this._mode=e||"javascript",this.editor.getSession().setMode("ace/mode/"+e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"text",{set:function(e){e!==this.oldVal&&(this.editor.setValue(e),this.editor.clearSelection(),this.editor.focus())},enumerable:!0,configurable:!0}),e}();r.decorators=[{type:t.Directive,args:[{selector:"[ace-editor]"}]}],r.ctorParameters=function(){return[{type:t.ElementRef}]},r.propDecorators={textChanged:[{type:t.Output}],editorRef:[{type:t.Output}],options:[{type:t.Input}],readOnly:[{type:t.Input}],theme:[{type:t.Input}],mode:[{type:t.Input}],text:[{type:t.Input}]};var i=function(){return function(){}}();i.decorators=[{type:t.NgModule,args:[{declarations:[r],exports:[r],providers:[]}]}],i.ctorParameters=function(){return[]},e.AceEditorDirective=r,e.AceEditorModule=i,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=ng-ace.umd.min.js.map