This commit is contained in:
Timothy Jaeryang Baek 2026-10-21 11:47:14 +09:00
parent b6b0fff5d6
commit fbeee59e99
2 changed files with 21 additions and 0 deletions

View file

@ -1514,6 +1514,10 @@
};
// ── File creation ────────────────────────────────────────────────────
const startNewFileIn = async (path: string) => {
if (await loadDir(path)) await startNewFile();
};
const startNewFile = async () => {
if (!currentWritable) return;
creatingFile = true;
@ -2556,6 +2560,7 @@
: undefined}
onDownload={downloadFile}
onNewFolder={startNewFolderIn}
onNewFile={startNewFileIn}
onDelete={requestDelete}
onMove={handleMovePaths}
onRename={handleRename}

View file

@ -25,6 +25,7 @@
export let onOpen: (entry: FileEntry) => void = () => {};
export let onNewFolder: ((path: string) => void) | undefined = undefined;
export let onNewFile: ((path: string) => void) | undefined = undefined;
export let onSelectForComparison: (() => void) | undefined = undefined;
export let onCompareWithSelected: (() => void) | undefined = undefined;
export let comparisonPath: string | null = null;
@ -406,6 +407,21 @@
<div class="flex items-center">{$i18n.t('New Folder')}</div>
</button>
{/if}
{#if entry.type === 'directory' && onNewFile}
<button
type="button"
class="{menuItemClass} disabled:opacity-40 disabled:hover:bg-transparent"
disabled={!writable}
on:click|stopPropagation={() => {
if (!writable) return;
menuOpen = false;
onNewFile?.(directoryPath);
}}
>
<Icon name="plus" size={12} strokeWidth={1.4} />
<div class="flex items-center">{$i18n.t('New File')}</div>
</button>
{/if}
{#if entry.type === 'file' && onSelectForComparison}
<button
type="button"