@@ -2,11 +2,11 @@ import BaseAppLoader from "@/components/app-loaders/base-app-loader";
22import Loading from "@/components/interface/status-screens/loading" ;
33import { EditorContext } from "@/components/providers/editor-context-provider" ;
44import { IMCContext } from "@/components/providers/imc-provider" ;
5- import { DragEventTypeEnum , PlatformEnum } from "@/lib/enums" ;
5+ import { PlatformEnum } from "@/lib/enums" ;
66import { usePlatformApi } from "@/lib/hooks/use-platform-api" ;
77import { getPlatform } from "@/lib/platform-api/platform-checker" ;
8- import { ExtensionApp , FileDragData } from "@/lib/types" ;
9- import { addToast } from "@heroui/react " ;
8+ import { ExtensionApp } from "@/lib/types" ;
9+ import { useDroppable } from "@dnd-kit/core " ;
1010import {
1111 ConnectionListener ,
1212 IMCMessage ,
@@ -32,6 +32,16 @@ export default function SandboxAppLoader({
3232 const editorContext = useContext ( EditorContext ) ;
3333 const imcContext = useContext ( IMCContext ) ;
3434
35+ const { resolvedTheme } = useTheme ( ) ;
36+ const { platformApi } = usePlatformApi ( ) ;
37+
38+ const { setNodeRef } = useDroppable ( {
39+ id : "app-node-view-" + viewModel . viewId ,
40+ data : {
41+ viewId : viewModel . viewId ,
42+ } ,
43+ } ) ;
44+
3545 const [ currentExtension , setCurrentExtension ] = useState <
3646 ExtensionApp | undefined
3747 > ( ) ;
@@ -48,9 +58,6 @@ export default function SandboxAppLoader({
4858 // const [isConnected, setIsConnected] = useState<boolean>(false);
4959 const [ isInitialized , setIsInitialized ] = useState < boolean > ( false ) ;
5060
51- const { resolvedTheme } = useTheme ( ) ;
52- const { platformApi } = usePlatformApi ( ) ;
53-
5461 // Update view Id when the view model changes
5562 useEffect ( ( ) => {
5663 // If the view Id changes (e.g. when switching file but not extension),
@@ -137,13 +144,6 @@ export default function SandboxAppLoader({
137144 } ;
138145 } , [ ] ) ;
139146
140- useEffect ( ( ) => {
141- console . log (
142- "Is dragging over canvas: " ,
143- editorContext ?. editorStates . isDraggingOverCanvas ,
144- ) ;
145- } , [ editorContext ?. editorStates . isDraggingOverCanvas ] ) ;
146-
147147 // Set is loading extension to true when current extension changes
148148 useEffect ( ( ) => {
149149 if ( currentExtension ) {
@@ -316,48 +316,7 @@ export default function SandboxAppLoader({
316316 return (
317317 < div
318318 className = "relative h-full w-full"
319- onDragOver = { ( e ) => {
320- e . stopPropagation ( ) ;
321- const types = e . dataTransfer . types ;
322- if (
323- types . includes ( `application/${ DragEventTypeEnum . File . toLowerCase ( ) } ` )
324- ) {
325- e . preventDefault ( ) ; // allow drop
326- e . dataTransfer . dropEffect = "move" ;
327- } else {
328- e . dataTransfer . dropEffect = "none" ;
329- }
330- } }
331- onDrop = { async ( e ) => {
332- const dataText = e . dataTransfer . getData (
333- `application/${ DragEventTypeEnum . File . toLowerCase ( ) } ` ,
334- ) ;
335- if ( ! dataText ) {
336- return ;
337- }
338- console . log ( "Dropped item:" , dataText ) ;
339- try {
340- const data = JSON . parse ( dataText ) as FileDragData ;
341-
342- e . preventDefault ( ) ;
343- const uri = data . uri ;
344-
345- // Send uri to app view
346- await imcContext ?. polyIMC ?. sendMessage (
347- viewModel . viewId ,
348- IMCMessageTypeEnum . EditorAppReceiveFileUri ,
349- {
350- uri,
351- } ,
352- ) ;
353- } catch ( error ) {
354- addToast ( {
355- title : "Failed to open file" ,
356- description : "The dropped file data is invalid." ,
357- color : "danger" ,
358- } ) ;
359- }
360- } }
319+ ref = { setNodeRef }
361320 >
362321 { isLookingForExtension ? (
363322 < div className = "bg-content1 h-full w-full" >
0 commit comments