11import type { XYPosition } from "@xyflow/react" ;
22
33import type { TaskType } from "@/types/taskNode" ;
4- import { EDITOR_POSITION_ANNOTATION } from "@/utils/annotations" ;
4+ import {
5+ EDITOR_POSITION_ANNOTATION ,
6+ ZINDEX_ANNOTATION ,
7+ } from "@/utils/annotations" ;
58import {
69 type ComponentSpec ,
710 type GraphSpec ,
@@ -17,6 +20,8 @@ import {
1720 getUniqueTaskName ,
1821} from "@/utils/unique" ;
1922
23+ import { getNodeTypeZIndexDefault } from "./zIndex" ;
24+
2025interface AddTaskResult {
2126 spec : ComponentSpec ;
2227 taskId : string | undefined ;
@@ -75,8 +80,9 @@ const addTask = (
7580 const graphSpec = newComponentSpec . implementation . graph ;
7681
7782 const nodePosition = { x : position . x , y : position . y } ;
78- const positionAnnotations = {
83+ const annotations = {
7984 [ EDITOR_POSITION_ANNOTATION ] : JSON . stringify ( nodePosition ) ,
85+ [ ZINDEX_ANNOTATION ] : getNodeTypeZIndexDefault ( taskType ) ,
8086 } ;
8187
8288 if ( taskType === "task" ) {
@@ -103,7 +109,7 @@ const addTask = (
103109
104110 const mergedAnnotations = {
105111 ...taskSpec . annotations ,
106- ...positionAnnotations ,
112+ ...annotations ,
107113 } ;
108114
109115 const updatedTaskSpec : TaskSpec = {
@@ -133,7 +139,7 @@ const addTask = (
133139 const inputSpec : InputSpec = {
134140 ...options ,
135141 name : inputId ,
136- annotations : positionAnnotations ,
142+ annotations,
137143 } ;
138144
139145 const inputs = ( newComponentSpec . inputs ?? [ ] ) . concat ( [ inputSpec ] ) ;
@@ -146,7 +152,7 @@ const addTask = (
146152 const outputSpec : OutputSpec = {
147153 ...options ,
148154 name : outputId ,
149- annotations : positionAnnotations ,
155+ annotations,
150156 } ;
151157
152158 const outputs = ( newComponentSpec . outputs ?? [ ] ) . concat ( [ outputSpec ] ) ;
0 commit comments