Skip to content

Commit

Permalink
Fix remaining errors in collab files
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Oct 5, 2021
1 parent fd7eae2 commit 078ab7d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const generateRandomPeers = ( count ) => {
? [ ...Array( count ) ].map( ( peer, index ) => ( {
id: index.toString(),
name: `Peery Collabson ${ index }`,
// eslint-disable-next-line no-restricted-syntax
avatarUrl: `https://i.pravatar.cc/64?cacheBust=${ Math.random() }`,
color: sample( defaultColors ) as string,
} ) )
Expand Down
15 changes: 15 additions & 0 deletions src/components/collaborative-editing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import CollaborativeEditingAvatars from './components/avatars';
* @property {(message: CollaborationTransportDocMessage|CollaborationTransportSelectionMessage) => void} sendMessage
* @property {(options: CollaborationTransportConnectOpts) => Promise<{isFirstInChannel: boolean}>} connect
* @property {() => Promise<void>} disconnect
*/

/**
* @typedef CollaborationTransportConnectOpts
* @property {Object} user
* @property {string} user.identity
Expand All @@ -33,19 +36,31 @@ import CollaborativeEditingAvatars from './components/avatars';
* @property {(message: object) => void} onReceiveMessage Callback to run when a message is received.
* @property {(peers: AvailablePeer[]) => void} setAvailablePeers Callback to run when peers change.
* @property {string} [channelId]
*/

/**
* @typedef AvailablePeer
* @property {string} id
* @property {string} name
* @property {string} color
* @property {string} [avatarUrl]
*/

/**
* @typedef CollaborationTransportDocMessage
* @property {string} identity
* @property {'doc'} type
* @property {Object} message
*/

/**
* @typedef CollaborationTransportSelectionMessage
* @property {string} identity
* @property {'selection'} type
* @property {EditorSelection} selection
*/

/**
* @typedef EditorSelection
* @property {Object} start
* @property {Object} end
Expand Down
3 changes: 2 additions & 1 deletion src/components/collaborative-editing/use-yjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const defaultColors = [ '#4676C0', '#6F6EBE', '#9063B6', '#C3498D', '#9E6
async function initYDoc( { getBlocks, onRemoteDataChange, settings, setPeerSelection, setAvailablePeers } ) {
const { channelId, transport } = settings;

/** @type string */
/** @type {string} */
const identity = uuidv4();

debug( `initYDoc (identity: ${ identity })` );
Expand Down Expand Up @@ -169,6 +169,7 @@ export default function useYjs( { settings } ) {
}

if ( ! settings.transport ) {
// eslint-disable-next-line no-console
console.error( `Collaborative editor is disabled because a transport module wasn't provided.` );
return;
}
Expand Down

0 comments on commit 078ab7d

Please sign in to comment.