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

fix: get POC running on the latest version of blocknote again #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
1,897 changes: 556 additions & 1,341 deletions hocuspocus-server/package-lock.json

Large diffs are not rendered by default.

35 changes: 18 additions & 17 deletions hocuspocus-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,37 @@
"clean": "rimraf dist && rimraf types"
},
"dependencies": {
"react": "^19.0.0",
"react-dom": "^19.0.0",
"@blocknote/react": "^0.25.0",
"@blocknote/core": "^0.25.0",
"@hono/node-ws": "^1.0.8",
"@blocknote/core": "https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@1596",
"@blocknote/react": "https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/react@1596",
"@blocknote/server-util": "https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/server-util@1596",
"@hocuspocus/extension-sqlite": "^2.15.2",
"@hocuspocus/server": "^2.15.2",
"@hono/node-server": "^1.0.8",
"@hono/node-ws": "^1.0.8",
"@tiptap/core": "^2.11.5",
"hono": "^4.7.2",
"@hocuspocus/server": "^2.15.2",
"@hocuspocus/extension-sqlite": "^2.15.2",
"y-prosemirror": "^1.2.15",
"@blocknote/server-util": "^0.25.0",
"yjs": "^13.6.23",
"prosemirror-state": "^1.4.1"
"prosemirror-state": "^1.4.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"y-prosemirror": "^1.3.1",
"yjs": "^13"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"eslint": "^8.10.0",
"eslint-config-react-app": "^7.0.0",
"eslint-plugin-import": "^2.31.0",
"prettier": "^2.7.1",
"rimraf": "^5.0.5",
"rollup-plugin-webpack-stats": "^0.2.2",
"typescript": "^5.3.3",
"undici": "^6",
"vite": "^5.3.4",
"vite-node": "^2.1.6",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-externalize-deps": "^0.8.0",
"vitest": "^2.0.3",
"undici": "^6",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"eslint-config-react-app": "^7.0.0",
"eslint-plugin-import": "^2.31.0"
"vitest": "^2.0.3"
},
"eslintConfig": {
"extends": [
Expand Down
2 changes: 1 addition & 1 deletion hocuspocus-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const documentMiddleware = createMiddleware<{

c.set("document", document);

await next();
return await next();
});

app.use("/documents/:documentId/*", documentMiddleware);
Expand Down
13 changes: 8 additions & 5 deletions hocuspocus-server/src/setMark.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CommentMark } from "@blocknote/core/comments";
import { ServerBlockNoteEditor } from "@blocknote/server-util";
import { Document } from "@hocuspocus/server";
import { EditorState, TextSelection } from "prosemirror-state";
Expand All @@ -23,10 +24,12 @@ export function setMark(
) {
// needed to get the pmSchema
// if you use a BlockNote custom schema, make sure to pass it to the create options
const editor = ServerBlockNoteEditor.create();
const editor = ServerBlockNoteEditor.create({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try with just passing comments to the editor options before merging this, I think that should work right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had tried this, but it wanted a ydoc I think. Maybe your PR will help this

_extensions: { comment: CommentMark },
});

// get the prosemirror document
const { doc: pNode, mapping } = initProseMirrorDoc(
const { doc: pNode, meta } = initProseMirrorDoc(
fragment,
editor.editor.pmSchema as any
);
Expand All @@ -37,13 +40,13 @@ export function setMark(
doc,
fragment,
yjsSelection.anchor,
mapping
meta.mapping
);
const head = relativePositionToAbsolutePosition(
doc,
fragment,
yjsSelection.head,
mapping
meta.mapping
);

// now, let's create the mark in the prosemirror document
Expand All @@ -60,7 +63,7 @@ export function setMark(
);

// finally, update the yjs document with the new prosemirror document
updateYFragment(doc, fragment, tr.doc, mapping);
updateYFragment(doc, fragment, tr.doc, meta);
}

// based on https://github.com/ueberdosis/tiptap/blob/f3258d9ee5fb7979102fe63434f6ea4120507311/packages/core/src/commands/setMark.ts#L66
Expand Down
7 changes: 5 additions & 2 deletions hocuspocus-server/src/threads.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { DefaultThreadStoreAuth, YjsThreadStore } from "@blocknote/core";
import {
DefaultThreadStoreAuth,
YjsThreadStore,
} from "@blocknote/core/comments";
import { Document } from "@hocuspocus/server";
import { Hono, Next } from "hono";
import { createMiddleware } from "hono/factory";
Expand Down Expand Up @@ -50,7 +53,7 @@ const threadStoreMiddleware = (options: { threadsMapKey: string }) =>
c.get("document").getMap(options.threadsMapKey),
new DefaultThreadStoreAuth(
c.get("userId"),
c.get("role") === "COMMENT-ONLY" ? "commenter" : "editor"
c.get("role") === "COMMENT-ONLY" ? "comment" : "editor"
)
);

Expand Down
2 changes: 1 addition & 1 deletion hocuspocus-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"moduleResolution": "Node",
"moduleResolution": "bundler",
"jsx": "react-jsx",
"strict": true,
"sourceMap": true,
Expand Down
5 changes: 4 additions & 1 deletion next-app/components/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"use client"; // this registers <Editor> as a Client Component
import { DefaultThreadStoreAuth, RESTYjsThreadStore } from "@blocknote/core";
import {
DefaultThreadStoreAuth,
RESTYjsThreadStore,
} from "@blocknote/core/comments";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
Expand Down
49 changes: 25 additions & 24 deletions next-app/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { NextConfig } from "next";
import path from "path";

const nextConfig: NextConfig = {
/* config options here */
Expand All @@ -11,31 +12,31 @@ const nextConfig: NextConfig = {
// };

// uncomment to directly load blocknote local blocknote dev
// config.resolve.alias = {
// yjs: path.resolve(__dirname, "./node_modules/yjs"),
// "@blocknote/core/fonts/inter.css": path.resolve(
// __dirname,
// "../../BlockNote/packages/core/src/fonts/inter.css"
// ),
// "@blocknote/mantine/style.css": path.resolve(
// __dirname,
// "../../BlockNote/packages/mantine/dist/style.css"
// ),
config.resolve.alias = {
yjs: path.resolve(__dirname, "./node_modules/yjs"),
// "@blocknote/core/fonts/inter.css": path.resolve(
// __dirname,
// "../../BlockNote/packages/core/src/fonts/inter.css"
// ),
// "@blocknote/mantine/style.css": path.resolve(
// __dirname,
// "../../BlockNote/packages/mantine/dist/style.css"
// ),

// "@blocknote/core": path.resolve(
// __dirname,
// "../../BlockNote/packages/core/"
// ),
// "@blocknote/react": path.resolve(
// __dirname,
// "../../BlockNote/packages/react/"
// ),
// "@blocknote/mantine": path.resolve(
// __dirname,
// "../../BlockNote/packages/mantine/"
// ),
// ...config.resolve.alias,
// };
// "@blocknote/core": path.resolve(
// __dirname,
// "../../BlockNote/packages/core/"
// ),
// "@blocknote/react": path.resolve(
// __dirname,
// "../../BlockNote/packages/react/"
// ),
// "@blocknote/mantine": path.resolve(
// __dirname,
// "../../BlockNote/packages/mantine/"
// ),
...config.resolve.alias,
};

return config;
},
Expand Down
Loading