@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,403 @@
|
|
|
1
|
+
// 选中框与拖拽手柄的样式与常量
|
|
2
|
+
import { useGraphStore } from "../store/graphStore"; // ← 使用你提供的 graphStore
|
|
3
|
+
import type { Shape } from "../types";
|
|
4
|
+
|
|
5
|
+
export type HandlePos = "nw" | "ne" | "sw" | "se";
|
|
6
|
+
|
|
7
|
+
export const HANDLE_SIZE = 10; // 手柄尺寸
|
|
8
|
+
export const SELECTION_PADDING = 6; // 选中框与内容的内边距
|
|
9
|
+
|
|
10
|
+
// 画布属性配置
|
|
11
|
+
export const ShapeConfig = {
|
|
12
|
+
SHAPE_TYPE: "diagram",
|
|
13
|
+
CANVAS_PADDING: 50, // 图元与画布边缘的最小距离
|
|
14
|
+
MIN_CANVAS_WIDTH: 300, // 画布最小宽度
|
|
15
|
+
MIN_CANVAS_HEIGHT: 200, // 画布最小高度
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// 选中框样式(
|
|
19
|
+
export const selectionBoxStyle = (shape: Shape) => {
|
|
20
|
+
const b = shape.bounds ?? {};
|
|
21
|
+
const pad = SELECTION_PADDING;
|
|
22
|
+
return {
|
|
23
|
+
position: "absolute" as const,
|
|
24
|
+
left: `${(b.x ?? 0) - pad}px`,
|
|
25
|
+
top: `${(b.y ?? 0) - pad}px`,
|
|
26
|
+
width: `${(b.width ?? 100) + pad * 2}px`,
|
|
27
|
+
height: `${(b.height ?? 50) + pad * 2}px`,
|
|
28
|
+
backgroundColor: "transparent",
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// 手柄鼠标样式
|
|
33
|
+
const handleCursor: Record<HandlePos, string> = {
|
|
34
|
+
nw: "nw-resize",
|
|
35
|
+
ne: "ne-resize",
|
|
36
|
+
sw: "sw-resize",
|
|
37
|
+
se: "se-resize",
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 计算手柄样式 —— 以 selection-box 内部为参照系
|
|
42
|
+
* 默认让红点“贴在 shape 四角”(即离选框边内缩 padding,且点心落在角上)
|
|
43
|
+
*/
|
|
44
|
+
export const handleStyle = (pos: HandlePos, shape: Shape) => {
|
|
45
|
+
const b = shape.bounds ?? {};
|
|
46
|
+
const pad = SELECTION_PADDING;
|
|
47
|
+
const s = HANDLE_SIZE;
|
|
48
|
+
|
|
49
|
+
// 选框尺寸(= shape 尺寸 + 2*padding)
|
|
50
|
+
const boxW = (b.width ?? 100) + pad * 2;
|
|
51
|
+
const boxH = (b.height ?? 50) + pad * 2;
|
|
52
|
+
|
|
53
|
+
let left = 0,
|
|
54
|
+
top = 0;
|
|
55
|
+
// 手柄贴在“选框四角”(不内缩)
|
|
56
|
+
const leftMin = 0;
|
|
57
|
+
const leftMax = boxW - s;
|
|
58
|
+
const topMin = 0;
|
|
59
|
+
const topMax = boxH - s;
|
|
60
|
+
|
|
61
|
+
if (pos === "nw") {
|
|
62
|
+
left = leftMin;
|
|
63
|
+
top = topMin;
|
|
64
|
+
}
|
|
65
|
+
if (pos === "ne") {
|
|
66
|
+
left = leftMax;
|
|
67
|
+
top = topMin;
|
|
68
|
+
}
|
|
69
|
+
if (pos === "sw") {
|
|
70
|
+
left = leftMin;
|
|
71
|
+
top = topMax;
|
|
72
|
+
}
|
|
73
|
+
if (pos === "se") {
|
|
74
|
+
left = leftMax;
|
|
75
|
+
top = topMax;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
position: "absolute" as const,
|
|
80
|
+
width: `${s}px`,
|
|
81
|
+
height: `${s}px`,
|
|
82
|
+
backgroundColor: "#ff0000",
|
|
83
|
+
border: "2px solid #fff",
|
|
84
|
+
borderRadius: "50%",
|
|
85
|
+
cursor: handleCursor[pos],
|
|
86
|
+
pointerEvents: "auto" as const,
|
|
87
|
+
left: `${left}px`,
|
|
88
|
+
top: `${top}px`,
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 获取画布形状
|
|
94
|
+
*/
|
|
95
|
+
export const getCanvasShape = () => {
|
|
96
|
+
const graphStore = useGraphStore();
|
|
97
|
+
return graphStore.shapes.find(shape => shape.shapeType === ShapeConfig.SHAPE_TYPE);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 计算所有子图元的边界范围
|
|
102
|
+
* */
|
|
103
|
+
export const calculateShapesBounds = () => {
|
|
104
|
+
const graphStore = useGraphStore();
|
|
105
|
+
// 过滤掉画布本身,只计算子图元
|
|
106
|
+
const childShapes = graphStore.shapes.filter(
|
|
107
|
+
(shape) => shape.shapeType !== ShapeConfig.SHAPE_TYPE
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
if (childShapes.length === 0) return null;
|
|
111
|
+
|
|
112
|
+
// 初始化边界值
|
|
113
|
+
let minX = Infinity;
|
|
114
|
+
let minY = Infinity;
|
|
115
|
+
let maxX = -Infinity;
|
|
116
|
+
let maxY = -Infinity;
|
|
117
|
+
|
|
118
|
+
// 遍历所有子图元计算边界
|
|
119
|
+
childShapes.forEach((shape: Shape) => {
|
|
120
|
+
if (!shape.bounds) return;
|
|
121
|
+
|
|
122
|
+
const { x, y, width, height } = shape.bounds;
|
|
123
|
+
// 使用空值合并运算符处理可能的 undefined 值
|
|
124
|
+
minX = Math.min(minX, x ?? 0);
|
|
125
|
+
minY = Math.min(minY, y ?? 0);
|
|
126
|
+
maxX = Math.max(maxX, (x ?? 0) + (width ?? 0));
|
|
127
|
+
maxY = Math.max(maxY, (y ?? 0) + (height ?? 0));
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
return { minX, minY, maxX, maxY };
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 调整画布大小
|
|
135
|
+
* */
|
|
136
|
+
export const adjustCanvasToFitAllShapes = () => {
|
|
137
|
+
const graphStore = useGraphStore();
|
|
138
|
+
// 获取画布形状
|
|
139
|
+
const canvas = graphStore.shapes.find(
|
|
140
|
+
(shape) => shape.shapeType === ShapeConfig.SHAPE_TYPE
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
if (!canvas || !canvas.bounds) return;
|
|
144
|
+
|
|
145
|
+
const shapesBounds = calculateShapesBounds();
|
|
146
|
+
const canvasX = canvas.bounds.x || 0;
|
|
147
|
+
const canvasY = canvas.bounds.y || 0;
|
|
148
|
+
const currentWidth = canvas.bounds.width || 0;
|
|
149
|
+
const currentHeight = canvas.bounds.height || 0;
|
|
150
|
+
|
|
151
|
+
// 如果没有子图元,确保不小于最小尺寸
|
|
152
|
+
if (!shapesBounds) {
|
|
153
|
+
ensureMinimumCanvasSize();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const { minX, minY, maxX, maxY } = shapesBounds;
|
|
158
|
+
|
|
159
|
+
// 计算所需的最小画布尺寸(刚好包含所有图元+边距)
|
|
160
|
+
const requiredWidth = Math.max(
|
|
161
|
+
maxX - canvasX + ShapeConfig.CANVAS_PADDING,
|
|
162
|
+
canvasX + ShapeConfig.CANVAS_PADDING - minX,
|
|
163
|
+
ShapeConfig.MIN_CANVAS_WIDTH
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const requiredHeight = Math.max(
|
|
167
|
+
maxY - canvasY + ShapeConfig.CANVAS_PADDING,
|
|
168
|
+
canvasY + ShapeConfig.CANVAS_PADDING - minY,
|
|
169
|
+
ShapeConfig.MIN_CANVAS_HEIGHT
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
// 只在需要扩大时才更新(不缩小)
|
|
173
|
+
const finalWidth = Math.max(currentWidth, requiredWidth);
|
|
174
|
+
const finalHeight = Math.max(currentHeight, requiredHeight);
|
|
175
|
+
|
|
176
|
+
// 仅在尺寸变化时才更新
|
|
177
|
+
if (finalWidth !== currentWidth || finalHeight !== currentHeight) {
|
|
178
|
+
graphStore.updateShape(canvas.id, {
|
|
179
|
+
bounds: {
|
|
180
|
+
...canvas.bounds,
|
|
181
|
+
width: finalWidth,
|
|
182
|
+
height: finalHeight,
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 确保画布不小于最小尺寸
|
|
190
|
+
* */
|
|
191
|
+
const ensureMinimumCanvasSize = () => {
|
|
192
|
+
const graphStore = useGraphStore();
|
|
193
|
+
const canvas = graphStore.shapes.find(
|
|
194
|
+
(shape) => shape.shapeType === ShapeConfig.SHAPE_TYPE
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
if (!canvas || !canvas.bounds) return;
|
|
198
|
+
|
|
199
|
+
const currentWidth = canvas.bounds.width || 0;
|
|
200
|
+
const currentHeight = canvas.bounds.height || 0;
|
|
201
|
+
|
|
202
|
+
// 确保不小于最小尺寸
|
|
203
|
+
const finalWidth = Math.max(currentWidth, ShapeConfig.MIN_CANVAS_WIDTH);
|
|
204
|
+
const finalHeight = Math.max(currentHeight, ShapeConfig.MIN_CANVAS_HEIGHT);
|
|
205
|
+
|
|
206
|
+
if (finalWidth !== currentWidth || finalHeight !== currentHeight) {
|
|
207
|
+
graphStore.updateShape(canvas.id, {
|
|
208
|
+
bounds: {
|
|
209
|
+
...canvas.bounds,
|
|
210
|
+
width: finalWidth,
|
|
211
|
+
height: finalHeight,
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* 计算操作按钮的位置样式
|
|
219
|
+
*/
|
|
220
|
+
export const actionButtonsStyle = (shape: Shape): Record<string, string> => {
|
|
221
|
+
const shapeBounds = shape.bounds ?? {};
|
|
222
|
+
const shapeWidth = shapeBounds.width ?? 100;
|
|
223
|
+
const shapeHeight = shapeBounds.height ?? 40;
|
|
224
|
+
if (!shape.scenarioMenus) {
|
|
225
|
+
return {}
|
|
226
|
+
}
|
|
227
|
+
// 按钮宽度:28px,间距4px,共5个按钮 (根据接口动态替换)
|
|
228
|
+
const hasTypeButton = !!shape.modelTypePropertyId;
|
|
229
|
+
const totalButtons = (shape.scenarioMenus ? shape.scenarioMenus!.length : 0) + (hasTypeButton ? 1 : 0);
|
|
230
|
+
const buttonsHeight = 28 * totalButtons + 4 * (totalButtons - (totalButtons > 0 ? 1 : 0));
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
position: "absolute",
|
|
234
|
+
left: `${shapeWidth + 15}px`, // 紧贴形状右侧,间距5px
|
|
235
|
+
top: `${(shapeHeight - buttonsHeight) / 2}px`, // 垂直居中
|
|
236
|
+
zIndex: "1000",
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* 名称虚线框容器样式 - 确保在父组件内水平居中
|
|
242
|
+
*/
|
|
243
|
+
export const nameTextBoxContainerStyle = (id: string): Record<string, string> => {
|
|
244
|
+
const graphStore = useGraphStore();
|
|
245
|
+
let shape = graphStore.shapes.find((shape) => shape.id === id)
|
|
246
|
+
const b = shape?.bounds ?? {} as any
|
|
247
|
+
const nb = (shape as any).nameBounds ?? {} as any
|
|
248
|
+
const ns = (shape as any).nameStyle ?? {} as any
|
|
249
|
+
|
|
250
|
+
// Pin 单独计算:容器贴合文字位置(可能在 Pin 外部)
|
|
251
|
+
if ((shape as any).shapeType === 'pin' && (nb.x != null) && (nb.y != null)) {
|
|
252
|
+
const fontSize = Number(ns.fontSize || nb.height || 12)
|
|
253
|
+
const fontFamily = String(ns.fontFamily || '思源黑体')
|
|
254
|
+
const fontWeight = String(ns.fontWeight || 'normal')
|
|
255
|
+
const text = String(shape?.name || '')
|
|
256
|
+
|
|
257
|
+
const measure = (t: string): number => {
|
|
258
|
+
try {
|
|
259
|
+
const canvas = document.createElement('canvas')
|
|
260
|
+
const ctx = canvas.getContext('2d')!
|
|
261
|
+
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`
|
|
262
|
+
const w = ctx.measureText(t).width
|
|
263
|
+
return Math.max(10, Math.ceil(w))
|
|
264
|
+
} catch { // SSR 或异常时降级
|
|
265
|
+
let acc = 0
|
|
266
|
+
for (const ch of t) {
|
|
267
|
+
if (/[^\x00-\x7F]/.test(ch)) acc += 1.0
|
|
268
|
+
else if (ch === ' ') acc += 0.5
|
|
269
|
+
else acc += 0.6
|
|
270
|
+
}
|
|
271
|
+
return Math.max(10, Math.ceil(acc * fontSize))
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const textWidth = measure(text)
|
|
276
|
+
const PADDING_X = 28 // 水平额外留白,保证输入框不显拥挤
|
|
277
|
+
const PADDING_Y = 12 // 垂直额外留白
|
|
278
|
+
const boxW = Math.min(480, Math.max(64, textWidth + PADDING_X))
|
|
279
|
+
const boxH = Math.max(28, Math.ceil(fontSize + PADDING_Y))
|
|
280
|
+
|
|
281
|
+
const xAbs = (b.x ?? 0) + Number(nb.x)
|
|
282
|
+
const yAbs = (b.y ?? 0) + Number(nb.y)
|
|
283
|
+
|
|
284
|
+
const anchor = String(ns.textAnchor || 'middle') as 'start' | 'middle' | 'end'
|
|
285
|
+
const baseline = String(ns.dominantBaseline || 'alphabetic')
|
|
286
|
+
|
|
287
|
+
// 水平定位
|
|
288
|
+
let left = xAbs
|
|
289
|
+
if (anchor === 'middle') left = xAbs - boxW / 2
|
|
290
|
+
else if (anchor === 'end') left = xAbs - boxW
|
|
291
|
+
|
|
292
|
+
// 垂直定位:依据 baseline
|
|
293
|
+
let top = yAbs
|
|
294
|
+
if (baseline === 'text-before-edge') top = yAbs
|
|
295
|
+
else if (baseline === 'text-after-edge') top = yAbs - fontSize
|
|
296
|
+
else if (baseline === 'middle') top = yAbs - fontSize / 2
|
|
297
|
+
else top = yAbs - fontSize // 默认当作 alphabetic
|
|
298
|
+
|
|
299
|
+
return {
|
|
300
|
+
position: 'absolute',
|
|
301
|
+
left: `${Math.round(left)}px`,
|
|
302
|
+
top: `${Math.round(top)}px`,
|
|
303
|
+
width: `${Math.round(boxW)}px`,
|
|
304
|
+
height: `${Math.round(boxH)}px`,
|
|
305
|
+
display: 'block',
|
|
306
|
+
zIndex: '1000',
|
|
307
|
+
pointerEvents: 'all',
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// 非 Pin:维持原逻辑(容器在父内水平居中)
|
|
312
|
+
const shapeBounds = shape?.bounds ?? {};
|
|
313
|
+
const nameBounds = shape?.nameBounds ?? {};
|
|
314
|
+
const absoluteY = (shapeBounds.y ?? 0) + (nameBounds.y ?? 0);
|
|
315
|
+
return {
|
|
316
|
+
position: "absolute",
|
|
317
|
+
left: `${shapeBounds.x ?? 0}px`,
|
|
318
|
+
top: `${absoluteY - 17}px`,
|
|
319
|
+
width: `${shapeBounds.width ?? 100}px`,
|
|
320
|
+
height: `${25}px`,
|
|
321
|
+
display: "flex",
|
|
322
|
+
justifyContent: "center",
|
|
323
|
+
alignItems: "center",
|
|
324
|
+
zIndex: "1000",
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* 名称虚线框样式 - 自适应父容器宽度
|
|
330
|
+
*/
|
|
331
|
+
export const nameTextBoxStyle = (shape: Shape): Record<string, string> => {
|
|
332
|
+
if ((shape as any).shapeType === 'pin') {
|
|
333
|
+
return {
|
|
334
|
+
width: "100%", // Pin:使用容器的全部宽度,确保可点击区域覆盖整个文本
|
|
335
|
+
height: "100%",
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return {
|
|
339
|
+
width: "calc(100% - 20px)", // 非 Pin:恢复原逻辑,留出左右边距
|
|
340
|
+
height: "100%",
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* 名称编辑容器样式 - 确保在父组件内水平居中
|
|
346
|
+
*/
|
|
347
|
+
export const nameEditorContainerStyle = (shape: Shape): Record<string, string> => {
|
|
348
|
+
const b = shape.bounds ?? {} as any
|
|
349
|
+
const nb = (shape as any).nameBounds ?? {} as any
|
|
350
|
+
const ns = (shape as any).nameStyle ?? {} as any
|
|
351
|
+
|
|
352
|
+
if ((shape as any).shapeType === 'pin' && (nb.x != null) && (nb.y != null)) {
|
|
353
|
+
const fontSize = Number(ns.fontSize || nb.height || 12)
|
|
354
|
+
const textLen = (shape.name?.length || 0)
|
|
355
|
+
const textWidth = Math.max(10, textLen * fontSize * 0.6)
|
|
356
|
+
const boxW = Math.min(300, Math.max(40, textWidth + 14))
|
|
357
|
+
const boxH = Math.max(22, fontSize + 10)
|
|
358
|
+
|
|
359
|
+
const xAbs = (b.x ?? 0) + Number(nb.x)
|
|
360
|
+
const yAbs = (b.y ?? 0) + Number(nb.y)
|
|
361
|
+
|
|
362
|
+
const anchor = String(ns.textAnchor || 'middle') as 'start' | 'middle' | 'end'
|
|
363
|
+
const baseline = String(ns.dominantBaseline || 'alphabetic')
|
|
364
|
+
|
|
365
|
+
let left = xAbs
|
|
366
|
+
if (anchor === 'middle') left = xAbs - boxW / 2
|
|
367
|
+
else if (anchor === 'end') left = xAbs - boxW
|
|
368
|
+
|
|
369
|
+
let top = yAbs
|
|
370
|
+
if (baseline === 'text-before-edge') top = yAbs
|
|
371
|
+
else if (baseline === 'text-after-edge') top = yAbs - fontSize
|
|
372
|
+
else if (baseline === 'middle') top = yAbs - fontSize / 2
|
|
373
|
+
else top = yAbs - fontSize
|
|
374
|
+
|
|
375
|
+
return {
|
|
376
|
+
position: 'absolute',
|
|
377
|
+
left: `${Math.round(left)}px`,
|
|
378
|
+
top: `${Math.round(top)}px`,
|
|
379
|
+
width: `${Math.round(boxW)}px`,
|
|
380
|
+
height: `${Math.round(boxH)}px`,
|
|
381
|
+
display: 'block',
|
|
382
|
+
zIndex: '1001',
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const shapeBounds = shape.bounds ?? {};
|
|
387
|
+
const nameBounds = shape.nameBounds ?? {};
|
|
388
|
+
|
|
389
|
+
// 计算text name在画布中的绝对位置
|
|
390
|
+
const absoluteY = (shapeBounds.y ?? 0) + (nameBounds.y ?? 0);
|
|
391
|
+
|
|
392
|
+
return {
|
|
393
|
+
position: "absolute",
|
|
394
|
+
left: `${shapeBounds.x ?? 0}px`,
|
|
395
|
+
top: `${absoluteY - 17}px`,
|
|
396
|
+
width: `${shapeBounds.width ?? 100}px`,
|
|
397
|
+
height: `${25}px`,
|
|
398
|
+
display: "flex",
|
|
399
|
+
justifyContent: "center", // 水平居中
|
|
400
|
+
alignItems: "center", // 垂直居中
|
|
401
|
+
zIndex: "1001",
|
|
402
|
+
};
|
|
403
|
+
};
|
package/src/utils/dom.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// 统一注册/清理拖拽监听,避免重复样板代码
|
|
2
|
+
|
|
3
|
+
export const withDrag = (
|
|
4
|
+
onMove: (e: MouseEvent) => void,
|
|
5
|
+
onUp: (e: MouseEvent) => void,
|
|
6
|
+
) => {
|
|
7
|
+
const move = (e: MouseEvent) => onMove(e)
|
|
8
|
+
const up = (e: MouseEvent) => {
|
|
9
|
+
try { onUp(e) } finally {
|
|
10
|
+
window.removeEventListener('mousemove', move)
|
|
11
|
+
window.removeEventListener('mouseup', up)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
window.addEventListener('mousemove', move)
|
|
15
|
+
window.addEventListener('mouseup', up)
|
|
16
|
+
// 返回取消函数(可手动中断)
|
|
17
|
+
return () => {
|
|
18
|
+
window.removeEventListener('mousemove', move)
|
|
19
|
+
window.removeEventListener('mouseup', up)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// utils/drag.ts
|
|
2
|
+
import type { Shape } from '../types'
|
|
3
|
+
import { getBounds, getDiagramRect, clampPointToRect } from './geom'
|
|
4
|
+
import {
|
|
5
|
+
finalRectOf,
|
|
6
|
+
pickContainerByPointerTopmost,
|
|
7
|
+
resolveParentAfterDrag
|
|
8
|
+
} from './containers'
|
|
9
|
+
type Rect = { x: number; y: number; width: number; height: number };
|
|
10
|
+
export type DragState = {
|
|
11
|
+
draggingIds: string[]
|
|
12
|
+
dragBase: Record<string, Rect> // 按下那一刻的快照
|
|
13
|
+
dragGhost: Record<string, Rect> // 拖动中的影子
|
|
14
|
+
groupBaseBox: Rect | null
|
|
15
|
+
dragAnchor: { x: number; y: number } | null
|
|
16
|
+
dragOffset: { x: number; y: number } | null
|
|
17
|
+
primaryDragId: string | null
|
|
18
|
+
hoverContainerId: string | null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const EPS = 0.0001
|
|
22
|
+
export const rectEqual = (a?: Rect, b?: Rect) =>
|
|
23
|
+
!!a && !!b &&
|
|
24
|
+
Math.abs(a.x - b.x) < EPS &&
|
|
25
|
+
Math.abs(a.y - b.y) < EPS &&
|
|
26
|
+
Math.abs(a.width - b.width) < EPS &&
|
|
27
|
+
Math.abs(a.height - b.height) < EPS
|
|
28
|
+
|
|
29
|
+
export const buildDragSnapshot = (
|
|
30
|
+
shapes: Shape[],
|
|
31
|
+
ids: string[],
|
|
32
|
+
) => {
|
|
33
|
+
const dragBase: Record<string, Rect> = {}
|
|
34
|
+
ids.forEach(id => {
|
|
35
|
+
const s = shapes.find(x => x.id === id); if (!s) return
|
|
36
|
+
const b = getBounds(s)
|
|
37
|
+
dragBase[id] = { x: b.x, y: b.y, width: b.width, height: b.height }
|
|
38
|
+
})
|
|
39
|
+
// 组外包矩形
|
|
40
|
+
let groupBaseBox: Rect | null = null
|
|
41
|
+
if (ids.length > 1) {
|
|
42
|
+
const rects = Object.values(dragBase)
|
|
43
|
+
const xs = rects.map(r => r.x), ys = rects.map(r => r.y)
|
|
44
|
+
const rs = rects.map(r => r.x + r.width), bs = rects.map(r => r.y + r.height)
|
|
45
|
+
const minX = Math.min(...xs), minY = Math.min(...ys)
|
|
46
|
+
const maxR = Math.max(...rs), maxB = Math.max(...bs)
|
|
47
|
+
groupBaseBox = { x: minX, y: minY, width: maxR - minX, height: maxB - minY }
|
|
48
|
+
}
|
|
49
|
+
return { dragBase, groupBaseBox }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 单拖:计算新的影子与悬停容器
|
|
53
|
+
export const stepSingleDrag = (
|
|
54
|
+
shapes: Shape[],
|
|
55
|
+
id: string,
|
|
56
|
+
pointer: { x: number; y: number },
|
|
57
|
+
dragOffset: { x: number; y: number } | null,
|
|
58
|
+
dragBase: Record<string, Rect>,
|
|
59
|
+
diagramId: string,
|
|
60
|
+
constrainEdges: { left?: boolean; top?: boolean; right?: boolean; bottom?: boolean }
|
|
61
|
+
) => {
|
|
62
|
+
const s = shapes.find(x => x.id === id); if (!s) return { ghost: {}, hover: null }
|
|
63
|
+
const base = dragBase[id]; if (!base) return { ghost: {}, hover: null }
|
|
64
|
+
const container = getDiagramRect(shapes)
|
|
65
|
+
|
|
66
|
+
let nx = pointer.x - (dragOffset?.x ?? 0)
|
|
67
|
+
let ny = pointer.y - (dragOffset?.y ?? 0)
|
|
68
|
+
; ({ x: nx, y: ny } = clampPointToRect({ x: nx, y: ny }, base, container, constrainEdges))
|
|
69
|
+
|
|
70
|
+
const dropRect: Rect = { x: nx, y: ny, width: base.width, height: base.height }
|
|
71
|
+
// 按“鼠标所指”
|
|
72
|
+
const candidate = pickContainerByPointerTopmost(
|
|
73
|
+
shapes,
|
|
74
|
+
pointer,
|
|
75
|
+
id,
|
|
76
|
+
diagramId,
|
|
77
|
+
[id], // 如果是组拖可以传整个组的 id 列表
|
|
78
|
+
-1 // 边缘更友好;想严格就改成 0 或正值
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
//没命中再回退到覆盖率方案(保持你原有体验)
|
|
82
|
+
// if (!candidate) {
|
|
83
|
+
// candidate = pickContainerByCoverage(shapes, dropRect, id, diagramId, 0.5)
|
|
84
|
+
// }
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
ghost: { [id]: dropRect } as Record<string, Rect>,
|
|
88
|
+
hover: candidate?.id ?? null
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 组拖:计算整组影子 & 用主拖动项判断 hover
|
|
93
|
+
export const stepGroupDrag = (
|
|
94
|
+
shapes: Shape[],
|
|
95
|
+
draggingIds: string[],
|
|
96
|
+
primaryId: string,
|
|
97
|
+
pointer: { x: number; y: number },
|
|
98
|
+
dragAnchor: { x: number; y: number },
|
|
99
|
+
groupBaseBox: Rect,
|
|
100
|
+
) => {
|
|
101
|
+
const diagramRect = getDiagramRect(shapes)
|
|
102
|
+
const dxRaw = pointer.x - dragAnchor.x
|
|
103
|
+
const dyRaw = pointer.y - dragAnchor.y
|
|
104
|
+
|
|
105
|
+
let gx = groupBaseBox.x + dxRaw
|
|
106
|
+
let gy = groupBaseBox.y + dyRaw
|
|
107
|
+
|
|
108
|
+
// 组级夹取(只限制 left/top ≥ diagram 最小值,与单拖一致)
|
|
109
|
+
const minLeft = Math.max(0, diagramRect.left)
|
|
110
|
+
const minTop = Math.max(0, diagramRect.top)
|
|
111
|
+
gx = Math.max(minLeft, gx)
|
|
112
|
+
gy = Math.max(minTop, gy)
|
|
113
|
+
|
|
114
|
+
const dx = gx - groupBaseBox.x
|
|
115
|
+
const dy = gy - groupBaseBox.y
|
|
116
|
+
|
|
117
|
+
// 构建整组 ghost
|
|
118
|
+
const ghost: Record<string, Rect> = {}
|
|
119
|
+
for (const id of draggingIds) {
|
|
120
|
+
const s = shapes.find(x => x.id === id); if (!s) continue
|
|
121
|
+
const b = getBounds(s)
|
|
122
|
+
ghost[id] = { x: b.x + dx, y: b.y + dy, width: b.width, height: b.height }
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// —— hover 统一改为“指针命中 topmost 容器”
|
|
126
|
+
// 用主拖动项获取 diagramId(也可以存你当前图的 id)
|
|
127
|
+
const priShape = shapes.find(x => x.id === primaryId)
|
|
128
|
+
const diagramId = priShape?.diagramId || ''
|
|
129
|
+
|
|
130
|
+
const hoverShape = pickContainerByPointerTopmost(
|
|
131
|
+
shapes,
|
|
132
|
+
pointer,
|
|
133
|
+
primaryId,
|
|
134
|
+
diagramId,
|
|
135
|
+
draggingIds, // 排除整组,避免命中自己或自己的后代
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
const hover = hoverShape?.id ?? null
|
|
139
|
+
return { ghost, hover }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 构造“虚拟形状表”,用于 end 阶段判定(父/子都用 ghost 后的位置)
|
|
143
|
+
export const buildVirtualShapes = (shapes: Shape[], ghost: Record<string, Rect>): Shape[] =>
|
|
144
|
+
shapes.map(s => ghost[s.id] ? ({ ...s, bounds: { ...s.bounds, ...ghost[s.id] } } as Shape) : s)
|
|
145
|
+
|
|
146
|
+
// 提交:根据 coverage 规则 attach/detach + 最小扩张 + clamp;返回“真正发生位移/尺寸变化的 shapes”
|
|
147
|
+
export const commitDrag = (
|
|
148
|
+
shapes: Shape[],
|
|
149
|
+
draggingIds: string[],
|
|
150
|
+
ghost: Record<string, Rect>,
|
|
151
|
+
_currentDiagramId: string | null, // 此函数不再参与容器判定,参数保留为兼容
|
|
152
|
+
updateShape: (id: string, updates: Partial<Shape>) => void,
|
|
153
|
+
baseMap?: Record<string, Rect>
|
|
154
|
+
) => {
|
|
155
|
+
const changedIds = new Set<string>()
|
|
156
|
+
|
|
157
|
+
// 仅把“参与拖拽的节点”的 ghost 写回;不处理父子关系,也不扩父或夹回
|
|
158
|
+
for (const id of draggingIds) {
|
|
159
|
+
const s = shapes.find(x => x.id === id)
|
|
160
|
+
const r = ghost[id] // 参与拖拽的 id 都应当在 ghost 里
|
|
161
|
+
if (!s || !r) continue
|
|
162
|
+
|
|
163
|
+
// 轻度防抖:做一个整像素落盘,避免 0.x 抖动
|
|
164
|
+
const nb: Rect = {
|
|
165
|
+
x: Math.round(r.x),
|
|
166
|
+
y: Math.round(r.y),
|
|
167
|
+
width: Math.round(r.width),
|
|
168
|
+
height: Math.round(r.height),
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const pb = (baseMap?.[id] ?? (s.bounds as Rect))
|
|
172
|
+
const same =
|
|
173
|
+
pb.x === nb.x && pb.y === nb.y && pb.width === nb.width && pb.height === nb.height
|
|
174
|
+
|
|
175
|
+
if (!same) {
|
|
176
|
+
updateShape(id, { bounds: nb })
|
|
177
|
+
changedIds.add(id)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return Array.from(changedIds)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** 结束一次变换(拖动/缩放/批量)的统一收尾:
|
|
185
|
+
*/
|
|
186
|
+
export const finalizeAfterTransform = (
|
|
187
|
+
shapes: Shape[],
|
|
188
|
+
changedIds: string[],
|
|
189
|
+
ghost: Record<string, Rect>,
|
|
190
|
+
draggingIds: string[],
|
|
191
|
+
diagramId: string | null | undefined,
|
|
192
|
+
hoverId: string | null | undefined,
|
|
193
|
+
updateShape: (id: string, updates: Partial<Shape>) => void,
|
|
194
|
+
): boolean => {
|
|
195
|
+
|
|
196
|
+
// 深度工具:先处理“外层”再处理“内层”,避免内层已换父时反复扩父
|
|
197
|
+
const depthOf = (sid: string) => {
|
|
198
|
+
let d = 0
|
|
199
|
+
let p = shapes.find(s => s.id === sid)?.parenShapeId ?? null
|
|
200
|
+
while (p) { d++; p = shapes.find(s => s.id === p)?.parenShapeId ?? null }
|
|
201
|
+
return d
|
|
202
|
+
}
|
|
203
|
+
const sorted = [...changedIds].sort((a, b) => depthOf(a) - depthOf(b))
|
|
204
|
+
|
|
205
|
+
let anyReparent = false
|
|
206
|
+
for (const id of sorted) {
|
|
207
|
+
const s = shapes.find(x => x.id === id); if (!s) continue
|
|
208
|
+
const finalRect = finalRectOf(ghost, s)
|
|
209
|
+
const did = resolveParentAfterDrag(
|
|
210
|
+
shapes, s, finalRect,
|
|
211
|
+
draggingIds,
|
|
212
|
+
diagramId,
|
|
213
|
+
updateShape,
|
|
214
|
+
0.5, // 覆盖阈值占位(内部已按 hover 优先)
|
|
215
|
+
hoverId ?? null,
|
|
216
|
+
{
|
|
217
|
+
//开启“嵌套时延迟扩父”的模式
|
|
218
|
+
deferExpandOnReparent: true,
|
|
219
|
+
},
|
|
220
|
+
)
|
|
221
|
+
if (did) anyReparent = true
|
|
222
|
+
}
|
|
223
|
+
return anyReparent
|
|
224
|
+
}
|