Serializing a diagram model does not save a custom node / port / link logic
Closed this issue · 1 comments
MFA-X-AI commented
Currently to implement the save function we firstly serialize the activeModel using activeModel.serialize();
then saving it to the document context. The serialize however does not save custom link behavior, such as
# xai-jupyterlab\xpipe\src\components\CustomPortModel.ts
export class CustomPortModel extends DefaultPortModel {
canLinkToPort(port: PortModel): boolean {
if (port instanceof DefaultPortModel) {
if(this.options.in === port.getOptions().in){
console.log("in not connected to in");
return false;
}
}
Hence when reloading using this.activeModel.deserializeModel(model, this.diagramEngine);
, any custom logic is lost.
Suggestion:
We may need to implement a custom serialization method, as mentioned here projectstorm/react-diagrams#744