@@ -10,6 +10,11 @@ import type { Document, Session } from '../services/SyncService.ts'
1010import { inject , provide , shallowRef } from 'vue'
1111import * as api from '../apis/connect.ts'
1212
13+ export interface Context {
14+ type : string
15+ id : number
16+ }
17+
1318export interface Connection {
1419 documentId : number
1520 sessionId : number
@@ -41,7 +46,7 @@ export const openDataKey = Symbol('text:opendata') as InjectionKey<
4146 * Handle the connection to the text api and provide it to child components
4247 *
4348 * @param props Props of the editor component.
44- * @param props.fileId Fileid of the file.
49+ * @param props.context of the document (i.e. type 'file' and id of the file)
4550 * @param props.relativePath Relative path to the file.
4651 * @param props.initialSession Initial session handed to the editor in direct editing
4752 * @param props.shareToken Share token of the file.
@@ -50,7 +55,7 @@ export const openDataKey = Symbol('text:opendata') as InjectionKey<
5055 */
5156export function provideConnection (
5257 props : {
53- fileId : number
58+ context : Context
5459 relativePath : string
5560 initialSession ?: InitialData
5661 shareToken ?: string
@@ -136,13 +141,13 @@ function openInitialSession(
136141 * @param props Props of the editor component
137142 * @param props.relativePath Relative path to the file.
138143 * @param props.shareToken Share token of the file.
139- * @param props.fileId id of the file
144+ * @param props.context of the document (i.e. type 'file' and id of the file)
140145 * @param baseVersionEtag Etag from the last editing session.
141146 * @param guestName to be shown to other participants.
142147 */
143148async function openShare (
144149 props : {
145- fileId : number
150+ context : Context
146151 relativePath : string
147152 shareToken ?: string
148153 } ,
@@ -154,7 +159,7 @@ async function openShare(
154159 guestName,
155160 token : props . shareToken ,
156161 filePath : props . relativePath ,
157- fileId : props . fileId ,
162+ fileId : props . context . id ,
158163 baseVersionEtag,
159164 } )
160165 }
@@ -164,20 +169,19 @@ async function openShare(
164169 * Get the connection and additional data from the initial session if available.
165170 *
166171 * @param props Props of the editor component
167- * @param props.fileId id of the file
172+ * @param props.context of the document (i.e. type 'file' and id of the file)
168173 * @param props.relativePath Relative path to the file.
169174 * @param baseVersionEtag Etag from the last editing session.
170175 */
171176async function openFile (
172177 props : {
173- fileId : number
178+ context : Context
174179 relativePath : string
175180 } ,
176181 baseVersionEtag : string | undefined ,
177182) {
178183 return api . openContext ( {
179- type : 'file' ,
180- id : props . fileId ,
184+ ...props . context ,
181185 filePath : props . relativePath ,
182186 baseVersionEtag,
183187 } )
0 commit comments