Skip to content
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

wip: feat: comments #1376

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4d6e252
wip: better liveblocks support
YousefED Nov 14, 2024
dcd7c72
Merge remote-tracking branch 'origin/main' into feature/liveblocks-v2
YousefED Nov 18, 2024
c659253
misc fixes
YousefED Nov 18, 2024
a03d33f
misc
YousefED Nov 19, 2024
85521df
revert minimal
YousefED Nov 19, 2024
e43741a
simplify setup
YousefED Nov 20, 2024
e0c7f0f
update config
YousefED Nov 20, 2024
d747238
fix
YousefED Nov 20, 2024
6ce69ea
fix
YousefED Nov 20, 2024
a3028c1
markview
YousefED Dec 14, 2024
15c7520
cleanup
YousefED Dec 14, 2024
b8a8d49
Merge remote-tracking branch 'origin/main' into feature/liveblocks-v2
YousefED Jan 8, 2025
1b44296
wip
YousefED Jan 10, 2025
23275a0
wip
YousefED Jan 13, 2025
721a4e9
wip
YousefED Jan 14, 2025
e824c42
wip
YousefED Jan 15, 2025
f2d4bb8
misc
YousefED Jan 16, 2025
434eafa
add threadstore tests
YousefED Jan 16, 2025
9d35f72
document recommended auth rules
YousefED Jan 16, 2025
58ed7c0
resolve
YousefED Jan 16, 2025
b761e1e
basic userstore impl
YousefED Jan 16, 2025
5f52147
user auth
YousefED Jan 16, 2025
060708d
Big comments UX WIP
matthewlipski Jan 24, 2025
5c6f45b
Merge branch 'main' into feature/comments
matthewlipski Jan 28, 2025
16c6a7a
Merge branch 'main' into feature/comments
matthewlipski Jan 28, 2025
a5e07c0
Updated reactions UX
matthewlipski Jan 28, 2025
b42047f
change reaction implementation
YousefED Feb 10, 2025
43a1eb0
reactions improvements
YousefED Feb 10, 2025
306c335
small cleanup
YousefED Feb 10, 2025
99d9d21
cleanups + mark some todos
YousefED Feb 10, 2025
4501af4
comments
YousefED Feb 11, 2025
eadb49d
fix locales
YousefED Feb 11, 2025
b81bab0
Merge remote-tracking branch 'upstream/main' into feature/comments
YousefED Feb 11, 2025
9f40651
fix build
YousefED Feb 11, 2025
7ae2b7f
cleanup + sample
YousefED Feb 11, 2025
748a183
fix build
YousefED Feb 11, 2025
e93b53b
fix lint
YousefED Feb 11, 2025
be9dd46
disable liveblocks for now
YousefED Feb 11, 2025
3e93d1e
lint
YousefED Feb 11, 2025
40269a5
fix linkify warning + make toggle editable comment
YousefED Feb 11, 2025
62a8944
fix content reset bug
YousefED Feb 11, 2025
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
2 changes: 1 addition & 1 deletion examples/01-basic/01-minimal/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useCreateBlockNote } from "@blocknote/react";

export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote();
const editor = useCreateBlockNote({});

// Renders the editor instance using a React component.
return <BlockNoteView editor={editor} />;
Expand Down
2 changes: 1 addition & 1 deletion examples/01-basic/02-block-objects/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Block } from "@blocknote/core";
import "@blocknote/core/fonts/inter.css";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useCreateBlockNote } from "@blocknote/react";
import { useState } from "react";

import "./styles.css";
Expand Down
10 changes: 5 additions & 5 deletions examples/07-collaboration/02-liveblocks/.bnexample.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"playground": true,
"docs": true,
"author": "yousefed",
"tags": ["Advanced", "Saving/Loading", "Collaboration"],
"tags": ["Advanced", "Liveblocks", "Collaboration"],
"dependencies": {
"@liveblocks/client": "^1.10.0",
"@liveblocks/react": "^1.10.0",
"@liveblocks/yjs": "^1.10.0",
"yjs": "^13.6.15"
"@liveblocks/client": "^2.11.0",
"@liveblocks/react": "^2.11.0",
"@liveblocks/react-ui": "^2.11.0",
"@liveblocks/react-blocknote": "^2.11.0"
}
}
49 changes: 15 additions & 34 deletions examples/07-collaboration/02-liveblocks/App.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,22 @@
import "@blocknote/core/fonts/inter.css";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { createClient } from "@liveblocks/client";
import LiveblocksProvider from "@liveblocks/yjs";
import * as Y from "yjs";

// Sets up Liveblocks client.
const client = createClient({
publicApiKey:
"pk_dev_lJAS4XHx3l1e0x_Gh9VMtrvo8PEB1vrNarC2YRtAOp4t6i9_QAcSX2U953GS6v7B",
});
// Enters a multiplayer room.
// Use a unique name as a "room" for your application.
const { room } = client.enterRoom("your-project-name", {
initialPresence: {},
});
// .. in imports are temporary for development (vite setup)

