): string => {
const stack: string[] = [];
if (isPlainObject(colors)) {
Object.keys(colors).forEach(key => {
stack.push(
``
);
stack.push(eachColor((colors as any)[key]));
stack.push('
');
});
} else if (isArray(colors)) {
colors.forEach(color => {
stack.push(
``
);
});
}
return stack.join('');
};
form.appendChild(
editor.c.fromHTML(
`${eachColor(editor.o.colors)}
`
)
);
// form.appendChild(
// editor.c.fromHTML(``)
// );
// const { extra } = refs(form);
// if (editor.o.showBrowserColorPicker && hasBrowserColorPicker()) {
// extra.appendChild(
// editor.c.fromHTML(
// `${iconPalette}
`
// )
// );
//
// editor.e.on(form, 'change', (e: MouseEvent) => {
// e.stopPropagation();
//
// const target = e.target as HTMLInputElement;
//
// if (!target || !target.tagName || !Dom.isTag(target, 'input')) {
// return;
// }
//
// const color: string = target.value || '';
//
// if (isFunction(callback)) {
// callback(color);
// }
//
// e.preventDefault();
// });
// }
editor.e.on(form, 'mousedown touchend', (e: MouseEvent) => {
e.stopPropagation();
e.preventDefault();
let target = e.target as HTMLElement;
if (
(!target ||
!target.tagName ||
Dom.isTag(target, 'svg') ||
Dom.isTag(target, 'path')) &&
target.parentNode
) {
target = Dom.closest(
target.parentNode,
'span',
editor.editor
) as HTMLElement;
}
if (
!Dom.isTag(target, 'span') ||
!target.classList.contains(cn + '__color-item')
) {
return;
}
const color: string = attr(target, '-color') || '';
if (callback && isFunction(callback)) {
callback(color);
}
});
// editor.e.fire('afterGenerateColorPicker', form, extra, callback, valueHex);
return form;
};