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

Fix lodash import #2671

Merged
merged 4 commits into from
Oct 3, 2023
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
5 changes: 5 additions & 0 deletions .changeset/four-hornets-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@udecode/slate": patch
---

Fix lodash import
8 changes: 3 additions & 5 deletions apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@
"next-usequerystate": "1.8.0-beta.13",
"prism-react-renderer": "^1.3.5",
"react": "^18.2.0",
"react-dnd": "patch:react-dnd@npm%3A15.1.2#~/.yarn/patches/react-dnd-npm-15.1.2-0351d81431.patch",
"react-dnd-html5-backend": "^15.1.3",
"react-dnd": "16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dom": "^18.2.0",
"react-lite-youtube-embed": "^2.3.52",
"react-modal-sheet": "2.0.0",
Expand All @@ -140,9 +140,7 @@
},
"resolutions": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-dnd": "^15.1.2",
"react-dnd-html5-backend": "^15.1.3"
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/lodash.template": "^4.5.1",
Expand Down
3 changes: 1 addition & 2 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ module.exports = {
moduleFileExtensions: ['js', 'json', 'ts', 'tsx'],
moduleNameMapper: {
'\\.(css|less|sass|scss)$': '<rootDir>/scripts/styleMock.cjs',
'^lodash-es$': 'lodash',
...getTsConfigBasePaths(),
// '^@udecode/plate-core$': '<rootDir>/packages/core/src',
...modules,
Expand All @@ -59,7 +58,7 @@ module.exports = {
},
setupFilesAfterEnv: ['<rootDir>/scripts/setupTests.ts'],
transformIgnorePatterns: [
'/node_modules/(?!(react-dnd|dnd-core|@react-dnd|react-tweet)/)',
'/node_modules/(?!(react-dnd|dnd-core|@react-dnd|react-dnd-html5-backend|react-tweet)/)',
],
watchman: false,
};
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@
"prettier": "^3.0.0",
"prettier-plugin-tailwindcss": "^0.4.0",
"react": "^18.2.0",
"react-dnd": "patch:react-dnd@npm%3A15.1.2#~/.yarn/patches/react-dnd-npm-15.1.2-0351d81431.patch",
"react-dnd-html5-backend": "^15.1.3",
"react-dnd-test-backend": "^15.1.2",
"react-dnd-test-backend": "^16.0.1",
"react-dom": "^18.2.0",
"react-is": "18.2.0",
"react-test-renderer": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/autoformat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@udecode/plate-common": "24.3.5",
"lodash-es": "^4.17.21"
"lodash": "^4.17.21"
},
"peerDependencies": {
"react": ">=16.8.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/autoformat/src/transforms/autoformatBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
someNode,
Value,
} from '@udecode/plate-common';
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';
import { Range } from 'slate';

import { AutoformatBlockRule } from '../types';
Expand Down
2 changes: 1 addition & 1 deletion packages/autoformat/src/transforms/autoformatMark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
TEditor,
Value,
} from '@udecode/plate-common';
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';
import { Point, Range } from 'slate';

import { AutoformatMarkRule } from '../types';
Expand Down
2 changes: 1 addition & 1 deletion packages/autoformat/src/transforms/autoformatText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
PlateEditor,
Value,
} from '@udecode/plate-common';
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';
import { Point, Range } from 'slate';

import { AutoformatTextRule } from '../types';
Expand Down
2 changes: 1 addition & 1 deletion packages/autoformat/src/utils/getMatchRange.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';

import { AutoformatRule, MatchRange } from '../types';

Expand Down
2 changes: 1 addition & 1 deletion packages/comments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@udecode/plate-common": "24.3.5",
"lodash-es": "^4.17.21"
"lodash": "^4.17.21"
},
"peerDependencies": {
"react": ">=16.8.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/comments/src/queries/getCommentPosition.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlateEditor, toDOMNode, Value } from '@udecode/plate-common';
import { clamp } from 'lodash-es';
import clamp from 'lodash/clamp.js';

import { TCommentText } from '../types';
import { getElementAbsolutePosition } from '../utils/getElementAbsolutePosition';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"clsx": "^1.2.1",
"is-hotkey": "^0.2.0",
"jotai": "1.7.2",
"lodash-es": "^4.17.21",
"lodash": "^4.17.21",
"nanoid": "^3.3.6",
"react-hotkeys-hook": "^4.4.1",
"use-deep-compare": "^1.1.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/components/Editor.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import { render } from '@testing-library/react';
import { isBlock, setNodes } from '@udecode/slate';
import { isEqual, memoize } from 'lodash-es';
import isEqual from 'lodash/isEqual.js';
import memoize from 'lodash/memoize.js';

import { PlatePlugin } from '../types/index';
import { createPlateEditor } from '../utils/index';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hooks/useEditableProps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from 'react';
import { isDefined } from '@udecode/utils';
import { omit } from 'lodash-es';
import omit from 'lodash/omit.js';
import { useDeepCompareMemo } from 'use-deep-compare';

import { usePlateSelectors } from '../stores';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hooks/usePlateEffects.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ForwardedRef, useEffect } from 'react';
import { Value } from '@udecode/slate';
import { isUndefined } from 'lodash-es';
import { isUndefined } from '@udecode/utils';

