1
- import { NodeEditor , GetSchemes , ClassicPreset } from "rete" ;
2
- import { AreaPlugin , AreaExtensions , Area2D } from "rete-area-plugin" ;
3
- import {
4
- ConnectionPlugin ,
5
- Presets as ConnectionPresets
6
- } from "rete-connection-plugin" ;
1
+ import { ClassicPreset , GetSchemes , NodeEditor } from "rete" ;
2
+ import { Area2D , AreaExtensions , AreaPlugin } from "rete-area-plugin" ;
3
+ import { ConnectionPlugin , Presets as ConnectionPresets } from "rete-connection-plugin" ;
7
4
import { ConnectionPathPlugin } from "rete-connection-path-plugin" ;
8
- import {
9
- HistoryExtensions ,
10
- HistoryPlugin ,
11
- Presets as HistoryPresets
12
- } from "rete-history-plugin" ;
13
- import { VuePlugin , Presets , VueArea2D } from "rete-vue-plugin" ;
5
+ import { HistoryExtensions , HistoryPlugin , Presets as HistoryPresets } from "rete-history-plugin" ;
6
+ import { Presets , VueArea2D , VuePlugin } from "rete-vue-plugin" ;
14
7
import { h } from "vue" ;
15
8
import CustomConnection from "../../components/PropertyConnection.vue" ;
16
9
import { removeNodeWithConnections } from "./utils.ts" ;
17
10
import EntityType from "../types/EntityType.ts" ;
18
11
import ConnectionInterfaceType from "../types/ConnectionInterfaceType.ts" ;
19
12
import EntityNodeComponent from "../../components/EntityNode.vue" ;
20
13
import CustomInputControl from "../../components/EntitySelectorInputControl.vue" ;
21
- import { noEntity , variableEntityConstructor } from "./constants.ts" ;
14
+ import { noEntity , variableEntityConstructor } from "./constants.ts" ;
22
15
import { noDataSource } from "../constants" ;
16
+ import { deepCopy } from "../utils" ;
23
17
24
18
// Each connection holds additional data, which is defined here
25
19
class Connection extends ClassicPreset . Connection <
@@ -96,7 +90,10 @@ export async function createEditor(container: HTMLElement) {
96
90
increaseVariablePropCounter = false ;
97
91
highestIdCount ++ ;
98
92
}
99
- props . data . property = variableEntityConstructor ( highestIdCount . toString ( ) )
93
+
94
+ if ( ! props . data . property ) {
95
+ props . data . property = variableEntityConstructor ( highestIdCount . toString ( ) )
96
+ }
100
97
101
98
const label = "connection" ;
102
99
@@ -122,9 +119,18 @@ export async function createEditor(container: HTMLElement) {
122
119
props . data . selected = true ;
123
120
area . update ( "connection" , id ) ;
124
121
} ,
125
- onChanged : ( value : EntityType ) => {
126
- props . data . property = value ;
127
- area . update ( "connection" , id ) ;
122
+ onChangedEntitySelector : ( value : EntityType ) => {
123
+ // in order to force the editor to notice the change,
124
+ // I need to create a copy of the connection,
125
+ // change the entity and add it back.
126
+ const thisConnection = deepCopy ( editor . getConnection ( id ) ) ;
127
+
128
+ if ( thisConnection ) {
129
+ thisConnection . property = value
130
+ editor . removeConnection ( id ) . then ( ( ) => {
131
+ editor . addConnection ( thisConnection ) ;
132
+ } ) ;
133
+ }
128
134
}
129
135
} ) ;
130
136
}
0 commit comments