Task 1: Core Functionalities
1. Project Setupβ
- Create Tauri project using
vanilla-ts
template
2. Frontend Structureβ
- Create HTML with:
<textarea>
for text editing- Two buttons (
Open
/Save
)
- Add CSS for basic layout (optional)
3. Backend Functions (Rust)β
- Use
std::fs
(built-in Rust module, no external crate needed):read_file(path: String) -> Result<String,String>
write_file(path: String, contents: String) -> Result<String, String>
- Expose these as Tauri commands using
#[tauri::command]
and add in.invoke_handler
4. Frontend Interaction (TypeScript)β
- Use Tauri APIs:
@tauri-apps/api/plugin-dialog
for file picker (open()
,save()
)@tauri-apps/api
invoke()
to call Rust commands
- Link button clicks to:
- Get file path via dialog, (hint:
open()
) - Pass path/content between frontend β backend (hint:
invoke()
)
- Get file path via dialog, (hint:
5. Security Configuration, if neededβ
- In
tauri.conf.json
:- Allow
fs
access to specific directories - Enable
dialog
API
- Allow
Key Technical Requirementsβ
Component | Technology/Package | Purpose |
---|---|---|
Frontend | Tauri Dialog API | File path selection |
Bridge | invoke() | TS β Rust communication |
Backend | Rust std::fs | Read/write files |
Error Handling | Rust Result type | Propagate I/O errors to frontend |
Conclusion Task 1β
- Great job! You have done it, now you have a text editor with the core functionalities!
- "First, make it work. Then make it work harder..." β Engineersβ Mantra