Skip to content

Commit

Permalink
Merge pull request #12775 from ckeditor/ck/12709-typedoc-utils
Browse files Browse the repository at this point in the history
Internal (utils): Cleans up API doc in ckeditor5-utils. Closes #12709.

Other (utils): Removed I generic parameter from Collection. See #12763.
  • Loading branch information
arkflpc authored Nov 14, 2022
2 parents ec729c0 + 21213e7 commit b27b23f
Show file tree
Hide file tree
Showing 110 changed files with 2,219 additions and 1,979 deletions.
4 changes: 1 addition & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ module.exports = {
' * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license',
' */'
]
} ],
// TODO: Remove after `eslint-config-ckeditor5` update.
'new-cap': 'off'
} ]
},
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"coveralls": "^3.1.0",
"css-loader": "^5.2.7",
"eslint": "^7.19.0",
"eslint-config-ckeditor5": "^4.0.2",
"eslint-config-ckeditor5": "^4.1.1",
"glob": "^7.1.6",
"http-server": "^14.1.1",
"husky": "^4.2.5",
Expand Down
5 changes: 2 additions & 3 deletions packages/ckeditor5-core/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*/

import type EventInfo from '@ckeditor/ckeditor5-utils/src/eventinfo';
import {
Observable,
import ObservableMixin, {
type ObservableChangeEvent,
type DecoratedMethodEvent,
type ObservableSetEvent
Expand All @@ -31,7 +30,7 @@ import type Editor from './editor/editor';
*
* @mixes module:utils/observablemixin~ObservableMixin
*/
export default class Command extends Observable {
export default class Command extends ObservableMixin() {
public readonly editor: Editor;

declare public value: unknown;
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-core/src/contextplugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @module core/contextplugin
*/

import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
import type Editor from './editor/editor';
import type Context from './context';
import type { PluginInterface } from './plugin';
Expand All @@ -29,7 +29,7 @@ import type { PluginInterface } from './plugin';
* @implements module:core/plugin~PluginInterface
* @mixes module:utils/observablemixin~ObservableMixin
*/
export default class ContextPlugin extends Observable implements PluginInterface {
export default class ContextPlugin extends ObservableMixin() implements PluginInterface {
public readonly context: Context | Editor;

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-core/src/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import EditingKeystrokeHandler from '../editingkeystrokehandler';
import type { LoadedPlugins, PluginConstructor } from '../plugin';
import type EditorUI from './editorui';
import type { EditorConfig } from './editorconfig';
import { type ObservableChangeEvent, Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
import ObservableMixin, { type ObservableChangeEvent } from '@ckeditor/ckeditor5-utils/src/observablemixin';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import { StylesProcessor } from '@ckeditor/ckeditor5-engine/src/view/stylesmap';
import type { Locale, LocaleTranslate } from '@ckeditor/ckeditor5-utils';
Expand All @@ -46,7 +46,7 @@ import type { Locale, LocaleTranslate } from '@ckeditor/ckeditor5-utils';
* @abstract
* @mixes module:utils/observablemixin~ObservableMixin
*/
export default abstract class Editor extends Observable {
export default abstract class Editor extends ObservableMixin() {
public readonly commands: CommandCollection;
public readonly config: Config<EditorConfig>;
public readonly conversion: Conversion;
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-core/src/editor/editorui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ComponentFactory from '@ckeditor/ckeditor5-ui/src/componentfactory';
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
import TooltipManager from '@ckeditor/ckeditor5-ui/src/tooltipmanager';

import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
import isVisible from '@ckeditor/ckeditor5-utils/src/dom/isvisible';

import type Editor from './editor';
Expand All @@ -27,7 +27,7 @@ import type EditorUIView from '@ckeditor/ckeditor5-ui/src/editorui/editoruiview'
*
* @mixes module:utils/emittermixin~EmitterMixin
*/
export default abstract class EditorUI extends Observable {
export default abstract class EditorUI extends ObservableMixin() {
public readonly editor: Editor;
public readonly componentFactory: ComponentFactory;
public readonly focusTracker: FocusTracker;
Expand Down
6 changes: 3 additions & 3 deletions packages/ckeditor5-core/src/pendingactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import ContextPlugin from './contextplugin';
import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
import ObservableMixin, { type Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
import Collection, { type CollectionAddEvent, type CollectionRemoveEvent } from '@ckeditor/ckeditor5-utils/src/collection';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';

Expand Down Expand Up @@ -55,7 +55,7 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
export default class PendingActions extends ContextPlugin implements Iterable<PendingAction> {
declare public hasAny: boolean;

private _actions!: Collection<PendingAction & { _id?: string }, '_id'>;
private _actions!: Collection<PendingAction>;

/**
* @inheritDoc
Expand Down Expand Up @@ -106,7 +106,7 @@ export default class PendingActions extends ContextPlugin implements Iterable<Pe
throw new CKEditorError( 'pendingactions-add-invalid-message', this );
}

const action = new Observable() as PendingAction;
const action = new ( ObservableMixin() )() as PendingAction;

action.set( 'message', message );
this._actions.add( action );
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-core/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @module core/plugin
*/

import { Observable, type ObservableSetEvent } from '@ckeditor/ckeditor5-utils/src/observablemixin';
import ObservableMixin, { type ObservableSetEvent } from '@ckeditor/ckeditor5-utils/src/observablemixin';
import type EventInfo from '@ckeditor/ckeditor5-utils/src/eventinfo';
import type Editor from './editor/editor';

Expand All @@ -19,7 +19,7 @@ import type Editor from './editor/editor';
* @implements module:core/plugin~PluginInterface
* @mixes module:utils/observablemixin~ObservableMixin
*/
export default class Plugin extends Observable implements PluginInterface {
export default class Plugin extends ObservableMixin() implements PluginInterface {
public readonly editor: Editor;

public declare isEnabled: boolean;
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-core/src/plugincollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
*/

import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
import type { LoadedPlugins, PluginConstructor, PluginInterface } from './plugin';

/**
* Manages a list of CKEditor plugins, including loading, resolving dependencies and initialization.
*
* @mixes module:utils/emittermixin~EmitterMixin
*/
export default class PluginCollection<TContext extends object> extends Emitter {
export default class PluginCollection<TContext extends object> extends EmitterMixin() {
private _context: TContext;
private _plugins: Map<PluginConstructor<TContext> | string, PluginInterface>;
private _availablePlugins: Map<string, PluginConstructor<TContext>>;
Expand Down
1 change: 0 additions & 1 deletion packages/ckeditor5-editor-inline/src/inlineeditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import InlineEditorUIView from './inlineeditoruiview';
* Read more about initializing the editor from source or as a build in
* {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`}.
*/
// eslint-disable-next-line new-cap
export default class InlineEditor extends DataApiMixin( ElementApiMixin( Editor ) ) {
/**
* @inheritDoc
Expand Down
12 changes: 6 additions & 6 deletions packages/ckeditor5-engine/src/controller/datacontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* @module engine/controller/datacontroller
*/

import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';

import Mapper from '../conversion/mapper';

Expand Down Expand Up @@ -60,7 +60,7 @@ import type DataProcessor from '../dataprocessor/dataprocessor';
*
* @mixes module:utils/emittermixin~EmitterMixin
*/
export default class DataController extends Emitter {
export default class DataController extends EmitterMixin() {
public readonly model: Model;
public readonly mapper: Mapper;
public readonly downcastDispatcher: DowncastDispatcher;
Expand Down Expand Up @@ -173,9 +173,9 @@ export default class DataController extends Emitter {
this.upcastDispatcher.on<UpcastElementEvent>( 'element', convertToModelFragment(), { priority: 'lowest' } );
this.upcastDispatcher.on<UpcastDocumentFragmentEvent>( 'documentFragment', convertToModelFragment(), { priority: 'lowest' } );

Observable.prototype.decorate.call( this, 'init' as any );
Observable.prototype.decorate.call( this, 'set' as any );
Observable.prototype.decorate.call( this, 'get' as any );
ObservableMixin().prototype.decorate.call( this, 'init' as any );
ObservableMixin().prototype.decorate.call( this, 'set' as any );
ObservableMixin().prototype.decorate.call( this, 'get' as any );

// Fire the `ready` event when the initialization has completed. Such low-level listener offers the possibility
// to plug into the initialization pipeline without interrupting the initialization flow.
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-engine/src/controller/editingcontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
remove
} from '../conversion/downcasthelpers';

import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import { convertSelectionChange } from '../conversion/upcasthelpers';

Expand All @@ -46,7 +46,7 @@ import type { ViewDocumentSelectionEvent } from '../view/observer/selectionobser
*
* @mixes module:utils/observablemixin~ObservableMixin
*/
export default class EditingController extends Observable {
export default class EditingController extends ObservableMixin() {
public readonly model: Model;
public readonly view: View;
public readonly mapper: Mapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import Consumable from './modelconsumable';
import Range from '../model/range';

import { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';

import type { default as Differ, DiffItem } from '../model/differ';
import type { default as MarkerCollection, Marker } from '../model/markercollection';
Expand Down Expand Up @@ -114,7 +114,7 @@ import type ViewElement from '../view/element';
* conversionApi.writer.insert( viewPosition, viewElement );
* } );
*/
export default class DowncastDispatcher extends Emitter {
export default class DowncastDispatcher extends EmitterMixin() {
/** @internal */
public readonly _conversionApi: Pick<DowncastConversionApi, 'dispatcher' | 'mapper' | 'schema'>;

Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-engine/src/conversion/mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ViewPosition from '../view/position';
import ViewRange from '../view/range';
import ViewText from '../view/text';

import { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';

import type ViewDocumentFragment from '../view/documentfragment';
Expand Down Expand Up @@ -43,7 +43,7 @@ import type ViewNode from '../view/node';
* stop the event.
* @mixes module:utils/emittermixin~EmitterMixin
*/
export default class Mapper extends Emitter {
export default class Mapper extends EmitterMixin() {
private _modelToViewMapping: WeakMap<ModelElement | ModelDocumentFragment, ViewElement | ViewDocumentFragment>;
private _viewToModelMapping: WeakMap<ViewElement | ViewDocumentFragment, ModelElement | ModelDocumentFragment>;
private _viewToModelLengthCallbacks: Map<string, ( element: ViewElement ) => number>;
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-engine/src/conversion/upcastdispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { isParagraphable, wrapInParagraph } from '../model/utils/autoparagraphin
import type ViewItem from '../view/item';

import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';

/**
* Upcast dispatcher is a central point of the view-to-model conversion, which is a process of
Expand Down Expand Up @@ -120,7 +120,7 @@ import { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
* @fires text
* @fires documentFragment
*/
export default class UpcastDispatcher extends Emitter {
export default class UpcastDispatcher extends EmitterMixin() {
public conversionApi: UpcastConversionApi;

private _splitParts: Map<ModelElement, Array<ModelElement>>;
Expand Down
6 changes: 3 additions & 3 deletions packages/ckeditor5-engine/src/model/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type Range from './range';
import type Writer from './writer';

import Collection from '@ckeditor/ckeditor5-utils/src/collection';
import { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import { isInsideSurrogatePair, isInsideCombinedSymbol } from '@ckeditor/ckeditor5-utils/src/unicode';

Expand All @@ -47,11 +47,11 @@ const graveyardName = '$graveyard';
*
* @mixes module:utils/emittermixin~EmitterMixin
*/
export default class Document extends Emitter {
export default class Document extends EmitterMixin() {
public readonly model: Model;
public readonly history: History;
public readonly selection: DocumentSelection;
public readonly roots: Collection<RootElement, 'rootName'>;
public readonly roots: Collection<RootElement>;
public readonly differ: Differ;

private readonly _postFixers: Set<( writer: Writer ) => boolean>;
Expand Down
6 changes: 2 additions & 4 deletions packages/ckeditor5-engine/src/model/documentselection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* eslint-disable new-cap */

/**
* @module engine/model/documentselection
*/
Expand Down Expand Up @@ -177,7 +175,7 @@ export default class DocumentSelection extends EmitterMixin( TypeCheckable ) {
* @readonly
* @type {module:utils/collection~Collection}
*/
public get markers(): Collection<Marker, 'name'> {
public get markers(): Collection<Marker> {
return this._selection.markers;
}

Expand Down Expand Up @@ -627,7 +625,7 @@ export type DocumentSelectionChangeEvent = {
// @extends module:engine/model/selection~Selection
//
class LiveSelection extends Selection {
public markers: Collection<Marker, 'name'>;
public markers: Collection<Marker>;

protected _model: Model;
protected _document: Document;
Expand Down
2 changes: 0 additions & 2 deletions packages/ckeditor5-engine/src/model/liveposition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* eslint-disable new-cap */

/**
* @module engine/model/liveposition
*/
Expand Down
2 changes: 0 additions & 2 deletions packages/ckeditor5-engine/src/model/liverange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* eslint-disable new-cap */

/**
* @module engine/model/liverange
*/
Expand Down
6 changes: 2 additions & 4 deletions packages/ckeditor5-engine/src/model/markercollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* eslint-disable new-cap */

/**
* @module engine/model/markercollection
*/
Expand All @@ -15,7 +13,7 @@ import LiveRange, { type LiveRangeChangeEvent } from './liverange';
import type Position from './position';
import type Range from './range';

import EmitterMixin, { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';

/**
Expand All @@ -32,7 +30,7 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
*
* @see module:engine/model/markercollection~Marker
*/
export default class MarkerCollection extends Emitter implements Iterable<Marker> {
export default class MarkerCollection extends EmitterMixin() implements Iterable<Marker> {
private _markers: Map<string, Marker>;

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-engine/src/model/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import type ModelElement from './element';
import type Operation from './operation/operation';

import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import { type DecoratedMethodEvent, Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
import ObservableMixin, { type DecoratedMethodEvent } from '@ckeditor/ckeditor5-utils/src/observablemixin';

// @if CK_DEBUG_ENGINE // const { dumpTrees } = require( '../dev-utils/utils' );
// @if CK_DEBUG_ENGINE // const { OperationReplayer } = require( '../dev-utils/operationreplayer' ).default;
Expand All @@ -43,7 +43,7 @@ import { type DecoratedMethodEvent, Observable } from '@ckeditor/ckeditor5-utils
*
* @mixes module:utils/observablemixin~ObservableMixin
*/
export default class Model extends Observable {
export default class Model extends ObservableMixin() {
public readonly markers: MarkerCollection;
public readonly document: Document;
public readonly schema: Schema;
Expand Down
Loading

0 comments on commit b27b23f

Please sign in to comment.