Skip to content

Commit 983bc65

Browse files
authored
fix: emojimart import (#950)
* fix emojimart import * fix
1 parent 76f9932 commit 983bc65

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/core/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Emoji, EmojiMartData } from "@emoji-mart/data";
2-
import { SearchIndex, init } from "emoji-mart";
2+
33
import { checkDefaultInlineContentTypeInSchema } from "../../blocks/defaultBlockTypeGuards";
44
import { BlockNoteEditor } from "../../editor/BlockNoteEditor";
55
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
@@ -11,6 +11,8 @@ let data:
1111
}>
1212
| undefined;
1313

14+
let emojiMart: typeof import("emoji-mart") | undefined;
15+
1416
export async function getDefaultEmojiPickerItems<
1517
BSchema extends BlockSchema,
1618
I extends InlineContentSchema,
@@ -27,16 +29,19 @@ export async function getDefaultEmojiPickerItems<
2729
// use a dynamic import to encourage bundle-splitting
2830
// and a smaller initial client bundle size
2931
data = import("@emoji-mart/data", { assert: { type: "json" } }) as any;
32+
33+
// load dynamically because emoji-mart doesn't specify type: module and breaks in nodejs
34+
emojiMart = await import("emoji-mart");
3035
const emojiMartData = (await data)!.default;
31-
await init({ data: emojiMartData });
36+
await emojiMart.init({ data: emojiMartData });
3237
}
3338

3439
const emojiMartData = (await data)!.default;
3540

3641
const emojisToShow =
3742
query.trim() === ""
3843
? Object.values(emojiMartData.emojis)
39-
: ((await SearchIndex.search(query)) as Emoji[]);
44+
: ((await emojiMart!.SearchIndex.search(query)) as Emoji[]);
4045

4146
return emojisToShow.map((emoji) => ({
4247
id: emoji.skins[0].native,

0 commit comments

Comments
 (0)