Created
November 22, 2021 08:48
-
-
Save anithegregorian/db35e3fbd45a6b02061a70ba51adc30c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CustomData(value) { | |
this.value = value; | |
} | |
var codec = new mxObjectCodec(new CustomData()); | |
codec.encode = function (enc, obj) { | |
var node = enc.document.createElement('CustomData'); | |
mxUtils.setTextContent(node, JSON.stringify(obj)); | |
return node; | |
}; | |
codec.decode = function (dec, node, into) { | |
var obj = JSON.parse(mxUtils.getTextContent(node)); | |
obj.constructor = CustomData; | |
return obj; | |
}; | |
mxCodecRegistry.register(codec); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment