Я ответил на свой вопрос.Если вы наследуете форму, не расширяя ее, вам не понадобится какая-либо разметка в объявлении новой формы.Вот старый способ объявления формы, которую я использовал:
OLD CODE DON'T USE THIS
var myCustomShape = new joint.shapes.devs.Model({
position: { x:50, y:50 },
size: { width: 75, height: 75 },
inPorts: ['Input'],
outPorts: ['Output'],
attrs: {
'.label': {
text: 'Source',
fill: 'black'
},
rect: {
fill: 'springgreen'
}
},
type: 'custom.myCustomShape'
});
Поэтому я переключился на расширение формы devs.Model, а затем сделал новый тип моего типа, например:
NEW WORKING CODE :)
joint.shapes.custom.myCustomShape = joint.shapes.devs.Model.extend({
markup: '<g class="rotatable"><g class="scalable"><rect class="body"/></g><image/><text class="label"/><g class="inPorts"/><g class="outPorts"/></g>',
defaults: joint.util.deepSupplement({
type: 'custom.myCustomShape',
size: { width: 75, height: 75 },
rect: {
stroke: '#d1d1d1',
fill: 'white'
},
circle: {
stroke: 'gray'
},
'.label': {
text: 'Base',
'ref-y': -20
},
'.inPorts circle': {
fill: '#c8c8c8'
},
'.outPorts circle': {
fill: '#262626'
},
}, joint.shapes.devs.Model.prototype.defaults)
});
И используется:
var customShape= new joint.shapes.custom.myCustomShape({
attrs: {
'.label': {
text: 'My Shape',
fill: 'black'
},
rect: {
fill: 'springgreen'
}
},
position: { x: 50, y: 50 },
size: { width: 75, height: 75 }
});
graph.addCell(customShape);
При экспорте и импорте графиков с формами, объявленными так, все работает правильно.