Skip to content

Commit 7bd93dd

Browse files
committed
to change
1 parent 42d7466 commit 7bd93dd

3 files changed

Lines changed: 32 additions & 7 deletions

File tree

src/frontend/apps/impress/src/features/docs/doc-editor/components/comments/CommentSideBar.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { CommentsExtension } from '@blocknote/core/comments';
22
import { BlockNoteView } from '@blocknote/mantine';
33
import { ThreadsSidebar, useCreateBlockNote } from '@blocknote/react';
4+
import { HocuspocusProvider } from '@hocuspocus/provider';
45
import { useTranslation } from 'react-i18next';
56
import { css } from 'styled-components';
7+
import { Awareness } from 'y-protocols/awareness.js';
68

79
import { Box, ButtonCloseModal, Text } from '@/components/';
810
import { Doc } from '@/docs/doc-management';
@@ -13,9 +15,14 @@ import { useComments } from './useComments';
1315
interface CommentSideBarProps {
1416
doc: Doc;
1517
onClose: () => void;
18+
provider: HocuspocusProvider;
1619
}
1720

18-
export const CommentSideBar = ({ doc, onClose }: CommentSideBarProps) => {
21+
export const CommentSideBar = ({
22+
doc,
23+
onClose,
24+
provider,
25+
}: CommentSideBarProps) => {
1926
const { user } = useAuth();
2027
const canSeeComment = doc.abilities.comment;
2128
const { t } = useTranslation();
@@ -28,9 +35,17 @@ export const CommentSideBar = ({ doc, onClose }: CommentSideBarProps) => {
2835

2936
const editor = useCreateBlockNote(
3037
{
38+
collaboration: {
39+
fragment: provider.document.getXmlFragment('document-store'),
40+
user: {
41+
name: '',
42+
color: '',
43+
},
44+
provider: provider as { awareness?: Awareness | undefined },
45+
},
3146
extensions: [CommentsExtension({ threadStore, resolveUsers })],
3247
},
33-
[threadStore, resolveUsers],
48+
[threadStore, resolveUsers, provider],
3449
);
3550

3651
return (
@@ -52,14 +67,14 @@ export const CommentSideBar = ({ doc, onClose }: CommentSideBarProps) => {
5267
</Box>
5368

5469
<BlockNoteView
55-
className="--docs--main-editor"
70+
//className="--docs--main-editor"
5671
aria-label={t('Document editor')}
5772
editor={editor}
5873
formattingToolbar={false}
5974
slashMenu={false}
6075
theme="light"
6176
comments={false}
62-
renderEditor={false}
77+
//renderEditor={false}
6378
>
6479
<ThreadsSidebar filter="all" sort="recent-activity" />
6580
</BlockNoteView>

src/frontend/apps/impress/src/features/right-panel/components/RightPanel.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { css } from 'styled-components';
33

44
import { Box } from '@/components';
55
import { CommentSideBar } from '@/features/docs/doc-editor/components/comments/CommentSideBar';
6-
import { useDocStore } from '@/features/docs/doc-management';
6+
import { useDocStore, useProviderStore } from '@/features/docs/doc-management';
77
import { HEADER_HEIGHT } from '@/features/header';
88

99
import { useRightPanelStore } from './useRightPanelStore';
@@ -12,8 +12,11 @@ export const RightPanel = () => {
1212
const { t } = useTranslation();
1313
const { currentDoc: doc } = useDocStore();
1414
const { setIsPanelOpen, isPanelOpen } = useRightPanelStore();
15+
const { provider, isReady } = useProviderStore();
16+
const isProviderReady =
17+
isReady && provider && provider?.configuration.name === doc?.id;
1518

16-
if (!doc) {
19+
if (!doc || !isProviderReady) {
1720
return null;
1821
}
1922

@@ -43,7 +46,11 @@ export const RightPanel = () => {
4346
`}
4447
`}
4548
>
46-
<CommentSideBar doc={doc} onClose={() => setIsPanelOpen(false)} />
49+
<CommentSideBar
50+
doc={doc}
51+
onClose={() => setIsPanelOpen(false)}
52+
provider={provider}
53+
/>
4754
</Box>
4855
);
4956
};

src/frontend/apps/impress/src/pages/docs/[id]/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ export function DocLayout() {
7171
>
7272
<MainLayout enableResizablePanel={true}>
7373
<DocLayoutGlobalStyle />
74+
{/* BlockNoteView should wrap ⬇ from here
75+
See https://github.com/TypeCellOS/BlockNote/blob/main/examples/07-collaboration/06-comments-with-sidebar/src/App.tsx
76+
*/}
7477
<Box $direction="row" $width="100%">
7578
<Box $width="100%" $margin={{ horizontal: 'auto' }} $padding="base">
7679
<FloatingBar />

0 commit comments

Comments
 (0)