有没有可以提供节点/边标签编辑功能的库?我已经搜索遍了 npm 和 github,但没有找到任何有用的东西。接近我需要的库是“zngduong/cytoscape.js-edit-content”,但它无法正常工作。我实现了上下文菜单,我创建的选项之一是编辑元素的标签。我在元素位置上生成输入标记时遇到问题。下面是我当前使用 this 的代码图书馆。
cy.cxtmenu({
selector: 'node, edge',
commands: [
{
content: '<span class="glyphicon glyphicon-pencil"></span>',
select: function(ele)
{
var $input = '<input type="text" value="'+ ele.data('name') +'" size="20" style="z-index: 10000;"/>';
$('div#cy').append($input);
}
},
{
content: '<span class="glyphicon glyphicon-remove"></span>',
select: function(ele){
}
},
{
content: '<span class="glyphicon glyphicon-trash"></span>',
select: function(ele){
ele.remove();
}
}
]
});
最佳答案
(1) 您无法将任何内容附加到 Cytoscape div。
(2) 您应该将标签文本存储在元素的 data 中.
(3) 您应该使用 stylesheet至 map标签的数据字段(例如 label: data(label)
)。
(4) 通过(3)和(4),设置node.data('label', newLabel)
更改标签文本。如何为此设计 UI 由您决定。例如,您可以在 qtip 中显示文本框。 .
关于javascript - Cytoscape.js 标签点击/单击上的节点/边缘标签编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42737609/