【发布时间】:2018-03-01 20:20:54
【问题描述】:
我想添加一个仅针对特定类型的元素(不是链接)打开的第三个检查器,例如仅针对 Rappid 中的 basic.Rect。
到目前为止,有 2 个 Inspectors。用于元素和用于链接。
有什么办法可以做到吗?
以下代码是 Rappid KitchenSkink 版本的一部分。
这里是函数createInspector:
createInspector: function(cellView) {
var cell = cellView.model || cellView;
// No need to re-render inspector if the cellView didn't change.
if (!this.inspector || this.inspector.options.cell !== cell) {
// Is there an inspector that has not been removed yet.
// Note that an inspector can be also removed when the underlying cell is removed.
if (this.inspector && this.inspector.el.parentNode) {
this.inspectorClosedGroups[this.inspector.options.cell.id] = _.map(app.inspector.$('.group.closed'), function(g) {
return $(g).attr('data-name');
});
// Clean up the old inspector if there was one.
this.inspector.updateCell();
this.inspector.remove();
}
var inspectorDefs = InspectorDefs[cell.get('type')];
this.inspector = new joint.ui.Inspector({
inputs: inspectorDefs ? inspectorDefs.inputs : CommonInspectorInputs,
groups: inspectorDefs ? inspectorDefs.groups : CommonInspectorGroups,
cell: cell
});
this.initializeInspectorTooltips();
this.inspector.render();
$('.inspector-container').html(this.inspector.el);
if (this.inspectorClosedGroups[cell.id]) {
_.each(this.inspectorClosedGroups[cell.id], this.inspector.closeGroup, this.inspector);
} else {
this.inspector.$('.group:not(:first-child)').addClass('closed');
}
}
}
【问题讨论】:
-
有什么办法可以做到吗?
-
我不是我正确理解这个问题。如何将
basic.Rect检查器定义添加到您的InspectorDefs对象中。 -
Roman 我不明白我应该在函数 createInspector 中编写什么代码来为这个特定元素打开一个新的检查器,比如说 basic.Rect。我想要一个具有不同检查器字段的第三个检查器,专门为此 basic.Rect 定义
标签: javascript jointjs inspector rappid