Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions examples/07-collaboration/05-comments/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function Document() {
);

return (
// <div style={{ height: "1000px", overflow: "scroll", position: "relative" }}>
<BlockNoteView
className={"comments-main-container"}
editor={editor}
Expand All @@ -109,5 +110,6 @@ function Document() {
/>
</div>
</BlockNoteView>
// </div>
);
}
7 changes: 7 additions & 0 deletions examples/07-collaboration/05-comments/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@
max-height: 200px;
overflow: auto !important;
}

/* .bn-editor,
.bn-container {
position: relative;
overflow: none !important;
height: fit-content;
} */
11 changes: 6 additions & 5 deletions packages/core/src/extensions/Comments/CommentsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class CommentsPlugin extends BlockNoteExtension {
);

const threadId = commentMark?.attrs.threadId as string | undefined;
self.selectThread(threadId, false);
self.selectThread(threadId);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the second param? Why is it removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You could set it to false to prevent scrolling to the mark (scrollToThread). We did this before and handled the scrolling in the Card component instead. Turns out. this was the only place it was set so I removed it outright.

},
},
}),
Expand Down Expand Up @@ -289,10 +289,11 @@ export class CommentsPlugin extends BlockNoteExtension {

// When a new thread is selected, scrolls the page to its reference text in
// the editor.
(
this.editor.prosemirrorView?.domAtPos(selectedThreadPosition.from)
.node as Element | undefined
)?.scrollIntoView({
const node = this.editor.prosemirrorView?.domAtPos(
selectedThreadPosition.from,
).node as Element | undefined;

node?.scrollIntoView({
behavior: "smooth",
block: "center",
});
Expand Down
17 changes: 3 additions & 14 deletions packages/mantine/src/comments/Card.tsx
Copy link
Contributor

Choose a reason for hiding this comment

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

Always happy to remove an effect!

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { assertEmpty, mergeCSSClasses } from "@blocknote/core";
import { ComponentProps, mergeRefs } from "@blocknote/react";
import { ComponentProps } from "@blocknote/react";
import {
Card as MantineCard,
Divider as MantineDivider,
Text as MantineText,
} from "@mantine/core";
import { forwardRef, useEffect, useRef } from "react";
import { forwardRef } from "react";

export const Card = forwardRef<
HTMLDivElement,
Expand All @@ -24,24 +24,13 @@ export const Card = forwardRef<

assertEmpty(rest, false);

// Makes the card scroll into view when selected.
const scrollRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (selected) {
scrollRef.current?.scrollIntoView({
behavior: "smooth",
block: "center",
});
}
}, [selected]);

return (
<MantineCard
className={mergeCSSClasses(className, selected ? "selected" : "")}
onFocus={onFocus}
onBlur={onBlur}
tabIndex={tabIndex}
ref={mergeRefs([ref, scrollRef])}
ref={ref}
>
{headerText && (
<MantineText className={"bn-header-text"}>{headerText}</MantineText>
Expand Down
Loading