Skip to content

Commit 144e983

Browse files
Refine task list marker spacing
1 parent 481b7ba commit 144e983

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

app/src/features/editor/extensions/list-advanced-rendering.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,20 @@ describe("Advanced list rendering", () => {
192192

193193
view.destroy();
194194
});
195+
196+
it("does not leave a source spacer after the decorated task marker", async () => {
197+
const { view } = createView(
198+
"- [ ] Task item that should wrap onto another line",
199+
);
200+
201+
await flush();
202+
203+
const taskLine = view.dom.querySelector(".cm-line.cm-md-task-list");
204+
expect(taskLine).not.toBeNull();
205+
expect(taskLine?.textContent).toBe(
206+
"Task item that should wrap onto another line",
207+
);
208+
209+
view.destroy();
210+
});
195211
});

app/src/features/editor/extensions/markdown-decorations/lists.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ import {
3030
const BULLET_INDENT = 2;
3131
const ORDERED_INDENT = 3;
3232
const LIST_INDENT_STEP = "1.5rem";
33-
const LIST_MARKER_WIDTH = "2rem";
34-
const LIST_WRAP_INDENT_OFFSET = "0.2rem";
33+
const LIST_MARKER_WIDTH = "2.2rem";
3534
const LIST_CHILD_BLOCK_OFFSET = LIST_MARKER_WIDTH;
3635
const LIST_SOURCE_INDENT_CHAR_WIDTH = "0.25rem";
3736
const BLOCKQUOTE_PREFIX_RE = /^(?:[ \t]{0,3}> ?)+/;
@@ -1396,9 +1395,9 @@ function addMarkerDecorations(
13961395
},
13971396
}).range(data.lineStart),
13981397
Decoration.replace({}).range(data.markerStart, data.markerEnd + 1),
1399-
taskMarkerDecoration.range(taskStart, taskEnd),
1398+
taskMarkerDecoration.range(taskStart, taskEnd + 1),
14001399
);
1401-
atomicRanges.push(taskMarkerDecoration.range(taskStart, taskEnd));
1400+
atomicRanges.push(taskMarkerDecoration.range(taskStart, taskEnd + 1));
14021401

14031402
if (checked && taskEnd + 1 < line.to) {
14041403
decorationRanges.push(
@@ -1826,11 +1825,9 @@ const listTheme = EditorView.theme({
18261825
".cm-md-list": {
18271826
"--cm-md-list-indent-step": LIST_INDENT_STEP,
18281827
"--cm-md-list-marker-width": LIST_MARKER_WIDTH,
1829-
"--cm-md-list-wrap-indent-offset": LIST_WRAP_INDENT_OFFSET,
18301828
paddingLeft:
1831-
"calc(var(--indent-level) * var(--cm-md-list-indent-step) + var(--cm-md-list-marker-width) + var(--cm-md-list-wrap-indent-offset)) !important",
1832-
textIndent:
1833-
"calc(-1 * (var(--cm-md-list-marker-width) + var(--cm-md-list-wrap-indent-offset)))",
1829+
"calc(var(--indent-level) * var(--cm-md-list-indent-step) + var(--cm-md-list-marker-width)) !important",
1830+
textIndent: "calc(var(--cm-md-list-marker-width) * -1)",
18341831
},
18351832
".cm-md-list *": {
18361833
textIndent: "0",
@@ -1907,7 +1904,7 @@ const listTheme = EditorView.theme({
19071904
height: "1.15em",
19081905
lineHeight: "1",
19091906
position: "relative",
1910-
transform: "translateY(0.20em)",
1907+
transform: "translateY(0.24em)",
19111908
width: "1.15em",
19121909
},
19131910
".cm-md-task-marker-checked .cm-md-task-marker-box": {

0 commit comments

Comments
 (0)