snapshot of https://github.com/ueberdosis/hocuspocus.git @ cf3cfa355b4d3bb61c6b6c80071f71783e32470e (2026-09-15)
Some checks failed
build / lint (22) (push) Failing after 17s
build / test (22) (push) Failing after 8s
build / lint (23) (push) Failing after 2s
build / build (22) (push) Has been skipped
build / build (23) (push) Has been skipped
build / test (23) (push) Failing after 4s
docsearch / docsearch (push) Failing after 1s
Some checks failed
build / lint (22) (push) Failing after 17s
build / test (22) (push) Failing after 8s
build / lint (23) (push) Failing after 2s
build / build (22) (push) Has been skipped
build / build (23) (push) Has been skipped
build / test (23) (push) Failing after 4s
docsearch / docsearch (push) Failing after 1s
This commit is contained in:
53
playground/frontend/app/articles/layout.tsx
Normal file
53
playground/frontend/app/articles/layout.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
"use client";
|
||||
|
||||
import { HocuspocusProviderWebsocket } from "@hocuspocus/provider";
|
||||
// import {
|
||||
// TiptapCollabProvider,
|
||||
// TiptapCollabProviderWebsocket,
|
||||
// } from "@tiptap-cloud/provider";
|
||||
import { useEffect, useState } from "react";
|
||||
import { SocketContext1 } from "@/app/SocketContext1";
|
||||
import { SocketContext2 } from "@/app/SocketContext2";
|
||||
|
||||
export default function Layout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
const [socket1, setSocket1] = useState<HocuspocusProviderWebsocket | null>(
|
||||
null,
|
||||
);
|
||||
const [socket2, setSocket2] = useState<HocuspocusProviderWebsocket | null>(
|
||||
null,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const newlyCreatedSocket1 = new HocuspocusProviderWebsocket({
|
||||
url: "ws://localhost:8000",
|
||||
});
|
||||
const newlyCreatedSocket2 = new HocuspocusProviderWebsocket({
|
||||
url: "ws://localhost:8000",
|
||||
});
|
||||
// const newlyCreatedSocket = new TiptapCollabProviderWebsocket({
|
||||
// appId: "",
|
||||
// });
|
||||
|
||||
setSocket1(newlyCreatedSocket1);
|
||||
setSocket2(newlyCreatedSocket2);
|
||||
|
||||
return () => {
|
||||
newlyCreatedSocket1?.destroy();
|
||||
newlyCreatedSocket2?.destroy();
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (socket1 && socket2) {
|
||||
return (
|
||||
<>
|
||||
<SocketContext1 value={socket1}>
|
||||
<SocketContext2 value={socket2}>{children}</SocketContext2>
|
||||
</SocketContext1>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user