Skip to content

Commit 812ff13

Browse files
committed
fix: pass file id for direct editing and fail y.js provider setup if none was passed
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent bb7ff0a commit 812ff13

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/services/SyncServiceProvider.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ import { logger } from '../helpers/logger.js'
3333
* @param {object} options.initialSession - initialSession to start from
3434
*/
3535
export default function createSyncServiceProvider({ ydoc, syncService, fileId, initialSession }) {
36+
if (!fileId) {
37+
// We need a file id as a unique identifier for y.js as otherwise state might leak between different files
38+
throw new Error('fileId is required')
39+
}
3640
const WebSocketPolyfill = initWebSocketPolyfill(syncService, fileId, initialSession)
3741
const websocketProvider = new WebsocketProvider(
3842
'ws://localhost:1234',

src/views/DirectEditing.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<div id="direct-editor" :class="{'icon-loading': saving}">
2525
<Editor ref="editor"
2626
:initial-session="initialSession"
27+
:file-id="initial.fileId"
2728
:active="true"
2829
:mime="initial.mimetype"
2930
:is-direct-editing="true"

0 commit comments

Comments
 (0)