Skip to content
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

The EditorWatchdog, ContextWatchdog, and Context classes are now exposed as static fields of the Editor class. #16415

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ckeditor5-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"dependencies": {
"@ckeditor/ckeditor5-engine": "41.4.2",
"@ckeditor/ckeditor5-utils": "41.4.2",
"@ckeditor/ckeditor5-watchdog": "41.4.2",
filipsobol marked this conversation as resolved.
Show resolved Hide resolved
"lodash-es": "4.17.21"
},
"devDependencies": {
Expand Down
22 changes: 22 additions & 0 deletions packages/ckeditor5-core/src/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from '@ckeditor/ckeditor5-engine';

import type { EditorUI } from '@ckeditor/ckeditor5-ui';
import { ContextWatchdog, EditorWatchdog } from '@ckeditor/ckeditor5-watchdog';

import Context from '../context.js';
import PluginCollection from '../plugincollection.js';
Expand Down Expand Up @@ -642,6 +643,27 @@ export default abstract class Editor extends /* #__PURE__ */ ObservableMixin() {
public static create( ...args: Array<unknown> ): void { // eslint-disable-line @typescript-eslint/no-unused-vars
throw new Error( 'This is an abstract method.' );
}

/**
* The {@link module:core/context~Context} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static Context = Context;

/**
* The {@link module:watchdog/editorwatchdog~EditorWatchdog} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static EditorWatchdog = EditorWatchdog;

/**
* The {@link module:watchdog/contextwatchdog~ContextWatchdog} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static ContextWatchdog = ContextWatchdog;
}

/**
Expand Down
16 changes: 16 additions & 0 deletions packages/ckeditor5-core/tests/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror.js';
import testUtils from '../../tests/_utils/utils.js';
import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js';
import Accessibility from '../../src/accessibility.js';
import EditorWatchdog from '@ckeditor/ckeditor5-watchdog/src/editorwatchdog.js';
import ContextWatchdog from '@ckeditor/ckeditor5-watchdog/src/contextwatchdog.js';

class TestEditor extends Editor {
static create( config ) {
Expand Down Expand Up @@ -1347,6 +1349,20 @@ describe( 'Editor', () => {
} );
} );
} );

describe( 'static fields', () => {
it( 'Editor.Context', () => {
expect( Editor.Context ).to.equal( Context );
} );

it( 'Editor.EditorWatchdog', () => {
expect( Editor.EditorWatchdog ).to.equal( EditorWatchdog );
} );

it( 'Editor.ContextWatchdog', () => {
expect( Editor.ContextWatchdog ).to.equal( ContextWatchdog );
} );
} );
} );

function getPlugins( editor ) {
Expand Down
24 changes: 0 additions & 24 deletions packages/ckeditor5-editor-balloon/src/ballooneditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import {
Editor,
Context,
ElementApiMixin,
attachToForm,
secureSourceElement,
Expand All @@ -20,8 +19,6 @@ import {
import { BalloonToolbar } from 'ckeditor5/src/ui.js';
import { CKEditorError, getDataFromElement } from 'ckeditor5/src/utils.js';

import { ContextWatchdog, EditorWatchdog } from 'ckeditor5/src/watchdog.js';

import BalloonEditorUI from './ballooneditorui.js';
import BalloonEditorUIView from './ballooneditoruiview.js';

Expand Down Expand Up @@ -219,27 +216,6 @@ export default class BalloonEditor extends /* #__PURE__ */ ElementApiMixin( Edit
);
} );
}

/**
* The {@link module:core/context~Context} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static Context = Context;

/**
* The {@link module:watchdog/editorwatchdog~EditorWatchdog} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static EditorWatchdog = EditorWatchdog;

/**
* The {@link module:watchdog/contextwatchdog~ContextWatchdog} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static ContextWatchdog = ContextWatchdog;
}

function getInitialData( sourceElementOrData: HTMLElement | string ): string {
Expand Down
24 changes: 0 additions & 24 deletions packages/ckeditor5-editor-classic/src/classiceditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ import ClassicEditorUIView from './classiceditoruiview.js';

import {
Editor,
Context,
ElementApiMixin,
attachToForm,
type EditorConfig,
type EditorReadyEvent
} from 'ckeditor5/src/core.js';
import { getDataFromElement, CKEditorError } from 'ckeditor5/src/utils.js';

import { ContextWatchdog, EditorWatchdog } from 'ckeditor5/src/watchdog.js';

import { isElement as _isElement } from 'lodash-es';

/**
Expand Down Expand Up @@ -203,27 +200,6 @@ export default class ClassicEditor extends /* #__PURE__ */ ElementApiMixin( Edit
);
} );
}

