Skip to content

Commit

Permalink
Mode options compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ckiffel committed Dec 26, 2016
1 parent 561b731 commit 5fedd37
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 148 deletions.
68 changes: 38 additions & 30 deletions bundles/ng2-ace-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ System.registerDynamic("src/directive", ["@angular/core", "brace", "brace/theme/
AceEditorDirective.prototype.init = function () {
this.editor.setOptions(this._options || {});
this.editor.setTheme("ace/theme/" + this._theme);
this.editor.getSession().setMode("ace/mode/" + this._mode);
this.mode = this._mode;
this.editor.setReadOnly(this._readOnly);
};
AceEditorDirective.prototype.initEvents = function () {
Expand Down Expand Up @@ -73,7 +73,11 @@ System.registerDynamic("src/directive", ["@angular/core", "brace", "brace/theme/
Object.defineProperty(AceEditorDirective.prototype, "mode", {
set: function (mode) {
this._mode = mode;
this.editor.getSession().setMode("ace/mode/" + mode);
if (typeof this.mode == 'object') {
this.editor.getSession().setMode(this._mode);
} else {
this.editor.getSession().setMode("ace/mode/" + this._mode);
}
},
enumerable: true,
configurable: true
Expand Down Expand Up @@ -104,18 +108,18 @@ System.registerDynamic("src/directive", ["@angular/core", "brace", "brace/theme/
enumerable: true,
configurable: true
});
__decorate([core_1.Output('textChanged'), __metadata('design:type', Object)], AceEditorDirective.prototype, "textChanged", void 0);
__decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorDirective.prototype, "options", null);
__decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorDirective.prototype, "readOnly", null);
__decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorDirective.prototype, "theme", null);
__decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorDirective.prototype, "mode", null);
__decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorDirective.prototype, "text", null);
__decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorDirective.prototype, "autoUpdateContent", null);
AceEditorDirective = __decorate([core_1.Directive({
selector: '[ace-editor]'
}), __metadata('design:paramtypes', [core_1.ElementRef])], AceEditorDirective);
return AceEditorDirective;
}();
__decorate([core_1.Output('textChanged'), __metadata("design:type", Object)], AceEditorDirective.prototype, "textChanged", void 0);
__decorate([core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object])], AceEditorDirective.prototype, "options", null);
__decorate([core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object])], AceEditorDirective.prototype, "readOnly", null);
__decorate([core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object])], AceEditorDirective.prototype, "theme", null);
__decorate([core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object])], AceEditorDirective.prototype, "mode", null);
__decorate([core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object])], AceEditorDirective.prototype, "text", null);
__decorate([core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object])], AceEditorDirective.prototype, "autoUpdateContent", null);
AceEditorDirective = __decorate([core_1.Directive({
selector: '[ace-editor]'
}), __metadata("design:paramtypes", [core_1.ElementRef])], AceEditorDirective);
exports.AceEditorDirective = AceEditorDirective;
return module.exports;
});
Expand Down Expand Up @@ -219,7 +223,11 @@ System.registerDynamic("src/component", ["@angular/core", "brace", "brace/theme/
});
AceEditorComponent.prototype.setMode = function (mode) {
this._mode = mode;
this._editor.getSession().setMode("ace/mode/" + mode);
if (typeof this._mode == 'object') {
this._editor.getSession().setMode(this._mode);
} else {
this._editor.getSession().setMode("ace/mode/" + this._mode);
}
};
Object.defineProperty(AceEditorComponent.prototype, "text", {
set: function (text) {
Expand Down Expand Up @@ -259,34 +267,34 @@ System.registerDynamic("src/component", ["@angular/core", "brace", "brace/theme/
AceEditorComponent.prototype.getEditor = function () {
return this._editor;
};
__decorate([core_1.Output('textChanged'), __metadata('design:type', Object)], AceEditorComponent.prototype, "textChanged", void 0);
__decorate([core_1.Input('style'), __metadata('design:type', Object)], AceEditorComponent.prototype, "style", void 0);
__decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorComponent.prototype, "options", null);
__decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorComponent.prototype, "readOnly", null);
__decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorComponent.prototype, "theme", null);
__decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorComponent.prototype, "mode", null);
__decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorComponent.prototype, "text", null);
__decorate([core_1.Input(), __metadata('design:type', Object), __metadata('design:paramtypes', [Object])], AceEditorComponent.prototype, "autoUpdateContent", null);
__decorate([core_1.Input(), __metadata('design:type', Number), __metadata('design:paramtypes', [Number])], AceEditorComponent.prototype, "durationBeforeCallback", null);
AceEditorComponent = __decorate([core_1.Component({
selector: 'ace-editor',
template: '',
styles: [':host { display:block;width:100%; }']
}), __metadata('design:paramtypes', [core_1.ElementRef])], AceEditorComponent);
return AceEditorComponent;
}();
__decorate([core_1.Output('textChanged'), __metadata("design:type", Object)], AceEditorComponent.prototype, "textChanged", void 0);
__decorate([core_1.Input('style'), __metadata("design:type", Object)], AceEditorComponent.prototype, "style", void 0);
__decorate([core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object])], AceEditorComponent.prototype, "options", null);
__decorate([core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object])], AceEditorComponent.prototype, "readOnly", null);
__decorate([core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object])], AceEditorComponent.prototype, "theme", null);
__decorate([core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object])], AceEditorComponent.prototype, "mode", null);
__decorate([core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object])], AceEditorComponent.prototype, "text", null);
__decorate([core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object])], AceEditorComponent.prototype, "autoUpdateContent", null);
__decorate([core_1.Input(), __metadata("design:type", Number), __metadata("design:paramtypes", [Number])], AceEditorComponent.prototype, "durationBeforeCallback", null);
AceEditorComponent = __decorate([core_1.Component({
selector: 'ace-editor',
template: '',
styles: [':host { display:block;width:100%; }']
}), __metadata("design:paramtypes", [core_1.ElementRef])], AceEditorComponent);
exports.AceEditorComponent = AceEditorComponent;
return module.exports;
});
System.registerDynamic('ng2-ace-editor', ['./src/directive', './src/component'], true, function ($__require, exports, module) {
System.registerDynamic("ng2-ace-editor", ["./src/directive", "./src/component"], true, function ($__require, exports, module) {
"use strict";

var define,
global = this || self,
GLOBAL = global;
var directive_1 = $__require('./src/directive');
var directive_1 = $__require("./src/directive");
exports.AceEditorDirective = directive_1.AceEditorDirective;
var component_1 = $__require('./src/component');
var component_1 = $__require("./src/component");
exports.AceEditorComponent = component_1.AceEditorComponent;
return module.exports;
});
6 changes: 3 additions & 3 deletions ng2-ace-editor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng2-ace-editor",
"version": "0.1.3",
"version": "0.1.4",
"description": "Ace editor integration with typescript for angular 2.",
"main": "ng2-ace-editor.js",
"typings": "ng2-ace-editor.d.ts",
Expand All @@ -9,7 +9,7 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/fxmontigny/ng2-ace-editor.git"
"url": "git+https://github.com/ckiffel/ng2-ace-editor.git"
},
"keywords": [
"ng2",
Expand All @@ -24,10 +24,10 @@
"ng2-ace",
"angular2-ace"
],
"author": "François-Xavier Montigny <fxaviermontigny@gmail.com>",
"author": "Christophe KIFFEL <christophe.kiffel@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/fxmontigny/ng2-ace-editor/issues"
"url": "https://github.com/ckiffel/ng2-ace-editor/issues"
},
"dependencies": {
"ace-builds": "^1.2.5",
Expand Down
2 changes: 1 addition & 1 deletion src/component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export declare class AceEditorComponent {
_options: any;
_readOnly: boolean;
_theme: string;
_mode: string;
_mode: any;
_autoUpdateContent: boolean;
_editor: any;
_durationBeforeCallback: number;
Expand Down
Loading

0 comments on commit 5fedd37

Please sign in to comment.