Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 7 to Angular 9 migration. #134

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
A9 4
  • Loading branch information
martinpagesaal committed Feb 13, 2020
commit ef0a944d3f7bef85ea53bd340d3097ba2783e67a
297 changes: 297 additions & 0 deletions dist/bundles/ng2-ace-editor-a9.umd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('brace'), require('brace/theme/monokai'), require('@angular/forms')) :
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'brace', 'brace/theme/monokai', '@angular/forms'], factory) :
(global = global || self, factory((global.ng = global.ng || {}, global.ng.ng2aceeditor = {}), global.ng.core, null, null, global.ng.forms));
}(this, (function (exports, i0, brace, monokai, forms) { 'use strict';

class AceEditorDirective {
constructor(elementRef, zone) {
this.zone = zone;
this.textChanged = new i0.EventEmitter();
this.textChange = new i0.EventEmitter();
this._options = {};
this._readOnly = false;
this._theme = "monokai";
this._mode = "html";
this._autoUpdateContent = true;
this._durationBeforeCallback = 0;
this._text = "";
let el = elementRef.nativeElement;
this.zone.runOutsideAngular(() => {
this.editor = ace["edit"](el);
});
this.editor.$blockScrolling = Infinity;
}
ngOnInit() {
this.init();
this.initEvents();
}
ngOnDestroy() {
this.editor.destroy();
}
init() {
this.editor.setOptions(this._options || {});
this.editor.setTheme(`ace/theme/${this._theme}`);
this.setMode(this._mode);
this.editor.setReadOnly(this._readOnly);
}
initEvents() {
this.editor.on('change', () => this.updateText());
this.editor.on('paste', () => this.updateText());
}
updateText() {
let newVal = this.editor.getValue();
if (newVal === this.oldText) {
return;
}
if (!this._durationBeforeCallback) {
this._text = newVal;
this.zone.run(() => {
this.textChange.emit(newVal);
this.textChanged.emit(newVal);
});
}
else {
if (this.timeoutSaving != null) {
clearTimeout(this.timeoutSaving);
}
this.timeoutSaving = setTimeout(() => {
this._text = newVal;
this.zone.run(() => {
this.textChange.emit(newVal);
this.textChanged.emit(newVal);
});
this.timeoutSaving = null;
}, this._durationBeforeCallback);
}
this.oldText = newVal;
}
set options(options) {
this._options = options;
this.editor.setOptions(options || {});
}
set readOnly(readOnly) {
this._readOnly = readOnly;
this.editor.setReadOnly(readOnly);
}
set theme(theme) {
this._theme = theme;
this.editor.setTheme(`ace/theme/${theme}`);
}
set mode(mode) {
this.setMode(mode);
}
setMode(mode) {
this._mode = mode;
if (typeof this._mode === 'object') {
this.editor.getSession().setMode(this._mode);
}
else {
this.editor.getSession().setMode(`ace/mode/${this._mode}`);
}
}
get text() {
return this._text;
}
set text(text) {
this.setText(text);
}
setText(text) {
if (this._text !== text) {
if (text === null || text === undefined) {
text = "";
}
if (this._autoUpdateContent === true) {
this._text = text;
this.editor.setValue(text);
this.editor.clearSelection();
}
}
}
set autoUpdateContent(status) {
this._autoUpdateContent = status;
}
set durationBeforeCallback(num) {
this.setDurationBeforeCallback(num);
}
setDurationBeforeCallback(num) {
this._durationBeforeCallback = num;
}
get aceEditor() {
return this.editor;
}
}
AceEditorDirective.ɵfac = function AceEditorDirective_Factory(t) { return new (t || AceEditorDirective)(i0["ɵɵdirectiveInject"](i0.ElementRef), i0["ɵɵdirectiveInject"](i0.NgZone)); };
AceEditorDirective.ɵdir = i0["ɵɵdefineDirective"]({ type: AceEditorDirective, selectors: [["", "ace-editor", ""]], inputs: { options: "options", readOnly: "readOnly", theme: "theme", mode: "mode", text: "text", autoUpdateContent: "autoUpdateContent", durationBeforeCallback: "durationBeforeCallback" }, outputs: { textChanged: "textChanged", textChange: "textChange" } });

class AceEditorComponent {
constructor(elementRef, zone) {
this.zone = zone;
this.textChanged = new i0.EventEmitter();
this.textChange = new i0.EventEmitter();
this.style = {};
this._options = {};
this._readOnly = false;
this._theme = "monokai";
this._mode = "html";
this._autoUpdateContent = true;
this._durationBeforeCallback = 0;
this._text = "";
this._onChange = (_) => {
};
this._onTouched = () => {
};
let el = elementRef.nativeElement;
this.zone.runOutsideAngular(() => {
this._editor = ace['edit'](el);
});
this._editor.$blockScrolling = Infinity;
}
ngOnInit() {
this.init();
this.initEvents();
}
ngOnDestroy() {
this._editor.destroy();
}
init() {
this.setOptions(this._options || {});
this.setTheme(this._theme);
this.setMode(this._mode);
this.setReadOnly(this._readOnly);
}
initEvents() {
this._editor.on('change', () => this.updateText());
this._editor.on('paste', () => this.updateText());
}
updateText() {
let newVal = this._editor.getValue();
if (newVal === this.oldText) {
return;
}
if (!this._durationBeforeCallback) {
this._text = newVal;
this.zone.run(() => {
this.textChange.emit(newVal);
this.textChanged.emit(newVal);
});
this._onChange(newVal);
}
else {
if (this.timeoutSaving) {
clearTimeout(this.timeoutSaving);
}
this.timeoutSaving = setTimeout(() => {
this._text = newVal;
this.zone.run(() => {
this.textChange.emit(newVal);
this.textChanged.emit(newVal);
});
this.timeoutSaving = null;
}, this._durationBeforeCallback);
}
this.oldText = newVal;
}
set options(options) {
this.setOptions(options);
}
setOptions(options) {
this._options = options;
this._editor.setOptions(options || {});
}
set readOnly(readOnly) {
this.setReadOnly(readOnly);
}
setReadOnly(readOnly) {
this._readOnly = readOnly;
this._editor.setReadOnly(readOnly);
}
set theme(theme) {
this.setTheme(theme);
}
setTheme(theme) {
this._theme = theme;
this._editor.setTheme(`ace/theme/${theme}`);
}
set mode(mode) {
this.setMode(mode);
}
setMode(mode) {
this._mode = mode;
if (typeof this._mode === 'object') {
this._editor.getSession().setMode(this._mode);
}
else {
this._editor.getSession().setMode(`ace/mode/${this._mode}`);
}
}
get value() {
return this.text;
}
set value(value) {
this.setText(value);
}
writeValue(value) {
this.setText(value);
}
registerOnChange(fn) {
this._onChange = fn;
}
registerOnTouched(fn) {
this._onTouched = fn;
}
get text() {
return this._text;
}
set text(text) {
this.setText(text);
}
setText(text) {
if (text === null || text === undefined) {
text = "";
}
if (this._text !== text && this._autoUpdateContent === true) {
this._text = text;
this._editor.setValue(text);
this._onChange(text);
this._editor.clearSelection();
}
}
set autoUpdateContent(status) {
this.setAutoUpdateContent(status);
}
setAutoUpdateContent(status) {
this._autoUpdateContent = status;
}
set durationBeforeCallback(num) {
this.setDurationBeforeCallback(num);
}
setDurationBeforeCallback(num) {
this._durationBeforeCallback = num;
}
getEditor() {
return this._editor;
}
}
AceEditorComponent.ɵfac = function AceEditorComponent_Factory(t) { return new (t || AceEditorComponent)(i0["ɵɵdirectiveInject"](i0.ElementRef), i0["ɵɵdirectiveInject"](i0.NgZone)); };
AceEditorComponent.ɵcmp = i0["ɵɵdefineComponent"]({ type: AceEditorComponent, selectors: [["ace-editor"]], inputs: { style: "style", options: "options", readOnly: "readOnly", theme: "theme", mode: "mode", value: "value", text: "text", autoUpdateContent: "autoUpdateContent", durationBeforeCallback: "durationBeforeCallback" }, outputs: { textChanged: "textChanged", textChange: "textChange" }, features: [i0["ɵɵProvidersFeature"]([{
provide: forms.NG_VALUE_ACCESSOR,
useExisting: i0.forwardRef(() => AceEditorComponent),
multi: true
}])], decls: 0, vars: 0, template: function AceEditorComponent_Template(rf, ctx) { }, styles: ["[_nghost-%COMP%] { display:block;width:100%; }"] });

class AceEditorModule {
}
AceEditorModule.ɵmod = i0["ɵɵdefineNgModule"]({ type: AceEditorModule });
AceEditorModule.ɵinj = i0["ɵɵdefineInjector"]({ factory: function AceEditorModule_Factory(t) { return new (t || AceEditorModule)(); }, providers: [], imports: [[]] });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0["ɵɵsetNgModuleScope"](AceEditorModule, { declarations: [AceEditorComponent,
AceEditorDirective], exports: [AceEditorComponent,
AceEditorDirective] }); })();

exports.AceEditorComponent = AceEditorComponent;
exports.AceEditorDirective = AceEditorDirective;
exports.AceEditorModule = AceEditorModule;

Object.defineProperty(exports, '__esModule', { value: true });

})));
25 changes: 15 additions & 10 deletions dist/src/component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { EventEmitter, ElementRef, OnInit, OnDestroy, NgZone } from "@angular/co
import { ControlValueAccessor } from "@angular/forms";
import "brace";
import "brace/theme/monokai";
import * as i0 from "@angular/core";
export declare class AceEditorComponent implements ControlValueAccessor, OnInit, OnDestroy {
private zone;
textChanged: EventEmitter<{}>;
textChange: EventEmitter<{}>;
textChanged: EventEmitter<any>;
textChange: EventEmitter<any>;
style: any;
_options: any;
_readOnly: boolean;
Expand All @@ -23,25 +24,29 @@ export declare class AceEditorComponent implements ControlValueAccessor, OnInit,
init(): void;
initEvents(): void;
updateText(): void;
options: any;
set options(options: any);
setOptions(options: any): void;
readOnly: any;
set readOnly(readOnly: any);
setReadOnly(readOnly: any): void;
theme: any;
set theme(theme: any);
setTheme(theme: any): void;
mode: any;
set mode(mode: any);
setMode(mode: any): void;
value: string;
get value(): string;
set value(value: string);
writeValue(value: any): void;
private _onChange;
registerOnChange(fn: any): void;
private _onTouched;
registerOnTouched(fn: any): void;
text: string;
get text(): string;
set text(text: string);
setText(text: any): void;
autoUpdateContent: any;
set autoUpdateContent(status: any);
setAutoUpdateContent(status: any): void;
durationBeforeCallback: number;
set durationBeforeCallback(num: number);
setDurationBeforeCallback(num: number): void;
getEditor(): any;
static ɵfac: i0.ɵɵFactoryDef<AceEditorComponent>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<AceEditorComponent, "ace-editor", never, { "style": "style"; "options": "options"; "readOnly": "readOnly"; "theme": "theme"; "mode": "mode"; "value": "value"; "text": "text"; "autoUpdateContent": "autoUpdateContent"; "durationBeforeCallback": "durationBeforeCallback"; }, { "textChanged": "textChanged"; "textChange": "textChange"; }, never>;
}
Loading