import { useEditorRef, usePlateStates } from '../stores';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Value } from '@udecode/slate';
import { AnyObject, isDefined } from '@udecode/utils';
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';

import { Nullable } from '../../../types';
import { PlateEditor } from '../../../types/PlateEditor';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/createPlugins.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Value } from '@udecode/slate';
import { cloneDeep } from 'lodash-es';
import cloneDeep from 'lodash/cloneDeep.js';

import { OverrideByKey } from '../types/OverrideByKey';
import { PlateEditor } from '../types/PlateEditor';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/flattenDeepPlugins.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Value } from '@udecode/slate';
import { defaultsDeep } from 'lodash-es';
import defaultsDeep from 'lodash/defaultsDeep.js';

import { PlateEditor } from '../types/PlateEditor';
import { PlatePlugin } from '../types/plugin/PlatePlugin';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/getKeysByTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Value } from '@udecode/slate';
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';

import { PlateEditor } from '../types/PlateEditor';

Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/utils/mergeDeepPlugins.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Value } from '@udecode/slate';
import { defaultsDeep, keyBy, merge, values } from 'lodash-es';
import defaultsDeep from 'lodash/defaultsDeep.js';
import keyBy from 'lodash/keyBy.js';
import merge from 'lodash/merge.js';
import values from 'lodash/values.js';

import { PlateEditor } from '../types/PlateEditor';
import { WithPlatePlugin } from '../types/plugin/PlatePlugin';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/mergeDeepToNodes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TNode } from '@udecode/slate';
import { merge } from 'lodash-es';
import merge from 'lodash/merge.js';

import { applyDeepToNodes, ApplyDeepToNodesOptions } from './applyDeepToNodes';

Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/utils/normalizeInitialValue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Value } from '@udecode/slate';
import { cloneDeep, isEqual } from 'lodash-es';
import cloneDeep from 'lodash/cloneDeep.js';
import isEqual from 'lodash/isEqual.js';

import { PlateEditor } from '../types';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/overridePluginsByKey.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Value } from '@udecode/slate';
import { defaultsDeep } from 'lodash-es';
import defaultsDeep from 'lodash/defaultsDeep.js';

import { NoInfer } from '../types/misc/NoInfer';
import { OverrideByKey } from '../types/OverrideByKey';
Expand Down
2 changes: 1 addition & 1 deletion packages/dnd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@udecode/plate-common": "24.3.5",
"lodash-es": "^4.17.21",
"lodash": "^4.17.21",
"raf": "^3.4.1"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/dnd/src/components/Scroller/ScrollArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
useEffect,
useRef,
} from 'react';
import { throttle } from 'lodash-es';
import throttle from 'lodash/throttle.js';
import raf from 'raf';

const getCoords = (e: any) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@udecode/plate-common": "24.3.5",
"lodash-es": "^4.17.21"
"lodash": "^4.17.21"
},
"peerDependencies": {
"react": ">=16.8.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/font/src/hooks/useColorsCustom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import { debounce } from 'lodash-es';
import debounce from 'lodash/debounce.js';

export const useColorsCustomState = ({
color,
Expand Down
2 changes: 1 addition & 1 deletion packages/list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"dependencies": {
"@udecode/plate-common": "24.3.5",
"@udecode/plate-reset-node": "24.3.5",
"lodash-es": "^4.17.21"
"lodash": "^4.17.21"
},
"peerDependencies": {
"react": ">=16.8.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/list/src/onKeyDownList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Value,
WithPlatePlugin,
} from '@udecode/plate-common';
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';
import { Range } from 'slate';

import { ELEMENT_LI } from './createListPlugin';
Expand Down
2 changes: 1 addition & 1 deletion packages/node-id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@udecode/plate-common": "24.3.5",
"lodash-es": "^4.17.21"
"lodash": "^4.17.21"
},
"peerDependencies": {
"react": ">=16.8.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/node-id/src/withNodeId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
Value,
WithPlatePlugin,
} from '@udecode/plate-common';
import { castArray, cloneDeep } from 'lodash-es';
import castArray from 'lodash/castArray.js';
import cloneDeep from 'lodash/cloneDeep.js';

import { NodeIdPlugin } from './createNodeIdPlugin';

Expand Down
2 changes: 1 addition & 1 deletion packages/normalizers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@udecode/plate-common": "24.3.5",
"lodash-es": "^4.17.21"
"lodash": "^4.17.21"
},
"peerDependencies": {
"react": ">=16.8.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/normalizers/src/withRemoveEmptyNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Value,
WithPlatePlugin,
} from '@udecode/plate-common';
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';

import { RemoveEmptyNodesPlugin } from './createRemoveEmptyNodesPlugin';

Expand Down
2 changes: 1 addition & 1 deletion packages/plate-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@udecode/slate-utils": "24.3.5",
"@udecode/utils": "24.3.0",
"clsx": "^1.2.1",
"lodash-es": "^4.17.21"
"lodash": "^4.17.21"
},
"peerDependencies": {
"react": ">=16.8.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/plate-utils/src/plate/onKeyDownToggleElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
WithPlatePlugin,
} from '@udecode/plate-core';
import { Value } from '@udecode/slate';
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';

