-
-
Notifications
You must be signed in to change notification settings - Fork 693
feat: Comments #1376
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: Comments #1376
Changes from 16 commits
4d6e252
dcd7c72
c659253
a03d33f
85521df
e43741a
e0c7f0f
d747238
6ce69ea
a3028c1
15c7520
b8a8d49
1b44296
23275a0
721a4e9
e824c42
f2d4bb8
434eafa
9d35f72
58ed7c0
b761e1e
5f52147
060708d
5c6f45b
16c6a7a
a5e07c0
b42047f
43a1eb0
306c335
99d9d21
4501af4
eadb49d
b81bab0
9f40651
7ae2b7f
748a183
e93b53b
be9dd46
3e93d1e
40269a5
62a8944
22fdde6
c293fdf
c0d1bd5
311881c
a71fc69
4d498de
c5a6a0c
3f7828d
d2c9f34
6df6886
5b7e3d4
3ef17e5
db7d339
6067a2b
298ba46
c007f84
99c599c
c0c848a
9576cfe
44b2dca
6c6b017
97f1f0a
5decc46
4cb7af0
27a2523
b27db16
65dfc20
2fe1052
e3291d0
165a014
807d8d1
e3e5867
6bdbf15
d0b3f39
cfd94eb
ac6a17c
f200646
7c0746e
4d293ef
f35a66a
8d9d542
0f1e019
490291f
11d9ee6
7d4b64e
8ec3e50
fa1e5a7
f2f29e7
e97985e
a4a90b8
df1d6a0
7b128dc
9ae74bd
953aefa
46101a0
ab00b5d
38a670d
8d8ebec
6744b26
a7a5656
ebfb4da
9944ca7
30003d7
f1557b1
a647ec3
065c74d
f26edd3
ae534b4
9a12826
828d13e
46836e5
641a6b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,13 @@ | ||
| # Comments & Threads | ||
|
|
||
| TODO | ||
| In this example, you can add comments to the document while collaborating with others. You can also pick user accounts with different permissions, as well as react to, reply to, and resolve existing comments. | ||
|
|
||
| **Try it out:** Click the "Add comment" button in the [Formatting Toolbar](/docs/ui-components/formatting-toolbar) to add a comment! | ||
|
|
||
| **Relevant Docs:** | ||
|
|
||
| - [Editor Setup](/docs/editor-basics/setup) | ||
| - [Real-time collaboration](/docs/collaboration/real-time-collaboration) | ||
| - [Y-Sweet on Jamsocket](https://docs.jamsocket.com/y-sweet/tutorials/blocknote) | ||
| - [Comments](/docs/collaboration/comments) | ||
|
|
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 |
|---|---|---|
|
|
@@ -125,75 +125,6 @@ export type BlockNoteEditorOptions< | |
| */ | ||
| animations?: boolean; | ||
|
|
||
| /** | ||
| * Disable internal extensions (based on keys / extension name) | ||
| */ | ||
| disableExtensions: string[]; | ||
|
|
||
| /** | ||
| * A dictionary object containing translations for the editor. | ||
| */ | ||
| dictionary?: Dictionary & Record<string, any>; | ||
|
|
||
| /** | ||
| * @deprecated, provide placeholders via dictionary instead | ||
| */ | ||
| placeholders: Record< | ||
| string | "default" | "emptyDocument", | ||
| string | undefined | ||
| >; | ||
|
|
||
| /** | ||
| * An object containing attributes that should be added to HTML elements of the editor. | ||
| * | ||
| * @example { editor: { class: "my-editor-class" } } | ||
| */ | ||
| domAttributes: Partial<BlockNoteDOMAttributes>; | ||
|
|
||
| /** | ||
| * The content that should be in the editor when it's created, represented as an array of partial block objects. | ||
| */ | ||
| initialContent: PartialBlock< | ||
| NoInfer<BSchema>, | ||
| NoInfer<ISchema>, | ||
| NoInfer<SSchema> | ||
| >[]; | ||
| /** | ||
| * Use default BlockNote font and reset the styles of <p> <li> <h1> elements etc., that are used in BlockNote. | ||
| * | ||
| * @default true | ||
| */ | ||
| defaultStyles: boolean; | ||
|
|
||
| schema: BlockNoteSchema<BSchema, ISchema, SSchema>; | ||
|
|
||
| /** | ||
| * The `uploadFile` method is what the editor uses when files need to be uploaded (for example when selecting an image to upload). | ||
| * This method should set when creating the editor as this is application-specific. | ||
| * | ||
| * `undefined` means the application doesn't support file uploads. | ||
| * | ||
| * @param file The file that should be uploaded. | ||
| * @returns The URL of the uploaded file OR an object containing props that should be set on the file block (such as an id) | ||
| */ | ||
| uploadFile: ( | ||
| file: File, | ||
| blockId?: string | ||
| ) => Promise<string | Record<string, any>>; | ||
|
|
||
| /** | ||
| * Resolve a URL of a file block to one that can be displayed or downloaded. This can be used for creating authenticated URL or | ||
| * implementing custom protocols / schemes | ||
| * @returns The URL that's | ||
| */ | ||
| resolveFileUrl: (url: string) => Promise<string>; | ||
|
|
||
| resolveUsers: (userIds: string[]) => Promise<User[]>; | ||
|
|
||
| // TODO: decide "comments" or "threads"? | ||
| comments: { | ||
| threadStore: ThreadStore; | ||
| }; | ||
| /** | ||
| * When enabled, allows for collaboration between multiple users. | ||
| */ | ||
|
|
@@ -226,6 +157,10 @@ export type BlockNoteEditorOptions< | |
| showCursorLabels?: "always" | "activity"; | ||
| }; | ||
|
|
||
| comments: { | ||
| threadStore: ThreadStore; | ||
| }; | ||
|
|
||
| /** | ||
| * Use default BlockNote font and reset the styles of <p> <li> <h1> elements etc., that are used in BlockNote. | ||
| * | ||
|
|
@@ -285,6 +220,8 @@ export type BlockNoteEditorOptions< | |
| */ | ||
| resolveFileUrl: (url: string) => Promise<string>; | ||
|
|
||
| resolveUsers: (userIds: string[]) => Promise<User[]>; | ||
|
|
||
| schema: BlockNoteSchema<BSchema, ISchema, SSchema>; | ||
|
|
||
| /** | ||
|
|
@@ -1431,11 +1368,11 @@ export class BlockNoteEditor< | |
| ); | ||
| } | ||
|
|
||
| public get ForceSelectionVisible() { | ||
| return this.showSelectionPlugin.ForceSelectionVisible; | ||
| public getForceSelectionVisible() { | ||
|
Collaborator
Author
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. why not use a getter / setter for this? (like we do for "isEditable")?
Collaborator
Author
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. @matthewlipski can you add a comment? |
||
| return this.showSelectionPlugin.getEnabled(); | ||
| } | ||
|
|
||
| public set ForceSelectionVisible(forceSelectionVisible: boolean) { | ||
| this.showSelectionPlugin.ForceSelectionVisible = forceSelectionVisible; | ||
| public setForceSelectionVisible(forceSelectionVisible: boolean) { | ||
| this.showSelectionPlugin.setEnabled(forceSelectionVisible); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,6 +147,7 @@ export class CommentsPlugin extends EventEmitter<any> { | |
| this.threadStore.subscribe(this.updateMarksFromThreads); | ||
|
Comment on lines
+145
to
+147
Contributor
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. Yea, we need an API for this |
||
|
|
||
| editor.onCreate(() => { | ||
| // Need to wait for TipTap editor state to be initialized | ||
| this.updateMarksFromThreads(this.threadStore.getThreads()); | ||
| editor.onSelectionChange(() => { | ||
|
Contributor
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. Feels weird to register this after the create hook, why not just register in the constructor separately?
Collaborator
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. It needs to access the TipTap state, and bc we init the comments plugin in the |
||
| if (this.pendingComment) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.