Skip to content

Commit

Permalink
Use a plugin that would crash the editor.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Oct 9, 2023
1 parent 74b9bbb commit e1a7c8c
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/app/initialization-crash/initialization-crash.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, ViewChild } from '@angular/core';
import { CKEditorComponent } from 'src/ckeditor';
import AngularEditor from 'ckeditor/build/ckeditor';
import type { ContextWatchdog } from '@ckeditor/ckeditor5-watchdog';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';

@Component( {
selector: 'app-initialization-crash',
Expand All @@ -12,15 +13,6 @@ export class InitializationCrashComponent {
public Editor = AngularEditor;
public EditorWatchdog = AngularEditor;

public constructor() {
( this.Editor as any ).create = () => {
throw 'init failure';
};
( this.EditorWatchdog as any ).create = () => {
throw 'init failure';
};
}

@ViewChild( CKEditorComponent ) public ckeditor?: CKEditorComponent;

public config: any;
Expand All @@ -37,6 +29,14 @@ export class InitializationCrashComponent {
};

this.config = {
extraPlugins: [
function( editor: any ) {
editor.data.on( 'init', () => {
// eslint-disable-next-line
throw new CKEditorError( 'example-error', editor );
} );
}
],
collaboration: {
channelId: 'foobar-baz'
}
Expand All @@ -51,12 +51,12 @@ export class InitializationCrashComponent {
}

public onError( error: any ): void {
console.error( 'Editor without watchdog crashed - catched', error );
console.error( 'Editor without watchdog threw an error which was caught', error );
this.errorOccurred = true;
}

public onErrorWatchdog( error: any ): void {
console.error( 'Editor with watchdog crashed - catched', error );
console.error( 'Editor with watchdog threw an error which was caught', error );
this.errorOccurredWatchdog = true;
}
}

0 comments on commit e1a7c8c

Please sign in to comment.