export const onKeyDownToggleElement =
<V extends Value = Value, E extends PlateEditor<V> = PlateEditor<V>>(
Expand Down
2 changes: 1 addition & 1 deletion packages/plate-utils/src/queries/isType.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getPluginType, PlateEditor } from '@udecode/plate-core';
import { Value } from '@udecode/slate';
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';

/**
* Does the node match the type provided.
Expand Down
3 changes: 2 additions & 1 deletion packages/plate-utils/src/utils/createNodesHOC.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FunctionComponent } from 'react';
import { AnyObject } from '@udecode/utils';
import { castArray, merge } from 'lodash-es';
import castArray from 'lodash/castArray.js';
import merge from 'lodash/merge.js';

import { createNodeHOC } from './createNodeHOC';

Expand Down
2 changes: 1 addition & 1 deletion packages/plate-utils/src/utils/defaultsDeepToNodes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { applyDeepToNodes, ApplyDeepToNodesOptions } from '@udecode/plate-core';
import { TNode } from '@udecode/slate';
import { defaults } from 'lodash-es';
import defaults from 'lodash/defaults.js';

/**
* Recursively merge a source object to children nodes with a query.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deserializeHtml, htmlStringToDOMNode } from '@udecode/plate-core';
import { deserializeHtml, htmlStringToDOMNode } from '@udecode/plate-common';
import { createPlateUIEditor } from 'www/src/lib/plate/create-plate-ui-editor';

import { serializeHtml } from '../../serializeHtml';
Expand Down
2 changes: 1 addition & 1 deletion packages/slate-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"dependencies": {
"@udecode/slate": "24.3.5",
"@udecode/utils": "24.3.0",
"lodash-es": "^4.17.21"
"lodash": "^4.17.21"
},
"peerDependencies": {
"slate": ">=0.94.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/slate-utils/src/queries/getPointBeforeLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
TEditor,
Value,
} from '@udecode/slate';
import { castArray, map } from 'lodash-es';
import castArray from 'lodash/castArray.js';
import map from 'lodash/map.js';
import { Location, Point } from 'slate';

import { isRangeAcrossBlocks } from './isRangeAcrossBlocks';
Expand Down
2 changes: 1 addition & 1 deletion packages/slate-utils/src/queries/getPreviousSiblingNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getNode, TEditor, Value } from '@udecode/slate';
import { last } from 'lodash-es';
import last from 'lodash/last.js';
import { Path } from 'slate';

export const getPreviousSiblingNode = <V extends Value = Value>(
Expand Down
2 changes: 1 addition & 1 deletion packages/slate-utils/src/queries/queryEditor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueryEditorOptions, someNode, TEditor, Value } from '@udecode/slate';
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';

import { isSelectionAtBlockEnd } from './isSelectionAtBlockEnd';
import { isSelectionAtBlockStart } from './isSelectionAtBlockStart';
Expand Down
2 changes: 1 addition & 1 deletion packages/slate-utils/src/transforms/removeMark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
unsetNodes,
Value,
} from '@udecode/slate';
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';
import { Range } from 'slate';

export interface RemoveMarkOptions<V extends Value = Value>
Expand Down
2 changes: 1 addition & 1 deletion packages/slate-utils/src/transforms/setMarks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EMarks, TEditor, Value, withoutNormalizing } from '@udecode/slate';
import { castArray } from 'lodash-es';
import castArray from 'lodash/castArray.js';

import { removeMark } from './removeMark';

Expand Down
Loading
Loading