I have 3 templates of Node, which 1 of them has copyable: false
(not sure if it makes sense). When I paste nodes & links from clipboard, I have an error:
Uncaught TypeError: Cannot read properties of null (reading 'iterator')
Digging into this error, I found some variable, which has not been redefined from null for some reason. In turn, c.Kj
function lead to some PartManager
’s function.
Piece of Node template:
$create(
Go.Node,
'Auto',
{
deletable: modelType !== 'modules',
copyable: modelType !== 'modules',
opacity: 1,
defaultAlignment: Go.Spot.Center,
selectionAdornmentTemplate: makeBorderSelected(STYLES),
selectionChanged(model: any) {
const initialOpacity = 1
if (model.isSelected) {
if (import.meta.env.MODE !== 'production') {
console.info('SELECTED MODEL:', { ...model.part.findTopLevelPart().data })
}
model.layerName = 'Foreground'
model.opacity = initialOpacity
} else {
model.layerName = ''
}
},
},
new Go.Binding('deletable', 'user_defined'),
new Go.Binding('location', 'position', Go.Point.parse).makeTwoWay(Go.Point.stringify),
more code goes here...
)
Example of Node’s model:
{
TEMP_TEMPLATE: "modules_model", // nodeCategoryProperty
id: "a893138e-46c8-47a2-a531-780a94cea74b", // nodeKeyProperty
description: "Description of 'status'",
is_virtual: false,
module_model_id: 48,
name: "status",
position: "483 252",
user_defined: false,
version: 14,
fields: [{
id: "1b9ce492-2ce1-4cb2-b618-c92a226f6bde"
avt: 0
description: "Description of 'id'"
dv: null
ei: null
generated: true
hidden: false
index: false
json_name: "id"
module_id: null
name: "id"
not_null: true
order: "0"
rmi: null
unique: true
vt: 1
}],
indexes: [{
fields: (3) ['c31a1296-4108-4812-9ba9-31a91c59b9fc']
id: "R9MNTimQfV6R9ogheMNS"
name: "my_index"
type: 1
}]
}
That error breakes my ClipboardPasted callback function which is critical.