refac
This commit is contained in:
@@ -483,6 +483,7 @@
|
|||||||
onNewFolder={startNewFolder}
|
onNewFolder={startNewFolder}
|
||||||
onNewFile={startNewFile}
|
onNewFile={startNewFile}
|
||||||
onUploadFiles={handleUploadFiles}
|
onUploadFiles={handleUploadFiles}
|
||||||
|
onMove={handleMove}
|
||||||
>
|
>
|
||||||
{#if fileImageUrl !== null}
|
{#if fileImageUrl !== null}
|
||||||
<Tooltip content={$i18n.t('Reset view')}>
|
<Tooltip content={$i18n.t('Reset view')}>
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
export let onNewFolder: () => void = () => {};
|
export let onNewFolder: () => void = () => {};
|
||||||
export let onNewFile: () => void = () => {};
|
export let onNewFile: () => void = () => {};
|
||||||
export let onUploadFiles: (files: File[]) => void = () => {};
|
export let onUploadFiles: (files: File[]) => void = () => {};
|
||||||
|
export let onMove: (source: string, destFolder: string) => void = () => {};
|
||||||
|
|
||||||
|
let dragOverCrumb: number | null = null;
|
||||||
|
|
||||||
let uploadInput: HTMLInputElement;
|
let uploadInput: HTMLInputElement;
|
||||||
let breadcrumbEl: HTMLDivElement;
|
let breadcrumbEl: HTMLDivElement;
|
||||||
@@ -41,8 +44,29 @@
|
|||||||
class="text-xs shrink-0 px-1 py-0.5 rounded hover:bg-gray-100 dark:hover:bg-gray-800 transition
|
class="text-xs shrink-0 px-1 py-0.5 rounded hover:bg-gray-100 dark:hover:bg-gray-800 transition
|
||||||
{!selectedFile && i === breadcrumbs.length - 1
|
{!selectedFile && i === breadcrumbs.length - 1
|
||||||
? 'text-gray-700 dark:text-gray-300'
|
? 'text-gray-700 dark:text-gray-300'
|
||||||
: 'text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-400'}"
|
: 'text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-400'}
|
||||||
|
{dragOverCrumb === i ? 'bg-blue-50 dark:bg-blue-900/30 ring-1 ring-blue-400 dark:ring-blue-500' : ''}"
|
||||||
on:click={() => onNavigate(crumb.path)}
|
on:click={() => onNavigate(crumb.path)}
|
||||||
|
on:dragover={(e) => {
|
||||||
|
if (!e.dataTransfer?.types.includes('application/x-terminal-file-move')) return;
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
dragOverCrumb = i;
|
||||||
|
}}
|
||||||
|
on:dragleave={() => {
|
||||||
|
if (dragOverCrumb === i) dragOverCrumb = null;
|
||||||
|
}}
|
||||||
|
on:drop={(e) => {
|
||||||
|
const raw = e.dataTransfer?.getData('application/x-terminal-file-move');
|
||||||
|
if (!raw) return;
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
dragOverCrumb = null;
|
||||||
|
try {
|
||||||
|
const data = JSON.parse(raw);
|
||||||
|
if (data.path) onMove(data.path, crumb.path);
|
||||||
|
} catch {}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{crumb.label}
|
{crumb.label}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user