feat: Enhance WebDAV file management and UI

- Add functionality to create new collections via API
- Implement copy and move operations between collections
- Improve image rendering in markdown preview with relative path resolution
- Add support for previewing binary files (images, PDFs)
- Refactor modal styling to use flat buttons and improve accessibility
This commit is contained in:
Mahmoud-Emad
2025-10-26 17:29:45 +03:00
parent 0ed6bcf1f2
commit f319f29d4c
20 changed files with 1679 additions and 113 deletions

View File

@@ -75,6 +75,55 @@ const PathUtils = {
isDescendant(path, ancestorPath) {
if (!path || !ancestorPath) return false;
return path.startsWith(ancestorPath + '/');
},
/**
* Check if a file is a binary/non-editable file based on extension
* @param {string} path - The file path
* @returns {boolean} True if the file is binary/non-editable
* @example PathUtils.isBinaryFile('image.png') // true
* @example PathUtils.isBinaryFile('document.md') // false
*/
isBinaryFile(path) {
const extension = PathUtils.getExtension(path).toLowerCase();
const binaryExtensions = [
// Images
'png', 'jpg', 'jpeg', 'gif', 'bmp', 'ico', 'svg', 'webp', 'tiff', 'tif',
// Documents
'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx',
// Archives
'zip', 'rar', '7z', 'tar', 'gz', 'bz2',
// Executables
'exe', 'dll', 'so', 'dylib', 'app',
// Media
'mp3', 'mp4', 'avi', 'mov', 'wmv', 'flv', 'wav', 'ogg',
// Other binary formats
'bin', 'dat', 'db', 'sqlite'
];
return binaryExtensions.includes(extension);
},
/**
* Get a human-readable file type description
* @param {string} path - The file path
* @returns {string} The file type description
* @example PathUtils.getFileType('image.png') // 'Image'
*/
getFileType(path) {
const extension = PathUtils.getExtension(path).toLowerCase();
const imageExtensions = ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'ico', 'svg', 'webp', 'tiff', 'tif'];
const documentExtensions = ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'];
const archiveExtensions = ['zip', 'rar', '7z', 'tar', 'gz', 'bz2'];
const mediaExtensions = ['mp3', 'mp4', 'avi', 'mov', 'wmv', 'flv', 'wav', 'ogg'];
if (imageExtensions.includes(extension)) return 'Image';
if (documentExtensions.includes(extension)) return 'Document';
if (archiveExtensions.includes(extension)) return 'Archive';
if (mediaExtensions.includes(extension)) return 'Media';
if (extension === 'pdf') return 'PDF';
return 'File';
}
};