@mx-sose-front/mx-sose-graph 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +343 -0
- package/dist/index.d.ts +3937 -0
- package/dist/index.esm.js +74367 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +38 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +70 -0
- package/src/components/ContextMenu.vue +475 -0
- package/src/components/Diagram/StrategicTaxonomyDiagram.vue +141 -0
- package/src/components/Edge/Edge.vue +366 -0
- package/src/components/InteractionLayer.vue +2033 -0
- package/src/components/Label.vue +0 -0
- package/src/components/LineStyle/ConnectionLine.vue +126 -0
- package/src/components/LineStyle/LineStyleMarker.vue +87 -0
- package/src/components/Pin/Pin.vue +220 -0
- package/src/components/Pin/Port.vue +172 -0
- package/src/components/Shape/Action.vue +121 -0
- package/src/components/Shape/ActivityAction.vue +155 -0
- package/src/components/Shape/Block.vue +306 -0
- package/src/components/Shape/ConceptualRole.vue +266 -0
- package/src/components/Shape/Diagram.vue +220 -0
- package/src/components/Shape/DividingLine.vue +594 -0
- package/src/components/Shape/DogEar.vue +224 -0
- package/src/components/Shape/Package.vue +340 -0
- package/src/constants/edgeShapeKeys.ts +81 -0
- package/src/constants/index.ts +440 -0
- package/src/index.ts +28 -0
- package/src/render/shape-registry.ts +17 -0
- package/src/render/shape-renderer.ts +103 -0
- package/src/statics/icons/childIcons/relations@3x.png +0 -0
- package/src/statics/icons/childIcons/role@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/344/277/241/345/217/267@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/344/277/241/346/201/257@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/344/277/241/346/201/257/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/345/206/205/351/203/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/345/206/205/351/203/250/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/345/217/202/346/225/260@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/345/217/202/346/225/260/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/345/257/271/350/261/241/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/211/247/350/241/214/350/200/205@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/216/245/345/217/243@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/216/247/345/210/266/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/264/273/345/212/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/264/273/345/212/250/344/270/216/350/203/275/345/212/233/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/264/273/345/212/250/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/264/273/345/212/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/264/273/345/212/250/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/212/266/346/200/201/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/253/257/345/217/243@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/272/246/346/235/237@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/272/246/346/235/237/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/272/246/346/235/237/345/256/232/344/271/211/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/272/246/346/235/237/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/347/273/223/346/236/204@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/350/207/252/347/224/261/345/210/206/347/261/273/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/350/247/222/350/211/262@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/350/277/236/346/216/245/345/231/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/350/277/236/351/200/232/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/270/232/345/212/241/351/253/230/347/272/247/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/345/206/205/351/203/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/345/206/205/351/203/250/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/345/217/202/346/225/260/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/347/212/266/346/200/201/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/347/272/246/346/235/237/345/233/276@3x-2.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/347/272/246/346/235/237/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//344/272/272/345/221/230/350/277/236/351/200/232/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/273/267/345/200/274/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//344/273/273/346/204/217/345/205/263/347/263/273@3x.png +0 -0
- package/src/statics/icons/childIcons//344/273/273/346/204/217/350/277/236/346/216/245/345/231/250@3x.png +0 -0
- package/src/statics/icons/childIcons//344/274/201/344/270/232/344/275/277/345/221/275@3x.png +0 -0
- package/src/statics/icons/childIcons//344/274/201/344/270/232/345/205/250/347/224/237/345/221/275/345/221/250/346/234/237@3x.png +0 -0
- package/src/statics/icons/childIcons//344/274/201/344/270/232/346/204/277/346/231/257@3x.png +0 -0
- package/src/statics/icons/childIcons//344/274/201/344/270/232/347/233/256/346/240/207@3x.png +0 -0
- package/src/statics/icons/childIcons//344/275/215/347/275/256@3x.png +0 -0
- package/src/statics/icons/childIcons//344/275/223/347/263/273/346/236/266/346/236/204@3x.png +0 -0
- package/src/statics/icons/childIcons//344/276/235/350/265/226@3x.png +0 -0
- package/src/statics/icons/childIcons//344/277/235/346/212/244@3x.png +0 -0
- package/src/statics/icons/childIcons//344/277/241/346/201/257/346/250/241/345/236/213@3x.png +0 -0
- package/src/statics/icons/childIcons//345/210/233/351/200/240@3x.png +0 -0
- package/src/statics/icons/childIcons//345/212/237/350/203/275@3x.png +0 -0
- package/src/statics/icons/childIcons//345/212/237/350/203/275/344/270/216/344/270/232/345/212/241/346/264/273/345/212/250/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//345/212/237/350/203/275/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//345/212/237/350/203/275/345/257/271/350/261/241/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//345/212/237/350/203/275/346/216/247/345/210/266/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//345/217/214/345/220/221/345/205/263/350/201/224@3x.png +0 -0
- package/src/statics/icons/childIcons//345/217/227/345/210/260/345/275/261/345/223/215@3x.png +0 -0
- package/src/statics/icons/childIcons//345/234/260/347/220/206/346/224/277/346/262/273/350/214/203/345/233/264/347/261/273/345/236/213@3x.png +0 -0
- package/src/statics/icons/childIcons//345/241/253/345/206/231/350/201/214/344/275/215/347/224/263/350/257/267@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/345/206/205/351/203/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/346/216/247/345/210/266@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/346/265/201/347/250/213@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/346/265/201/347/250/213/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/347/272/246/346/235/237@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/347/272/246/346/235/237/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/347/272/246/346/235/237/345/256/232/344/271/211/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/350/277/236/351/200/232/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/351/232/224/347/246/273@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/211/345/205/250/351/243/216/351/231/251@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/232/345/220/221/345/205/263/347/263/273@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/232/345/220/221/345/205/263/350/201/224@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/232/345/220/221/347/273/204/346/210/220@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/232/345/220/221/350/201/232/345/220/210@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/344/272/272/345/221/230@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/344/274/201/344/270/232/351/230/266/346/256/265@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/344/275/215/347/275/256@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/345/261/236/346/200/247/350/256/276/347/275/256@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/346/210/230/347/225/245/351/230/266/346/256/265/347/224/230/347/211/271/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/346/214/201/347/273/255/344/273/273/345/212/241@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/346/234/215/345/212/241@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/346/235/241/344/273/266@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/347/216/257/345/242/203@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/347/273/204/347/273/207@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/201/214/344/275/215@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/201/214/350/264/243@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/264/243/344/273/273@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/265/204/346/272/220@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/265/204/346/272/220/344/270/216/345/256/236/351/231/205/351/241/271/347/233/256/345/257/271/345/272/224/345/205/263/347/263/273/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/265/204/346/272/220/346/246/202/345/277/265/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/265/204/346/272/220/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/350/265/204/346/272/220/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/351/241/271/347/233/256@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/351/241/271/347/233/256/344/270/216/350/203/275/345/212/233/347/232/204/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/351/241/271/347/233/256/351/207/214/347/250/213/347/242/221@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/351/241/271/347/233/256/351/207/214/347/250/213/347/242/221/346/261/207/346/200/273/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//345/256/236/351/231/205/351/243/216/351/231/251@3x.png +0 -0
- package/src/statics/icons/childIcons//345/261/225/347/244/272@3x.png +0 -0
- package/src/statics/icons/childIcons//345/267/262/347/237/245/350/265/204/346/272/220@3x.png +0 -0
- package/src/statics/icons/childIcons//345/274/200/345/261/225/345/267/245/344/275/234/350/203/275/345/212/233@3x.png +0 -0
- package/src/statics/icons/childIcons//345/274/225/347/224/250/345/261/236/346/200/247@3x.png +0 -0
- package/src/statics/icons/childIcons//345/275/261/345/223/215@3x-2.png +0 -0
- package/src/statics/icons/childIcons//345/275/261/345/223/215@3x.png +0 -0
- package/src/statics/icons/childIcons//346/204/277/346/231/257/345/256/243/350/250/200@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/344/277/241/346/201/257@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/344/277/241/346/201/257/345/233/276@3x-2.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/344/277/241/346/201/257/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/345/217/202/346/225/260/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/345/256/236/351/231/205/346/210/230/347/225/245/351/230/266/346/256/265/345/210/206/347/261/273/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/345/256/236/351/231/205/351/203/250/347/275/262/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/346/265/201/347/250/213/345/233/276@3x-2.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/347/212/266/346/200/201/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/347/272/246/346/235/237@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/347/272/246/346/235/237/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/347/272/246/346/235/237/345/256/232/344/271/211/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/350/277/236/351/200/232/345/233/276@3x-2.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/350/277/236/351/200/232/347/237/251/351/230/265@3x-2.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/350/277/236/351/200/232/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//346/210/230/347/225/245/351/230/266/346/256/265@3x.png +0 -0
- package/src/statics/icons/childIcons//346/211/247/350/241/214@3x.png +0 -0
- package/src/statics/icons/childIcons//346/211/247/350/241/214/350/200/205/345/206/205/351/203/250/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/211/247/350/241/214/350/200/205/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/211/247/350/241/214/350/200/205/347/273/223/346/236/204/345/233/276@3x-2.png +0 -0
- package/src/statics/icons/childIcons//346/211/247/350/241/214/350/200/205/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/211/247/350/241/214/350/200/205/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/211/277/346/213/205/351/243/216/351/231/251@3x.png +0 -0
- package/src/statics/icons/childIcons//346/212/200/346/234/257@3x.png +0 -0
- package/src/statics/icons/childIcons//346/213/245/346/234/211/346/265/201/347/250/213@3x.png +0 -0
- package/src/statics/icons/childIcons//346/217/220/344/276/233/346/235/203/351/231/220@3x.png +0 -0
- package/src/statics/icons/childIcons//346/227/266/346/234/272@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/344/270/216/344/270/232/345/212/241/346/264/273/345/212/250/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/344/270/216/346/234/215/345/212/241/345/220/210/345/220/214/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/344/270/216/350/203/275/345/212/233/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/344/277/241/345/217/267@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/206/205/351/203/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/206/205/351/203/250/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/212/237/350/203/275@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/212/237/350/203/275/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/217/202/346/225/260@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/217/202/346/225/260/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/345/257/271/350/261/241/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/346/216/245/345/217/243@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/346/216/247/345/210/266/346/265/201@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/347/212/266/346/200/201/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/347/253/257/345/217/243@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/347/272/246/346/235/237/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/347/272/246/346/235/237/345/256/232/344/271/211/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/347/273/223/346/236/204@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/350/247/222/350/211/262@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/350/267/257/347/272/277/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/350/277/236/346/216/245/345/231/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/350/277/236/351/200/232/350/241/250@3x-2.png +0 -0
- package/src/statics/icons/childIcons//346/234/215/345/212/241/350/277/236/351/200/232/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/235/203/351/231/220@3x.png +0 -0
- package/src/statics/icons/childIcons//346/235/241/344/273/266@3x.png +0 -0
- package/src/statics/icons/childIcons//346/240/207/345/207/206/344/270/232/345/212/241/346/264/273/345/212/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/240/207/345/207/206/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/240/207/345/207/206/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//346/240/207/345/207/206/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/240/207/345/207/206/350/267/257/347/272/277/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/240/207/345/207/206/350/277/275/346/272/257/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//346/246/202/345/277/265/350/247/222/350/211/262@3x.png +0 -0
- package/src/statics/icons/childIcons//346/263/233/345/214/226@3x.png +0 -0
- package/src/statics/icons/childIcons//347/212/266/345/206/265@3x.png +0 -0
- package/src/statics/icons/childIcons//347/216/257/345/242/203@3x.png +0 -0
- package/src/statics/icons/childIcons//347/233/270/346/257/224@3x (1).png +0 -0
- package/src/statics/icons/childIcons//347/263/273/347/273/237@3x.png +0 -0
- package/src/statics/icons/childIcons//347/273/204/346/210/220@3x.png +0 -0
- package/src/statics/icons/childIcons//347/273/204/347/273/207@3x.png +0 -0
- package/src/statics/icons/childIcons//347/273/204/347/273/207/351/230/266/346/256/265@3x.png +0 -0
- package/src/statics/icons/childIcons//347/273/221/345/256/232/350/277/236/346/216/245/345/231/250@3x.png +0 -0
- package/src/statics/icons/childIcons//347/274/223/350/247/243@3x.png +0 -0
- package/src/statics/icons/childIcons//350/201/214/344/275/215@3x.png +0 -0
- package/src/statics/icons/childIcons//350/201/232/345/220/210@3x.png +0 -0
- package/src/statics/icons/childIcons//350/203/275/345/212/233@3x.png +0 -0
- package/src/statics/icons/childIcons//350/203/275/345/212/233/350/201/214/350/264/243@3x.png +0 -0
- package/src/statics/icons/childIcons//350/203/275/345/212/233/351/205/215/347/275/256@3x.png +0 -0
- package/src/statics/icons/childIcons//350/203/275/345/244/237/350/203/234/344/273/273@3x.png +0 -0
- package/src/statics/icons/childIcons//350/207/252/347/204/266/350/265/204/346/272/220@3x.png +0 -0
- package/src/statics/icons/childIcons//350/246/201/346/261/202@3x.png +0 -0
- package/src/statics/icons/childIcons//350/256/276/347/275/256/347/261/273/345/236/213.png +0 -0
- package/src/statics/icons/childIcons//350/264/237/350/264/243@3x.png +0 -0
- package/src/statics/icons/childIcons//350/264/243/344/273/273@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/344/272/247/351/243/216/351/231/251/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/344/270/216/344/270/232/345/212/241/346/264/273/345/212/250/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/344/270/216/350/203/275/345/212/233/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/344/277/241/345/217/267@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/344/277/241/346/201/257@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/344/277/241/346/201/257/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/345/206/205/351/203/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/345/206/205/351/203/250/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/345/217/202/346/225/260@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/345/217/202/346/225/260/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/345/267/245/344/273/266@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/216/245/345/217/243@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/234/215/345/212/241@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/236/266/346/236/204@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/264/273/345/212/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/264/273/345/212/250/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/347/212/266/346/200/201/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/347/253/257/345/217/243@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/347/272/246/346/235/237@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/347/273/223/346/236/204@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/347/274/223/350/247/243/346/216/252/346/226/275@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/350/247/222/350/211/262@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/350/277/236/346/216/245/345/231/250@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//350/265/204/346/272/220/350/277/236/351/200/232/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//350/275/257/344/273/266@3x.png +0 -0
- package/src/statics/icons/childIcons//350/276/223/345/205/245/346/240/223@3x.png +0 -0
- package/src/statics/icons/childIcons//350/276/223/345/207/272/346/240/223@3x.png +0 -0
- package/src/statics/icons/childIcons//350/276/276/345/210/260@3x.png +0 -0
- package/src/statics/icons/childIcons//350/277/236/346/216/245/345/231/250@3x.png +0 -0
- package/src/statics/icons/childIcons//350/277/236/347/272/277@3x.png +0 -0
- package/src/statics/icons/childIcons//351/207/214/347/250/213/347/242/221/344/276/235/350/265/226@3x.png +0 -0
- package/src/statics/icons/childIcons//351/230/266/346/256/265@3x.png +0 -0
- package/src/statics/icons/childIcons//351/234/200/346/261/202/346/235/203/351/231/220@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/266/347/272/247/344/270/232/345/212/241/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/344/270/273/351/242/230@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/345/206/205/351/203/250/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/346/246/202/345/277/265/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/346/246/202/345/277/265/350/241/250@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/346/264/273/345/212/250@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/346/264/273/345/212/250/344/270/216/350/203/275/345/212/233/347/232/204/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/346/264/273/345/212/250/345/212/250/344/275/234@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/346/265/201/347/250/213/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/347/273/223/346/236/204/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/350/247/222/350/211/262@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/350/267/257/347/272/277/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/350/277/236/351/200/232/345/233/276@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/351/207/214/347/250/213/347/242/221@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/271/347/233/256/351/207/214/347/250/213/347/242/221/350/247/222/350/211/262@3x.png +0 -0
- package/src/statics/icons/childIcons//351/241/272/345/272/217@3x-2.png +0 -0
- package/src/statics/icons/childIcons//351/241/272/345/272/217@3x.png +0 -0
- package/src/statics/icons/childIcons//351/243/216/351/231/251@3x.png +0 -0
- package/src/statics/icons/childIcons//351/243/216/351/231/251/344/270/216/345/256/211/345/205/250/346/216/247/345/210/266/346/230/240/345/260/204/347/237/251/351/230/265@3x.png +0 -0
- package/src/statics/icons/childIcons//351/253/230/347/272/247/344/270/232/345/212/241/346/246/202/345/277/265@3x.png +0 -0
- package/src/statics/icons/createMenu/config.png +0 -0
- package/src/statics/icons/createMenu/contact.png +0 -0
- package/src/statics/icons/createMenu/copy.png +0 -0
- package/src/statics/icons/createMenu/delete.png +0 -0
- package/src/statics/icons/createMenu/diagram.png +0 -0
- package/src/statics/icons/createMenu/element.png +0 -0
- package/src/statics/icons/createMenu/locateChart.png +0 -0
- package/src/statics/icons/createMenu/paste.png +0 -0
- package/src/statics/icons/createMenu/rename.png +0 -0
- package/src/statics/icons/createMenu/scissors.png +0 -0
- package/src/store/eventBus.ts +38 -0
- package/src/store/graphStore.ts +782 -0
- package/src/store/index.ts +8 -0
- package/src/style/index.css +1 -0
- package/src/style/tailwind.css +33 -0
- package/src/types/index.ts +200 -0
- package/src/utils/autoExpandParent.ts +94 -0
- package/src/utils/colorUtils.ts +137 -0
- package/src/utils/compartment.ts +534 -0
- package/src/utils/containers.ts +910 -0
- package/src/utils/diagram.ts +403 -0
- package/src/utils/dom.ts +21 -0
- package/src/utils/drag.ts +224 -0
- package/src/utils/edgeUtils.ts +787 -0
- package/src/utils/geom.ts +177 -0
- package/src/utils/graphDragService.ts +329 -0
- package/src/utils/highlightUtils.ts +162 -0
- package/src/utils/hittest.ts +135 -0
- package/src/utils/iconLoader.ts +105 -0
- package/src/utils/index.ts +20 -0
- package/src/utils/packgeMap.ts +1 -0
- package/src/utils/pinUtils.ts +484 -0
- package/src/utils/policy.ts +212 -0
- package/src/utils/zorder.ts +39 -0
- package/src/view/graph.vue +419 -0
- package/src/vite-env.d.ts +33 -0
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { ref, computed, shallowReactive, type Ref } from 'vue'
|
|
3
|
+
import type { Shape, OwnerPayload, ShapeSizeUpdatePayload } from '../types'
|
|
4
|
+
import { eventBus } from './eventBus'
|
|
5
|
+
import { getPolicy, checkNestViaFront, } from '../utils/policy'
|
|
6
|
+
import _ from "lodash";
|
|
7
|
+
import { collectDescendantIds, } from '../utils/containers'
|
|
8
|
+
import { normalizeZOrder } from '../utils/zorder'
|
|
9
|
+
import {
|
|
10
|
+
buildDragSnapshot,
|
|
11
|
+
stepSingleDrag,
|
|
12
|
+
stepGroupDrag,
|
|
13
|
+
commitDrag,
|
|
14
|
+
finalizeAfterTransform,
|
|
15
|
+
} from '../utils/drag'
|
|
16
|
+
import {
|
|
17
|
+
isShapeTypeNotInPackageTypes, removeChildShapeFromCompartment, addChildShapeToCompartment, hydrateComparentsFromJSON,
|
|
18
|
+
rebuildAllCompartmentChildrenAsShapes,
|
|
19
|
+
syncComparentShapesIntoRuntime,
|
|
20
|
+
} from '../utils/compartment'
|
|
21
|
+
import { EdgeUtils } from '../utils/edgeUtils'
|
|
22
|
+
import { expandParentByChild } from '../utils/autoExpandParent'
|
|
23
|
+
import { applyReparentAndClone, autoExpandMovedCompartmentsAfterDrag, buildDragEndPayloads, buildPrevParentMap, collectAffectedShapeIds, createOnNestDoneCallback } from '../utils/graphDragService'
|
|
24
|
+
type Rect = { x: number; y: number; width: number; height: number };
|
|
25
|
+
export const useGraphStore = defineStore('graph', () => {
|
|
26
|
+
// 状态
|
|
27
|
+
const shapes = ref<Shape[]>([])
|
|
28
|
+
// 缩放比例 - 按画布ID存储
|
|
29
|
+
const scales = ref<Record<string, number>>({});
|
|
30
|
+
const selectedShape = ref<Shape | null>(null)
|
|
31
|
+
const diagramTitle = ref('未命名图表')
|
|
32
|
+
// 是否正在拖动元素
|
|
33
|
+
const isDragging = ref(false)
|
|
34
|
+
// 嵌套悬停容器高亮
|
|
35
|
+
const hoverContainerId = ref<string | null>(null)
|
|
36
|
+
// 当前元素是否允许嵌套
|
|
37
|
+
const hoverNestable = ref<boolean | null>(null)
|
|
38
|
+
// 存放“等待后端改类型”的图元 id 列表
|
|
39
|
+
const pendingNestedIds = ref<string[]>([])
|
|
40
|
+
// 当前拖动的元素 id
|
|
41
|
+
const draggingShapeId = ref<string | null>(null)
|
|
42
|
+
const draggingIds = ref<string[]>([]) // 当前正在拖动的 id 集合(单个时只有一个)
|
|
43
|
+
const dragAnchor = ref<{ x: number; y: number } | null>(null) // 按下时的指针位置
|
|
44
|
+
const dragBase = ref<Record<string, Rect>>({}) // 按下时的元素快照(完整矩形)
|
|
45
|
+
const dragGhost = shallowReactive<Record<string, Rect>>({}) // 拖动中的影子(不直接改实体)
|
|
46
|
+
let lastHoverId: string | null = '__INIT__' as any // 只在 hover 变化时才重算 canNest
|
|
47
|
+
const canDropOnCanvas = ref(false)//用来控制图元是否可以放到画布上面,不可以的话显示禁用标志
|
|
48
|
+
// 拖拽前的选中元素(用于恢复 UI 选中)
|
|
49
|
+
const dragSelectionSnapshot = ref<string[]>([])
|
|
50
|
+
// 拖拽时的“主拖动项”(用于组拖命中计算/高亮时可用)
|
|
51
|
+
const primaryDragId = ref<string | null>(null)
|
|
52
|
+
const groupBaseBox = ref<Rect | null>(null)
|
|
53
|
+
// 指针相对图元左上角的偏移,用于保持拖动时鼠标与元素的相对位置
|
|
54
|
+
const dragOffset = ref<{ x: number; y: number } | null>(null)
|
|
55
|
+
//当前打开画布的列表
|
|
56
|
+
const diagrams = ref<Shape[]>([])
|
|
57
|
+
//当前打开的画布id
|
|
58
|
+
const currentDiagramId = ref<string | null>(null)
|
|
59
|
+
//当前激活的画布id
|
|
60
|
+
const activeDiagramId = ref<string | null>(null);
|
|
61
|
+
// 当前被选中的多个 id
|
|
62
|
+
const selectedIds = ref<string[]>([])
|
|
63
|
+
const comparentsHydratedOnce = ref(false)
|
|
64
|
+
// 外部拖拽创建中的形状 id(用于隐藏实际形状,只显示 ghost)
|
|
65
|
+
const externalCreatingId = ref<string | null>(null)
|
|
66
|
+
// 计算属性
|
|
67
|
+
const shapeCount = computed(() => shapes.value.length)
|
|
68
|
+
const hasSelectedShape = computed(() => selectedShape.value !== null)
|
|
69
|
+
//图元shapeKey
|
|
70
|
+
const taggedValueLabels = ref<string[]>([]) // 隔间组件的图元类型
|
|
71
|
+
const packagesTypes = ref<string[]>([]) // 需要展示线的隔间组件的图元类型
|
|
72
|
+
const classMetaTypes = ref<string[]>([]) //可以生成的class类型
|
|
73
|
+
const ownerRequiredShapeKeys = ref<string[]>([])//哪些图元需要自动补 ownerId
|
|
74
|
+
const pinsTypes=ref<string[]>([])//栓类型
|
|
75
|
+
const portsTypes = ref<string[]>([])//端口类型
|
|
76
|
+
// 方法
|
|
77
|
+
/**
|
|
78
|
+
* 添加图元
|
|
79
|
+
* @param shape - The shape to add
|
|
80
|
+
*/
|
|
81
|
+
// 添加图元
|
|
82
|
+
const addShape = (shape: Shape) => {
|
|
83
|
+
// 检查是否是边类型且已经存在相同类型、相同源和目标的边
|
|
84
|
+
if (shape.shapeType === 'edge' && shape.sourceId && shape.targetId) {
|
|
85
|
+
const existingEdge = shapes.value.find(
|
|
86
|
+
s => s.shapeType === 'edge' &&
|
|
87
|
+
s.sourceId === shape.sourceId &&
|
|
88
|
+
s.targetId === shape.targetId &&
|
|
89
|
+
s.shapeKey === shape.shapeKey
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// 如果已经存在相同类型的边,则不添加并发送警告事件
|
|
93
|
+
if (existingEdge) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
shapes.value.push(shape)
|
|
99
|
+
// 通过事件总线发送事件
|
|
100
|
+
eventBus.emit('shape-added', shape)
|
|
101
|
+
}
|
|
102
|
+
//移除图元
|
|
103
|
+
const removeShape = (shapeId: string) => {
|
|
104
|
+
const index = shapes.value.findIndex(s => s.id == shapeId)
|
|
105
|
+
if (index > -1) {
|
|
106
|
+
const removedShape = shapes.value.splice(index, 1)[0]
|
|
107
|
+
// 通过事件总线发送事件
|
|
108
|
+
// eventBus.emit('shape-removed', removedShape)
|
|
109
|
+
// 若该图元有父,且父是隔间:从 comparents 里移除这个子 Shape
|
|
110
|
+
if (removedShape.parenShapeId) {
|
|
111
|
+
const parent = shapes.value.find(s => s.id == removedShape.parenShapeId)
|
|
112
|
+
if (parent && isShapeTypeNotInPackageTypes(parent)) {
|
|
113
|
+
removeChildShapeFromCompartment(parent, removedShape, updateShape)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// 如果删除的是当前选中的形状,清除选中状态
|
|
117
|
+
if (selectedShape.value?.id === shapeId) {
|
|
118
|
+
selectedShape.value = null
|
|
119
|
+
eventBus.emit('shape-deselected')
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//删除选中的元素
|
|
124
|
+
const removeSelected = () => {
|
|
125
|
+
if (!selectedIds.value.length) return
|
|
126
|
+
// 先拍个快照,避免过程中 selectedIds 变化
|
|
127
|
+
const ids = [...selectedIds.value]
|
|
128
|
+
ids.forEach(id => removeShape(id))
|
|
129
|
+
// 清空选择状态
|
|
130
|
+
selectedShape.value = null
|
|
131
|
+
selectedIds.value = []
|
|
132
|
+
}
|
|
133
|
+
function refreshChildSnapshotInCompartment(parent: Shape, child: Shape) {
|
|
134
|
+
// 直接“先移后加”达到“替换快照”的效果(工具内部会用快照,避免 Proxy/循环)
|
|
135
|
+
removeChildShapeFromCompartment(parent, child, updateShapeRaw)
|
|
136
|
+
addChildShapeToCompartment(parent, child, updateShapeRaw)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// 用于画布渲染的可见图元列表
|
|
140
|
+
const visibleShapes = computed<Shape[]>(() => {
|
|
141
|
+
const pendings = pendingNestedIds.value
|
|
142
|
+
if (!pendings.length) return shapes.value
|
|
143
|
+
const pendingSet = new Set(pendings)
|
|
144
|
+
return shapes.value.filter(s => !pendingSet.has(s.id))
|
|
145
|
+
})
|
|
146
|
+
// 更新单个图元(不处理父子关系 / comparents,同步由外层 updateShape 负责)
|
|
147
|
+
const updateShapeRaw = (shapeId: string, updates: Partial<Shape>, id: 'id' | 'modelId' = 'id') => {
|
|
148
|
+
const shape = shapes.value.find(s => s[id] === shapeId)
|
|
149
|
+
if (shape) {
|
|
150
|
+
// 对 Pin 做强保护:永不允许把 parenShapeId 置空/undefined
|
|
151
|
+
if (shape.shapeType === 'pin' && 'parenShapeId' in updates) {
|
|
152
|
+
const v: any = (updates as any).parenShapeId
|
|
153
|
+
if (v == null || v === '') {
|
|
154
|
+
// 丢弃本次对父字段的修改,仅应用其它字段
|
|
155
|
+
const { parenShapeId, ...rest } = updates as any
|
|
156
|
+
updates = rest as Partial<Shape>
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// 归一化:如果调用方显式想“清空父”,统一改成空字符串(历史兼容)
|
|
160
|
+
if ('parenShapeId' in updates && (updates as any).parenShapeId == null) {
|
|
161
|
+
(updates as any).parenShapeId = ''
|
|
162
|
+
}
|
|
163
|
+
const nextBounds = updates.bounds ? { ...shape.bounds, ...updates.bounds } : shape.bounds
|
|
164
|
+
const nextStyle = updates.style ? { ...(shape.style || {}), ...(updates.style as any) } : shape.style
|
|
165
|
+
Object.assign(shape, updates, { bounds: nextBounds, style: nextStyle })
|
|
166
|
+
eventBus.emit('shape-updated', shape, updates)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// 更新图元数据
|
|
170
|
+
const updateShape = (shapeId: string, updates: Partial<Shape>, id: 'id' | 'modelId' = 'id') => {
|
|
171
|
+
const before = shapes.value.find(s => s[id] === shapeId) || null
|
|
172
|
+
const oldPid = before?.parenShapeId ?? null
|
|
173
|
+
// 先真正写入
|
|
174
|
+
updateShapeRaw(shapeId, updates, id)
|
|
175
|
+
const after = shapes.value.find(s => s[id] === shapeId) || null
|
|
176
|
+
if (!after) return
|
|
177
|
+
|
|
178
|
+
// 如果更新了bounds,需要重新计算相关连线的位置
|
|
179
|
+
if (updates.bounds) {
|
|
180
|
+
EdgeUtils.updateRelatedEdges(shapes.value, [after.id], (shape) => {
|
|
181
|
+
updateShape(shape.id, shape);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const newPid = after.parenShapeId ?? null
|
|
186
|
+
// 父变了:从旧父移除、向新父添加(工具内部有去重/幂等)
|
|
187
|
+
if (oldPid !== newPid) {
|
|
188
|
+
if (oldPid) {
|
|
189
|
+
const oldP = shapes.value.find(s => s.id === oldPid)
|
|
190
|
+
if (oldP && isShapeTypeNotInPackageTypes(oldP)) {
|
|
191
|
+
removeChildShapeFromCompartment(oldP, after, updateShapeRaw)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (newPid) {
|
|
195
|
+
const newP = shapes.value.find(s => s.id === newPid)
|
|
196
|
+
if (newP && isShapeTypeNotInPackageTypes(newP)) {
|
|
197
|
+
addChildShapeToCompartment(newP, after, updateShapeRaw)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
// 父没变 & 在隔间里:刷新快照(属性变化时也要同步到 comparentShapes)
|
|
203
|
+
if (newPid) {
|
|
204
|
+
const p = shapes.value.find(s => s.id === newPid)
|
|
205
|
+
if (p && isShapeTypeNotInPackageTypes(p)) {
|
|
206
|
+
refreshChildSnapshotInCompartment(p, after)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const sameId = (a?: string | null, b?: string | null) =>
|
|
211
|
+
(a ?? null) === (b ?? null)
|
|
212
|
+
//选中图元
|
|
213
|
+
const selectShape = (shape: Shape | null) => {
|
|
214
|
+
const prevId = selectedShape.value?.id ?? null
|
|
215
|
+
const nextId = shape?.id ?? null
|
|
216
|
+
if (sameId(prevId, nextId)) return
|
|
217
|
+
selectedShape.value = shape
|
|
218
|
+
selectedIds.value = shape ? [shape.id] : []
|
|
219
|
+
// 通过事件总线发送事件
|
|
220
|
+
eventBus.emit('shape-selected', shape)
|
|
221
|
+
}
|
|
222
|
+
// 被框选中的多个 shape/映射 selectedIds.value中的数据
|
|
223
|
+
const marqueeShapes = computed(() => {
|
|
224
|
+
const byId = (id: string) => shapes.value.find(s => s.id === id)
|
|
225
|
+
const isShape = (x: Shape | undefined): x is Shape => !!x
|
|
226
|
+
const pending = new Set(pendingNestedIds.value)
|
|
227
|
+
return selectedIds.value
|
|
228
|
+
.map(byId)
|
|
229
|
+
.filter(isShape)
|
|
230
|
+
.filter(s => !pending.has(s.id))
|
|
231
|
+
})
|
|
232
|
+
//获取元素拖动预览框
|
|
233
|
+
const ghostShadow = computed<Shape[]>(() => {
|
|
234
|
+
const out: Shape[] = []
|
|
235
|
+
// 兜底:防止被持久化还原成非数组
|
|
236
|
+
const pendingList = Array.isArray(pendingNestedIds.value)
|
|
237
|
+
? pendingNestedIds.value
|
|
238
|
+
: []
|
|
239
|
+
const pendingSet = new Set(pendingList)
|
|
240
|
+
for (const id in dragGhost) {
|
|
241
|
+
// 如果当前 id 在 pending 里,不生成 ghost
|
|
242
|
+
if (pendingSet.has(id)) continue
|
|
243
|
+
const orig = shapes.value.find(x => x.id === id)
|
|
244
|
+
if (!orig) continue
|
|
245
|
+
out.push({
|
|
246
|
+
...orig,
|
|
247
|
+
bounds: { ...dragGhost[id] },
|
|
248
|
+
meta: { ...(orig as any).meta, isGhost: true } as any,
|
|
249
|
+
} as Shape)
|
|
250
|
+
}
|
|
251
|
+
return out
|
|
252
|
+
})
|
|
253
|
+
// 选择一组(用于框选/Shift 叠加)
|
|
254
|
+
const selectMany = (ids: string[]) => {
|
|
255
|
+
selectedIds.value = Array.from(new Set(ids))
|
|
256
|
+
selectedShape.value = ids.length
|
|
257
|
+
? (shapes.value.find(s => s.id === ids[0]) ?? null)
|
|
258
|
+
: null
|
|
259
|
+
}
|
|
260
|
+
// 清空选择
|
|
261
|
+
const clearSelection = () => selectShape(null)
|
|
262
|
+
// 设置图表标题
|
|
263
|
+
const setTitle = (title: string) => {
|
|
264
|
+
diagramTitle.value = title
|
|
265
|
+
// 通过事件总线发送事件
|
|
266
|
+
eventBus.emit('title-changed', title)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// 批量操作
|
|
270
|
+
const updateShapes = (newShapes: Shape[]) => {
|
|
271
|
+
// 先把 comparents[*].comparentShapes 铺平同步到运行时
|
|
272
|
+
const expanded = syncComparentShapesIntoRuntime(newShapes)
|
|
273
|
+
shapes.value = expanded
|
|
274
|
+
pendingNestedIds.value = []
|
|
275
|
+
eventBus.emit('shapes-updated', expanded)
|
|
276
|
+
hydrateAllComparents()
|
|
277
|
+
}
|
|
278
|
+
// 获取当前图元数据
|
|
279
|
+
const getShapes = () => {
|
|
280
|
+
return shapes.value
|
|
281
|
+
}
|
|
282
|
+
//清空图元数据
|
|
283
|
+
const clearAll = () => {
|
|
284
|
+
shapes.value = []
|
|
285
|
+
diagrams.value = []
|
|
286
|
+
selectedShape.value = null
|
|
287
|
+
pendingNestedIds.value = []
|
|
288
|
+
eventBus.emit('shapes-cleared')
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** 把所有隔间父的 comparents 从 comparentsJSON 还原;若没有 JSON 就按 parenShapeId 兜底重建 */
|
|
292
|
+
const hydrateAllComparents = () => {
|
|
293
|
+
if (comparentsHydratedOnce.value) return
|
|
294
|
+
if (!shapes.value.length) return
|
|
295
|
+
|
|
296
|
+
let hadAnyJSON = false
|
|
297
|
+
for (const p of shapes.value) {
|
|
298
|
+
if (isShapeTypeNotInPackageTypes(p)) {
|
|
299
|
+
const any = p as any
|
|
300
|
+
if (typeof any.comparentsJSON === 'string' && any.comparentsJSON.length) {
|
|
301
|
+
hydrateComparentsFromJSON(p, updateShape)
|
|
302
|
+
hadAnyJSON = true
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
// 历史数据可能还没有 comparentsJSON:按父子关系兜底重建一次
|
|
307
|
+
if (!hadAnyJSON) {
|
|
308
|
+
rebuildAllCompartmentChildrenAsShapes(shapes.value, updateShape)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
comparentsHydratedOnce.value = true
|
|
312
|
+
}
|
|
313
|
+
//拖动元素相关操作
|
|
314
|
+
// 开始拖动已有元素(仅对 shape 生效)
|
|
315
|
+
const byId = (id: string) => shapes.value.find(s => s.id === id) || null
|
|
316
|
+
const startDragShape = (shapeId: string, pointer: { x: number; y: number }) => {
|
|
317
|
+
startDrag([shapeId], pointer)
|
|
318
|
+
}
|
|
319
|
+
const startDrag = (ids: string[], pointer: { x: number; y: number }) => {
|
|
320
|
+
// 记录“当前真正被用户选中”的快照 —— 结束时恢复
|
|
321
|
+
dragSelectionSnapshot.value = selectedIds.value.length ? [...selectedIds.value] : [ids[0]]
|
|
322
|
+
primaryDragId.value = ids[0] || null
|
|
323
|
+
|
|
324
|
+
// 展开“选中项 + 后代”的集合(你现有的逻辑保留)
|
|
325
|
+
const expanded: string[] = []
|
|
326
|
+
ids.forEach(id => {
|
|
327
|
+
expanded.push(id)
|
|
328
|
+
collectDescendantIds(shapes.value, id).forEach(cid => expanded.push(cid))
|
|
329
|
+
})
|
|
330
|
+
const validIds = Array.from(new Set(expanded)).filter(id => {
|
|
331
|
+
const s = byId(id); return s && getPolicy(s!).draggable
|
|
332
|
+
})
|
|
333
|
+
if (!validIds.length) return
|
|
334
|
+
|
|
335
|
+
const snap = buildDragSnapshot(shapes.value, validIds)
|
|
336
|
+
dragBase.value = snap.dragBase
|
|
337
|
+
groupBaseBox.value = snap.groupBaseBox
|
|
338
|
+
// 初始化 dragGhost:就地更新,避免新引用
|
|
339
|
+
for (const k in dragGhost) delete dragGhost[k] // 清空旧 key
|
|
340
|
+
for (const k in snap.dragBase) dragGhost[k] = snap.dragBase[k] // 写入新 key
|
|
341
|
+
draggingIds.value = validIds
|
|
342
|
+
dragAnchor.value = { x: pointer.x, y: pointer.y }
|
|
343
|
+
if (validIds.length === 1) {
|
|
344
|
+
const b = dragBase.value[validIds[0]]
|
|
345
|
+
dragOffset.value = { x: pointer.x - b.x, y: pointer.y - b.y }
|
|
346
|
+
draggingShapeId.value = validIds[0]
|
|
347
|
+
} else {
|
|
348
|
+
dragOffset.value = null
|
|
349
|
+
draggingShapeId.value = null
|
|
350
|
+
}
|
|
351
|
+
isDragging.value = true
|
|
352
|
+
}
|
|
353
|
+
const finalCheckCanNest = async (childId: string, parentId: string | null) => {
|
|
354
|
+
const child = byId(childId)
|
|
355
|
+
const parent = parentId ? byId(parentId) : null
|
|
356
|
+
// 画布:取 currentDiagramId,否则回落 child.diagramId
|
|
357
|
+
const diagram = shapes.value.find(
|
|
358
|
+
s => s.diagramId == (currentDiagramId.value || child?.diagramId)
|
|
359
|
+
) || null
|
|
360
|
+
if (!child) return false
|
|
361
|
+
const { ok } = await checkNestViaFront(child, parent, diagram) // 后端只返回 true/false
|
|
362
|
+
if (ok) {
|
|
363
|
+
canDropOnCanvas.value = true
|
|
364
|
+
} else {
|
|
365
|
+
canDropOnCanvas.value = false
|
|
366
|
+
}
|
|
367
|
+
return !!ok
|
|
368
|
+
}
|
|
369
|
+
//统一设置 hover 状态(方便复用/保证一致)
|
|
370
|
+
const setHoverState = (id: string | null, nestable: boolean | null) => {
|
|
371
|
+
hoverContainerId.value = id
|
|
372
|
+
hoverNestable.value = nestable
|
|
373
|
+
}
|
|
374
|
+
// —— server hover 校验缓存 & 并发控制 —— //
|
|
375
|
+
const hoverServerCache = new Map<string, { ok: boolean; t: number }>()
|
|
376
|
+
let hoverReqSeq = 0 // 每次发请求递增;只采纳最新的响应
|
|
377
|
+
const HOVER_CACHE_TTL = 400 // ms(短缓存,减少连发)
|
|
378
|
+
// 只在 hover 变化时计算嵌套许可
|
|
379
|
+
const maybeUpdateHover = async (hover: string | null, draggedId: string | null) => {
|
|
380
|
+
if (hover === lastHoverId) return
|
|
381
|
+
lastHoverId = hover
|
|
382
|
+
const child = draggedId ? byId(draggedId) : null
|
|
383
|
+
if (!hover) {
|
|
384
|
+
// 脱离父元素的时候也进行校验
|
|
385
|
+
hoverContainerId.value = null
|
|
386
|
+
hoverNestable.value = null
|
|
387
|
+
if (draggedId) {
|
|
388
|
+
await finalCheckCanNest(draggedId, null)
|
|
389
|
+
}
|
|
390
|
+
return
|
|
391
|
+
}
|
|
392
|
+
// 已经是这个父元素的子元素了,只是在里面挪位置 —— 不需要再校验
|
|
393
|
+
if (child && child.parenShapeId === hover) {
|
|
394
|
+
hoverContainerId.value = hover
|
|
395
|
+
hoverNestable.value = null // 或者 null
|
|
396
|
+
return
|
|
397
|
+
}
|
|
398
|
+
hoverContainerId.value = hover
|
|
399
|
+
if (!draggedId) {
|
|
400
|
+
setHoverState(hover, null)
|
|
401
|
+
return
|
|
402
|
+
}
|
|
403
|
+
// const child = byId(draggedId)
|
|
404
|
+
const parent = byId(hover)
|
|
405
|
+
// 元素找不到,也不做判断
|
|
406
|
+
if (!child || !parent) {
|
|
407
|
+
setHoverState(hover, null)
|
|
408
|
+
return
|
|
409
|
+
}
|
|
410
|
+
// 如果目标是模拟数据(inert),保持你之前的特殊处理:不触发校验 & 不高亮
|
|
411
|
+
if (Object.prototype.hasOwnProperty.call(parent as any, 'inert')) {
|
|
412
|
+
setHoverState(null, null)
|
|
413
|
+
return
|
|
414
|
+
}
|
|
415
|
+
// 先标记为“判定中”(null),避免先乐观 true 再变 false 的闪烁
|
|
416
|
+
hoverNestable.value = null
|
|
417
|
+
// ==== 短缓存 ====
|
|
418
|
+
const key = `${currentDiagramId.value || ''}:${draggedId}->${hover}`
|
|
419
|
+
const now = Date.now()
|
|
420
|
+
const cached = hoverServerCache.get(key)
|
|
421
|
+
if (cached && now - cached.t <= HOVER_CACHE_TTL) {
|
|
422
|
+
hoverNestable.value = !!cached.ok
|
|
423
|
+
return
|
|
424
|
+
}
|
|
425
|
+
// 并发控制:只采纳最后一次请求
|
|
426
|
+
const mySeq = ++hoverReqSeq
|
|
427
|
+
try {
|
|
428
|
+
// 让 front 去调后端,只用后端给的 true/ false
|
|
429
|
+
const { ok } = await checkNestViaFront(child, parent, shapes.value[0])
|
|
430
|
+
if (hoverReqSeq === mySeq && hover === hoverContainerId.value) {
|
|
431
|
+
hoverServerCache.set(key, { ok: !!ok, t: Date.now() })
|
|
432
|
+
hoverNestable.value = !!ok // 这里只认后端
|
|
433
|
+
}
|
|
434
|
+
if (ok) {
|
|
435
|
+
canDropOnCanvas.value = true
|
|
436
|
+
} else {
|
|
437
|
+
canDropOnCanvas.value = false
|
|
438
|
+
}
|
|
439
|
+
} catch {
|
|
440
|
+
if (hoverReqSeq === mySeq && hover === hoverContainerId.value) {
|
|
441
|
+
// 失败时,你可以选择 false 或 null,这里保守按 false 处理
|
|
442
|
+
setHoverState(null, false)
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
//拖动过程中
|
|
447
|
+
const moveDraggedShape = (pointer: { x: number; y: number }) => {
|
|
448
|
+
if (!isDragging.value || draggingIds.value.length === 0) return
|
|
449
|
+
|
|
450
|
+
if (draggingIds.value.length === 1) {
|
|
451
|
+
const id = draggingIds.value[0]
|
|
452
|
+
const s = byId(id); if (!s) return
|
|
453
|
+
const { ghost, hover } = stepSingleDrag(
|
|
454
|
+
shapes.value,
|
|
455
|
+
id,
|
|
456
|
+
pointer,
|
|
457
|
+
dragOffset.value,
|
|
458
|
+
dragBase.value,
|
|
459
|
+
currentDiagramId.value || s.diagramId,
|
|
460
|
+
getPolicy(s).constrainToDiagram
|
|
461
|
+
)
|
|
462
|
+
// 就地写 shallowReactive,不再每帧解构新对象
|
|
463
|
+
for (const k in ghost) dragGhost[k] = ghost[k]
|
|
464
|
+
// 可选:清理多余 key(如果 stepSingleDrag 不会返回完整集)
|
|
465
|
+
for (const k in dragGhost) if (!(k in ghost)) delete dragGhost[k]
|
|
466
|
+
// 只有 hover 变化才算 canNest,避免每帧重算
|
|
467
|
+
maybeUpdateHover(hover, id)
|
|
468
|
+
return
|
|
469
|
+
}
|
|
470
|
+
if (!dragAnchor.value || !groupBaseBox.value || !primaryDragId.value) return
|
|
471
|
+
const { ghost, hover } = stepGroupDrag(
|
|
472
|
+
shapes.value,
|
|
473
|
+
draggingIds.value,
|
|
474
|
+
primaryDragId.value,
|
|
475
|
+
pointer,
|
|
476
|
+
dragAnchor.value,
|
|
477
|
+
groupBaseBox.value
|
|
478
|
+
)
|
|
479
|
+
for (const k in ghost) dragGhost[k] = ghost[k]
|
|
480
|
+
for (const k in dragGhost) if (!(k in ghost)) delete dragGhost[k]
|
|
481
|
+
|
|
482
|
+
maybeUpdateHover(hover, primaryDragId.value)
|
|
483
|
+
}
|
|
484
|
+
// 结束拖动:提交位置/尺寸 + 处理归属 + 规范层级
|
|
485
|
+
const endDragShape = async (source?: string) => {
|
|
486
|
+
if (!isDragging.value) return
|
|
487
|
+
// 提交拖动几何(commitDrag 只是“位置/大小”的更新)
|
|
488
|
+
const changedIds = commitDrag(
|
|
489
|
+
shapes.value,
|
|
490
|
+
[...draggingIds.value],
|
|
491
|
+
dragGhost,
|
|
492
|
+
currentDiagramId.value || shapes.value[0].diagramId,
|
|
493
|
+
updateShape,
|
|
494
|
+
dragBase.value
|
|
495
|
+
)
|
|
496
|
+
if (!changedIds.length) {
|
|
497
|
+
cleanupAfterDrag()
|
|
498
|
+
return
|
|
499
|
+
}
|
|
500
|
+
// 记录拖动前的父 id,用于嵌套回滚 & 业务上报
|
|
501
|
+
const prevParentById = buildPrevParentMap(shapes.value, changedIds)
|
|
502
|
+
const containerForFinalize =
|
|
503
|
+
hoverContainerId.value && hoverNestable.value ? hoverContainerId.value : null
|
|
504
|
+
|
|
505
|
+
// finalizeAfterTransform:决定“最终 parent + bounds”
|
|
506
|
+
const didReparent = finalizeAfterTransform(
|
|
507
|
+
shapes.value,
|
|
508
|
+
changedIds,
|
|
509
|
+
dragGhost,
|
|
510
|
+
draggingIds.value,
|
|
511
|
+
currentDiagramId.value,
|
|
512
|
+
containerForFinalize,
|
|
513
|
+
updateShape,
|
|
514
|
+
)
|
|
515
|
+
//嵌套 / 克隆 / comparents 业务处理(pinDrop 场景跳过)
|
|
516
|
+
let ownerPayload: OwnerPayload | null = null
|
|
517
|
+
let clonedIds: string[] = []
|
|
518
|
+
if (source !== 'pinDrop') {
|
|
519
|
+
const nestResult = await applyReparentAndClone({
|
|
520
|
+
shapes: shapes.value,
|
|
521
|
+
changedIds,
|
|
522
|
+
prevParentById,
|
|
523
|
+
source,
|
|
524
|
+
dragBase: dragBase.value,
|
|
525
|
+
updateShape,
|
|
526
|
+
pendingNestedIds,
|
|
527
|
+
addShape,
|
|
528
|
+
})
|
|
529
|
+
|
|
530
|
+
if (nestResult.cancelled) {
|
|
531
|
+
// 嵌套校验失败,已经在 graphDragService 里回滚了位置/父级,这里只需要收尾
|
|
532
|
+
cleanupAfterDrag()
|
|
533
|
+
return
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
ownerPayload = nestResult.ownerPayload
|
|
537
|
+
clonedIds = nestResult.clonedIds
|
|
538
|
+
}
|
|
539
|
+
// 如果真的发生了“换父”,整理一下 zIndex(保持绘制顺序)
|
|
540
|
+
if (didReparent) {
|
|
541
|
+
normalizeZOrder(
|
|
542
|
+
shapes.value,
|
|
543
|
+
currentDiagramId.value,
|
|
544
|
+
updateShape,
|
|
545
|
+
1,
|
|
546
|
+
1,
|
|
547
|
+
)
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// —— Pin 终极兜底:不允许在本次拖拽后变成“无父” ——
|
|
551
|
+
for (const id of changedIds) {
|
|
552
|
+
const node = shapes.value.find(s => s.id === id)
|
|
553
|
+
if (node?.shapeType === 'pin') {
|
|
554
|
+
const prevPid = prevParentById[id]
|
|
555
|
+
const nowPid = node.parenShapeId ?? null
|
|
556
|
+
if ((!nowPid || nowPid === '') && prevPid) {
|
|
557
|
+
updateShape(id, { parenShapeId: prevPid })
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// 更新相关 edge 的 waypoints
|
|
563
|
+
EdgeUtils.updateRelatedEdges(shapes.value, changedIds, (shape) => {
|
|
564
|
+
updateShape(shape.id, shape)
|
|
565
|
+
})
|
|
566
|
+
//对“本次直接拖动的隔间”做一次自动扩容检查
|
|
567
|
+
autoExpandMovedCompartmentsAfterDrag(shapes.value, changedIds, updateShape)
|
|
568
|
+
// 收集受影响的所有 shape(自身 + 父 + 子树 + 祖先)
|
|
569
|
+
const affectedIds = collectAffectedShapeIds(shapes.value, changedIds, clonedIds)
|
|
570
|
+
//组装 payloads(深拷贝),给更新接口用
|
|
571
|
+
const payloads = buildDragEndPayloads(affectedIds, shapes.value)
|
|
572
|
+
// 创建嵌套完成后的回调:成功后按子扩父 + 发 shape-size-update
|
|
573
|
+
const onNestDone = createOnNestDoneCallback({
|
|
574
|
+
shapesRef: shapes,
|
|
575
|
+
ownerPayload,
|
|
576
|
+
updateShape,
|
|
577
|
+
})
|
|
578
|
+
|
|
579
|
+
//对外只暴露一个事件:shape-drag-end
|
|
580
|
+
eventBus.emit('shape-drag-end', payloads, ownerPayload, onNestDone)
|
|
581
|
+
|
|
582
|
+
// 清理拖拽状态
|
|
583
|
+
cleanupAfterDrag()
|
|
584
|
+
}
|
|
585
|
+
// 处理缩放结束后的事件发射
|
|
586
|
+
const endResizeShape = (id: string) => {
|
|
587
|
+
// 更新相关edge的waypoints
|
|
588
|
+
EdgeUtils.updateRelatedEdges(shapes.value, [id], (shape) => {
|
|
589
|
+
updateShape(shape.id, shape);
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
// 收集受影响的元素
|
|
593
|
+
const affected = new Set<string>();
|
|
594
|
+
affected.add(id);
|
|
595
|
+
const parentId = shapes.value.find(s => s.id === id)?.parenShapeId ?? null;
|
|
596
|
+
if (parentId) {
|
|
597
|
+
affected.add(parentId);
|
|
598
|
+
collectDescendantIds(shapes.value, parentId).forEach(cid => affected.add(cid));
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// 把所有受影响元素的“祖先链”也并入
|
|
602
|
+
for (const affectedId of Array.from(affected)) {
|
|
603
|
+
let cur: string | null = affectedId;
|
|
604
|
+
let guard = 0;
|
|
605
|
+
while (cur && guard++ < 1000) {
|
|
606
|
+
const s = shapes.value.find(x => x.id === cur);
|
|
607
|
+
const p = s ? (s as any).parenShapeId ?? null : null;
|
|
608
|
+
if (!p) break;
|
|
609
|
+
affected.add(p);
|
|
610
|
+
cur = p;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// 组装并派发shape-drag-end事件
|
|
615
|
+
const payloads = Array.from(affected)
|
|
616
|
+
.map(affectedId => shapes.value.find(s => s.id === affectedId))
|
|
617
|
+
.filter(Boolean)
|
|
618
|
+
.map(s => _.cloneDeep(s!)) as Shape[];
|
|
619
|
+
eventBus.emit('shape-drag-end', payloads,);
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
//清理状态
|
|
623
|
+
const cleanupAfterDrag = () => {
|
|
624
|
+
if (dragSelectionSnapshot.value.length <= 1) {
|
|
625
|
+
const keepId = dragSelectionSnapshot.value[0] || null
|
|
626
|
+
const s = keepId ? byId(keepId) : null
|
|
627
|
+
} else {
|
|
628
|
+
selectMany(dragSelectionSnapshot.value)
|
|
629
|
+
}
|
|
630
|
+
hoverContainerId.value = null
|
|
631
|
+
hoverNestable.value = null
|
|
632
|
+
isDragging.value = false
|
|
633
|
+
draggingShapeId.value = null
|
|
634
|
+
dragOffset.value = null
|
|
635
|
+
draggingIds.value = []
|
|
636
|
+
dragAnchor.value = null
|
|
637
|
+
dragBase.value = {}
|
|
638
|
+
groupBaseBox.value = null
|
|
639
|
+
dragSelectionSnapshot.value = []
|
|
640
|
+
primaryDragId.value = null
|
|
641
|
+
for (const k in dragGhost) delete dragGhost[k]
|
|
642
|
+
}
|
|
643
|
+
//设置当前打开的画布id
|
|
644
|
+
const setCurrentDiagramId = (id: string | null) => {
|
|
645
|
+
currentDiagramId.value = id
|
|
646
|
+
}
|
|
647
|
+
const setActiveDiagramId = (id: string | null) => {
|
|
648
|
+
activeDiagramId.value = id;
|
|
649
|
+
};
|
|
650
|
+
// 获取当前缩放比例
|
|
651
|
+
const getScale = (diagramId?: string | null) => {
|
|
652
|
+
const targetId = diagramId || activeDiagramId.value;
|
|
653
|
+
// 如果指定画布没有缩放记录,返回默认值1
|
|
654
|
+
return scales.value[targetId || 'default'] || 1;
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
// 设置缩放比例
|
|
658
|
+
const setScale = (newScale: number, diagramId?: string | null) => {
|
|
659
|
+
// 限制缩放范围,避免过大或过小
|
|
660
|
+
const minScale = 0.1;
|
|
661
|
+
const maxScale = 5;
|
|
662
|
+
const targetId = diagramId || activeDiagramId.value || 'default';
|
|
663
|
+
scales.value[targetId] = Math.max(minScale, Math.min(maxScale, newScale));
|
|
664
|
+
eventBus.emit("scale-changed", scales.value[targetId]);
|
|
665
|
+
};
|
|
666
|
+
//新增画布
|
|
667
|
+
const addDiagram = (diagram: Shape) => {
|
|
668
|
+
diagrams.value.push(diagram)
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* 初始化所有连线的端点
|
|
672
|
+
* 用于在初始加载后端数据后,自动计算所有连线的合适端点,避免线横跨图元
|
|
673
|
+
*/
|
|
674
|
+
const initializeAllEdgeEndpoints = () => {
|
|
675
|
+
EdgeUtils.initializeAllEdgeEndpoints(shapes.value, (shape) => {
|
|
676
|
+
updateShape(shape.id, shape);
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* 由“子元素数据”触发的扩父入口:
|
|
681
|
+
* - 只需要传子元素(child),其中 parenShapeId 即为父 id
|
|
682
|
+
* - 内部调用 expandParentByChild → 得到 expanded / affectedIds
|
|
683
|
+
* - 若有扩父,再组装 sizePayload 并发 shape-size-update 事件
|
|
684
|
+
*/
|
|
685
|
+
const expandParentAndEmitSizeUpdateByChild = (child: Shape) => {
|
|
686
|
+
if (!child.parenShapeId) {
|
|
687
|
+
return
|
|
688
|
+
}
|
|
689
|
+
if (pinsTypes.value.includes(child.shapeKey)) return
|
|
690
|
+
const { expanded, affectedIds } = expandParentByChild({
|
|
691
|
+
shapes: shapes.value,
|
|
692
|
+
child,
|
|
693
|
+
updateShape,
|
|
694
|
+
})
|
|
695
|
+
|
|
696
|
+
if (!expanded) return
|
|
697
|
+
|
|
698
|
+
const childId = child.id
|
|
699
|
+
|
|
700
|
+
// 组装“只更新大小”的 payload:id + JSON.stringify(bounds)
|
|
701
|
+
const sizePayload: ShapeSizeUpdatePayload[] = affectedIds
|
|
702
|
+
.map(id => shapes.value.find(s => s.id === id))
|
|
703
|
+
.filter((s): s is Shape => !!s)
|
|
704
|
+
// 过滤掉子元素本身,只把真正扩父的父/祖先发给接口
|
|
705
|
+
.filter(s => s.id !== childId)
|
|
706
|
+
.map(s => ({
|
|
707
|
+
id: s.id,
|
|
708
|
+
bounds: JSON.stringify(s.bounds ?? {}),
|
|
709
|
+
}))
|
|
710
|
+
|
|
711
|
+
if (!sizePayload.length) return
|
|
712
|
+
|
|
713
|
+
// 发事件给统一监听,监听里再去调用 updateShapeSize(单条接口就 for 循环)
|
|
714
|
+
eventBus.emit('shape-size-update', sizePayload)
|
|
715
|
+
}
|
|
716
|
+
return {
|
|
717
|
+
// 状态
|
|
718
|
+
shapes,
|
|
719
|
+
pendingNestedIds,
|
|
720
|
+
selectedShape,
|
|
721
|
+
diagramTitle,
|
|
722
|
+
isDragging, draggingShapeId, dragOffset,
|
|
723
|
+
diagrams,
|
|
724
|
+
selectedIds,
|
|
725
|
+
hoverContainerId,
|
|
726
|
+
hoverNestable,
|
|
727
|
+
currentDiagramId,
|
|
728
|
+
canDropOnCanvas,
|
|
729
|
+
//图元shapeKey
|
|
730
|
+
taggedValueLabels,
|
|
731
|
+
packagesTypes,
|
|
732
|
+
classMetaTypes,
|
|
733
|
+
ownerRequiredShapeKeys,
|
|
734
|
+
pinsTypes,
|
|
735
|
+
portsTypes,
|
|
736
|
+
// 计算属性
|
|
737
|
+
shapeCount,
|
|
738
|
+
hasSelectedShape,
|
|
739
|
+
marqueeShapes,
|
|
740
|
+
ghostShadow,
|
|
741
|
+
scales,
|
|
742
|
+
activeDiagramId,
|
|
743
|
+
// 当前活动画布的缩放比例
|
|
744
|
+
currentScale: computed(() => getScale()),
|
|
745
|
+
// 方法
|
|
746
|
+
addShape,
|
|
747
|
+
removeShape,
|
|
748
|
+
updateShape,
|
|
749
|
+
selectShape,
|
|
750
|
+
setTitle,
|
|
751
|
+
updateShapes,
|
|
752
|
+
clearAll,
|
|
753
|
+
startDragShape,
|
|
754
|
+
startDrag,
|
|
755
|
+
moveDraggedShape,
|
|
756
|
+
endDragShape,
|
|
757
|
+
getShapes,
|
|
758
|
+
addDiagram,
|
|
759
|
+
setCurrentDiagramId,
|
|
760
|
+
selectMany,
|
|
761
|
+
clearSelection,
|
|
762
|
+
removeSelected,
|
|
763
|
+
finalCheckCanNest,
|
|
764
|
+
setHoverState,
|
|
765
|
+
initializeAllEdgeEndpoints,
|
|
766
|
+
endResizeShape,
|
|
767
|
+
getScale,
|
|
768
|
+
setScale,
|
|
769
|
+
setActiveDiagramId,
|
|
770
|
+
visibleShapes,
|
|
771
|
+
externalCreatingId,
|
|
772
|
+
expandParentAndEmitSizeUpdateByChild,
|
|
773
|
+
}
|
|
774
|
+
},
|
|
775
|
+
//配置持久化
|
|
776
|
+
{
|
|
777
|
+
//@ts-ignore
|
|
778
|
+
persist: {
|
|
779
|
+
paths: ['shapes', 'selectedShape']
|
|
780
|
+
} as any,
|
|
781
|
+
}
|
|
782
|
+
)
|