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

Replace lodash-es with es-toolkit #17496

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion packages/ckeditor5-autosave/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi

The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):

* Lodash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.
* es-toolkit - Copyright (c) 2024 Viva Republica, Inc.

Trademarks
----------
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-autosave/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@ckeditor/ckeditor5-core": "43.3.1",
"@ckeditor/ckeditor5-utils": "43.3.1",
"ckeditor5": "43.3.1",
"lodash-es": "4.17.21"
"es-toolkit": "1.27.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-dev-utils": "^45.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-autosave/src/autosave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { DomEmitterMixin, type DomEmitter } from 'ckeditor5/src/utils.js';

import type { DocumentChangeEvent } from 'ckeditor5/src/engine.js';

import { debounce, type DebouncedFunc } from 'lodash-es';
import { debounce } from 'es-toolkit/compat';

/* globals window */

Expand Down Expand Up @@ -81,7 +81,7 @@ export default class Autosave extends Plugin {
* Debounced save method. The `save()` method is called the specified `waitingTime` after `debouncedSave()` is called,
* unless a new action happens in the meantime.
*/
private _debouncedSave: DebouncedFunc<( () => void )>;
private _debouncedSave: ReturnType<typeof debounce<( () => Promise<void> )>>;

/**
* The last saved document version.
Expand Down
1 change: 1 addition & 0 deletions packages/ckeditor5-ckbox/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):

* blurhash - Copyright (c) 2018 Wolt Enterprises (MIT license).
* es-toolkit - Copyright (c) 2024 Viva Republica, Inc.

Trademarks
----------
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-ckbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@ckeditor/ckeditor5-utils": "43.3.1",
"ckeditor5": "43.3.1",
"blurhash": "2.0.5",
"lodash-es": "4.17.21"
"es-toolkit": "1.27.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-autosave": "43.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from 'ckeditor5/src/utils.js';
import type { Element as ModelElement } from 'ckeditor5/src/engine.js';
import { Notification } from 'ckeditor5/src/ui.js';
import { isEqual } from 'lodash-es';
import { isEqual } from 'es-toolkit/compat';

import { sendHttpRequest } from '../utils.js';
import { prepareImageAssetAttributes } from '../ckboxcommand.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { setData as setModelData, getData as getModelData } from '@ckeditor/cked
import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view.js';
import { Notification } from 'ckeditor5/src/ui.js';
import TokenMock from '@ckeditor/ckeditor5-cloud-services/tests/_utils/tokenmock.js';
import _ from 'lodash-es';
import * as _ from 'es-toolkit';
import CloudServicesCoreMock from '../_utils/cloudservicescoremock.js';
import CKBoxEditing from '../../src/ckboxediting.js';
import CKBoxImageEditEditing from '../../src/ckboximageedit/ckboximageeditediting.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-clipboard/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi

The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):

* Lodash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.
* es-toolkit - Copyright (c) 2024 Viva Republica, Inc.

Trademarks
----------
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-clipboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@ckeditor/ckeditor5-ui": "43.3.1",
"@ckeditor/ckeditor5-utils": "43.3.1",
"@ckeditor/ckeditor5-widget": "43.3.1",
"lodash-es": "4.17.21"
"es-toolkit": "1.27.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-alignment": "43.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-clipboard/src/clipboardmarkersutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @module clipboard/clipboardmarkersutils
*/
import { mapValues } from 'lodash-es';
import { mapValues } from 'es-toolkit/compat';

import { uid } from '@ckeditor/ckeditor5-utils';
import { Plugin, type NonEmptyArray } from '@ckeditor/ckeditor5-core';
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-clipboard/src/dragdroptarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {

import LineView from './lineview.js';

import { throttle } from 'lodash-es';
import { throttle } from 'es-toolkit/compat';

/**
* Part of the Drag and Drop handling. Responsible for finding and displaying the drop target.
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-core/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi

The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):

* Lodash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.
* es-toolkit - Copyright (c) 2024 Viva Republica, Inc.

Trademarks
----------
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@ckeditor/ckeditor5-engine": "43.3.1",
"@ckeditor/ckeditor5-utils": "43.3.1",
"@ckeditor/ckeditor5-watchdog": "43.3.1",
"lodash-es": "4.17.21"
"es-toolkit": "1.27.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-autoformat": "43.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-core/src/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @module core/editor/editor
*/

import { set, get } from 'lodash-es';
import { set, get } from 'es-toolkit/compat';

import {
Config,
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-core/src/editor/utils/attachtoform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @module core/editor/utils/attachtoform
*/

import { isFunction } from 'lodash-es';
import { isFunction } from 'es-toolkit/compat';

import { CKEditorError } from '@ckeditor/ckeditor5-utils';

Expand Down
10 changes: 5 additions & 5 deletions packages/ckeditor5-core/tests/_utils/classictesteditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* globals HTMLElement */
/* eslint-disable new-cap */

import Editor from '../../src/editor/editor.js';
Expand All @@ -12,7 +13,6 @@ import BoxedEditorUIView from '@ckeditor/ckeditor5-ui/src/editorui/boxed/boxeded
import ElementReplacer from '@ckeditor/ckeditor5-utils/src/elementreplacer.js';
import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview.js';
import getDataFromElement from '@ckeditor/ckeditor5-utils/src/dom/getdatafromelement.js';
import { isElement } from 'lodash-es';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror.js';

/**
Expand All @@ -28,7 +28,7 @@ export default class ClassicTestEditor extends ElementApiMixin( Editor ) {
constructor( sourceElementOrData, config ) {
super( config );

if ( isElement( sourceElementOrData ) ) {
if ( sourceElementOrData instanceof HTMLElement ) {
this.sourceElement = sourceElementOrData;
}

Expand Down Expand Up @@ -84,9 +84,9 @@ export default class ClassicTestEditor extends ElementApiMixin( Editor ) {
editor.initPlugins()
// Simulate EditorUI.init() (e.g. like in ClassicEditorUI). The ui#view
// should be rendered after plugins are initialized.
.then( () => editor.ui.init( isElement( sourceElementOrData ) ? sourceElementOrData : null ) )
.then( () => editor.ui.init( sourceElementOrData instanceof HTMLElement ? sourceElementOrData : null ) )
.then( () => {
if ( !isElement( sourceElementOrData ) && config.initialData ) {
if ( !( sourceElementOrData instanceof HTMLElement ) && config.initialData ) {
// Documented in core/editor/editorconfig.jsdoc.
// eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
throw new CKEditorError( 'editor-create-initial-data', null );
Expand Down Expand Up @@ -171,5 +171,5 @@ export class ClassicTestEditorUI extends EditorUI {
}

function getInitialData( sourceElementOrData ) {
return isElement( sourceElementOrData ) ? getDataFromElement( sourceElementOrData ) : sourceElementOrData;
return sourceElementOrData instanceof HTMLElement ? getDataFromElement( sourceElementOrData ) : sourceElementOrData;
}
2 changes: 1 addition & 1 deletion packages/ckeditor5-core/tests/accessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { Editor } from '@ckeditor/ckeditor5-core';
import { expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils.js';
import { cloneDeep } from 'lodash-es';
import { cloneDeep } from 'es-toolkit';

describe( 'Accessibility', () => {
let editor, accessibility;
Expand Down
4 changes: 0 additions & 4 deletions packages/ckeditor5-editor-balloon/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ Sources of Intellectual Property Included in CKEditor

Where not otherwise indicated, all CKEditor content is authored by CKSource engineers and consists of CKSource-owned intellectual property. In some specific instances, CKEditor will incorporate work done by developers outside of CKSource with their express permission.

The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):

* Lodash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.

Trademarks
----------

Expand Down
3 changes: 1 addition & 2 deletions packages/ckeditor5-editor-balloon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"@ckeditor/ckeditor5-engine": "43.3.1",
"@ckeditor/ckeditor5-ui": "43.3.1",
"@ckeditor/ckeditor5-utils": "43.3.1",
"ckeditor5": "43.3.1",
"lodash-es": "4.17.21"
"ckeditor5": "43.3.1"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "43.3.1",
Expand Down
4 changes: 1 addition & 3 deletions packages/ckeditor5-editor-balloon/src/ballooneditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import { CKEditorError, getDataFromElement } from 'ckeditor5/src/utils.js';
import BalloonEditorUI from './ballooneditorui.js';
import BalloonEditorUIView from './ballooneditoruiview.js';

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

/**
* The balloon editor implementation (Medium-like editor).
* It uses an inline editable and a toolbar based on the {@link module:ui/toolbar/balloon/balloontoolbar~BalloonToolbar}.
Expand Down Expand Up @@ -230,5 +228,5 @@ function getInitialData( sourceElementOrData: HTMLElement | string ): string {
}

function isElement( value: any ): value is Element {
return _isElement( value );
return value instanceof HTMLElement;
}
7 changes: 3 additions & 4 deletions packages/ckeditor5-editor-balloon/tests/ballooneditorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* globals document, Event */
/* globals document, Event, HTMLElement */

import BalloonEditor from '../src/ballooneditor.js';
import BalloonEditorUI from '../src/ballooneditorui.js';
Expand All @@ -15,7 +15,6 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph.js';
import Heading from '@ckeditor/ckeditor5-heading/src/heading.js';

import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard.js';
import { isElement } from 'lodash-es';
import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor.js';
import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js';
import { assertBinding } from '@ckeditor/ckeditor5-utils/tests/_utils/utils.js';
Expand Down Expand Up @@ -354,7 +353,7 @@ class VirtualBalloonTestEditor extends VirtualTestEditor {
constructor( sourceElementOrData, config ) {
super( config );

if ( isElement( sourceElementOrData ) ) {
if ( sourceElementOrData instanceof HTMLElement ) {
this.sourceElement = sourceElementOrData;
}

Expand All @@ -377,7 +376,7 @@ class VirtualBalloonTestEditor extends VirtualTestEditor {
.then( () => {
editor.ui.init();

const initialData = isElement( sourceElementOrData ) ?
const initialData = sourceElementOrData instanceof HTMLElement ?
sourceElementOrData.innerHTML :
sourceElementOrData;

Expand Down
4 changes: 0 additions & 4 deletions packages/ckeditor5-editor-classic/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ Sources of Intellectual Property Included in CKEditor

Where not otherwise indicated, all CKEditor content is authored by CKSource engineers and consists of CKSource-owned intellectual property. In some specific instances, CKEditor will incorporate work done by developers outside of CKSource with their express permission.

The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):

* Lodash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.

Trademarks
----------

Expand Down
3 changes: 1 addition & 2 deletions packages/ckeditor5-editor-classic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"@ckeditor/ckeditor5-engine": "43.3.1",
"@ckeditor/ckeditor5-ui": "43.3.1",
"@ckeditor/ckeditor5-utils": "43.3.1",
"ckeditor5": "43.3.1",
"lodash-es": "4.17.21"
"ckeditor5": "43.3.1"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "43.3.1",
Expand Down
4 changes: 1 addition & 3 deletions packages/ckeditor5-editor-classic/src/classiceditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
} from 'ckeditor5/src/core.js';
import { getDataFromElement, CKEditorError } from 'ckeditor5/src/utils.js';

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

/**
* The classic editor implementation. It uses an inline editable and a sticky toolbar, all enclosed in a boxed UI.
* See the {@glink examples/builds/classic-editor demo}.
Expand Down Expand Up @@ -215,5 +213,5 @@ function getInitialData( sourceElementOrData: HTMLElement | string ): string {
}

function isElement( value: any ): value is Element {
return _isElement( value );
return value instanceof HTMLElement;
}
7 changes: 3 additions & 4 deletions packages/ckeditor5-editor-classic/tests/classiceditorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* globals window, document, Event, console */
/* globals window, document, Event, console, HTMLElement */

import View from '@ckeditor/ckeditor5-ui/src/view.js';

Expand All @@ -19,7 +19,6 @@ import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-util
import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard.js';
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils.js';
import { assertBinding } from '@ckeditor/ckeditor5-utils/tests/_utils/utils.js';
import { isElement } from 'lodash-es';
import { ContextualBalloon, Dialog, DialogViewPosition } from '@ckeditor/ckeditor5-ui';

describe( 'ClassicEditorUI', () => {
Expand Down Expand Up @@ -1028,7 +1027,7 @@ class VirtualClassicTestEditor extends VirtualTestEditor {
constructor( sourceElementOrData, config ) {
super( config );

if ( isElement( sourceElementOrData ) ) {
if ( sourceElementOrData instanceof HTMLElement ) {
this.sourceElement = sourceElementOrData;
}

Expand All @@ -1054,7 +1053,7 @@ class VirtualClassicTestEditor extends VirtualTestEditor {
.then( () => {
editor.ui.init();

const initialData = isElement( sourceElementOrData ) ?
const initialData = sourceElementOrData instanceof HTMLElement ?
sourceElementOrData.innerHTML :
sourceElementOrData;

Expand Down
4 changes: 0 additions & 4 deletions packages/ckeditor5-editor-decoupled/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ Sources of Intellectual Property Included in CKEditor

Where not otherwise indicated, all CKEditor content is authored by CKSource engineers and consists of CKSource-owned intellectual property. In some specific instances, CKEditor will incorporate work done by developers outside of CKSource with their express permission.

The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):

* Lodash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.

Trademarks
----------

Expand Down
3 changes: 1 addition & 2 deletions packages/ckeditor5-editor-decoupled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"@ckeditor/ckeditor5-engine": "43.3.1",
"@ckeditor/ckeditor5-ui": "43.3.1",
"@ckeditor/ckeditor5-utils": "43.3.1",
"ckeditor5": "43.3.1",
"lodash-es": "4.17.21"
"ckeditor5": "43.3.1"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "43.3.1",
Expand Down
4 changes: 1 addition & 3 deletions packages/ckeditor5-editor-decoupled/src/decouplededitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import {
import DecoupledEditorUI from './decouplededitorui.js';
import DecoupledEditorUIView from './decouplededitoruiview.js';

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

/**
* The decoupled editor implementation. It provides an inline editable and a toolbar. However, unlike other editors,
* it does not render these components anywhere in the DOM unless configured.
Expand Down Expand Up @@ -257,5 +255,5 @@ function getInitialData( sourceElementOrData: HTMLElement | string ): string {
}

function isElement( value: any ): value is Element {
return _isElement( value );
return value instanceof HTMLElement;
}
Loading