feat: publish HoloLake model-native living system source
This commit is contained in:
parent
6ad10edde1
commit
c395dd3a99
2467 changed files with 615073 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
import { useEffect } from 'react'
|
||||
import type { ImmediateCreateOptions } from './useNoteCreation'
|
||||
|
||||
export const CREATE_NOTE_IN_FOLDER_EVENT = 'tolaria:create-note-in-folder'
|
||||
|
||||
interface CreateNoteInFolderDetail {
|
||||
folderPath: string
|
||||
rootPath?: string
|
||||
}
|
||||
|
||||
type ImmediateCreate = (type?: string, options?: ImmediateCreateOptions) => void
|
||||
|
||||
export function requestCreateNoteInFolder(folderPath: string, rootPath?: string): void {
|
||||
window.dispatchEvent(new CustomEvent<CreateNoteInFolderDetail>(CREATE_NOTE_IN_FOLDER_EVENT, {
|
||||
detail: { folderPath, rootPath },
|
||||
}))
|
||||
}
|
||||
|
||||
export function useCreateNoteInFolderRequests(createNote: ImmediateCreate): void {
|
||||
useEffect(() => {
|
||||
const handleCreateNoteInFolder = (event: Event) => {
|
||||
const { folderPath, rootPath } = (event as CustomEvent<CreateNoteInFolderDetail>).detail
|
||||
createNote(undefined, {
|
||||
creationPath: 'folder_context_menu',
|
||||
folderPath,
|
||||
vaultPath: rootPath,
|
||||
})
|
||||
}
|
||||
|
||||
window.addEventListener(CREATE_NOTE_IN_FOLDER_EVENT, handleCreateNoteInFolder)
|
||||
return () => window.removeEventListener(CREATE_NOTE_IN_FOLDER_EVENT, handleCreateNoteInFolder)
|
||||
}, [createNote])
|
||||
}
|
||||
Loading…
Reference in a new issue