-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Coediting: Refactor Collaborative Editing to be more independent from…
… Gutenberg
- Loading branch information
Showing
30 changed files
with
1,438 additions
and
1,275 deletions.
There are no files selected for viewing
This file contains 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 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 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,59 @@ | ||
# Gutenberg Collaborative Editing Client | ||
## Based on WebRTC | ||
--- | ||
|
||
### Starting App | ||
Peer starting coediting has to generate a uuid using: | ||
``` | ||
const coeditingId = Coediting.uuid(); // static function | ||
``` | ||
|
||
After that pass that to Coediting module: | ||
|
||
``` | ||
window.history.replaceState( '', '', '#' + coeditingId ); | ||
const coediting = new Coediting( coeditingId ); | ||
``` | ||
|
||
Peer not starting coediting has to join and get that coeditingId somehow possibly by sharing url. | ||
|
||
___ | ||
|
||
## API | ||
|
||
**Events** | ||
|
||
* `peerFound` - checked via long polling to /get/coeditingId route to server. | ||
``` | ||
coediting.on( 'peerFound', function( peer ) { | ||
// peer => peer signal used for connection establishment | ||
} ); | ||
``` | ||
|
||
* `peerSignal` - received from other peer as offer. | ||
``` | ||
coediting.on('peerSignal', function(signal){ | ||
// signal => signal that is received from another peer. | ||
}); | ||
``` | ||
|
||
* `peerConnected` - emitted after peerSignal and connection is established. | ||
``` | ||
coediting.on('peerConnected', function(){ | ||
// peer is connected. | ||
}); | ||
``` | ||
|
||
* `peerData - triggered when data is received. | ||
``` | ||
coediting.on('peerData', function(data){ | ||
//data is always json stringified | ||
}); | ||
``` | ||
|
||
|
||
## Data Format | ||
|
||
Payload should always be JSON object which can be sent directly using coediting.send without stringify. | ||
|
||
|
Oops, something went wrong.