-
-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: file drop handling for super notes (#1990)
- Loading branch information
Showing
10 changed files
with
111 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/web/src/javascripts/Controllers/FilesControllerProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ReactNode, createContext, useContext, memo } from 'react' | ||
import { observer } from 'mobx-react-lite' | ||
import { FilesController } from '@/Controllers/FilesController' | ||
|
||
const FilesControllerContext = createContext<FilesController | undefined>(undefined) | ||
|
||
export const useFilesController = () => { | ||
const value = useContext(FilesControllerContext) | ||
|
||
if (!value) { | ||
throw new Error('Component must be a child of <FilesControllerProvider />') | ||
} | ||
|
||
return value | ||
} | ||
|
||
type ChildrenProps = { | ||
children: ReactNode | ||
} | ||
|
||
type ProviderProps = { | ||
controller: FilesController | ||
} & ChildrenProps | ||
|
||
const MemoizedChildren = memo(({ children }: ChildrenProps) => <>{children}</>) | ||
|
||
const FilesControllerProvider = ({ controller, children }: ProviderProps) => { | ||
return ( | ||
<FilesControllerContext.Provider value={controller}> | ||
<MemoizedChildren children={children} /> | ||
</FilesControllerContext.Provider> | ||
) | ||
} | ||
|
||
export default observer(FilesControllerProvider) |
1 change: 0 additions & 1 deletion
1
...or/Contexts/LinkingControllerProvider.tsx → ...Controllers/LinkingControllerProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters