当我双击节点时,文本编辑会转到

时间:2017-10-07 14:56:27

标签: javascript mxgraph

当我双击节点时,文本编辑会转到某个位置,而不是节点。以下是代码,我不知道发生了什么。我正在使用AJAX从服务器端获取mxGraph XML。

根据评论编辑源代码

// Creates the div for the graph
mxEvent.disableContextMenu(container);
document.body.appendChild(container);
var xmlDocument = mxUtils.parseXml(xml);
var decoder = new mxCodec(xmlDocument);
var node = xmlDocument.documentElement;
container.innerHTML = '';
graph = new mxGraph(container);
    graph.cellEditor.init();
        graph.cellEditor.textarea.style.position='absolute';
graph.setHtmlLabels(true);
graph.setPanning(true);
graph.setTooltips(true);
graph.setConnectable(true);
// Changes the default style for edges "in-place"
var style = graph.getStylesheet().getDefaultEdgeStyle();

style[mxConstants.STYLE_ROUNDED] = true;
style[mxConstants.STYLE_EDGE] = mxEdgeStyle.ElbowConnector;
decoder.decode(node, graph.getModel());

var layout = new mxHierarchicalLayout(graph, mxConstants.DIRECTION_WEST);
var parent = graph.getDefaultParent();
layout.execute(parent);

1 个答案:

答案 0 :(得分:0)

在初始化期间添加以下代码帮助我

graph.cellEditor.init();
graph.cellEditor.textarea.style.position='absolute';
相关问题