Checklists in the body, colour from tags, and commit-derived CalVer #4

Merged
bvandeusen merged 73 commits from dev into main 2026-08-29 13:39:45 -04:00
2 changed files with 10 additions and 6 deletions
Showing only changes of commit f50204a98b - Show all commits
@@ -167,11 +167,13 @@ fun List<EditorBlock>.plusTask(): Pair<List<EditorBlock>, Long> {
* only the way it is drawn.
*/
internal fun List<EditorBlock>.promotingTasks(index: Int): List<EditorBlock> {
val block = getOrNull(index) ?: return this
if (block.isTask) return this
val block = getOrNull(index)
if (block == null || block.isTask) return this
val split = splitBlocks(block.value.text, nextId())
if (split.size == 1 && !split.first().isTask) return this
return take(index) + split + drop(index + 1)
// A single prose block back means there was nothing to promote. `splitBlocks` never
// returns an empty list, so `first()` is safe.
val changed = split.size > 1 || split.first().isTask
return if (changed) take(index) + split + drop(index + 1) else this
}
/**
+4 -2
View File
@@ -137,6 +137,8 @@ export function promoteTasks(blocks: EditorBlock[], index: number): EditorBlock[
const block = blocks[index];
if (!block || block.checked !== null) return blocks;
const split = splitBlocks(block.text, nextId(blocks));
if (split.length === 1 && split[0].checked === null) return blocks;
return [...blocks.slice(0, index), ...split, ...blocks.slice(index + 1)];
// A single prose block back means there was nothing to promote. `splitBlocks` never
// returns an empty array, so `split[0]` is safe.
const changed = split.length > 1 || split[0].checked !== null;
return changed ? [...blocks.slice(0, index), ...split, ...blocks.slice(index + 1)] : blocks;
}