Skip to content

Commit 133a77b

Browse files
author
codewec
committed
chore: refactoring
1 parent 7e2d9dc commit 133a77b

60 files changed

Lines changed: 2544 additions & 1686 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ logs
2222
.env
2323
.env.*
2424
!.env.example
25+
data

AGENTS.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# AGENTS.md
2+
3+
This document gives AI agents a practical map of the `editoro` codebase.
4+
5+
## 1) Project Overview
6+
7+
- Stack: `Nuxt 4`, `Nuxt UI 4`, `Pinia`, `@nuxtjs/i18n`.
8+
- Purpose: local markdown workspace similar to Obsidian.
9+
- Storage: all user files are on disk in `data/`.
10+
- Main UI:
11+
- left: file tree with DnD, create/rename/delete.
12+
- right: editor / image preview / folder browser.
13+
- Supported locales: `en` (default), `ru`.
14+
15+
## 2) Key Runtime Flows
16+
17+
1. App mounts `app/pages/index.vue` -> renders `EditoroWorkspace`.
18+
2. `useEditoro()` (`app/composables/useEditoro.ts`) returns grouped API.
19+
3. `useEditoroState()` composes stores + lifecycle + view model + actions.
20+
4. Tree and route query `?file=...` are synchronized in `useEditoroFileSelection`.
21+
5. Markdown content autosaves via editor persistence composable.
22+
6. Image uploads go to sibling `.media` folder of current markdown file.
23+
24+
## 3) Architecture (Current)
25+
26+
### UI Components
27+
28+
- `app/components/editoro/Workspace.vue`: top-level layout composition.
29+
- `app/components/editoro/Sidebar.vue`: tree panel + settings modal.
30+
- `app/components/editoro/MainHeader.vue`: file/folder title + actions + save status.
31+
- `app/components/editoro/MainContent.vue`: folder browser / image preview / editor.
32+
- `app/components/editoro/Modals.vue`: create/rename/delete dialogs.
33+
34+
### Stores
35+
36+
- `app/stores/editoroTree.ts`: tree state, loading, selection, DnD.
37+
- `app/stores/editoroEditor.ts`: editor content, mode, save state, upload API.
38+
- `app/stores/editoroPreferences.ts`: locale, color mode, hidden entries.
39+
- `app/stores/editoroUi.ts`: modals and other UI control state.
40+
41+
### Composable Layers
42+
43+
- `app/composables/useEditoroState.ts`: orchestration root.
44+
- `app/composables/useEditoroContext.ts`: internal wiring of stores/actions/view-model.
45+
- `app/composables/useEditoroLifecycle.ts`: SSR+mount hooks/watchers.
46+
- `app/composables/useEditoroFileSelection.ts`: selected node <-> route file query logic.
47+
- `app/composables/useEditoroEntryActions.ts`: create/rename/delete flows.
48+
- `app/composables/useEditoroViewModel.ts`: computed UI-facing derived data.
49+
- `app/composables/api/*`: builders of final public grouped API.
50+
- `app/composables/workspace/*Bindings.ts`: binds state to component props/events.
51+
52+
### Server
53+
54+
- `server/utils/data-storage.ts`: all filesystem operations and invariants.
55+
- `server/api/files/*.ts`: tree/content/create/move/delete/image/media endpoints.
56+
- `app/services/files-api.ts`: client API wrappers for server endpoints.
57+
58+
## 4) Critical Invariants (Do Not Break)
59+
60+
1. Security/path safety:
61+
- Any filesystem path must remain inside `data/`.
62+
- Use existing helpers (`normalizeRelativePath`, `resolveDataPath`).
63+
2. Markdown editing:
64+
- Only markdown files are editable/savable (`.md`).
65+
- Non-markdown files show unsupported format or preview (for images).
66+
3. Route sync:
67+
- Opened file must be reflected in `?file=...`.
68+
- On refresh, restore selection if file exists; clear query if invalid.
69+
4. Tree UX:
70+
- Preserve expanded paths on reload.
71+
- Keep selected node and ancestors expanded when possible.
72+
5. Media handling:
73+
- Uploaded images go to `<markdown-folder>/.media`.
74+
- On markdown save, remove orphan media files.
75+
- Remove empty `.media` directories after cleanup.
76+
6. SSR/hydration:
77+
- Avoid client-only state mismatches that cause hydration warnings.
78+
- Keep lifecycle hooks inside proper setup/composable execution flow.
79+
80+
## 5) File Map for Common Tasks
81+
82+
- Change tree behavior/icons: `server/utils/data-storage.ts`, `Sidebar.vue`, `app/utils/editoro-tree.ts`.
83+
- Change selection/query behavior: `useEditoroFileSelection.ts`, `useEditoroLifecycle.ts`.
84+
- Change autosave/status: `useEditoroEditorPersistence.ts`, `useEditoroEditorStatus.ts`, `MainHeader.vue`.
85+
- Change image upload/DnD in editor: `useEditoroMainContentMedia.ts`, `useEditoroEditorUploads.ts`, `server/api/files/image.post.ts`.
86+
- Change i18n/settings: `editoroPreferences.ts`, `nuxt.config.ts`, `i18n/locales/*.json`.
87+
88+
## 6) Development Commands
89+
90+
Use `pnpm` in normal environment:
91+
92+
```bash
93+
pnpm install
94+
pnpm dev
95+
pnpm lint
96+
pnpm typecheck
97+
pnpm build
98+
```
99+
100+
## 7) Change Checklist for Agents
101+
102+
Before coding:
103+
- Identify impacted layer(s): component, store, composable, server API.
104+
- Prefer existing abstractions over adding logic to `Workspace.vue`.
105+
106+
While coding:
107+
- Keep strict TypeScript typing; avoid `any`.
108+
- In composables/helpers, keep comments in English.
109+
- Preserve existing public API shape of `useEditoro()` unless refactor requires migration everywhere.
110+
111+
After coding:
112+
- Run `lint` + `typecheck`.
113+
- Manually verify:
114+
- tree selection and expansion,
115+
- route `?file=...` restore on refresh,
116+
- create/rename/delete for files and folders,
117+
- markdown autosave indicator behavior,
118+
- image upload, preview, and orphan cleanup.
119+
120+
## 8) Preferred Refactoring Direction
121+
122+
- Keep `Workspace.vue` declarative (bindings only).
123+
- Move heavy logic from components to composables.
124+
- Keep stores focused:
125+
- tree-only concerns in tree store/composables,
126+
- editor-only concerns in editor store/composables,
127+
- preferences-only concerns in preferences store.
128+
- Keep server filesystem logic centralized in `data-storage.ts`.
129+
130+
## 9) Notes About Existing UX Decisions
131+
132+
- Default locale is English.
133+
- Hidden entries toggle exists and hidden folders use a different folder icon.
134+
- Sidebar width is persisted and restored.
135+
- Rich/raw is handled as a toggle mode.
136+
- For folders, right panel shows folder contents with navigation to parent.
137+

app/components/AppLogo.vue

Lines changed: 0 additions & 40 deletions
This file was deleted.

app/components/TemplateMenu.vue

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)