1
0

Fixes miscoloring meta

This commit is contained in:
Zef Hemel 2023-08-21 16:37:10 +02:00
parent 688985c133
commit 38a95d2382
2 changed files with 25 additions and 14 deletions

View File

@ -12,14 +12,30 @@ export function listBulletPlugin() {
const widgets: any[] = [];
syntaxTree(state).iterate({
enter: ({ type, from, to }) => {
if (isCursorInRange(state, [from, to])) return;
if (type.name === "ListMark") {
const listMark = state.sliceDoc(from, to);
if (bulletListMarkerRE.test(listMark)) {
const dec = Decoration.replace({
widget: new ListBulletWidget(listMark),
});
widgets.push(dec.range(from, to));
if (isCursorInRange(state, [from, to])) {
// Cursor is in the list mark
widgets.push(
Decoration.mark({
class: "sb-li-cursor",
}).range(from, to),
);
} else {
// Cursor is outside the list mark, render as a (silver) bullet
const listMark = state.sliceDoc(from, to);
if (bulletListMarkerRE.test(listMark)) {
const dec = Decoration.replace({
widget: new ListBulletWidget(listMark),
});
widgets.push(dec.range(from, to));
} else {
// Ordered list, no special rendering
widgets.push(
Decoration.mark({
class: "sb-li-cursor",
}).range(from, to),
);
}
}
}
},

View File

@ -206,16 +206,11 @@
}
}
/* Color list item this way */
.sb-line-li .sb-meta {
/* Color list items when the cursor is on it */
.sb-li-cursor .sb-meta {
color: var(--editor-line-meta-color);
}
/* Then undo other meta */
.sb-line-li .sb-meta~.sb-meta {
color: var(--editor-meta-color);
}
.sb-table-widget {
thead tr {
background-color: var(--editor-table-head-background-color);