Skip to content

Commit aabbd3a

Browse files
committed
chore: remove unused dependencies and bundle react-icons
@blocknote/core: - Remove unused @tiptap/extension-horizontal-rule (custom divider block) - Remove unused @tiptap/extension-paragraph (custom paragraph block) - Remove lib0; replace lib0/random uuidv4 with crypto.randomUUID() - Update YjsThreadStore test mock accordingly @blocknote/react: - Remove unused lodash.merge and @types/lodash.merge - Remove unused @floating-ui/utils (transitive dep only) - Move @types/use-sync-external-store to optionalDependencies - Bundle react-icons into dist output (tree-shaken) instead of externalizing it, so consumers no longer need to install it - Define local IconType to avoid leaking react-icons in .d.ts output
1 parent d609476 commit aabbd3a

14 files changed

Lines changed: 54 additions & 70 deletions

File tree

packages/core/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,14 @@
9797
"@tiptap/core": "^3.13.0",
9898
"@tiptap/extension-bold": "^3.13.0",
9999
"@tiptap/extension-code": "^3.13.0",
100-
"@tiptap/extension-horizontal-rule": "^3.13.0",
101100
"@tiptap/extension-italic": "^3.13.0",
102-
"@tiptap/extension-paragraph": "^3.13.0",
103101
"@tiptap/extension-strike": "^3.13.0",
104102
"@tiptap/extension-text": "^3.13.0",
105103
"@tiptap/extension-underline": "^3.13.0",
106104
"@tiptap/extensions": "^3.13.0",
107105
"@tiptap/pm": "^3.13.0",
108106
"emoji-mart": "^5.6.0",
109107
"fast-deep-equal": "^3.1.3",
110-
"lib0": "^0.2.99",
111108
"prosemirror-highlight": "^0.15.1",
112109
"prosemirror-model": "^1.25.4",
113110
"prosemirror-state": "^1.4.4",

packages/core/src/comments/threadstore/yjs/YjsThreadStore.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { CommentBody } from "../../types.js";
44
import { DefaultThreadStoreAuth } from "../DefaultThreadStoreAuth.js";
55
import { YjsThreadStore } from "./YjsThreadStore.js";
66

7-
// Mock UUID to generate sequential IDs
7+
// Mock crypto.randomUUID to generate sequential IDs
88
let mockUuidCounter = 0;
9-
vi.mock("lib0/random", async (importOriginal) => ({
10-
...(await importOriginal<typeof import("lib0/random")>()),
11-
uuidv4: () => `mocked-uuid-${++mockUuidCounter}`,
12-
}));
9+
const originalRandomUUID = crypto.randomUUID.bind(crypto);
10+
vi.spyOn(crypto, "randomUUID").mockImplementation(
11+
() => `mocked-uuid-${++mockUuidCounter}` as ReturnType<typeof originalRandomUUID>,
12+
);
1313

