JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cdn.alloyui.com/2.5.0/aui/aui-min.js"></script>
<link rel="stylesheet" href="http://cdn.alloyui.com/2.5.0/aui-css/css/bootstrap.min.css">
<div id="myDiagramContainer">
<div id="myDiagramBuilder"></div>
</div>
<button id="getJSON">GET JSON</button>
CSS
.diagram-node-custom .diagram-node-content {
background: url(http://www.saltlakemailing.com/wp-content/uploads/2012/03/process_icon.png) no-repeat scroll center transparent;
}
JavaScript
var Y = YUI().use('aui-diagram-builder',
function (Y) {
Y.DiagramNodeCustom = Y.Component.create({
NAME: 'diagram-node',
ATTRS: {
type: {
value: 'custom'
},
customAttr: {
validator: Y.Lang.isString,
value: 'A Custom default'
}
},
EXTENDS: Y.DiagramNodeTask,
prototype: {
////////////////NEW/////////////////
initializer: function () {
this.SERIALIZABLE_ATTRS.push('customAttr');
},
//////////////END NEW//////////////////
getPropertyModel: function () {
var instance = this;
var model = Y.DiagramNodeTask.superclass.getPropertyModel.apply(instance, arguments);
model.push({
attributeName: 'customAttr',
name: 'Custom Attribute'
});
return model;
}
}
});
Y.DiagramBuilder.types['custom'] = Y.DiagramNodeCustom;
Y.diagramBuilder = new Y.DiagramBuilder({
boundingBox: '#myDiagramContainer',
fields: [{
name: 'name1',
type: 'custom',
customAttr: 'VALUECUSTOM',
xy: [100, 100]
}],
srcNode: '#myDiagramBuilder'
}).render();
Y.one('#getJSON').on(
'click',
function (event) {
console.log('JSON: ' + JSON.stringify(Y.diagramBuilder.toJSON()));
});
});