Show comment context in thread

This commit is contained in:
Tom Moor
2024-01-04 22:30:22 -05:00
parent 63eae352ee
commit 47c13c9916
6 changed files with 55 additions and 17 deletions

View File

@@ -16,6 +16,8 @@ export type CommentMark = {
id: string;
/* The id of the user who created the comment */
userId: string;
/* The text of the comment */
text: string;
};
export type Task = {
@@ -88,8 +90,7 @@ export default class ProsemirrorHelper {
}
/**
* Returns true if the trimmed content of the passed document is an empty
* string.
* Returns true if the trimmed content of the passed document is an empty string.
*
* @returns True if the editor is empty
*/
@@ -98,8 +99,7 @@ export default class ProsemirrorHelper {
}
/**
* Iterates through the document to find all of the comments that exist as
* marks.
* Iterates through the document to find all of the comments that exist as marks.
*
* @param doc Prosemirror document node
* @returns Array<CommentMark>
@@ -110,7 +110,10 @@ export default class ProsemirrorHelper {
doc.descendants((node) => {
node.marks.forEach((mark) => {
if (mark.type.name === "comment") {
comments.push(mark.attrs as CommentMark);
comments.push({
...mark.attrs,
text: node.textContent,
} as CommentMark);
}
});
@@ -121,8 +124,7 @@ export default class ProsemirrorHelper {
}
/**
* Iterates through the document to find all of the tasks and their completion
* state.
* Iterates through the document to find all of the tasks and their completion state.
*
* @param doc Prosemirror document node
* @returns Array<Task>