Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 0 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,14 @@
"@tiptap/core": "^3.13.0",
"@tiptap/extension-bold": "^3.13.0",
"@tiptap/extension-code": "^3.13.0",
"@tiptap/extension-horizontal-rule": "^3.13.0",
"@tiptap/extension-italic": "^3.13.0",
"@tiptap/extension-paragraph": "^3.13.0",
"@tiptap/extension-strike": "^3.13.0",
"@tiptap/extension-text": "^3.13.0",
"@tiptap/extension-underline": "^3.13.0",
"@tiptap/extensions": "^3.13.0",
"@tiptap/pm": "^3.13.0",
"emoji-mart": "^5.6.0",
"fast-deep-equal": "^3.1.3",
"lib0": "^0.2.99",
"prosemirror-highlight": "^0.15.1",
"prosemirror-model": "^1.25.4",
"prosemirror-state": "^1.4.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { CommentBody } from "../../types.js";
import { DefaultThreadStoreAuth } from "../DefaultThreadStoreAuth.js";
import { YjsThreadStore } from "./YjsThreadStore.js";

// Mock UUID to generate sequential IDs
// Mock crypto.randomUUID to generate sequential IDs
let mockUuidCounter = 0;
vi.mock("lib0/random", async (importOriginal) => ({
...(await importOriginal<typeof import("lib0/random")>()),
uuidv4: () => `mocked-uuid-${++mockUuidCounter}`,
}));
const originalRandomUUID = crypto.randomUUID.bind(crypto);
vi.spyOn(crypto, "randomUUID").mockImplementation(
() => `mocked-uuid-${++mockUuidCounter}` as ReturnType<typeof originalRandomUUID>,
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

describe("YjsThreadStore", () => {
let store: YjsThreadStore;
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/comments/threadstore/yjs/YjsThreadStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { uuidv4 } from "lib0/random";

Comment thread
nperez0111 marked this conversation as resolved.
Outdated
import * as Y from "yjs";
import { CommentBody, CommentData, ThreadData } from "../../types.js";
import { ThreadStoreAuth } from "../ThreadStoreAuth.js";
Expand Down Expand Up @@ -57,7 +57,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {

const comment: CommentData = {
type: "comment",
id: uuidv4(),
id: crypto.randomUUID(),
userId: this.userId,
createdAt: date,
updatedAt: date,
Expand All @@ -68,7 +68,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {

const thread: ThreadData = {
type: "thread",
id: uuidv4(),
id: crypto.randomUUID(),
createdAt: date,
updatedAt: date,
comments: [comment],
Expand Down Expand Up @@ -105,7 +105,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
const date = new Date();
const comment: CommentData = {
type: "comment",
id: uuidv4(),
id: crypto.randomUUID(),
userId: this.userId,
createdAt: date,
updatedAt: date,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/extensions/Placeholder/Placeholder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Plugin, PluginKey } from "prosemirror-state";
import { Decoration, DecorationSet } from "prosemirror-view";
import { uuidv4 } from "lib0/random";

import {
createExtension,
ExtensionOptions,
Expand All @@ -23,7 +23,7 @@ export const PlaceholderExtension = createExtension(
new Plugin({
key: PLUGIN_KEY,
view: (view) => {
const uniqueEditorSelector = `placeholder-selector-${uuidv4()}`;
const uniqueEditorSelector = `placeholder-selector-${crypto.randomUUID()}`;
view.dom.classList.add(uniqueEditorSelector);
const styleEl = document.createElement("style");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "@tiptap/core";
import { Fragment, Slice } from "prosemirror-model";
import { Plugin, PluginKey } from "prosemirror-state";
import { uuidv4 } from "lib0/random";


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

return uuidv4();
return crypto.randomUUID();
},
filterTransaction: null,
};
Expand Down
9 changes: 4 additions & 5 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,18 @@
"@blocknote/core": "0.51.3",
"@emoji-mart/data": "^1.2.1",
"@floating-ui/react": "^0.27.18",
"@floating-ui/utils": "^0.2.10",
"@tanstack/react-store": "0.7.7",
"@tiptap/core": "^3.13.0",
"@tiptap/pm": "^3.13.0",
"@tiptap/react": "^3.13.0",
"@types/use-sync-external-store": "1.5.0",
"emoji-mart": "^5.6.0",
"fast-deep-equal": "^3.1.3",
"lodash.merge": "^4.6.2",
"react-icons": "^5.5.0",
"use-sync-external-store": "1.6.0"
},
"devDependencies": {
"@types/lodash.foreach": "^4.5.9",
"@types/lodash.groupby": "^4.6.9",
"@types/lodash.merge": "^4.6.9",
"react-icons": "^5.5.0",
"@types/react": "^19.2.3",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.1",
Expand All @@ -91,6 +87,9 @@
"vite-plugin-externalize-deps": "^0.10.0",
"vitest": "^4.1.2"
},
"optionalDependencies": {
"@types/use-sync-external-store": "1.5.0"
},
"peerDependencies": {
"react": "^18.0 || ^19.0 || >= 19.0.0-rc",
"react-dom": "^18.0 || ^19.0 || >= 19.0.0-rc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
formatKeyboardShortcut,
} from "@blocknote/core";
import { useCallback } from "react";
import { IconType } from "react-icons";
import type { IconType } from "../../../icons.js";
import {
RiBold,
RiCodeFill,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "@blocknote/core";
import { TableHandlesExtension } from "@blocknote/core/extensions";
import { useCallback } from "react";
import { IconType } from "react-icons";
import type { IconType } from "../../../icons.js";
import {
RiAlignCenter,
RiAlignJustify,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
StyleSchema,
} from "@blocknote/core";
import { useMemo } from "react";
import type { IconType } from "react-icons";
import type { IconType } from "../../../icons.js";
import {
RiH1,
RiH2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
RiVolumeUpFill,
} from "react-icons/ri";

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

const icons: Record<string, IconType> = {
Expand Down
12 changes: 12 additions & 0 deletions packages/react/src/icons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Compatible replacement for `IconType` from react-icons.
* Defined locally so consumers don't need react-icons installed for
* type-checking.
*/
export type IconType = React.ComponentType<
React.SVGAttributes<SVGElement> & {
size?: string | number;
color?: string;
title?: string;
}
>;
2 changes: 2 additions & 0 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export * from "./schema/ReactBlockSpec.js";
export * from "./schema/ReactInlineContentSpec.js";
export * from "./schema/ReactStyleSpec.js";

export * from "./icons.js";

export * from "./util/elementOverflow.js";
export * from "./util/mergeRefs.js";

Expand Down
10 changes: 10 additions & 0 deletions packages/react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ export default defineConfig((conf) => ({
// make sure to externalize deps that shouldn't be bundled
// into your library
external: (source) => {
// Bundle react-icons into the output (tree-shaken) so consumers
// don't need to install it as a peer/runtime dependency.
const bundledDeps = ["react-icons"];
if (
bundledDeps.some(
(dep) => source === dep || source.startsWith(dep + "/")
)
) {
return false;
}
if (
Object.keys({
...pkg.dependencies,
Expand Down
54 changes: 9 additions & 45 deletions pnpm-lock.yaml

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

Loading