diff --git a/README.md b/README.md index 63a5fa4..0946c85 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [](https://github.com/llerandi/json-tree-editor/actions/workflows/ci.yaml) [](LICENSE) -[](https://tauri.app) +[](https://tauri.app) [](https://www.rust-lang.org) [](#building-for-production) @@ -53,7 +53,7 @@ rustc --version Once Rust is installed, run: ``` -cargo install tauri-cli --version "^2.0" --locked +cargo install tauri-cli --version "^1.0" --locked ``` This downloads and compiles the CLI. It may take a few minutes the first time. diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 01115b8..4d23094 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -3,17 +3,15 @@ name = "json-tree-editor" version = "0.1.0" edition = "2021" -# The lib target is required by Tauri's build process. -[lib] -name = "app_lib" -crate-type = ["staticlib", "cdylib", "rlib"] - [build-dependencies] -tauri-build = { version = "2", features = [] } +tauri-build = { version = "1", features = [] } [dependencies] -tauri = { version = "2", features = [] } -tauri-plugin-dialog = "2" -tauri-plugin-fs = "2" +tauri = { version = "1", features = [ + "dialog-save", + "dialog-open", + "fs-write-file", + "fs-read-file", +] } serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json deleted file mode 100644 index 98c1bb6..0000000 --- a/src-tauri/capabilities/default.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "https://schema.tauri.app/config/2/capability.json", - "identifier": "default", - "description": "Permissions used by the main window.", - "windows": ["main"], - "permissions": [ - "core:default", - "dialog:allow-save", - "dialog:allow-open", - "fs:allow-write-text-file", - "fs:allow-read-text-file" - ] -} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs deleted file mode 100644 index f37aa51..0000000 --- a/src-tauri/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -// lib.rs is the entry point used by Tauri's build system. -// All application setup happens here: plugins are registered and the -// event loop is started. - -#[cfg_attr(mobile, tauri::mobile_entry_point)] -pub fn run() { - tauri::Builder::default() - // Enables the native file-open and file-save dialogs. - .plugin(tauri_plugin_dialog::init()) - // Enables reading and writing files on the user's file system. - .plugin(tauri_plugin_fs::init()) - .run(tauri::generate_context!()) - .expect("error while running the application"); -} diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 37ac4d0..d387909 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -1,7 +1,7 @@ -// On Windows in release mode this attribute hides the console window that -// would otherwise appear behind the app. It has no effect on other platforms. #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] fn main() { - app_lib::run() + tauri::Builder::default() + .run(tauri::generate_context!()) + .expect("error while running tauri application"); } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 7f9ee81..e8807b6 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,13 +1,40 @@ { - "$schema": "https://schema.tauri.app/config/2", - "productName": "JSON Tree Editor", - "version": "0.1.0", - "identifier": "com.treeform.json-tree-editor", + "$schema": "../node_modules/@tauri-apps/cli/schema.json", "build": { - "frontendDist": "../src" + "distDir": "../src" }, - "app": { + "package": { + "productName": "JSON Tree Editor", + "version": "0.1.0" + }, + "tauri": { "withGlobalTauri": true, + "allowlist": { + "all": false, + "dialog": { + "save": true, + "open": true + }, + "fs": { + "readFile": true, + "writeFile": true, + "scope": ["**"] + } + }, + "bundle": { + "active": true, + "identifier": "com.treeform.json-tree-editor", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + }, + "security": { + "csp": null + }, "windows": [ { "title": "JSON Tree Editor", @@ -17,20 +44,6 @@ "minHeight": 400, "resizable": true } - ], - "security": { - "csp": null - } - }, - "bundle": { - "active": true, - "targets": "all", - "icon": [ - "icons/32x32.png", - "icons/128x128.png", - "icons/128x128@2x.png", - "icons/icon.icns", - "icons/icon.ico" ] } } diff --git a/src/index.html b/src/index.html index f2f1b1a..db2b9bd 100644 --- a/src/index.html +++ b/src/index.html @@ -28,10 +28,7 @@ .header-left { display: flex; flex-direction: column; gap: 2px; } h1 { font-size: 1.15rem; font-weight: 600; color: #fff; letter-spacing: -0.3px; } - #file-label { - font-size: 0.75rem; - color: #4a5070; - } + #file-label { font-size: 0.75rem; color: #4a5070; } .actions { display: flex; gap: 8px; flex-wrap: wrap; } @@ -52,20 +49,13 @@ } .btn-secondary:hover { background: #252a3d; color: #c0c8e0; } - .btn-primary { - background: #4f6ef7; - color: #fff; - } + .btn-primary { background: #4f6ef7; color: #fff; } .btn-primary:hover { background: #3d5ce6; } /* ── Tree ── */ #tree { display: flex; flex-direction: column; gap: 6px; } - .node-wrapper { - display: flex; - flex-direction: column; - gap: 6px; - } + .node-wrapper { display: flex; flex-direction: column; gap: 6px; } .node { display: flex; @@ -81,13 +71,11 @@ } .node:hover { border-color: #353a55; } - /* Drag states */ .node.dragging { opacity: 0.35; } .node.drag-over-top { border-top: 2px solid #4f6ef7; } .node.drag-over-bottom { border-bottom: 2px solid #4f6ef7; } .node.drag-over-child { border: 1px solid #4f6ef7; box-shadow: 0 0 0 2px rgba(79,110,247,0.2); } - /* Depth colour bars */ .indent-bar { width: 3px; height: 28px; border-radius: 2px; flex-shrink: 0; } .depth-0 .indent-bar { background: transparent; } .depth-1 .indent-bar { background: #4f6ef7; opacity: 0.7; } @@ -181,8 +169,8 @@ background: transparent; color: #4a5070; } - .icon-btn:hover { background: #1e2338; color: #8090c0; } - .icon-btn.delete:hover { background: #2d1a1a; color: #e06060; } + .icon-btn:hover { background: #1e2338; color: #8090c0; } + .icon-btn.delete:hover { background: #2d1a1a; color: #e06060; } /* ── Hint ── */ .hint { @@ -221,8 +209,9 @@ justify-content: space-between; align-items: center; } - .preview-close { cursor: pointer; } - .preview-close:hover { color: #a0b0d0; } + + #preview-close { cursor: pointer; } + #preview-close:hover { color: #a0b0d0; } #preview-content { padding: 16px; @@ -263,11 +252,11 @@