diff options
Diffstat (limited to 'src/preload/index.ts')
| -rw-r--r-- | src/preload/index.ts | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/preload/index.ts b/src/preload/index.ts index b1db391..05dc893 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -92,6 +92,7 @@ const api = { message?: string }>, otLeaveDoc: (docId: string) => ipcRenderer.invoke('ot:leaveDoc', docId), + otAttachDoc: (docId: string) => ipcRenderer.invoke('ot:attachDoc', docId), otSendOp: (docId: string, ops: unknown[], version: number, hash: string) => ipcRenderer.invoke('ot:sendOp', docId, ops, version, hash), otFetchAllCommentContexts: () => @@ -184,6 +185,70 @@ const api = { ipcRenderer.on('sync:newDoc', handler) return () => ipcRenderer.removeListener('sync:newDoc', handler) }, + onSyncEntityCreated: (cb: (data: { + kind: 'doc' | 'file' | 'folder' + entityId: string + relPath: string + name: string + parentFolderId?: string + }) => void) => { + const handler = (_e: Electron.IpcRendererEvent, data: { + kind: 'doc' | 'file' | 'folder' + entityId: string + relPath: string + name: string + parentFolderId?: string + }) => cb(data) + ipcRenderer.on('sync:entityCreated', handler) + return () => ipcRenderer.removeListener('sync:entityCreated', handler) + }, + onSyncEntityRemoved: (cb: (data: { + kind: 'doc' | 'file' | 'folder' + entityId: string + relPath: string + }) => void) => { + const handler = (_e: Electron.IpcRendererEvent, data: { + kind: 'doc' | 'file' | 'folder' + entityId: string + relPath: string + }) => cb(data) + ipcRenderer.on('sync:entityRemoved', handler) + return () => ipcRenderer.removeListener('sync:entityRemoved', handler) + }, + onSyncEntityRenamed: (cb: (data: { + kind: 'doc' | 'file' | 'folder' + entityId: string + oldPath: string + newPath: string + newName: string + }) => void) => { + const handler = (_e: Electron.IpcRendererEvent, data: { + kind: 'doc' | 'file' | 'folder' + entityId: string + oldPath: string + newPath: string + newName: string + }) => cb(data) + ipcRenderer.on('sync:entityRenamed', handler) + return () => ipcRenderer.removeListener('sync:entityRenamed', handler) + }, + onSyncEntityMoved: (cb: (data: { + kind: 'doc' | 'file' | 'folder' + entityId: string + oldPath: string + newPath: string + parentFolderId: string + }) => void) => { + const handler = (_e: Electron.IpcRendererEvent, data: { + kind: 'doc' | 'file' | 'folder' + entityId: string + oldPath: string + newPath: string + parentFolderId: string + }) => cb(data) + ipcRenderer.on('sync:entityMoved', handler) + return () => ipcRenderer.removeListener('sync:entityMoved', handler) + }, // Cursor tracking cursorUpdate: (docId: string, row: number, column: number) => |
