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

feat: new tiptap example #33

Merged
merged 5 commits into from
Dec 15, 2023
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
26 changes: 10 additions & 16 deletions examples/tiptap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,29 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@radix-ui/react-dialog": "^1.0.2",
"@radix-ui/react-popover": "^1.0.2",
"@radix-ui/react-select": "^1.1.1",
"@radix-ui/react-tabs": "^1.0.1",
"@radix-ui/react-tooltip": "^1.0.2",
"@rocicorp/reflect-yjs": "0.0.1",
"@rocicorp/reflect": "^0.38.202311200859",
"@tiptap/extension-collaboration-cursor": "^2.0.4",
"@rocicorp/reflect-yjs": "0.0.1",
"@tiptap/core": "^2.0.4",
"@tiptap/extension-character-count": "^2.0.4",
"@tiptap/extension-collaboration": "^2.0.4",
"@tiptap/extension-collaboration-cursor": "^2.0.4",
"@tiptap/extension-highlight": "^2.0.4",
"@tiptap/extension-image": "^2.0.4",
"@tiptap/extension-link": "^2.0.4",
"@tiptap/extension-placeholder": "^2.0.4",
"@tiptap/extension-task-item": "^2.0.4",
"@tiptap/extension-task-list": "^2.0.4",
"@tiptap/extension-text-align": "^2.0.4",
"@tiptap/extension-typography": "^2.0.4",
"@tiptap/extension-youtube": "^2.0.4",
"@tiptap/pm": "^2.0.4",
"@tiptap/react": "^2.0.4",
"@tiptap/starter-kit": "^2.0.4",
"@types/node": "^20.3.1",
"@types/react-dom": "^18.2.17",
"@types/react": "^18.2.38",
"clsx": "^2.0.0",
"@types/react-dom": "^18.2.17",
"concurrently": "^8.2.2",
"lexical": "^0.11.1",
"nanoid": "^5.0.3",
"next": "^13.5.4",
"typescript": "^5.3.2",
"yjs": "^13.6.10"
},
"dependencies": {
"@tiptap/extension-code-block-lowlight": "^2.1.13",
"lowlight": "^3.1.0"
}
}
11,356 changes: 11,356 additions & 0 deletions examples/tiptap/public/remixicon.symbol.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion examples/tiptap/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "../styles/globals.css";
import "../styles/text-editor.css";

export const metadata = {
title: "Reflect + Yjs + Tiptap",
Expand Down
41 changes: 0 additions & 41 deletions examples/tiptap/src/components/Avatars.module.css

This file was deleted.

48 changes: 0 additions & 48 deletions examples/tiptap/src/components/Avatars.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions examples/tiptap/src/components/CustomTaskItem.module.css

This file was deleted.

31 changes: 0 additions & 31 deletions examples/tiptap/src/components/CustomTaskItem.tsx

This file was deleted.

50 changes: 50 additions & 0 deletions examples/tiptap/src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"use client";
import React, { useEffect, useState } from "react";
import { Provider } from "@rocicorp/reflect-yjs";
import { UserInfo } from "./TextEditor";

export function Footer({
provider,
currentUser,
}: {
provider: Provider;
currentUser: UserInfo;
}) {
const [users, setUsers] = useState<Record<string, UserInfo>>({});
useEffect(() => {
const { awareness } = provider;
const updateUsers = () => {
const awarenessusers = Object.fromEntries(
[...awareness.getStates().entries()].map(([key, state]) => [
key,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(state as any).user,
])
);

setUsers(awarenessusers);
};
updateUsers();
awareness.on("change", updateUsers);
return () => {
awareness.off("change", updateUsers);
};
}, [provider]);

const usersLength = Object.keys(users).length;

return (
<div className="editor__footer">
<div
className={`editor__status editor__status--${
usersLength ? "connected" : "offline"
}`}
>
{usersLength ? `${usersLength} online` : "offline"}
</div>
<div className="editor__name">{currentUser.name}</div>
</div>
);
}

export default Footer;
7 changes: 7 additions & 0 deletions examples/tiptap/src/components/MenuBar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.divider {
background-color: rgba(#fff, 0.25);
height: 1.25rem;
margin-left: 0.5rem;
margin-right: 0.75rem;
width: 1px;
}
Loading