diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000000000000000000000000000000000000..4d27a59eb23a204b35ad0e09ba512b1662a0c4f6 --- /dev/null +++ b/README.en.md @@ -0,0 +1,164 @@ +# JSON Editor + +A powerful macOS JSON editor, built on Swift and SwiftUI. + +## Introduction + +JSON Editor is a modern JSON editing tool designed specifically for macOS. It provides two modes: an intuitive tree view and raw text editing, supporting features such as real-time syntax highlighting, search, formatting, and minification. + +## Key Features + +### Core Features +- **Dual View Modes**: Switch freely between Tree View and Raw Text editing +- **Syntax Highlighting**: Color differentiation for different JSON types (keys, strings, numbers, booleans, null) +- **Collapse/Expand**: Supports node collapsing and expanding for easier browsing of complex JSON structures +- **Search Functionality**: Real-time search, highlight matches, support quick jumping + +### Editing Features +- **Format**: Beautify JSON output with one click +- **Minify**: Remove whitespace to achieve minimum JSON size +- **Undo/Redo**: Complete edit history support +- **Copy Functions**: + - Copy key names + - Copy values + - Copy key-value pairs + - Copy JSON snippets + - Copy paths + +### File Operations +- **New**: Create a blank document +- **Open**: Support opening local JSON files +- **Save**: Save to current file +- **Save As**: Save to a new file +- **Import**: Import JSON from clipboard +- **Load Example**: Built-in sample data + +### Themes & Localization +- **Theme Support**: Provides multiple themes, automatically adapting to Light/Dark mode +- **Multi-language**: Supports Chinese and English interfaces +- **Custom Colors**: Configurable syntax highlighting color schemes + +## System Requirements + +- macOS 12.0 (Monterey) or higher +- Xcode 14.0 or higher (for compiling from source) + +## Installation Methods + +### Method 1: Using Homebrew (Recommended) + +```bash +brew install --cask json-editor +``` + +### Method 2: Compile from Source + +```bash +# Clone the project +git clone https://gitee.com/huacheng80/json-view-utils.git +cd json-view-utils + +# Generate Xcode project +./build.sh + +# Open with Xcode and compile +open JSONEditor.xcodeproj +``` + +### Method 3: Run Directly + +The project provides a `build.sh` script to quickly build and run the application: + +```bash +./build.sh +``` + +## Usage Instructions + +### Basic Operations + +1. **Open File**: Click the Toolbar "Open" button or use shortcut `Cmd+O` +2. **Switch View**: Use toolbar buttons to switch between Tree View and Raw Text View +3. **Toggle Node**: Click the expand arrow on the left side of a node to collapse/expand +4. **Search**: Enter keywords in the search box, supports real-time highlighting + +### Shortcuts + +| Operation | Shortcut | +|------|--------| +| New Document | `Cmd+N` | +| Open File | `Cmd+O` | +| Save | `Cmd+S` | +| Save As | `Cmd+Shift+S` | +| Undo | `Cmd+Z` | +| Redo | `Cmd+Shift+Z` | +| Copy | `Cmd+C` | +| Paste | `Cmd+V` | +| Find | `Cmd+F` | +| Format | `Cmd+Option+F` | +| Minify | `Cmd+Option+M` | + +### Context Menu Operations + +Right-click a node in the Tree View to use the following operations: +- Copy key name +- Copy value +- Copy key-value pair +- Copy JSON snippet +- Copy path + +## Project Structure + +``` +json-view-utils/ +├── Sources/ +│ └── JSONEditor/ +│ ├── JSONEditorApp.swift # App Entry +│ ├── Model/ +│ │ ├── JSONModel.swift # JSON Data Model and Parser +│ │ ├── Theme.swift # Theme Management +│ │ └── L10n.swift # Localization Support +│ ├── ViewModel/ +│ │ └── EditorViewModel.swift # Editor Business Logic +│ ├── Views/ +│ │ ├── ContentView.swift # Main View Container +│ │ ├── TreeView.swift # Tree View +│ │ ├── RawTextEditor.swift # Raw Text Editor +│ │ └── Panels.swift # Welcome Panel and Status Bar +│ └── SelfTest.swift # Self-test Module +├── Resources/ +│ ├── AppIcon.svg # App Icon +│ ├── Info.plist # App Configuration +│ └── render_icon.swift # Icon Rendering Script +├── build.sh # Build Script +└── Package.swift # Swift Package Configuration +``` + +## Tech Stack + +- **Swift**: Primary programming language +- **SwiftUI**: User interface framework +- **AppKit**: Native macOS application framework +- **XcodeGen**: Project generation tool +- **Regular Expressions**: JSON syntax parsing + +## Contributing + +Welcome to participate in the project in the following ways: +- Submit bug reports +- Propose new feature suggestions +- Submit code improvements +- Improve documentation + +## License + +This project is open-sourced under the MIT License. + +## Contact + +- Project URL: https://gitee.com/huacheng80/json-view-utils +- Feedback: Please submit an Issue on the Gitee project page + +## Acknowledgments + +Thanks to all developers who have contributed code and suggestions to this project! \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..654ee1c9ab5c67de022477aa40db204b0452975b --- /dev/null +++ b/README.md @@ -0,0 +1,166 @@ + + +# JSON Editor + +一个功能强大的 macOS JSON 编辑器,基于 Swift 和 SwiftUI 构建。 + +## 简介 + +JSON Editor 是一个专为 macOS 设计的现代 JSON 编辑工具,提供直观的树形视图和原始文本编辑两种模式,支持实时语法高亮、搜索、格式化、压缩等功能。 + +## 主要功能 + +### 核心功能 +- **双视图模式**:树形视图和原始文本编辑随心切换 +- **语法高亮**:针对不同 JSON 类型(键、字符串、数字、布尔值、null)进行颜色区分 +- **折叠/展开**:支持节点折叠和展开,便于浏览复杂 JSON 结构 +- **搜索功能**:实时搜索,高亮匹配结果,支持快速跳转 + +### 编辑功能 +- **格式化**:一键美化 JSON 输出 +- **压缩**:移除空白字符,实现 JSON 最小化 +- **撤销/重做**:完整的编辑历史支持 +- **复制功能**: + - 复制键名 + - 复制值 + - 复制键值对 + - 复制 JSON 片段 + - 复制路径 + +### 文件操作 +- **新建**:创建空白文档 +- **打开**:支持打开本地 JSON 文件 +- **保存**:保存到当前文件 +- **另存为**:保存到新文件 +- **导入**:从剪贴板导入 JSON +- **示例加载**:内置示例数据 + +### 主题与本地化 +- **主题支持**:提供多种主题,自动适配浅色/深色模式 +- **多语言**:支持中文和英文界面 +- **自定义颜色**:可配置语法高亮配色 + +## 系统要求 + +- macOS 12.0 (Monterey) 或更高版本 +- Xcode 14.0 或更高版本(用于从源码编译) + +## 安装方法 + +### 方法一:使用 Homebrew(推荐) + +```bash +brew install --cask json-editor +``` + +### 方法二:从源码编译 + +```bash +# 克隆项目 +git clone https://gitee.com/huacheng80/json-view-utils.git +cd json-view-utils + +# 生成 Xcode 项目 +./build.sh + +# 使用 Xcode 打开并编译 +open JSONEditor.xcodeproj +``` + +### 方法三:直接运行 + +项目提供了 `build.sh` 脚本,可以快速构建并运行应用: + +```bash +./build.sh +``` + +## 使用说明 + +### 基本操作 + +1. **打开文件**:点击工具栏"打开"按钮或使用快捷键 `Cmd+O` +2. **切换视图**:使用工具栏按钮在树形视图和原始文本视图间切换 +3. **折叠节点**:点击节点左侧的展开箭头折叠/展开 +4. **搜索**:在搜索框输入关键字,支持实时高亮显示 + +### 快捷键 + +| 操作 | 快捷键 | +|------|--------| +| 新建文档 | `Cmd+N` | +| 打开文件 | `Cmd+O` | +| 保存 | `Cmd+S` | +| 另存为 | `Cmd+Shift+S` | +| 撤销 | `Cmd+Z` | +| 重做 | `Cmd+Shift+Z` | +| 复制 | `Cmd+C` | +| 粘贴 | `Cmd+V` | +| 查找 | `Cmd+F` | +| 格式化 | `Cmd+Option+F` | +| 压缩 | `Cmd+Option+M` | + +### 右键菜单操作 + +在树形视图中右键点击节点,可使用以下操作: +- 复制键名 +- 复制值 +- 复制键值对 +- 复制 JSON 片段 +- 复制路径 + +## 项目结构 + +``` +json-view-utils/ +├── Sources/ +│ └── JSONEditor/ +│ ├── JSONEditorApp.swift # 应用入口 +│ ├── Model/ +│ │ ├── JSONModel.swift # JSON 数据模型和解析器 +│ │ ├── Theme.swift # 主题管理 +│ │ └── L10n.swift # 本地化支持 +│ ├── ViewModel/ +│ │ └── EditorViewModel.swift # 编辑器业务逻辑 +│ ├── Views/ +│ │ ├── ContentView.swift # 主视图容器 +│ │ ├── TreeView.swift # 树形视图 +│ │ ├── RawTextEditor.swift # 原始文本编辑器 +│ │ └── Panels.swift # 欢迎面板和状态栏 +│ └── SelfTest.swift # 自测试模块 +├── Resources/ +│ ├── AppIcon.svg # 应用图标 +│ ├── Info.plist # 应用配置 +│ └── render_icon.swift # 图标渲染脚本 +├── build.sh # 构建脚本 +└── Package.swift # Swift 包配置 +``` + +## 技术栈 + +- **Swift**:主要编程语言 +- **SwiftUI**:用户界面框架 +- **AppKit**:原生 macOS 应用框架 +- **XcodeGen**:项目生成工具 +- **正则表达式**:JSON 语法解析 + +## 参与贡献 + +欢迎通过以下方式参与项目: +- 提交 Bug 报告 +- 提出新功能建议 +- 提交代码改进 +- 改进文档 + +## 开源协议 + +本项目采用 MIT 许可证开源。 + +## 联系方式 + +- 项目地址:https://gitee.com/huacheng80/json-view-utils +- 问题反馈:请在 Gitee 项目页面提交 Issue + +## 致谢 + +感谢所有为这个项目贡献代码和建议的开发者! \ No newline at end of file