我想以编程方式关闭格式化的文字在我的图表的每一个细胞,所以我能避免在mxgraph编辑器qazxsw POI(类似于Draw.io)
这里是我的尝试:
Not supported by viewer
但它似乎没有工作(即,如果我把它关掉从格式面板中的复选框,它的工作原理,但这样一来,我仍然可以在我的SVG的graph.stopEditing();
graph.getModel().beginUpdate();
try
{
var cells = graph.getChildCells(graph.getDefaultParent());
cells.forEach(function (cell)
{
var state = graph.getView().getState(cell);
if (state == null)
{
return;
}
if (state.style['html'] != '1') {
return;
}
var label = graph.convertValueToString(state.cell);
if (mxUtils.getValue(state.style, 'nl2Br', '1') != '0')
{
label = label.replace(/\n/g, '').replace(/<br\s*.?>/g, '\n');
}
// Removes HTML tags
var temp = document.createElement('div');
temp.innerHTML = label;
label = mxUtils.extractTextWithWhitespace(temp.childNodes);
graph.cellLabelChanged(state.cell, label);
graph.setCellStyles('html', null);
});
ui.fireEvent(new mxEventObject('styleChanged', 'keys', ['html'],
'values', ['0'], 'cells', cells));
}
finally
{
graph.getModel().endUpdate();
}
输出)我在做什么错呢?
更换:
[Not supported by viewer]
有:
graph.setCellStyles('html', null);