Skip to content

Commit c51ae68

Browse files
committed
feat: add load, clear
1 parent 558b00b commit c51ae68

File tree

8 files changed

+231
-10
lines changed

8 files changed

+231
-10
lines changed

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"dependencies": {
1313
"@monaco-editor/react": "^4.7.0",
1414
"@tauri-apps/api": "^2",
15+
"@tauri-apps/plugin-dialog": "^2.2.2",
1516
"@tauri-apps/plugin-opener": "^2.2.7",
1617
"@tauri-apps/plugin-shell": "^2.2.1",
1718
"lucide-react": "^0.511.0",

src-tauri/Cargo.lock

Lines changed: 131 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ tauri-build = { version = "2", features = [] }
1919

2020
[dependencies]
2121
tauri = { version = "2", features = [] }
22+
tauri-plugin-dialog = "2"
2223
tauri-plugin-opener = "2"
2324
tauri-plugin-store = "2"
2425
serde = { version = "1", features = ["derive"] }

src-tauri/capabilities/default.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@
33
"identifier": "default",
44
"description": "Capability for the main window",
55
"windows": ["main"],
6-
"permissions": [
7-
"core:default",
8-
"opener:default"
9-
]
6+
"permissions": ["core:default", "opener:default", "dialog:allow-open"]
107
}

src-tauri/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,22 @@ async fn load_app_data(app: tauri::AppHandle) -> Result<AppData, String> {
9494
}
9595
}
9696

97+
#[tauri::command]
98+
async fn read_file(path: String) -> Result<String, String> {
99+
std::fs::read_to_string(&path).map_err(|e| format!("Failed to read file '{}': {}", path, e))
100+
}
101+
97102
#[cfg_attr(mobile, tauri::mobile_entry_point)]
98103
pub fn run() {
99104
tauri::Builder::default()
105+
.plugin(tauri_plugin_dialog::init())
100106
.plugin(tauri_plugin_opener::init())
101107
.plugin(tauri_plugin_store::Builder::default().build())
102108
.invoke_handler(tauri::generate_handler![
103109
format_json_string,
104110
save_app_data,
105-
load_app_data
111+
load_app_data,
112+
read_file
106113
])
107114
.run(tauri::generate_context!())
108115
.expect("error while running tauri application");

src/App.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ body {
7474

7575
.editor-header {
7676
display: flex;
77-
justify-content: flex-end;
77+
justify-content: space-between;
7878
align-items: center;
7979
padding: 0.5em 0.75em;
8080
background-color: #f8f9fa;
@@ -97,6 +97,16 @@ body {
9797
gap: 0.25em;
9898
}
9999

100+
.editor-actions-left {
101+
display: flex;
102+
gap: 0.25em;
103+
}
104+
105+
.editor-actions-right {
106+
display: flex;
107+
gap: 0.25em;
108+
}
109+
100110
.action-button {
101111
display: flex;
102112
align-items: center;

0 commit comments

Comments
 (0)