UNPKG

ng-ace-tern

Version:

An ace editor directive for angular.

3 lines (2 loc) 2.54 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-tern"]={},e.ng.core)}(this,function(e,n){"use strict";var t=function(){function e(e){var t=this;this.elementRef=e,this.textChanged=new n.EventEmitter,this.editorRef=new n.EventEmitter;var o=e.nativeElement;o.classList.add("editor"),this.editor=window.ace.edit(o),setTimeout(function(){t.editorRef.emit(t.editor)}),this.editor.on("change",function(){var e=t.editor.getValue();e!==t.oldVal&&("undefined"!=typeof t.oldVal&&t.textChanged.emit(e),t.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.prototype.ngOnInit=function(){var e;e=this.editor,window.ace.config.loadModule("ace/ext/tern",function(){e.setOptions({enableTern:{defs:["browser","ecma5"],plugins:{doc_comment:{fullDocs:!0}},useWorker:e.getSession().getUseWorker(),switchToDoc:function(e,t){console.log("switchToDoc called but not defined. name="+e+"; start=",t)},startedCb:function(){console.log("editor.ternServer:",e.ternServer)}},enableSnippets:!0,enableBasicAutocompletion:!0})})},e}();t.decorators=[{type:n.Directive,args:[{selector:"[ace-editor]"}]}],t.ctorParameters=function(){return[{type:n.ElementRef}]},t.propDecorators={textChanged:[{type:n.Output}],editorRef:[{type:n.Output}],options:[{type:n.Input}],readOnly:[{type:n.Input}],theme:[{type:n.Input}],mode:[{type:n.Input}],text:[{type:n.Input}]};var o=function(){};o.decorators=[{type:n.NgModule,args:[{declarations:[t],exports:[t],providers:[]}]}],o.ctorParameters=function(){return[]},e.AceEditorDirective=t,e.AceEditorModule=o,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=ng-ace-tern.umd.min.js.map