feat: adds initial file drag and drop functionality - #376
Conversation
|
@noel-schenk is attempting to deploy a commit to the Triplex Team on Vercel. A member of the Team first needs to authorize it. |
|
sweet! appreciate the contribution, where do you see the major points are to look at in the PR that need work? could you annotate the PR with comments on interesting piece of code / behavior / anything? video walk through would go a treat as well tldr what do we need to do to get this merged? |
|
Sure, :) currently working and then some holiday, but after, before the GGJ, I might have some time to fix more.
Probably more issues I haven't found yet. Recording.2026-01-08.143251.mp4 |
|
oh cool I like that it uses native vscode drag and drop, good work so far! I'll x-link this to discord |
we should be able to do something about this
easy enough fix, default could select the first component on drop, then a have hotkey to show a UI to select a specific one?
easy enough to massage this
do you think we could immediately add the component during the drag when it hits the scene and then you can position it while still dragging?
like if you drag multiple files? is this a limitation or something we can code around to add them all at the same time? |
- Added add to active component / scene - Added drag and drop support for default exports
|
I took over the PR now.
|
- implemented requestVSCE. Sends data to server and awaits the response. - implemented component select. If the imported file contains multiple component and no default component, you can select wich item to add. - fixed name collisions. The there is already a 'Scene' in the current file and you want to import a component names 'Scene' it gets aliased to 'Scene_1', 'Scene_2' etc
|
Improved drag and drop:
|
|
@itsdouges Do you mind having a look and get some feedback? |
|
im trying to push commits to your remote branch but can't, do you have contributors not being allowed to push set? going to fix some formatting and then go over the code |
|
@Bellian great fix where you can drop it immediately after "dropping" it into the triplex editor (after pressing shift)! |
| {...bindingsDND} | ||
| > | ||
| {errorData && errorData.type === 'unknown' && ( | ||
| <Dialog onDismiss={onDismissError}> |
There was a problem hiding this comment.
Rather than having our own error dialog can we use the error toasts in vscode? There should be a bridge message to trigger for it
There was a problem hiding this comment.
It's this https://github.com/pmndrs/triplex/blob/main/packages/@triplex/editor-next/src/util/bridge.ts#L112 but if we are only waiting for the response for the error I reckon delete all this and show a vscode native toast instead
| async updateCode( | ||
| data: | ||
| | { | ||
| code: string; |
There was a problem hiding this comment.
Can we fix all the formatting changes? Check your IDE is using the prettier from triplex
| return await document.insertComponent(data); | ||
| }), | ||
| on(panel.webview, "send-request", async ({ data, event, id }) => { | ||
| const results = await execCallback(event, data); |
There was a problem hiding this comment.
Are we only waiting for the result to see if we have to show an error? If so we can just show a vscode toast message instead rather that having to round trip back through the editor.
Would let us delete a lot of code as well
There was a problem hiding this comment.
This also sends the information what components are abke to load for the select dialog.
If a file has more than 1 export and no defaukt export there is a promt to select the imported component.
| {errorData && errorData.type === 'multiple-exports' && ( | ||
| <Dialog onDismiss={onDismissError}> | ||
| <form className="flex flex-col gap-2.5 p-2.5" onSubmit={onSubmit}> | ||
| <span className="text-heading select-none font-medium"> |
There was a problem hiding this comment.
Ah I see an error could be this. I want to look what we have available during a drag because it would be cool if we can start checking before the user drops 🤔
| } | ||
|
|
||
| if (!componentFile) { | ||
| throw new DNDError(`Component file not found: ${componentPath}`); |
There was a problem hiding this comment.
I'd just throw a standard error. Whats the need to subclass?
There was a problem hiding this comment.
Currently for typing because of the multiple compnent data.
| export function resolveRemoteURL(path: string) { | ||
| if (path.startsWith('vscode-remote://')) { | ||
| // we hav a remote file drop! | ||
| path = path.replace(/vscode-remote:\/\/[^/]*/, 'file://'); |
There was a problem hiding this comment.
Can you tell me more about how vscode remote files work with triplex
| } | ||
|
|
||
|
|
||
| export function useDND(sendCallback: any, activeScene: string, scenePath: string) { |
There was a problem hiding this comment.
Anys will be a lint violation
| e.stopPropagation(); | ||
| }; | ||
|
|
||
| const handleDragEnter = (e: DragEvent<HTMLDivElement>) => { |
There was a problem hiding this comment.
This hooks is pretty specific to the vscode dnd. Does the renderer need the dnd logic or can the editor take care of it for now?
| <Tunnel.Out /> | ||
| <DebugAttributes /> | ||
| {isDragging && ( | ||
| <div |
There was a problem hiding this comment.
This isn't doing anything anymore right
| }): Scene | null { | ||
|
|
||
| if (modules == undefined || modules == null) { | ||
| return null; |
There was a problem hiding this comment.
I regulary got en error loading stuff here. Do not know precisely what went wrong.
Got a "try to access prop of undefined"
|
@Bellian I have some changes to push
all good if I push here? |
|
@itsdouges sure I've added you as a collaborator to the branch :) Sorry for the delay we are in a totally different time zone :D |
|
hey folks I pushed a few changes, my main goal was to try and reduce the total amount of code we needed to add for this feature. here's what I did:
can you test and let me know how it goes? and if there's any issues feel free to push some fixes. I haven't applied the vscode-remote file stuff, feels like there is a bigger story for triplex to properly support it.. maybe? e.g. can you open a remote file in triplex today? would love a contribution to make that overarching story better, i've never actually used those kinds of files before. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Hey @itsdouges amazing software you have created! We want to use it for this year's Global Game Jam.
We figured it would be nice to be able to drag and drop components into scenes. This PR adds an initial version of that.
I would suggest not merging it, as it still has some issues and flaws. But I wanted to first thank you very much for this wonderful extension and second, maybe help contribute a bit for a future feature.
Closes #43