Migrate utils to ts

This commit is contained in:
2025-04-04 19:23:31 +02:00
parent 49ecaac720
commit e4fb276cf7
12 changed files with 287 additions and 111 deletions

7
app/src/types/api.ts Normal file
View File

@@ -0,0 +1,7 @@
declare global {
interface Window {
API_BASE_URL: string;
}
}
export const API_BASE_URL = window.API_BASE_URL;

36
app/src/types/file.ts Normal file
View File

@@ -0,0 +1,36 @@
export enum FileAction {
Create = 'create',
Delete = 'delete',
Rename = 'rename',
}
export enum FileExtension {
Markdown = '.md',
JPG = '.jpg',
JPEG = '.jpeg',
PNG = '.png',
GIF = '.gif',
WebP = '.webp',
SVG = '.svg',
}
export const IMAGE_EXTENSIONS = [
FileExtension.JPG,
FileExtension.JPEG,
FileExtension.PNG,
FileExtension.GIF,
FileExtension.WebP,
FileExtension.SVG,
];
export interface DefaultFile {
name: string;
path: string;
content: string;
}
export const DEFAULT_FILE: DefaultFile = {
name: 'New File.md',
path: 'New File.md',
content: '# Welcome to NovaMD\n\nStart editing here!',
};

18
app/src/types/markdown.ts Normal file
View File

@@ -0,0 +1,18 @@
export enum InlineContainerType {
Paragraph = 'paragraph',
ListItem = 'listItem',
TableCell = 'tableCell',
Blockquote = 'blockquote',
Heading = 'heading',
Emphasis = 'emphasis',
Strong = 'strong',
Delete = 'delete',
}
export const INLINE_CONTAINER_TYPES = new Set<InlineContainerType>(
Object.values(InlineContainerType)
);
export const MARKDOWN_REGEX = {
WIKILINK: /(!?)\[\[(.*?)\]\]/g,
} as const;

5
app/src/types/modal.ts Normal file
View File

@@ -0,0 +1,5 @@
export enum ModalType {
NewFile = 'newFile',
DeleteFile = 'deleteFile',
CommitMessage = 'commitMessage',
}

4
app/src/types/theme.ts Normal file
View File

@@ -0,0 +1,4 @@
export enum Theme {
Light = 'light',
Dark = 'dark',
}

View File

@@ -0,0 +1,32 @@
import { Theme } from './theme';
export interface WorkspaceSettings {
theme: Theme;
autoSave: boolean;
gitEnabled: boolean;
gitUrl: string;
gitUser: string;
gitToken: string;
gitAutoCommit: boolean;
gitCommitMsgTemplate: string;
}
export const DEFAULT_WORKSPACE_SETTINGS: WorkspaceSettings = {
theme: Theme.Light,
autoSave: false,
gitEnabled: false,
gitUrl: '',
gitUser: '',
gitToken: '',
gitAutoCommit: false,
gitCommitMsgTemplate: '${action} ${filename}',
};
export interface Workspace extends WorkspaceSettings {
name: string;
}
export const DEFAULT_WORKSPACE: Workspace = {
name: '',
...DEFAULT_WORKSPACE_SETTINGS,
};