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
+23 -7
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),
);
}
}
}
},