1414
describe("YjsThreadStore", () => {
1515
let store: YjsThreadStore;

packages/core/src/comments/threadstore/yjs/YjsThreadStore.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { uuidv4 } from "lib0/random";
1+
22
import * as Y from "yjs";
33
import { CommentBody, CommentData, ThreadData } from "../../types.js";
44
import { ThreadStoreAuth } from "../ThreadStoreAuth.js";
@@ -57,7 +57,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
5757

5858
const comment: CommentData = {
5959
type: "comment",
60-
id: uuidv4(),
60+
id: crypto.randomUUID(),
6161
userId: this.userId,
6262
createdAt: date,
6363
updatedAt: date,
@@ -68,7 +68,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
6868

6969
const thread: ThreadData = {
7070
type: "thread",
71-
id: uuidv4(),
71+
id: crypto.randomUUID(),
7272
createdAt: date,
7373
updatedAt: date,
7474
comments: [comment],
@@ -105,7 +105,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
105105
const date = new Date();
106106
const comment: CommentData = {
107107
type: "comment",
108-
id: uuidv4(),
108+
id: crypto.randomUUID(),
109109
userId: this.userId,
110110
createdAt: date,
111111
updatedAt: date,

packages/core/src/extensions/Placeholder/Placeholder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Plugin, PluginKey } from "prosemirror-state";
22
import { Decoration, DecorationSet } from "prosemirror-view";
3-
import { uuidv4 } from "lib0/random";
3+
44
import {
55
createExtension,
66
ExtensionOptions,
@@ -23,7 +23,7 @@ export const PlaceholderExtension = createExtension(
2323
new Plugin({
2424
key: PLUGIN_KEY,
2525
view: (view) => {
26-
const uniqueEditorSelector = `placeholder-selector-${uuidv4()}`;
26+
const uniqueEditorSelector = `placeholder-selector-${crypto.randomUUID()}`;
2727
view.dom.classList.add(uniqueEditorSelector);
2828
const styleEl = document.createElement("style");
2929

packages/core/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from "@tiptap/core";
77
import { Fragment, Slice } from "prosemirror-model";
88
import { Plugin, PluginKey } from "prosemirror-state";
9-
import { uuidv4 } from "lib0/random";
9+
1010

1111
/**
1212
* Code from Tiptap UniqueID extension (https://tiptap.dev/api/extensions/unique-id)
@@ -65,7 +65,7 @@ const UniqueID = Extension.create({
6565
return testOptions.mockID.toString() as string;
6666
}
6767

68-
return uuidv4();
68+
return crypto.randomUUID();
6969
},
7070
filterTransaction: null,
7171
};

packages/react/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,18 @@
6161
"@blocknote/core": "0.51.3",
6262
"@emoji-mart/data": "^1.2.1",
6363
"@floating-ui/react": "^0.27.18",
64-
"@floating-ui/utils": "^0.2.10",
6564
"@tanstack/react-store": "0.7.7",
6665
"@tiptap/core": "^3.13.0",
6766
"@tiptap/pm": "^3.13.0",
6867
"@tiptap/react": "^3.13.0",
69-
"@types/use-sync-external-store": "1.5.0",
7068
"emoji-mart": "^5.6.0",
7169
"fast-deep-equal": "^3.1.3",
72-
"lodash.merge": "^4.6.2",
73-
"react-icons": "^5.5.0",
7470
"use-sync-external-store": "1.6.0"
7571
},
7672
"devDependencies": {
7773
"@types/lodash.foreach": "^4.5.9",
7874
"@types/lodash.groupby": "^4.6.9",
79-
"@types/lodash.merge": "^4.6.9",
75+
"react-icons": "^5.5.0",
8076
"@types/react": "^19.2.3",
8177
"@types/react-dom": "^19.2.3",
8278
"@vitejs/plugin-react": "^6.0.1",
@@ -91,6 +87,9 @@
9187
"vite-plugin-externalize-deps": "^0.10.0",
9288
"vitest": "^4.1.2"
9389
},
90+
"optionalDependencies": {
91+
"@types/use-sync-external-store": "1.5.0"
92+
},
9493
"peerDependencies": {
9594
"react": "^18.0 || ^19.0 || >= 19.0.0-rc",
9695
"react-dom": "^18.0 || ^19.0 || >= 19.0.0-rc"

packages/react/src/components/FormattingToolbar/DefaultButtons/BasicTextStyleButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
formatKeyboardShortcut,
77
} from "@blocknote/core";
88
import { useCallback } from "react";
9-
import { IconType } from "react-icons";
9+
import type { IconType } from "../../../icons.js";
1010
import {
1111
RiBold,
1212
RiCodeFill,

packages/react/src/components/FormattingToolbar/DefaultButtons/TextAlignButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from "@blocknote/core";
1212
import { TableHandlesExtension } from "@blocknote/core/extensions";
1313
import { useCallback } from "react";
14-
import { IconType } from "react-icons";
14+
import type { IconType } from "../../../icons.js";
1515
import {
1616
RiAlignCenter,
1717
RiAlignJustify,

packages/react/src/components/FormattingToolbar/DefaultSelects/BlockTypeSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
StyleSchema,
77
} from "@blocknote/core";
88
import { useMemo } from "react";
9-
import type { IconType } from "react-icons";
9+
import type { IconType } from "../../../icons.js";
1010
import {
1111
RiH1,
1212
RiH2,

packages/react/src/components/SuggestionMenu/getDefaultReactSlashMenuItems.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
RiVolumeUpFill,
2929
} from "react-icons/ri";
3030

31-
import { IconType } from "react-icons";
31+
import type { IconType } from "../../icons.js";
3232
import { DefaultReactSuggestionItem } from "./types.js";
3333

3434
const icons: Record<string, IconType> = {

0 commit comments

Comments
 (0)