/
import.ts
42 lines (35 loc) · 1.14 KB
/
import.ts
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
import { IModuleConfig } from '../types'
import { App } from '/@/App'
import { showFolderPicker } from '/@/components/FileSystem/Pickers/showFolderPicker'
import { AnyHandle } from '/@/components/FileSystem/Types'
import { IFolderHandler } from '/@/components/ImportFolder/Manager'
import {
IPluginOpenWithAction,
pluginActionStore,
} from '/@/components/UIElements/DirectoryViewer/ContextMenu/Actions/OpenWith'
interface IPickDirectoryOptions {
multiple?: boolean
}
export const ImportModule = ({ disposables }: IModuleConfig) => ({
addFolderImporter: async (handle: IFolderHandler) => {
const app = await App.getApp()
disposables.push(app.folderImportManager.addImporter(handle))
},
async importHandle(handle: AnyHandle) {
const app = await App.getApp()
await app.fileDropper.import(handle)
},
registerOpenWithHandler: (handler: IPluginOpenWithAction) => {
pluginActionStore.add(handler)
const disposable = {
dispose: () => {
pluginActionStore.delete(handler)
},
}
disposables.push(disposable)
return disposable
},
showDirectoryPicker: async (opts: IPickDirectoryOptions) => {
return await showFolderPicker(opts)
},
})