diff --git a/package-lock.json b/package-lock.json index 2725a58..392dfcc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,9 @@ "name": "reactflow-shadcn-app", "version": "0.1.0", "dependencies": { + "@monaco-editor/react": "^4.7.0", + "js-yaml": "^4.1.0", + "monaco-editor": "^0.55.1", "react": "18.2.0", "react-dom": "18.2.0", "reactflow": "^11.0.0", @@ -1193,6 +1196,29 @@ } } }, + "node_modules/@monaco-editor/loader": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@monaco-editor/loader/-/loader-1.7.0.tgz", + "integrity": "sha512-gIwR1HrJrrx+vfyOhYmCZ0/JcWqG5kbfG7+d3f/C1LXk2EvzAbHSg3MQ5lO2sMlo9izoAZ04shohfKLVT6crVA==", + "license": "MIT", + "dependencies": { + "state-local": "^1.0.6" + } + }, + "node_modules/@monaco-editor/react": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@monaco-editor/react/-/react-4.7.0.tgz", + "integrity": "sha512-cyzXQCtO47ydzxpQtCGSQGOC8Gk3ZUeBXFAxD+CWXYFo5OqZyZUonFl0DwUlTyAfRHntBfw2p3w4s9R6oe1eCA==", + "license": "MIT", + "dependencies": { + "@monaco-editor/loader": "^1.5.0" + }, + "peerDependencies": { + "monaco-editor": ">= 0.25.0 < 1", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, "node_modules/@mswjs/interceptors": { "version": "0.41.3", "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.41.3.tgz", @@ -1730,6 +1756,13 @@ "integrity": "sha512-xMAgYwceFhRA2zY+XbEA7mxYbA093wdiW8Vu6gZPGWy9cmOyU9XesH1tNcEWsKFd5Vzrqx5T3D38PWx1FIIXkA==", "license": "MIT" }, + "node_modules/@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", + "license": "MIT", + "optional": true + }, "node_modules/@types/validate-npm-package-name": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/validate-npm-package-name/-/validate-npm-package-name-4.0.2.tgz", @@ -2703,6 +2736,15 @@ "dev": true, "license": "MIT" }, + "node_modules/dompurify": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.2.7.tgz", + "integrity": "sha512-WhL/YuveyGXJaerVlMYGWhvQswa7myDG17P7Vu65EWC05o8vfeNbvNf4d/BOvH99+ZW+LlQsc1GDKMa1vNK6dw==", + "license": "(MPL-2.0 OR Apache-2.0)", + "optionalDependencies": { + "@types/trusted-types": "^2.0.7" + } + }, "node_modules/dotenv": { "version": "17.3.1", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.3.1.tgz", @@ -3921,6 +3963,18 @@ "node": ">=12" } }, + "node_modules/marked": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-14.0.0.tgz", + "integrity": "sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==", + "license": "MIT", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -4061,6 +4115,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/monaco-editor": { + "version": "0.55.1", + "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.55.1.tgz", + "integrity": "sha512-jz4x+TJNFHwHtwuV9vA9rMujcZRb0CEilTEwG2rRSpe/A7Jdkuj8xPKttCgOh+v/lkHy7HsZ64oj+q3xoAFl9A==", + "license": "MIT", + "dependencies": { + "dompurify": "3.2.7", + "marked": "14.0.0" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -5320,6 +5384,12 @@ "node": ">=0.10.0" } }, + "node_modules/state-local": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/state-local/-/state-local-1.0.7.tgz", + "integrity": "sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w==", + "license": "MIT" + }, "node_modules/statuses": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", diff --git a/package.json b/package.json index 55673e8..b54f6c1 100644 --- a/package.json +++ b/package.json @@ -8,19 +8,22 @@ "preview": "vite preview" }, "dependencies": { + "@monaco-editor/react": "^4.7.0", + "js-yaml": "^4.1.0", + "monaco-editor": "^0.55.1", "react": "18.2.0", "react-dom": "18.2.0", "reactflow": "^11.0.0", "shadcn": "^3.8.5" }, "devDependencies": { - "vite": "^4.0.0", - "@vitejs/plugin-react": "^3.0.0", - "tailwindcss": "^3.4.0", - "postcss": "^8.4.0", - "autoprefixer": "^10.4.0", - "typescript": "^5.0.0", "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0" + "@types/react-dom": "^18.0.0", + "@vitejs/plugin-react": "^3.0.0", + "autoprefixer": "^10.4.0", + "postcss": "^8.4.0", + "tailwindcss": "^3.4.0", + "typescript": "^5.0.0", + "vite": "^4.0.0" } } diff --git a/src/App.tsx b/src/App.tsx index 8a4ffa1..bd0ee42 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -15,31 +15,38 @@ import ReactFlow, { EdgeChange, } from 'reactflow' import CustomNode from './components/CustomNode' +import ConfigNode from './components/ConfigNode' +import RenderingNode from './components/RenderingNode' +import FlowContext from './lib/flowContext' + +// Generate short unique node ids when missing +const genId = () => `node_${Math.random().toString(36).slice(2, 9)}` const initialNodes: Node[] = [ { - id: '1', - position: { x: 250, y: 5 }, - data: { label: 'Node A' }, - type: 'custom', + id: 'config-1', + position: { x: 50, y: 50 }, + data: { yaml: "# example:\nmessage: Hello from config" }, + type: 'config', }, { - id: '2', - position: { x: 100, y: 200 }, - data: { label: 'Node B' }, - type: 'custom', + id: 'render-1', + position: { x: 350, y: 80 }, + data: {}, + type: 'render', }, -] +].map((n) => ({ ...n, id: n.id ?? genId() })) -const initialEdges: Edge[] = [ - { id: 'e1-2', source: '1', target: '2' }, -] +const initialEdges: Edge[] = [{ id: 'e-config-render', source: 'config-1', target: 'render-1' }] export default function App() { const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes) const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges) - const nodeTypes = React.useMemo(() => ({ custom: CustomNode }), []) + const nodeTypes = React.useMemo( + () => ({ custom: CustomNode, config: ConfigNode, render: RenderingNode }), + [] + ) const onConnect = React.useCallback( (params: Connection) => setEdges((eds) => addEdge(params, eds)), @@ -48,19 +55,21 @@ export default function App() { return (
{output}
+