Skip to content

Commit

Permalink
fix: drop file on terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanSalt committed Oct 8, 2024
1 parent 5d1d09d commit cfb18bb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
19 changes: 16 additions & 3 deletions addons/explorer/src/renderer/FileExplorer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ function openExternal(file: FileEntity) {
function openExternalDirectory() {
ipcRenderer.invoke('open-path', modelValue)
}
function startDragging(event: DragEvent, file: FileEntity) {
if (event.dataTransfer) {
event.dataTransfer.setData('text/plain', file.path)
}
ipcRenderer.invoke('drag-file', file.path)
}
</script>

<template>
Expand All @@ -113,13 +120,16 @@ function openExternalDirectory() {
<a
v-for="file in files"
:key="file.name"
draggable="true"
:class="['file', { directory: file.isDirectory }]"
@click="selectFile(file)"
@dragstart.prevent="startDragging($event, file)"
>
<VisualIcon
:name="file.isSymlink
? (file.isDirectory ? 'lucide-folder-symlink' : 'lucide-file-symlink')
: (file.isDirectory ? 'lucide-folder' : 'lucide-file')"
class="file-icon"
/>
<span class="file-name">{{ file.name }}{{ file.isDirectory ? path.sep : '' }}</span>
<span class="action-list">
Expand Down Expand Up @@ -166,13 +176,16 @@ function openExternalDirectory() {
&:active {
transform: scale(0.99);
}
&.directory {
.file-icon,
.file-name {
color: rgb(var(--theme-blue));
}
}
}
.file-name {
flex: 1;
min-width: 0;
.file.directory & {
color: rgb(var(--theme-blue));
}
}
.action-list {
display: flex;
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/TerminalTeletype.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts" setup>
import '@xterm/xterm/css/xterm.css'
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
import { webUtils } from 'electron'
import fuzzaldrin from 'fuzzaldrin-plus'
import { quote } from 'shell-quote'
import { onBeforeUpdate } from 'vue'
Expand Down Expand Up @@ -30,7 +31,7 @@ function dropFile(event: DragEvent) {
if (!dataTransfer) return
const files = dataTransfer.files
if (files.length) {
const paths = Array.from(files).map(({ path }) => path)
const paths = Array.from(files).map(file => webUtils.getPathForFile(file))
tab.xterm.paste(quote(paths))
} else {
const data = dataTransfer.getData('text')
Expand Down

0 comments on commit cfb18bb

Please sign in to comment.