-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Watchdog support for the Context feature #6079
Comments
After some internal talks, we changed the API to the one which can be later used in integrations as well. Usage proposal: const mainWatchdog = ContextWatchdog.for( Context, contextOptions );
mainWatchdog.add( {
editor1: {
type: 'editor',
creator: () => ClassicTestEditor.create( element1, config1 ),
},
annotatedInput: {
type: 'contextItem',
creator: () => { }
}
} );
mainWatchdog.add( {
editor2: {
type: 'editor',
creator: () => ClassicTestEditor.create( element2, config2 ),
},
} );
await mainWatchdog.getReady();
mainWatchdog.remove( [ 'editor1', 'editor2' ] );
await mainWatchdog.getReady();
await mainWatchdog.destroy(); So here's the API: // Initialization
const contextWatchdog = ContextWatchdog.for( Context, contextOptions );
// Create items and initialize error handling in them:
contextWatchdog.add( itemConfigs: Object<string, EditorConfig | ContextItemConfig> ): void;
interface EditorConfig {
type: 'editor';
creator: () => Promise<Editor>;
destructor?: ( editor: Editor ) => Promise<void>;
}
interface ContextItemConfig {
type: 'contextItem';
creator: () => Promise<ContextItem>;
destructor?: ( contextItem: ContextItem ) => Promise<void>;
}
// Destroy given items and stop watching them:
contextWatchdog.remove( items: string[] ): void;
// Destroy watchdog with all items:
contextWatchdog.destroy();
// After this action all future `contextWatchdog.add()` should throw. Angular integration: <ckeditor
[editor]="ClassicEditor"
[(ngModel)]="model1"
[config]="config1"
[watchdog]="mainWatchdog">
</ckeditor>
<ckeditor
[editor]="InlineEditor"
[config]="config2"
[data]="data2"
[watchdog]="mainWatchdog">
</ckeditor> This way the Angular integration component ( This also means that |
The
|
getReady => waitForReady? |
After some initial testing of this API I found that the During the editor restart, we need to be able to update the editor configuration or data and call the {
type: 'editor'
creator: ClassicTestEditor.create.bind( ClassicTestEditor ),
creationArguments: [ element, config ],
} Alternatively, the {
type: 'editor'
creator: ClassicTestEditor.create.bind( ClassicTestEditor ),
config: {},
sourceElementOrData: '<p>foo</p>'
} |
Feature: Introduced `ContextWatchdog` which is a watchdog for `Context`. Closes ckeditor/ckeditor5#6079. Closes ckeditor/ckeditor5#6042. Closes ckeditor/ckeditor5#4696. BREAKING CHANGE: The `Watchdog` class was renamed to `EditorWatchdog` and is available in `src/editorwatchdog.js`. BREAKING CHANGE: The `EditorWatchdog.for()` method was removed in favor of the constructor. BREAKING CHANGE: The `EditorWatchdog#constructor()` API changed, now the `EditorWatchdog` accepts the editor class as the first argument and the watchdog configuration as the second argument. The `EditorWatchdog` editor creator now defaults to `( sourceElementOrData, config ) => Editor.create( sourceElementOrData, config )`.
📝 Provide a description of the new feature
A follow-up to #5891.
With introducing the Context feature the Watchdog should work in the following situations:
These cases can't be solved with the current Watchdog API or can be done with a lot of boilerplate code that should be hidden from the user.
I'm proposing the following API that introduces the
registerSubWatchdogs()
method that will handle these cases:What's also important here is that with the special method like
registerSubWatchdogs()
:The text was updated successfully, but these errors were encountered: