Skip to content

Commit

Permalink
Lodash: Remove completely from format-library package
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Aug 31, 2022
1 parent ec6bff8 commit 6d7aafa
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/format-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
"@wordpress/i18n": "file:../i18n",
"@wordpress/icons": "file:../icons",
"@wordpress/rich-text": "file:../rich-text",
"@wordpress/url": "file:../url",
"lodash": "^4.17.21"
"@wordpress/url": "file:../url"
},
"peerDependencies": {
"react": "^17.0.0",
Expand Down
13 changes: 10 additions & 3 deletions packages/format-library/src/link/index.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import { find } from 'lodash';
import Clipboard from '@react-native-clipboard/clipboard';

/**
Expand Down Expand Up @@ -86,13 +85,21 @@ export const link = {
let startIndex = value.start;
let endIndex = value.end;

while ( find( value.formats[ startIndex ], startFormat ) ) {
while (
value.formats[ startIndex ].find(
( format ) => format?.type === startFormat.type
)
) {
startIndex--;
}

endIndex++;

while ( find( value.formats[ endIndex ], startFormat ) ) {
while (
value.formats[ endIndex ].find(
( format ) => format?.type === startFormat.type
)
) {
endIndex++;
}

Expand Down
7 changes: 1 addition & 6 deletions packages/format-library/src/text-color/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { isEmpty } from 'lodash';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -82,7 +77,7 @@ function TextColorEdit( {
[ value, colors ]
);

const hasColorsToChoose = ! isEmpty( colors ) || ! allowCustomControl;
const hasColorsToChoose = colors.length || ! allowCustomControl;
if ( ! hasColorsToChoose && ! isActive ) {
return null;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/format-library/src/text-color/index.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import { isEmpty } from 'lodash';
import { View } from 'react-native';

/**
Expand Down Expand Up @@ -89,7 +88,7 @@ function TextColorEdit( {
[ value, colors ]
);

const hasColorsToChoose = ! isEmpty( colors ) || ! allowCustomControl;
const hasColorsToChoose = colors.length || ! allowCustomControl;

const onPressButton = useCallback( () => {
if ( hasColorsToChoose ) {
Expand Down
7 changes: 1 addition & 6 deletions packages/format-library/src/text-color/inline.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { get } from 'lodash';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -112,7 +107,7 @@ function setColors( value, name, colorSettings, colors ) {
function ColorPicker( { name, property, value, onChange } ) {
const colors = useSelect( ( select ) => {
const { getSettings } = select( blockEditorStore );
return get( getSettings(), [ 'colors' ], [] );
return getSettings().colors ?? [];
}, [] );
const onColorChange = useCallback(
( color ) => {
Expand Down

0 comments on commit 6d7aafa

Please sign in to comment.