assign color swatches correctly: skip overlays in the middle

This commit is contained in:
tophf 2017-11-21 18:36:11 +03:00
parent 7f37b8d1dd
commit ce8a0a2d42
2 changed files with 17 additions and 2 deletions

View File

@ -17,8 +17,12 @@
background-repeat: repeat;
}
.cm-colorview + .cm-colorview.cm-overlay::before,
.cm-colorview.cm-overlay + .cm-colorview::before {
/* overlay at the start splits our colorview: don't style the tail */
.cm-colorview.cm-overlay + .cm-colorview:not([data-colorpicker])::before,
/* overlay in the middle splits our colorview: don't style the middle */
.cm-colorview + .cm-colorview.cm-overlay:not([data-colorpicker])::before,
/* ...and the tail */
.cm-colorview + .cm-colorview.cm-overlay:not([data-colorpicker]) + .cm-colorview:not([data-colorpicker])::before {
content: none;
}

View File

@ -163,6 +163,17 @@
}
elements = elements || text.getElementsByClassName(OWN_DOM_CLASS);
const el = elements[elementIndex++];
while (true) {
const nextStyle = styles[i + 3];
const nextStart = styles[i];
if (nextStyle && nextStyle.includes(OWN_TOKEN_NAME) &&
nextStart > start && nextStart <= start + data.color.length) {
elementIndex++;
i += 2;
} else {
break;
}
}
if (el.colorpickerData && el.colorpickerData.color === data.color) {
continue;
}