Skip to content

Commit e9b5afe

Browse files
committed
Setup linkage with yjs codemirror and webrtc signalling server
1 parent f285352 commit e9b5afe

File tree

7 files changed

+273
-7
lines changed

7 files changed

+273
-7
lines changed

apps/frontend/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# URL endpoints of the services
22
NEXT_PUBLIC_QUESTION_SERVICE_URL="http://localhost:8080/"
33
NEXT_PUBLIC_USER_SERVICE_URL="http://localhost:3001/"
4-
NEXT_PUBLIC_MATCHING_SERVICE_URL="ws://localhost:8081/match"
4+
NEXT_PUBLIC_MATCHING_SERVICE_URL="ws://localhost:8081/match"
5+
NEXT_PUBLIC_SIGNALLING_SERVICE_URL="ws://localhost:4444/"

apps/frontend/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"dependencies": {
1212
"@ant-design/icons": "^5.5.1",
1313
"@ant-design/nextjs-registry": "^1.0.1",
14+
"@codemirror/lang-javascript": "^6.2.2",
15+
"@codemirror/state": "^6.4.1",
1416
"antd": "^5.20.6",
1517
"codemirror": "^6.0.1",
1618
"next": "14.2.13",
@@ -20,7 +22,9 @@
2022
"react-use-websocket": "^4.9.0",
2123
"sass": "^1.79.2",
2224
"typeface-montserrat": "^1.1.13",
23-
"y-codemirror.next": "^0.3.5"
25+
"y-codemirror.next": "^0.3.5",
26+
"y-webrtc": "^10.3.0",
27+
"yjs": "^13.6.20"
2428
},
2529
"devDependencies": {
2630
"@types/node": "^20",

apps/frontend/pnpm-lock.yaml

Lines changed: 142 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/frontend/src/app/collaboration/[id]/page.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
SendOutlined,
2727
} from "@ant-design/icons";
2828
import { ProgrammingLanguageOptions } from "@/utils/SelectOptions";
29+
import CollaborativeEditor from "@/components/CollaborativeEditor/CollaborativeEditor";
2930

3031
interface CollaborationProps {}
3132

@@ -45,6 +46,7 @@ export default function CollaborationPage(props: CollaborationProps) {
4546
const [collaborationId, setCollaborationId] = useState<string | undefined>(
4647
undefined
4748
);
49+
const [currentUser, setCurrentUser] = useState<string | undefined>(undefined);
4850
const [matchedUser, setMatchedUser] = useState<string | undefined>(undefined);
4951

5052
// Chat states
@@ -70,10 +72,12 @@ export default function CollaborationPage(props: CollaborationProps) {
7072
const docRefId: string = localStorage.getItem("docRefId") ?? "";
7173
const collabId: string = localStorage.getItem("collabId") ?? "";
7274
const matchedUser: string = localStorage.getItem("matchedUser") ?? "";
75+
const currentUser: string = localStorage.getItem("user") ?? "";
7376

7477
// Set states from localstorage
7578
setCollaborationId(collabId);
7679
setMatchedUser(matchedUser);
80+
setCurrentUser(currentUser);
7781

7882
GetSingleQuestion(docRefId).then((data: Question) => {
7983
setQuestionTitle(`${data.id}. ${data.title}`);
@@ -185,6 +189,12 @@ export default function CollaborationPage(props: CollaborationProps) {
185189
onSelect={(val) => setSelectedLanguage(val)}
186190
/>
187191
</div>
192+
{collaborationId && currentUser && (
193+
<CollaborativeEditor
194+
user={currentUser}
195+
collaborationId={collaborationId}
196+
/>
197+
)}
188198
</div>
189199
</Row>
190200
</Col>

apps/frontend/src/app/collaboration/[id]/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103

104104
.chat-message-box {
105105
margin-top: 1rem;
106-
height: 70%;
106+
height: 365px;
107107
border: 1px solid #d9d9d9;
108108
border-radius: 6px;
109109
overflow-y: scroll;

0 commit comments

Comments
 (0)