Compare commits
5 Commits
bba49e019e
...
claude/iss
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04387d66a9 | ||
| 471bff1a8c | |||
|
|
9aa28a9fa3 | ||
| 4733916523 | |||
|
|
eb3a23ab03 |
119
README.md
119
README.md
@@ -1,73 +1,70 @@
|
|||||||
# React + TypeScript + Vite
|
# ConceptSketch
|
||||||
|
|
||||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
An interactive concept map editor for creating and exploring hierarchical graph diagrams. Build knowledge structures visually by connecting nodes into nested subgraphs.
|
||||||
|
|
||||||
Currently, two official plugins are available:
|
## Features
|
||||||
|
|
||||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
- **Interactive graph editing** — click nodes to create children, ctrl+click to multi-select, click edges to remove them
|
||||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
- **Nested subgraphs** — convert any node into its own subgraph layer for infinite nesting
|
||||||
|
- **Breadcrumb navigation** — navigate through graph hierarchy with breadcrumb trail
|
||||||
|
- **Sidebar tree view** — see and navigate the full hierarchical structure at a glance
|
||||||
|
- **Rename nodes** — right-click any node to rename, create subgraphs, or remove
|
||||||
|
- **Orphaned nodes** — right-click empty canvas area to create standalone nodes
|
||||||
|
- **Save & load** — export/import your entire graph as a JSON file
|
||||||
|
|
||||||
## React Compiler
|
## Getting Started
|
||||||
|
|
||||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
### Prerequisites
|
||||||
|
|
||||||
## Expanding the ESLint configuration
|
- Node.js (v18+)
|
||||||
|
- npm
|
||||||
|
|
||||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
### Installation
|
||||||
|
|
||||||
```js
|
```bash
|
||||||
export default defineConfig([
|
npm install
|
||||||
globalIgnores(['dist']),
|
|
||||||
{
|
|
||||||
files: ['**/*.{ts,tsx}'],
|
|
||||||
extends: [
|
|
||||||
// Other configs...
|
|
||||||
|
|
||||||
// Remove tseslint.configs.recommended and replace with this
|
|
||||||
tseslint.configs.recommendedTypeChecked,
|
|
||||||
// Alternatively, use this for stricter rules
|
|
||||||
tseslint.configs.strictTypeChecked,
|
|
||||||
// Optionally, add this for stylistic rules
|
|
||||||
tseslint.configs.stylisticTypeChecked,
|
|
||||||
|
|
||||||
// Other configs...
|
|
||||||
],
|
|
||||||
languageOptions: {
|
|
||||||
parserOptions: {
|
|
||||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
||||||
tsconfigRootDir: import.meta.dirname,
|
|
||||||
},
|
|
||||||
// other options...
|
|
||||||
},
|
|
||||||
},
|
|
||||||
])
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
### Development
|
||||||
|
|
||||||
```js
|
```bash
|
||||||
// eslint.config.js
|
npm run dev
|
||||||
import reactX from 'eslint-plugin-react-x'
|
|
||||||
import reactDom from 'eslint-plugin-react-dom'
|
|
||||||
|
|
||||||
export default defineConfig([
|
|
||||||
globalIgnores(['dist']),
|
|
||||||
{
|
|
||||||
files: ['**/*.{ts,tsx}'],
|
|
||||||
extends: [
|
|
||||||
// Other configs...
|
|
||||||
// Enable lint rules for React
|
|
||||||
reactX.configs['recommended-typescript'],
|
|
||||||
// Enable lint rules for React DOM
|
|
||||||
reactDom.configs.recommended,
|
|
||||||
],
|
|
||||||
languageOptions: {
|
|
||||||
parserOptions: {
|
|
||||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
||||||
tsconfigRootDir: import.meta.dirname,
|
|
||||||
},
|
|
||||||
// other options...
|
|
||||||
},
|
|
||||||
},
|
|
||||||
])
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Opens at `http://localhost:5173` with hot module replacement.
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx playwright test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
| Action | Result |
|
||||||
|
|---|---|
|
||||||
|
| Click a node | Create a new child node |
|
||||||
|
| Ctrl+click nodes, then click target | Link selected nodes as parents to target |
|
||||||
|
| Click an edge | Delete that edge |
|
||||||
|
| Right-click a node | Open context menu (Rename / Subgraph / Remove) |
|
||||||
|
| Right-click empty area | Create an orphaned (unconnected) node |
|
||||||
|
| Click sidebar tree item | Navigate to that subgraph |
|
||||||
|
|
||||||
|
## Tech Stack
|
||||||
|
|
||||||
|
- **React 19** + **TypeScript**
|
||||||
|
- **Vite** — build tool
|
||||||
|
- **Viz.js** (Graphviz) — graph rendering
|
||||||
|
- **D3** — SVG interactivity
|
||||||
|
- **Ant Design** — UI components
|
||||||
|
- **Zustand** — state management
|
||||||
|
|
||||||
|
## File Format
|
||||||
|
|
||||||
|
Graphs are saved as `concept-sketch.json`. The format supports nested subgraphs with recursive structure, preserving the full hierarchy.
|
||||||
|
|||||||
@@ -264,12 +264,7 @@ const Graph = forwardRef<GraphHandle, { setGraphPath: React.Dispatch<React.SetSt
|
|||||||
title: selectedNodeName,
|
title: selectedNodeName,
|
||||||
key: pathSegmentId,
|
key: pathSegmentId,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
const index = graphsPath.findIndex(p => p.key === pathSegmentId);
|
setGraphsPath(prev => prev.slice(0, prev.findIndex(p => p.key === pathSegmentId) + 1));
|
||||||
setGraphsPath(prev => {
|
|
||||||
prev.splice(index + 1);
|
|
||||||
|
|
||||||
return [...prev];
|
|
||||||
});
|
|
||||||
selectGraphId(pathSegmentId);
|
selectGraphId(pathSegmentId);
|
||||||
}
|
}
|
||||||
} as BreadcrumbItemType;
|
} as BreadcrumbItemType;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Input, Modal } from "antd";
|
import { Input, Modal } from "antd";
|
||||||
import { graphContext, type NodeContext } from "./Graph";
|
import { graphContext, type NodeContext } from "./Graph";
|
||||||
import { useContext, useState } from "react";
|
import { useContext, useState } from "react";
|
||||||
|
import { useGraphLayersTreeStore } from "../stores/TreeStore";
|
||||||
|
|
||||||
export default function NodeRenameModal({
|
export default function NodeRenameModal({
|
||||||
nodeContext,
|
nodeContext,
|
||||||
@@ -15,7 +16,8 @@ export default function NodeRenameModal({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const [nodeName, setSelectedNodeName] = useState(nodeContext.nodeName);
|
const [nodeName, setSelectedNodeName] = useState(nodeContext.nodeName);
|
||||||
const graphContextValue = useContext(graphContext)!;
|
const graphContextValue = useContext(graphContext)!;
|
||||||
|
const renameTreeNode = useGraphLayersTreeStore(state => state.rename);
|
||||||
|
|
||||||
function renameNode() {
|
function renameNode() {
|
||||||
const node = graphContextValue.graph.nodes.find(n => n.id === nodeContext.nodeId);
|
const node = graphContextValue.graph.nodes.find(n => n.id === nodeContext.nodeId);
|
||||||
@@ -24,6 +26,7 @@ export default function NodeRenameModal({
|
|||||||
}
|
}
|
||||||
node.label = nodeName;
|
node.label = nodeName;
|
||||||
graphContextValue.setGraph(prev => ({ ...prev, nodes: graphContextValue.graph.nodes }));
|
graphContextValue.setGraph(prev => ({ ...prev, nodes: graphContextValue.graph.nodes }));
|
||||||
|
renameTreeNode(nodeContext.nodeId, nodeName);
|
||||||
openRenameModal(false);
|
openRenameModal(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export interface TreeStore {
|
|||||||
tree: TreeDataNode[];
|
tree: TreeDataNode[];
|
||||||
add: (childNode: NodeContext, parentNodeId: string | undefined) => void;
|
add: (childNode: NodeContext, parentNodeId: string | undefined) => void;
|
||||||
remove: (nodeId: string) => void;
|
remove: (nodeId: string) => void;
|
||||||
|
rename: (nodeId: string, newName: string) => void;
|
||||||
reset: () => void;
|
reset: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +91,20 @@ export const useGraphLayersTreeStore = create<TreeStore>()((set) => ({
|
|||||||
tree: createTree([...state.rootNodes], nodesFlatById)
|
tree: createTree([...state.rootNodes], nodesFlatById)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
rename: (nodeId, newName) => set((state) => {
|
||||||
|
const node = state.nodesFlatById.get(nodeId);
|
||||||
|
if (!node) {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
const nodesFlatById = new Map(state.nodesFlatById);
|
||||||
|
nodesFlatById.set(nodeId, { ...node, title: newName });
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
nodesFlatById,
|
||||||
|
rootNodes: [...state.rootNodes],
|
||||||
|
tree: createTree([...state.rootNodes], nodesFlatById),
|
||||||
|
};
|
||||||
|
}),
|
||||||
reset: () => set({
|
reset: () => set({
|
||||||
nodesFlatById: new Map<React.Key, TreeDataNode>(),
|
nodesFlatById: new Map<React.Key, TreeDataNode>(),
|
||||||
parentIdByChildId: new Map<React.Key, string>(),
|
parentIdByChildId: new Map<React.Key, string>(),
|
||||||
|
|||||||
Reference in New Issue
Block a user