diff --git a/package.json b/package.json index d1d5caf..e8d6682 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@angular/platform-browser": "^2.1.0 || ^4.0.0", "@angular/platform-server": "^2.1.0 || ^4.0.0", "@types/ckeditor": "0.0.33", + "@types/codemirror": "0.0.40", "@types/core-js": "^0.9.34", "@types/node": "^6.0.45", "rxjs": "^5.2.0", diff --git a/src/codemirror.component.ts b/src/codemirror.component.ts index 8af1c93..81fb822 100644 --- a/src/codemirror.component.ts +++ b/src/codemirror.component.ts @@ -12,6 +12,7 @@ import { } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import * as CodeMirror from 'codemirror'; +import {InitEvent} from "./init_event"; /** * CodeMirror component @@ -35,10 +36,11 @@ export class CodemirrorComponent implements AfterViewInit, OnDestroy { @Output() change = new EventEmitter(); @Output() focus = new EventEmitter(); @Output() blur = new EventEmitter(); + @Output() init = new EventEmitter(); @ViewChild('host') host; - @Output() instance = null; + instance: CodeMirror.Editor = null; _value = ''; @@ -89,6 +91,8 @@ export class CodemirrorComponent implements AfterViewInit, OnDestroy { this.instance.on('blur', () => { this.blur.emit(); }); + + this.init.emit(new InitEvent(this.instance)); } /** diff --git a/src/init_event.ts b/src/init_event.ts new file mode 100644 index 0000000..4850a2e --- /dev/null +++ b/src/init_event.ts @@ -0,0 +1,10 @@ +import * as CodeMirror from "codemirror"; + +export class InitEvent { + codeMirrorInstance: CodeMirror.Editor + + + constructor(codeMirrorInstance: CodeMirror.Editor) { + this.codeMirrorInstance = codeMirrorInstance; + } +} \ No newline at end of file