Merge pull request #553 from tidalcycles/highlighting-colors
fix: colorable highlighting
This commit is contained in:
commit
95c44b1ce2
2 changed files with 11 additions and 4 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -39,4 +39,7 @@ server/samples/old
|
||||||
repl/stats.html
|
repl/stats.html
|
||||||
coverage
|
coverage
|
||||||
public/icons/apple-splash-*
|
public/icons/apple-splash-*
|
||||||
dev-dist
|
dev-dist
|
||||||
|
Dirt-Samples
|
||||||
|
tidal-drum-machines
|
||||||
|
webaudiofontdata
|
||||||
|
|
|
||||||
|
|
@ -58,15 +58,19 @@ const highlightField = StateField.define({
|
||||||
haps
|
haps
|
||||||
.map((hap) =>
|
.map((hap) =>
|
||||||
(hap.context.locations || []).map(({ start, end }) => {
|
(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 from = tr.newDoc.line(start.line).from + start.column;
|
||||||
let to = tr.newDoc.line(end.line).from + end.column;
|
let to = tr.newDoc.line(end.line).from + end.column;
|
||||||
const l = tr.newDoc.length;
|
const l = tr.newDoc.length;
|
||||||
if (from > l || to > l) {
|
if (from > l || to > l) {
|
||||||
return; // dont mark outside of range, as it will throw an error
|
return; // dont mark outside of range, as it will throw an error
|
||||||
}
|
}
|
||||||
//const mark = Decoration.mark({ attributes: { style: `outline: 2px solid ${color};` } });
|
let mark;
|
||||||
const mark = Decoration.mark({ attributes: { class: `outline outline-2 outline-foreground` } });
|
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);
|
return mark.range(from, to);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue