🐛 tab support

This commit is contained in:
2026-02-28 10:40:26 +10:00
parent 02c5a09538
commit 62cd20c723
9 changed files with 81 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
import { readdir, readFile, writeFile, mkdir, unlink, rename as fsRename, rm } from 'fs/promises'
import { join, dirname } from 'path'
import { join, dirname, basename } from 'path'
import type { FileNode, RevisionMeta } from '../renderer/types/editor'
const DRAFT_ROOT =
@@ -249,3 +249,14 @@ export async function createSubdirectory(parentPath: string, name: string): Prom
await mkdir(newDir, { recursive: true })
return newDir
}
export async function moveFileOrDir(sourcePath: string, targetDirPath: string): Promise<string> {
assertInDraftRoot(sourcePath)
const destDir = targetDirPath === '__root__' ? DRAFT_ROOT : targetDirPath
assertInDraftRoot(destDir)
const newPath = join(destDir, basename(sourcePath))
assertInDraftRoot(newPath)
if (newPath === sourcePath) return sourcePath
await fsRename(sourcePath, newPath)
return newPath
}