-
Notifications
You must be signed in to change notification settings - Fork 53
Feature: Add collaborative text editing using Yjs, y-webrtc and y-monaco #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nileshtrivedi
wants to merge
13
commits into
leanprover-community:main
Choose a base branch
from
nileshtrivedi:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
29a80f8
Feature: Add collaborative text editing using Yjs, y-webrtc and y-monaco
nileshtrivedi e145009
symc with upstream
nileshtrivedi c1c8475
implement yjs signaling server within index.mjs
nileshtrivedi 5680152
restore top-level package.json
nileshtrivedi 1582aa6
sync with upstream
nileshtrivedi 5d8cb52
fix: add package-lock.json
joneugster cc46a9d
menu button; styling; popups
joneugster c67b47c
move css to separate file
joneugster 0d57ce2
password and user count
joneugster 49b91a5
fix settings text field; use color from style sheet
joneugster a6f508b
fix brittle port replacement
joneugster 3ce6b01
add high contrast border to selection
joneugster 9df6860
use env variable to enable/disable feature; write doc; fixes
joneugster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
joneugster marked this conversation as resolved.
joneugster marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| import { useAtom } from 'jotai' | ||
| import { FormEvent, useState } from 'react' | ||
|
|
||
| import { Popup } from '../navigation/Popup' | ||
| import { | ||
| collabDisplayNameAtom, | ||
| collabPasswordAtom, | ||
| collabRoomAtom, | ||
| isCollaboratingAtom, | ||
| } from '../store/collaboration-atoms' | ||
|
|
||
| /** The popup to join a collaboration room. */ | ||
| function CollaborationPopup({ open, handleClose }: { open: boolean; handleClose: () => void }) { | ||
| const [collabRoom, setCollabRoom] = useAtom(collabRoomAtom) | ||
| const [collabDisplayName, setCollabDisplayName] = useAtom(collabDisplayNameAtom) | ||
| const [collabPassword, setCollabPassword] = useAtom(collabPasswordAtom) | ||
| const [, setIsCollaborating] = useAtom(isCollaboratingAtom) | ||
| const [collabError, setCollabError] = useState('') | ||
|
|
||
| function onSubmit(ev: FormEvent) { | ||
| ev.preventDefault() | ||
| const isValid = /^[\w\d]{3,20}$/ | ||
| const isValidPwd = /^[\w\d]{1,20}$/ | ||
| if (!isValid.test(collabRoom)) { | ||
| setCollabError('Room name must be 3-20 alphanumeric characters.') | ||
| return | ||
| } | ||
| if (collabPassword != undefined && !isValidPwd.test(collabPassword)) { | ||
| setCollabError('The password must be up to 20 alphanumeric characters.') | ||
| return | ||
| } | ||
| if (!isValid.test(collabDisplayName)) { | ||
| setCollabError('Display name must be 3-20 alphanumeric characters.') | ||
| return | ||
| } | ||
| setCollabError('') | ||
| if (collabRoom) { | ||
| setIsCollaborating(true) | ||
| handleClose() | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <Popup open={open} handleClose={handleClose}> | ||
| <h2>Start or join collaboration</h2> | ||
| <form onSubmit={onSubmit}> | ||
| <div> | ||
| <p> | ||
| Others can join the collaboration by using the same "room name". The "display name" can | ||
| be chosen freely. | ||
| </p> | ||
| <p> | ||
| An optional password can be provided to restrict room access. Note that supplying a | ||
| different password will not result in an error. Instead each combination of room name | ||
| and password will have its own room. | ||
| </p> | ||
| </div> | ||
| <label>Room name:</label> | ||
| <input | ||
| required | ||
| autoFocus | ||
| type="text" | ||
| placeholder="Room name" | ||
| value={collabRoom} | ||
| onChange={(e) => { | ||
| setCollabRoom(e.target.value) | ||
| setCollabError('') | ||
| }} | ||
| /> | ||
| <label>Display name:</label> | ||
| <input | ||
| required | ||
| type="text" | ||
| placeholder="Your display name" | ||
| value={collabDisplayName} | ||
| onChange={(e) => { | ||
| setCollabDisplayName(e.target.value) | ||
| setCollabError('') | ||
| }} | ||
| /> | ||
| <label>Password (optional):</label> | ||
| <input | ||
| type="password" | ||
| placeholder="room password" | ||
| value={collabPassword} | ||
| onChange={(e) => { | ||
| const pwd = e.target.value | ||
| if (pwd.length == 0) { | ||
| setCollabPassword(undefined) | ||
| } else { | ||
| setCollabPassword(pwd) | ||
| } | ||
| setCollabError('') | ||
| }} | ||
| /> | ||
| {collabError && <p className="form-error">{collabError}</p>} | ||
| <input type="submit" value="Join" /> | ||
| </form> | ||
| </Popup> | ||
| ) | ||
| } | ||
|
|
||
| export default CollaborationPopup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { useAtom } from 'jotai' | ||
| import { FormEvent } from 'react' | ||
|
|
||
| import { Popup } from '../navigation/Popup' | ||
| import { collabRoomAtom, isCollaboratingAtom } from '../store/collaboration-atoms' | ||
|
|
||
| /** The popup to join a collaboration room. */ | ||
| function LeaveCollaborationPopup({ | ||
| open, | ||
| handleClose, | ||
| }: { | ||
| open: boolean | ||
| handleClose: () => void | ||
| }) { | ||
| const [, setIsCollaborating] = useAtom(isCollaboratingAtom) | ||
| const [collabRoom] = useAtom(collabRoomAtom) | ||
|
|
||
| function onSubmit(ev: FormEvent) { | ||
| ev.preventDefault() | ||
| setIsCollaborating(false) | ||
| handleClose() | ||
| } | ||
|
|
||
| return ( | ||
| <Popup open={open} handleClose={handleClose}> | ||
| <h2>{`Leave collaboration '${collabRoom}'?`}</h2> | ||
| <form onSubmit={onSubmit}> | ||
| <div className="button-row"> | ||
| <button | ||
| onClick={(ev) => { | ||
| ev.preventDefault() | ||
| handleClose() | ||
| }} | ||
| > | ||
| Stay | ||
| </button> | ||
| <input type="submit" value="Leave" /> | ||
| </div> | ||
| </form> | ||
| </Popup> | ||
| ) | ||
| } | ||
|
|
||
| export default LeaveCollaborationPopup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| .yRemoteSelection { | ||
| background-color: color-mix(in srgb, var(--vscode-symbolIcon-eventForeground) 25%, transparent); | ||
| border: 1px solid var(--vscode-contrastActiveBorder); /* for high-contrast theme */ | ||
| } | ||
|
|
||
| .yRemoteSelectionHead { | ||
| position: absolute; | ||
| border-left: var(--vscode-symbolIcon-eventForeground) solid 2px; | ||
| border-top: var(--vscode-symbolIcon-eventForeground) solid 2px; | ||
| border-bottom: var(--vscode-symbolIcon-eventForeground) solid 2px; | ||
| height: 100%; | ||
| box-sizing: border-box; | ||
| } | ||
|
|
||
| .yRemoteSelectionHead::after { | ||
| position: absolute; | ||
| content: ' '; | ||
| border: 3px solid var(--vscode-symbolIcon-eventForeground); | ||
| border-radius: 4px; | ||
| left: -4px; | ||
| top: -5px; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.