# vue-x6-editor **Repository Path**: tang_zhanwang/vue-x6-editor ## Basic Information - **Project Name**: vue-x6-editor - **Description**: 是一个基于@antv/x6以及plain-ui-composition封装的Vue3.0可视化流程编辑组件;旨在于封装开箱即用的常用功能,包括快速定义画布组件、快速定义画布React组件、撤销重做、放大缩小、数据导入导出、冻结画布、拦截新增(删除)节点(边)等功能; - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 12 - **Created**: 2023-06-30 - **Last Updated**: 2023-06-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [toc] - 在线示例:[http://martsforever-pot.gitee.io/vue-x6-editor/](http://martsforever-pot.gitee.io/vue-x6-editor/) - React版本:[https://gitee.com/martsforever-pot/react-x6-editor](https://gitee.com/martsforever-pot/react-x6-editor) # 简介 - 是一个基于[@antv/x6](https://antv-x6.gitee.io/zh/docs/tutorial/about/)以及[plain-ui-composition](http://plain-pot.gitee.io/plain-ui-doc/#components%2Fcomposition%2Fintroduce.entire)封装的Vue3.0可视化流程编辑组件; - 旨在于封装开箱即用的常用功能,包括快速定义画布组件、快速定义画布React组件、撤销重做、放大缩小、数据导入导出、冻结画布、拦截新增(删除)节点(边)等功能; # 安装 ## 安装依赖 ```bash npm i vue-x6-editor plain-ui-compositoin @antv/x6 @antv/x6-vue-shape -S ``` ## 示例代码 - `plain-ui-composition`是一个基于Vue3.0 CompositionAPI封装的插件库,旨在于提供更好的组件与TS类型提示开发体验。 - 目前仅支持组合式API的方式使用。 ### JSX使用示例 ```jsx import {createApp} from "vue"; import {designPage} from 'plain-ui-composition'; import {createBranchNode, createEndNode, createFlowEdge, createFlowNode, createRenderNode, createStartNode, ReactX6Editor, useFlowEditor} from "vue-x6-editor"; import 'vue-x6-editor/dist/vue-x6-editor.css' import './main.scss'; const App = designPage(() => { const editor = useFlowEditor({ onlyOneStartNode: true, operators: [ { label: '选项一', icon: () => (), handler: () => console.log('option 1...') } ] }); editor.components.registry(createStartNode()); editor.components.registry(createFlowNode()); editor.components.registry(createBranchNode()); editor.components.registry(createEndNode()); editor.components.registry(createFlowEdge()); editor.components.registry(createRenderNode()); import('./flow.data.json').then(data => {editor.methods.update(data.default);}); editor.hooks.onCreateContextmenu.use(({ options, edge, node, type }) => { switch (type) { case 'node': options.push({ label: '自定义node选项2', icon: () => , handler: () => alert('自定义node选项2') }); return; case 'edge': options.push({ label: '自定义edge选项', icon: 'data', handler: () => alert('自定义edge选项') }); return; case 'vertex': options.push({ label: '自定义拐点选项', icon: 'data', handler: () => alert('自定义拐点选项') }); return; case 'blank': options.push({ label: '自定义白板选项', icon: 'data', handler: () => alert('自定义白板选项') }); return; } }); return () => (