Skip to content

chore: remove lodash #448

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

Merged
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
63 changes: 53 additions & 10 deletions package-lock.json

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

4 changes: 1 addition & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
"@tiptap/extension-underline": "^2.0.3",
"@tiptap/pm": "^2.0.3",
"hast-util-from-dom": "^4.2.0",
"lodash": "^4.17.21",
"prosemirror-model": "^1.18.3",
"prosemirror-state": "^1.4.3",
"prosemirror-transform": "^1.7.2",
Expand All @@ -82,7 +81,7 @@
"rehype-parse": "^8.0.4",
"rehype-remark": "^9.1.2",
"rehype-stringify": "^9.0.3",
"rehype-format":"^5.0.0",
"rehype-format": "^5.0.0",
"remark-gfm": "^3.0.1",
"remark-parse": "^10.0.1",
"remark-rehype": "^10.1.0",
Expand All @@ -95,7 +94,6 @@
},
"devDependencies": {
"@types/hast": "^2.3.4",
"@types/lodash": "^4.14.179",
"@types/uuid": "^8.3.4",
"eslint": "^8.10.0",
"jsdom": "^21.1.0",
Expand Down
7 changes: 6 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
"@tippyjs/react": "^4.2.6",
"@tiptap/core": "^2.0.3",
"@tiptap/react": "^2.0.3",
"lodash": "^4.17.21",
"lodash.foreach": "^4.5.0",
"lodash.groupby": "^4.6.0",
"lodash.merge": "^4.6.2",
"react": "^18",
"react-dom": "^18.2.0",
"react-icons": "^4.3.1",
Expand All @@ -67,6 +69,9 @@
"devDependencies": {
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"@types/lodash.groupby": "^4.6.9",
"@types/lodash.merge": "^4.6.9",
"@types/lodash.foreach": "^4.5.9",
"@vitejs/plugin-react": "^4.0.4",
"eslint": "^8.10.0",
"prettier": "^2.7.1",
Expand Down
26 changes: 13 additions & 13 deletions packages/react/src/BlockNoteTheme.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CSSObject, MantineThemeOverride } from "@mantine/core";
import _ from "lodash";
import merge from "lodash.merge";

export type CombinedColor = {
text: string;
Expand Down Expand Up @@ -106,7 +106,7 @@ export const blockNoteToMantineTheme = (theme: Theme): MantineThemeOverride => {
// Slash Menu, Formatting Toolbar dropdown, color picker dropdown
Menu: {
styles: () => ({
dropdown: _.merge<CSSObject, CSSObject>(
dropdown: merge<CSSObject, CSSObject>(
{
backgroundColor: theme.colors.menu.background,
border: border,
Expand Down Expand Up @@ -137,7 +137,7 @@ export const blockNoteToMantineTheme = (theme: Theme): MantineThemeOverride => {
},
TableHandle: {
styles: () => ({
root: _.merge<CSSObject, CSSObject>(
root: merge<CSSObject, CSSObject>(
{
display: "flex",
alignItems: "center",
Expand All @@ -158,7 +158,7 @@ export const blockNoteToMantineTheme = (theme: Theme): MantineThemeOverride => {
},
TableHandleMenu: {
styles: () => ({
root: _.merge<CSSObject, CSSObject>(
root: merge<CSSObject, CSSObject>(
{
".mantine-Menu-item": {
fontSize: "12px",
Expand All @@ -171,7 +171,7 @@ export const blockNoteToMantineTheme = (theme: Theme): MantineThemeOverride => {
},
Tabs: {
styles: () => ({
root: _.merge<CSSObject, CSSObject>(
root: merge<CSSObject, CSSObject>(
{
width: "100%",
backgroundColor: theme.colors.menu.background,
Expand Down Expand Up @@ -249,7 +249,7 @@ export const blockNoteToMantineTheme = (theme: Theme): MantineThemeOverride => {
},
ColorIcon: {
styles: () => ({
root: _.merge<CSSObject, CSSObject>(
root: merge<CSSObject, CSSObject>(
{
border: border,
borderRadius: innerBorderRadius,
Expand All @@ -260,7 +260,7 @@ export const blockNoteToMantineTheme = (theme: Theme): MantineThemeOverride => {
},
DragHandleMenu: {
styles: () => ({
root: _.merge<CSSObject, CSSObject>(
root: merge<CSSObject, CSSObject>(
{
".mantine-Menu-item": {
fontSize: "12px",
Expand All @@ -273,7 +273,7 @@ export const blockNoteToMantineTheme = (theme: Theme): MantineThemeOverride => {
},
Editor: {
styles: () => ({
root: _.merge<CSSObject, CSSObject>(
root: merge<CSSObject, CSSObject>(
{
".ProseMirror": {
backgroundColor: theme.colors.editor.background,
Expand Down Expand Up @@ -315,7 +315,7 @@ export const blockNoteToMantineTheme = (theme: Theme): MantineThemeOverride => {
},
Toolbar: {
styles: () => ({
root: _.merge<CSSObject, CSSObject>(
root: merge<CSSObject, CSSObject>(
{
backgroundColor: theme.colors.menu.background,
boxShadow: shadow,
Expand Down Expand Up @@ -373,7 +373,7 @@ export const blockNoteToMantineTheme = (theme: Theme): MantineThemeOverride => {
},
ToolbarInputDropdown: {
styles: () => ({
root: _.merge<CSSObject, CSSObject>(
root: merge<CSSObject, CSSObject>(
{
backgroundColor: theme.colors.menu.background,
border: border,
Expand Down Expand Up @@ -418,7 +418,7 @@ export const blockNoteToMantineTheme = (theme: Theme): MantineThemeOverride => {
},
Tooltip: {
styles: () => ({
root: _.merge<CSSObject, CSSObject>(
root: merge<CSSObject, CSSObject>(
{
backgroundColor: theme.colors.tooltip.background,
border: border,
Expand All @@ -437,7 +437,7 @@ export const blockNoteToMantineTheme = (theme: Theme): MantineThemeOverride => {
},
SlashMenu: {
styles: () => ({
root: _.merge<CSSObject, CSSObject>(
root: merge<CSSObject, CSSObject>(
{
position: "relative",
".mantine-Menu-item": {
Expand Down Expand Up @@ -470,7 +470,7 @@ export const blockNoteToMantineTheme = (theme: Theme): MantineThemeOverride => {
},
SideMenu: {
styles: () => ({
root: _.merge<CSSObject, CSSObject>(
root: merge<CSSObject, CSSObject>(
{
backgroundColor: "transparent",
".mantine-UnstyledButton-root": {
Expand Down
9 changes: 5 additions & 4 deletions packages/react/src/SlashMenu/components/DefaultSlashMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { createStyles, Menu } from "@mantine/core";
import * as _ from "lodash";
import foreach from "lodash.foreach";
import groupBy from "lodash.groupby";

import { BlockSchema } from "@blocknote/core";
import { SlashMenuItem } from "./SlashMenuItem";
import { SlashMenuProps } from "./SlashMenuPositioner";
import { BlockSchema } from "@blocknote/core";

export function DefaultSlashMenu<BSchema extends BlockSchema>(
props: SlashMenuProps<BSchema>
Expand All @@ -14,9 +15,9 @@ export function DefaultSlashMenu<BSchema extends BlockSchema>(
const renderedItems: any[] = [];
let index = 0;

const groups = _.groupBy(props.filteredItems, (i) => i.group);
const groups = groupBy(props.filteredItems, (i) => i.group);

_.forEach(groups, (groupedItems) => {
foreach(groups, (groupedItems) => {
renderedItems.push(
<Menu.Label key={groupedItems[0].group}>
{groupedItems[0].group}
Expand Down