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[] = []; const widgets: any[] = [];
syntaxTree(state).iterate({ syntaxTree(state).iterate({
enter: ({ type, from, to }) => { enter: ({ type, from, to }) => {
if (isCursorInRange(state, [from, to])) return;
if (type.name === "ListMark") { if (type.name === "ListMark") {
const listMark = state.sliceDoc(from, to); if (isCursorInRange(state, [from, to])) {
if (bulletListMarkerRE.test(listMark)) { // Cursor is in the list mark
const dec = Decoration.replace({ widgets.push(
widget: new ListBulletWidget(listMark), Decoration.mark({
}); class: "sb-li-cursor",
widgets.push(dec.range(from, to)); }).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 */ /* Color list items when the cursor is on it */
.sb-line-li .sb-meta { .sb-li-cursor .sb-meta {
color: var(--editor-line-meta-color); 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 { .sb-table-widget {
thead tr { thead tr {
background-color: var(--editor-table-head-background-color); background-color: var(--editor-table-head-background-color);