-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectron.d.ts
More file actions
146 lines (139 loc) · 5.41 KB
/
Copy pathelectron.d.ts
File metadata and controls
146 lines (139 loc) · 5.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import { FileData, SaveResult } from '../shared/types'
import {
WorkspaceConfig,
WorkspaceSession,
FileTreeNode,
FolderChange
} from '../shared/workspace-types'
// Re-export for convenience
export type { WorkspaceConfig, WorkspaceSession, FileTreeNode, FolderChange }
// App-level session for restoring workspaces across app restarts
export interface AppSession {
openWorkspaces: string[] // Array of workspace root paths
activeWorkspacePath: string | null
lastSavedAt: number
visibleWorkspacePaths?: string[] // Workspaces with visibleInTabBar=true
focusedPaneWorkspacePath?: string | null
// Deprecated fields (kept for backwards compatibility on load)
multiPaneEnabled?: boolean
visiblePaneWorkspacePaths?: string[]
}
export interface OrphanedDraft {
tabId: string
content: string
lastModified: number
}
export interface CrashRecoveryInfo {
didCrash: boolean
orphanedDrafts: OrphanedDraft[]
}
export interface SettingsSchema {
theme: {
current: string
customThemes: Record<string, string>
}
shortcuts: {
currentPreset: string
customPresets: Record<string, Record<string, string>>
}
layout: {
previewSyncLocked: boolean
splitRatio: number
}
editor: {
vimMode: boolean
}
}
export interface ElectronAPI {
file: {
open: () => Promise<FileData[]>
readByPath: (filePath: string) => Promise<FileData | null>
save: (path: string, content: string) => Promise<boolean>
saveAs: (content: string, suggestedName?: string) => Promise<string | null>
copyImage: (
sourcePath: string,
tabId: string,
markdownFilePath: string | null
) => Promise<string | null>
autoSave: (tabId: string, content: string, filePath: string | null) => Promise<string | null>
getTempDir: (tabId: string) => Promise<string>
moveTempFiles: (tabId: string, savedPath: string) => Promise<boolean>
cleanupTemp: (tabId: string) => Promise<boolean>
readImageAsDataURL: (imagePath: string) => Promise<string | null>
copyToWorkspace: (sourcePath: string, workspaceRootPath: string) => Promise<string | null>
}
window: {
minimize: () => void
maximize: () => void
close: () => void
zoom: (delta: number) => void
resetZoom: () => void
getZoom: () => Promise<number>
isMaximized: () => Promise<boolean>
print: () => void
exportPdf: (html: string, title: string) => Promise<string | null>
exportHtml: (html: string, title: string) => Promise<string | null>
toggleDevTools: () => void
getPosition: () => Promise<{ x: number; y: number }>
setPosition: (x: number, y: number) => void
}
settings: {
getAll: () => Promise<SettingsSchema>
get: <K extends keyof SettingsSchema>(key: K) => Promise<SettingsSchema[K]>
set: <K extends keyof SettingsSchema>(key: K, value: SettingsSchema[K]) => Promise<boolean>
setMultiple: (data: Partial<SettingsSchema>) => Promise<boolean>
reset: () => Promise<SettingsSchema>
getPath: () => Promise<string>
}
workspace: {
// Open folder dialog and return workspace info
openFolder: (usedColors?: string[]) => Promise<{ path: string; config: WorkspaceConfig } | null>
// Load workspace config from path
loadConfig: (folderPath: string) => Promise<WorkspaceConfig | null>
// Save workspace config
saveConfig: (folderPath: string, config: WorkspaceConfig) => Promise<boolean>
// Load workspace session (tabs, scroll positions, etc.)
loadSession: (folderPath: string) => Promise<WorkspaceSession | null>
// Save workspace session
saveSession: (folderPath: string, session: WorkspaceSession) => Promise<boolean>
// List files in directory (non-recursive)
listFiles: (folderPath: string, showHidden?: boolean) => Promise<FileTreeNode[]>
// List files recursively
listFilesRecursive: (folderPath: string, maxDepth?: number, showHidden?: boolean) => Promise<FileTreeNode[]>
// Start watching a folder for changes
watchFolder: (folderPath: string) => Promise<boolean>
// Stop watching a folder
unwatchFolder: (folderPath: string) => Promise<boolean>
// Create .wrangle directory
createWorkspaceDir: (folderPath: string) => Promise<boolean>
// Check if file is inside workspace
isPathInWorkspace: (filePath: string, workspacePath: string) => Promise<boolean>
// Check if folder has .wrangle directory
hasWorkspaceDir: (folderPath: string) => Promise<boolean>
// Load app-level session
loadAppSession: () => Promise<AppSession | null>
// Save app-level session
saveAppSession: (session: AppSession) => Promise<boolean>
// Load default workspace session (for non-folder tabs)
loadDefaultSession: () => Promise<WorkspaceSession | null>
// Save default workspace session
saveDefaultSession: (session: WorkspaceSession) => Promise<boolean>
// Listen for folder changes
onFolderChanged: (
callback: (folderPath: string, changes: FolderChange[]) => void
) => () => void
}
shell: {
showItemInFolder: (fullPath: string) => void
}
crashRecovery: {
check: () => Promise<CrashRecoveryInfo>
}
onMenuCommand: (callback: (command: string) => void) => () => void
onFileOpenedFromPath: (callback: (fileData: { path: string; content: string }) => void) => () => void
}
declare global {
interface Window {
electron: ElectronAPI
}
}