Hi,
We are using an ofModel()
binding with an empty ''
sourceprop
. This works as expected:
The returned value is the data stored in model.modelData
. However, when the clipboard is involved: selecting a node an hitting ctrl+c
, the value becomes the nodeData
, is this expected? Or shouldn’t we be using ofModel()
in combination with an empty sourceprop
?
Example:
<!DOCTYPE html>
<html>
<head>
<title>Model data empty src prop</title>
<meta charset="UTF-8">
</head>
<body onload="init()">
<div id="app">
<div id="diagram" style="border: solid 1px black; width:100%; height:300px"></div>
</div>
<script src="https://unpkg.com/gojs"></script>
<script id="code">
function init() {
var $ = go.GraphObject.make; // for conciseness in defining templates
myDiagram = $(go.Diagram, "diagram", {
"undoManager.isEnabled": true
});
// define a simple Node template
myDiagram.nodeTemplate = $(go.Node, "Auto",
$(go.Shape, "RoundedRectangle", { strokeWidth: 0 },
new go.Binding("fill", "", (value, target) => {
return value[target.diagram.model.modelData.colorVisualizationSetting]
}),
new go.Binding("fill", "colorVisualizationSetting", (value, target) => {
return target.part.data[value]
}).ofModel(),
),
$(go.TextBlock,
{ margin: 8, font: "bold 14px sans-serif", stroke: '#333' },
new go.Binding("text", "", (val) => {
console.log(val)
return val.prop1
}).ofModel()
)
);
myDiagram.model = new go.GraphLinksModel(
[
{ key: "alpha", color1: 'red', color2: 'blue', color3: 'green' },
{ key: "bravo", color1: 'green', color2: 'red', color3: 'blue' },
{ key: "charlie", color1: 'blue', color2: 'green', color3: 'red' },
]
);
myDiagram.model.modelData = {
prop1: 'prop1',
prop2: 'prop2',
}
myDiagram.model.linkKeyProperty = 'key'
}
</script>
</body>
</html>
See console log