/**
* The {@link module:core/context~Context} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static Context = Context;

/**
* The {@link module:watchdog/editorwatchdog~EditorWatchdog} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static EditorWatchdog = EditorWatchdog;

/**
* The {@link module:watchdog/contextwatchdog~ContextWatchdog} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static ContextWatchdog = ContextWatchdog;
}

function getInitialData( sourceElementOrData: HTMLElement | string ): string {
Expand Down
24 changes: 0 additions & 24 deletions packages/ckeditor5-editor-decoupled/src/decouplededitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import {
Editor,
Context,
ElementApiMixin,
secureSourceElement,
type EditorConfig,
Expand All @@ -20,8 +19,6 @@ import {
getDataFromElement
} from 'ckeditor5/src/utils.js';

import { ContextWatchdog, EditorWatchdog } from 'ckeditor5/src/watchdog.js';

import DecoupledEditorUI from './decouplededitorui.js';
import DecoupledEditorUIView from './decouplededitoruiview.js';

Expand Down Expand Up @@ -245,27 +242,6 @@ export default class DecoupledEditor extends /* #__PURE__ */ ElementApiMixin( Ed
);
} );
}

/**
* The {@link module:core/context~Context} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static Context = Context;

/**
* The {@link module:watchdog/editorwatchdog~EditorWatchdog} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static EditorWatchdog = EditorWatchdog;

/**
* The {@link module:watchdog/contextwatchdog~ContextWatchdog} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static ContextWatchdog = ContextWatchdog;
}

function getInitialData( sourceElementOrData: HTMLElement | string ): string {
Expand Down
24 changes: 0 additions & 24 deletions packages/ckeditor5-editor-inline/src/inlineeditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import {
Editor,
Context,
ElementApiMixin,
attachToForm,
secureSourceElement,
Expand All @@ -18,8 +17,6 @@ import {
} from 'ckeditor5/src/core.js';
import { getDataFromElement, CKEditorError } from 'ckeditor5/src/utils.js';

import { ContextWatchdog, EditorWatchdog } from 'ckeditor5/src/watchdog.js';

import InlineEditorUI from './inlineeditorui.js';
import InlineEditorUIView from './inlineeditoruiview.js';

Expand Down Expand Up @@ -206,27 +203,6 @@ export default class InlineEditor extends /* #__PURE__ */ ElementApiMixin( Edito
);
} );
}

/**
* The {@link module:core/context~Context} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static Context = Context;

/**
* The {@link module:watchdog/editorwatchdog~EditorWatchdog} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static EditorWatchdog = EditorWatchdog;

/**
* The {@link module:watchdog/contextwatchdog~ContextWatchdog} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static ContextWatchdog = ContextWatchdog;
}

function getInitialData( sourceElementOrData: HTMLElement | string ): string {
Expand Down
24 changes: 0 additions & 24 deletions packages/ckeditor5-editor-multi-root/src/multirooteditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import {
Editor,
Context,
secureSourceElement,
type EditorConfig,
type EditorReadyEvent
Expand All @@ -24,8 +23,6 @@ import {
type DecoratedMethodEvent
} from 'ckeditor5/src/utils.js';

import { ContextWatchdog, EditorWatchdog } from 'ckeditor5/src/watchdog.js';

import MultiRootEditorUI from './multirooteditorui.js';
import MultiRootEditorUIView from './multirooteditoruiview.js';

Expand Down Expand Up @@ -886,27 +883,6 @@ export default class MultiRootEditor extends Editor {
} );
}

/**
* The {@link module:core/context~Context} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static Context = Context;

/**
* The {@link module:watchdog/editorwatchdog~EditorWatchdog} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static EditorWatchdog = EditorWatchdog;

/**
* The {@link module:watchdog/contextwatchdog~ContextWatchdog} class.
*
* Exposed as static editor field for easier access in editor builds.
*/
public static ContextWatchdog = ContextWatchdog;

/**
* @internal
*/
Expand Down