Skip to content

Commit

Permalink
Add support for mode event
Browse files Browse the repository at this point in the history
  • Loading branch information
mihilion committed Aug 2, 2023
1 parent 0e2fb59 commit 6c27494
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ckeditor/ckeditor.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,17 @@ describe( 'CKEditorComponent', () => {
expect( spy ).toHaveBeenCalledTimes( 1 );
} );

it( 'mode should emit component mode', () => {
fixture.detectChanges();

const spy = jasmine.createSpy();
component.mode.subscribe( spy );

component.instance.fire( 'mode' );

expect( spy ).toHaveBeenCalledTimes( 1 );
} );

it( 'paste should emit component paste', () => {
fixture.detectChanges();

Expand Down
13 changes: 13 additions & 0 deletions src/ckeditor/ckeditor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ export class CKEditorComponent implements AfterViewInit, OnDestroy, ControlValue
*/
@Output() blur = new EventEmitter<CKEditor4.EventInfo>();

/**
* Fires when the native mode event occurs. It corresponds with the `editor#mode`
* https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#event-mode
* event.
*/
@Output() mode = new EventEmitter<CKEditor4.EventInfo>();

/**
* A callback executed when the content of the editor changes. Part of the
* `ControlValueAccessor` (https://angular.io/api/forms/ControlValueAccessor) interface.
Expand Down Expand Up @@ -417,6 +424,12 @@ export class CKEditorComponent implements AfterViewInit, OnDestroy, ControlValue
} );
} );

editor.on( 'mode', evt => {
this.ngZone.run( () => {
this.mode.emit( evt );
} );
} );

editor.on( 'dataReady', this.propagateChange, this );

if ( this.instance.undoManager ) {
Expand Down

0 comments on commit 6c27494

Please sign in to comment.