-
Notifications
You must be signed in to change notification settings - Fork 1
fix: get POC running on the latest version of blocknote again #2
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { ServerBlockNoteEditor } from "@blocknote/server-util"; | ||
import { Mark, mergeAttributes } from "@tiptap/core"; | ||
import { Document } from "@hocuspocus/server"; | ||
import { EditorState, TextSelection } from "prosemirror-state"; | ||
import { | ||
|
@@ -23,7 +24,75 @@ 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({ | ||
_extensions: { | ||
// TODO to get this to work, I needed to pass a copy of the comment mark to get it into the schema | ||
comments: Mark.create({ | ||
name: "comment", | ||
excludes: "", | ||
inclusive: false, | ||
keepOnSplit: true, | ||
group: "blocknoteIgnore", // ignore in blocknote json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to figure out what to do about this... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch! this was a leftover, it's been fixed already. will make a PR |
||
|
||
addAttributes() { | ||
// Return an object with attribute configuration | ||
return { | ||
// orphans are marks that currently don't have an active thread. It could be | ||
// that users have resolved the thread. Resolved threads by default are not shown in the document, | ||
// but we need to keep the mark (positioning) data so we can still "revive" it when the thread is unresolved | ||
// or we enter a "comments" view that includes resolved threads. | ||
orphan: { | ||
parseHTML: (element) => !!element.getAttribute("data-orphan"), | ||
renderHTML: (attributes) => { | ||
return (attributes as { orphan: boolean }).orphan | ||
? { | ||
"data-orphan": "true", | ||
} | ||
: {}; | ||
}, | ||
default: false, | ||
}, | ||
threadId: { | ||
parseHTML: (element) => element.getAttribute("data-bn-thread-id"), | ||
renderHTML: (attributes) => { | ||
return { | ||
"data-bn-thread-id": (attributes as { threadId: string }) | ||
.threadId, | ||
}; | ||
}, | ||
default: "", | ||
}, | ||
}; | ||
}, | ||
|
||
renderHTML({ | ||
HTMLAttributes, | ||
}: { | ||
HTMLAttributes: Record<string, any>; | ||
}) { | ||
return [ | ||
"span", | ||
mergeAttributes(HTMLAttributes, { | ||
class: "bn-thread-mark", | ||
}), | ||
]; | ||
}, | ||
|
||
parseHTML() { | ||
return [{ tag: "span.bn-thread-mark" }]; | ||
}, | ||
|
||
extendMarkSchema(extension) { | ||
if (extension.name === "comment") { | ||
return { | ||
blocknoteIgnore: true, | ||
}; | ||
} | ||
return {}; | ||
}, | ||
}), | ||
}, | ||
}); | ||
|
||
// get the prosemirror document | ||
const { doc: pNode, mapping } = initProseMirrorDoc( | ||
|
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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