From ce8a0a2d422c2c0fee9de1e108a8e04243488a75 Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 21 Nov 2017 18:36:11 +0300 Subject: [PATCH] assign color swatches correctly: skip overlays in the middle --- vendor-overwrites/colorpicker/colorpicker.css | 8 ++++++-- vendor-overwrites/colorpicker/colorview.js | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/vendor-overwrites/colorpicker/colorpicker.css b/vendor-overwrites/colorpicker/colorpicker.css index 532a6a07..21dd4084 100644 --- a/vendor-overwrites/colorpicker/colorpicker.css +++ b/vendor-overwrites/colorpicker/colorpicker.css @@ -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; } diff --git a/vendor-overwrites/colorpicker/colorview.js b/vendor-overwrites/colorpicker/colorview.js index 7086926b..7bf179ce 100644 --- a/vendor-overwrites/colorpicker/colorview.js +++ b/vendor-overwrites/colorpicker/colorview.js @@ -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; }