如何将 ui.ColorPalette 添加到自定义的 ui.Halo 句柄?光环图标应显示调色板中的第一种颜色。
我正在使用快速。
谢谢
我找到了解决方案。也许有人可以查看代码并判断解决方案是否正确,并就如何获取光环句柄 (l_target) 提供更好的解决方案。谢谢迪特
//this is my halo handle
var l_target = document.getElementsByClassName('handle mycolor se');
var l_fill = cellView.model.attr ('rect/fill');
var l_content = [
{content: '#ccff99'},
{content: '#B3B3B3'},
{content: '#808080'},
{content: '#4D4D4D'},
{content: '#E6E6E6'},
{content: '#FFC7C9'},
{content: '#FFA0A4'},
{content: '#E3686D'}
];
var l_selected = l_content.findIndex (c => c.content === l_fill);
m_colorPalette = new joint.ui.ColorPalette({
options: l_content,
selected: l_selected
});
m_colorPalette.on ('option:select', function (element) {
cellView.model.attr ('rect/fill', element.content);
});
m_colorPalette.render().el;
l_target [0].appendChild (m_colorPalette.render().el);