11import { Camera } from "../../Camera" ;
2- import { Entity } from "../../stageObject/abstract/StageEntity" ;
2+ import { StageObject } from "../../stageObject/abstract/StageObject" ;
3+ import { Edge } from "../../stageObject/association/Edge" ;
4+ import { ConnectPoint } from "../../stageObject/entity/ConnectPoint" ;
5+ import { ImageNode } from "../../stageObject/entity/ImageNode" ;
36import { Section } from "../../stageObject/entity/Section" ;
47import { TextNode } from "../../stageObject/entity/TextNode" ;
8+ import { UrlNode } from "../../stageObject/entity/UrlNode" ;
59import { StageManager } from "../StageManager" ;
610
711export namespace StageTagManager {
@@ -11,7 +15,8 @@ export namespace StageTagManager {
1115 * 目前先仅支持TextNode
1216 */
1317 export function changeTagBySelected ( ) {
14- for ( const selectedEntities of StageManager . getSelectedEntities ( ) . filter ( ( entity ) => entity instanceof TextNode ) ) {
18+ for ( const selectedEntities of StageManager . getSelectedStageObjects ( ) ) {
19+ // 若有则删,若无则加
1520 if ( StageManager . TagOptions . hasTag ( selectedEntities . uuid ) ) {
1621 StageManager . TagOptions . removeTag ( selectedEntities . uuid ) ;
1722 } else {
@@ -27,9 +32,12 @@ export namespace StageTagManager {
2732 export function refreshTagNames ( ) {
2833 const res : { tagName : string ; uuid : string } [ ] = [ ] ;
2934 const tagUUIDs = StageManager . TagOptions . getTagUUIDs ( ) ;
30- const tagObjectList : Entity [ ] = [ ] ;
35+ const tagObjectList : StageObject [ ] = [ ] ;
3136 for ( const tagUUID of tagUUIDs ) {
32- tagObjectList . push ( StageManager . getEntitiesByUUIDs ( [ tagUUID ] ) [ 0 ] ) ;
37+ const stageObject = StageManager . getStageObjectByUUID ( tagUUID ) ;
38+ if ( stageObject ) {
39+ tagObjectList . push ( stageObject ) ;
40+ }
3341 }
3442 // 排序,从上到下,从左到右
3543 tagObjectList . sort ( ( a , b ) => {
@@ -41,19 +49,35 @@ export namespace StageTagManager {
4149 } ) ;
4250
4351 for ( const tagObject of tagObjectList ) {
52+ let title = "" ;
4453 if ( tagObject instanceof TextNode ) {
45- res . push ( { tagName : tagObject . text , uuid : tagObject . uuid } ) ;
54+ title = tagObject . text ;
4655 } else if ( tagObject instanceof Section ) {
47- res . push ( { tagName : tagObject . text , uuid : tagObject . uuid } ) ;
56+ title = tagObject . text ;
57+ } else if ( tagObject instanceof UrlNode ) {
58+ title = tagObject . title ;
59+ } else if ( tagObject instanceof ImageNode ) {
60+ title = "Image: " + tagObject . uuid . slice ( 0 , 4 ) ;
61+ } else if ( tagObject instanceof Edge ) {
62+ title = tagObject . text . slice ( 0 , 20 ) . trim ( ) ;
63+ if ( title . length === 0 ) {
64+ title = "未命名连线" ;
65+ }
66+ } else if ( tagObject instanceof ConnectPoint ) {
67+ title = tagObject . details . slice ( 0 , 20 ) . trim ( ) ;
68+ if ( title . length === 0 ) {
69+ title = "Connect Point: " + tagObject . uuid . slice ( 0 , 4 ) ;
70+ }
4871 } else {
49- res . push ( { tagName : tagObject . uuid , uuid : tagObject . uuid } ) ;
72+ title = "Unknown: " + tagObject . uuid . slice ( 0 , 4 ) ;
5073 }
74+ res . push ( { tagName : title , uuid : tagObject . uuid } ) ;
5175 }
5276 return res ;
5377 }
5478
55- export function moveToTag ( tagUUID : string ) {
56- const tagObject = StageManager . getEntitiesByUUIDs ( [ tagUUID ] ) [ 0 ] ;
79+ export function moveCameraToTag ( tagUUID : string ) {
80+ const tagObject = StageManager . getStageObjectByUUID ( tagUUID ) ;
5781 if ( ! tagObject ) {
5882 return ;
5983 }
0 commit comments