瀏覽代碼

Added support for other Editor signatures. Changed ctx to context.

Maciej Bukowski 6 年之前
父節點
當前提交
2b08b4cf69
共有 2 個文件被更改,包括 11 次插入9 次删除
  1. 7 5
      packages/ckeditor5-watchdog/src/watchdog.js
  2. 4 4
      packages/ckeditor5-watchdog/tests/watchdog.js

+ 7 - 5
packages/ckeditor5-watchdog/src/watchdog.js

@@ -182,6 +182,10 @@ export default class Watchdog {
 		return Promise.resolve()
 			.then( () => this.destroy() )
 			.then( () => {
+				if ( typeof this._elementOrData === 'string' ) {
+					return this.create( this._data, this._config );
+				}
+
 				const updatedConfig = Object.assign( {}, this._config, {
 					initialData: this._data
 				} );
@@ -210,7 +214,6 @@ export default class Watchdog {
 			 */
 			throw new CKEditorError(
 				'watchdog-creator-not-defined: The watchdog creator is not defined, define it using `watchdog.setCreator()`.',
-				undefined,
 				{}
 			);
 		}
@@ -223,7 +226,6 @@ export default class Watchdog {
 			 */
 			throw new CKEditorError(
 				'watchdog-destructor-not-defined: The watchdog destructor is not defined, define it using `watchdog.setDestructor()`',
-				undefined,
 				{}
 			);
 		}
@@ -306,7 +308,7 @@ export default class Watchdog {
 			return;
 		}
 
-		if ( !event.error.ctx ) {
+		if ( !event.error.context ) {
 			console.error( 'The error is missing its context and Watchdog cannot restart the proper editor.' );
 
 			return;
@@ -334,8 +336,8 @@ export default class Watchdog {
 	 */
 	_isErrorComingFromThisEditor( error ) {
 		return (
-			areElementsConnected( this._editor, error.ctx ) ||
-			areElementsConnected( error.ctx, this._editor )
+			areElementsConnected( this._editor, error.context ) ||
+			areElementsConnected( error.context, this._editor )
 		);
 	}
 

+ 4 - 4
packages/ckeditor5-watchdog/tests/watchdog.js

@@ -286,7 +286,7 @@ describe( 'Watchdog', () => {
 			} );
 		} );
 
-		it( 'Watchdog should intercept editor errors and restart the editor if the editor can be found from the ctx', () => {
+		it( 'Watchdog should intercept editor errors and restart the editor if the editor can be found from the context', () => {
 			const watchdog = new Watchdog();
 
 			watchdog.setCreator( ( el, config ) => FakeEditor.create( el, config ) );
@@ -309,7 +309,7 @@ describe( 'Watchdog', () => {
 			} );
 		} );
 
-		it( 'Watchdog should intercept editor errors and restart the editor if the editor can be found from the ctx #2', () => {
+		it( 'Watchdog should intercept editor errors and restart the editor if the editor can be found from the context #2', () => {
 			const watchdog = new Watchdog();
 
 			watchdog.setCreator( ( el, config ) => FakeEditor.create( el, config ) );
@@ -660,6 +660,6 @@ class FakeEditor extends VirtualTestEditor {
 	}
 }
 
-function throwCKEditorError( name, ctx ) {
-	throw new CKEditorError( name, undefined, ctx );
+function throwCKEditorError( name, context ) {
+	throw new CKEditorError( name, context );
 }