Refactor common functions

This commit is contained in:
2024-10-01 22:32:40 +02:00
parent e7fbdd9a8d
commit 61051ebdce
6 changed files with 79 additions and 145 deletions

View File

@@ -7,6 +7,7 @@ import {
pullChanges,
lookupFileByName,
} from '../services/api';
import { isImageFile } from '../utils/fileHelpers';
const DEFAULT_FILE = {
name: 'New File.md',
@@ -14,11 +15,6 @@ const DEFAULT_FILE = {
content: '# Welcome to NovaMD\n\nStart editing here!',
};
const isImageFile = (filePath) => {
const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.svg'];
return imageExtensions.some((ext) => filePath.toLowerCase().endsWith(ext));
};
const useFileManagement = (gitEnabled = false) => {
const [content, setContent] = useState(DEFAULT_FILE.content);
const [files, setFiles] = useState([]);