Skip to content

Commit

Permalink
feat: adds codeMirrorLoaded that fires after codeMirror set (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
sp90 authored Jan 31, 2023
1 parent 176e769 commit 1c7d51d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ All Inputs of [ngModel](https://angular.io/api/forms/NgModel#inputs) and

All outputs of [ngModel](https://angular.io/api/forms/NgModel#outputs) and

- `codeMirrorLoaded` - called when codeMirror instance is initiated
- `focusChange` - called when the editor is focused or loses focus
- `scroll` - called when the editor is scrolled (not wrapped inside angular change detection must manually trigger change detection or run inside ngzone)
- `cursorActivity` - called when the text cursor is moved
Expand Down
3 changes: 3 additions & 0 deletions src/lib/codemirror.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export class CodemirrorComponent
/* called when file(s) are dropped */
// eslint-disable-next-line @angular-eslint/no-output-native
@Output() drop = new EventEmitter<[Editor, DragEvent]>();
/* called when codeMirror instance is initiated on the component */
@Output() codeMirrorLoaded = new EventEmitter<CodemirrorComponent>();
@ViewChild('ref') ref!: ElementRef<HTMLTextAreaElement>;
value = '';
disabled = false;
Expand Down Expand Up @@ -126,6 +128,7 @@ export class CodemirrorComponent
this._ngZone.run(() => this.dropFiles(cm, e));
});
this.codeMirror.setValue(this.value);
this.codeMirrorLoaded.emit(this);
});
}
ngDoCheck() {
Expand Down

0 comments on commit 1c7d51d

Please sign in to comment.