From 284f6293a2aeb26f428c9f2f59ac532f28d1ac96 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Wed, 19 Apr 2023 01:06:32 +0200 Subject: [PATCH] fix: colorable highlighting --- packages/react/src/components/CodeMirror6.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/react/src/components/CodeMirror6.jsx b/packages/react/src/components/CodeMirror6.jsx index f33436c65..aa90eb308 100644 --- a/packages/react/src/components/CodeMirror6.jsx +++ b/packages/react/src/components/CodeMirror6.jsx @@ -58,15 +58,19 @@ const highlightField = StateField.define({ haps .map((hap) => (hap.context.locations || []).map(({ start, end }) => { - // const color = hap.context.color || e.value.color || '#FFCA28'; + const color = hap.context.color || e.value.color; let from = tr.newDoc.line(start.line).from + start.column; let to = tr.newDoc.line(end.line).from + end.column; const l = tr.newDoc.length; if (from > l || to > l) { return; // dont mark outside of range, as it will throw an error } - //const mark = Decoration.mark({ attributes: { style: `outline: 2px solid ${color};` } }); - const mark = Decoration.mark({ attributes: { class: `outline outline-2 outline-foreground` } }); + let mark; + if (color) { + mark = Decoration.mark({ attributes: { style: `outline: 4px solid ${color};` } }); + } else { + mark = Decoration.mark({ attributes: { class: `outline outline-2 outline-foreground` } }); + } return mark.range(from, to); }), )