Skip to content

fix: Removed @emoji-mart/react dependency #1484

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 1 commit into from
Mar 4, 2025
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
11 changes: 1 addition & 10 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
"dependencies": {
"@blocknote/core": "^0.24.2",
"@emoji-mart/data": "^1.2.1",
"@emoji-mart/react": "^1.1.1",
"@floating-ui/react": "^0.26.4",
"@tiptap/core": "^2.7.1",
"@tiptap/react": "^2.7.1",
"@tiptap/pm": "^2.7.1",
"emoji-mart": "^5.6.0",
"lodash.merge": "^4.6.2",
"react-icons": "^5.2.1"
},
Expand Down
23 changes: 23 additions & 0 deletions packages/react/src/components/Comments/EmojiMartPicker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// From https://github.com/missive/emoji-mart/blob/main/packages/emoji-mart-react/react.tsx
import React, { useEffect, useRef } from "react";
import { Picker } from "emoji-mart";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this include the whole bundle of emoji mart data? Or is that separate?

Do we need this as a dynamic import?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think so, iirc from doing manual testing the emojis are fetched on initial render. Diving into the source code seems to support this:

https://github.com/missive/emoji-mart/blob/main/packages/emoji-mart/src/components/Picker/Picker.tsx#L112

The _init gets called in the Picker component's componentWillReceiveProps function, so either way it's not until the first render.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, cool, wasn't aware of how it works


// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default function EmojiPicker(props: any) {
const ref = useRef(null);
const instance = useRef(null) as any;

if (instance.current) {
instance.current.update(props);
}

useEffect(() => {
instance.current = new Picker({ ...props, ref });

return () => {
instance.current = null;
};
}, []); // eslint-disable-line react-hooks/exhaustive-deps

return React.createElement("div", { ref });
}
2 changes: 1 addition & 1 deletion packages/react/src/components/Comments/EmojiPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Picker from "@emoji-mart/react";
import { ReactNode, useState } from "react";

import { useComponentsContext } from "../../editor/ComponentsContext.js";
import { useBlockNoteContext } from "../../editor/BlockNoteContext.js";
import Picker from "./EmojiMartPicker.js";

export const EmojiPicker = (props: {
onEmojiSelect: (emoji: { native: string }) => void;
Expand Down
Loading