// Sets up Yjs document and Liveblocks Yjs provider.
const doc = new Y.Doc();
const provider = new LiveblocksProvider(room, doc);
// Need to be imported before @liveblocks/react-blocknote styles
import "@liveblocks/react-ui/styles.css";
// Need to be imported after @liveblocks/react-ui styles
import "@liveblocks/react-blocknote/styles.css";

export default function App() {
const editor = useCreateBlockNote({
collaboration: {
// The Yjs Provider responsible for transporting updates:
provider,
// Where to store BlockNote data in the Y.Doc:
fragment: doc.getXmlFragment("document-store"),
// Information (name and color) for this user:
user: {
name: "My Username",
color: "#ff0000",
},
},
});
import { Editor } from "./Editor.jsx";
import { Room } from "./Room.jsx";
import "./globals.css";

// Renders the editor instance.
return <BlockNoteView editor={editor} />;
export default function App() {
// Renders the editor instance using a React component.
return (
<Room>
<Editor />
</Room>
);
}
14 changes: 14 additions & 0 deletions examples/07-collaboration/02-liveblocks/Editor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use client";

import { BlockNoteView } from "@blocknote/mantine";
import { useCreateBlockNoteWithLiveblocks } from "@liveblocks/react-blocknote";
import { Threads } from "./Threads";
export function Editor() {
const editor = useCreateBlockNoteWithLiveblocks({});

return (
<BlockNoteView editor={editor}>
<Threads editor={editor} />
</BlockNoteView>
);
}
51 changes: 51 additions & 0 deletions examples/07-collaboration/02-liveblocks/Room.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"use client";

import {
ClientSideSuspense,
LiveblocksProvider,
RoomProvider,
} from "@liveblocks/react/suspense";
import { ReactNode } from "react";

const users = [
{
id: "1",
name: "John Doe",
avatar: "https://liveblocks.io/avatars/avatar-1.png",
},
{
id: "2",
name: "Alice Smith",
avatar: "https://liveblocks.io/avatars/avatar-2.png",
},
{
id: "3",
name: "Bob Johnson",
avatar: "https://liveblocks.io/avatars/avatar-3.png",
},
];

export function Room({ children }: { children: ReactNode }) {
return (
<LiveblocksProvider
publicApiKey={
"pk_dev_KuhEOKuRRciDDFTpS7qThHZmqzx7D9dKjDs7xIP21ojB2AnZ8whd9ZrV5u97zuMG"
}
resolveMentionSuggestions={async (args) => {
return users
.filter((user) =>
user.name.toLowerCase().startsWith(args.text.toLowerCase())
)
.map((user) => user.id);
}}
resolveUsers={async (args) => {
return args.userIds.map((id) => users.find((user) => user.id === id));
}}>
<RoomProvider id="my-room">
<ClientSideSuspense fallback={<div>Loading…</div>}>
{children}
</ClientSideSuspense>
</RoomProvider>
</LiveblocksProvider>
);
}
29 changes: 29 additions & 0 deletions examples/07-collaboration/02-liveblocks/Threads.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { BlockNoteEditor } from "@blocknote/core";
import {
AnchoredThreads,
FloatingComposer,
FloatingThreads,
} from "@liveblocks/react-blocknote";
import { useThreads } from "@liveblocks/react/suspense";

export function Threads({
editor,
}: {
editor: BlockNoteEditor<any, any, any>;
}) {
const { threads } = useThreads({ query: { resolved: false } });

return (
<>
<div className="anchored-threads">
<AnchoredThreads editor={editor} threads={threads} />
</div>
<FloatingThreads
editor={editor}
threads={threads}
className="floating-threads"
/>
<FloatingComposer editor={editor} className="floating-composer" />
</>
);
}
27 changes: 27 additions & 0 deletions examples/07-collaboration/02-liveblocks/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* For mobile */
.floating-threads {
display: none;
}

/* For desktop */
.anchored-threads {
display: block;
max-width: 300px;
width: 100%;
position: absolute;
right: 12px;
}

@media (max-width: 640px) {
.floating-threads {
display: block;
}

.anchored-threads {
display: none;
}
}

.lb-portal {
z-index: 3000;
}
8 changes: 4 additions & 4 deletions examples/07-collaboration/02-liveblocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"@blocknote/shadcn": "latest",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"@liveblocks/client": "^1.10.0",
"@liveblocks/react": "^1.10.0",
"@liveblocks/yjs": "^1.10.0",
"yjs": "^13.6.15"
"@liveblocks/client": "^2.11.0",
"@liveblocks/react": "^2.11.0",
"@liveblocks/react-ui": "^2.11.0",
"@liveblocks/react-blocknote": "^2.11.0"
},
"devDependencies": {
"@types/react": "^18.0.25",
Expand Down
14 changes: 4 additions & 10 deletions examples/07-collaboration/02-liveblocks/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
],
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
Expand All @@ -22,15 +18,13 @@
"jsx": "react-jsx",
"composite": true
},
"include": [
"."
],
"__ADD_FOR_LOCAL_DEV_references": [
"include": ["."],
"references": [
{
"path": "../../../packages/core/"
},
{
"path": "../../../packages/react/"
}
]
}
}
Loading