From e69faff7820c3a4a2b6bdd523e210ab0da61e666 Mon Sep 17 00:00:00 2001 From: Chris McCormick Date: Sun, 4 Jan 2026 22:24:34 +0800 Subject: [PATCH] Ability to delete a card. --- TODO.md | 2 +- index.html | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 79d8092..54bd3c6 100644 --- a/TODO.md +++ b/TODO.md @@ -9,13 +9,13 @@ ## TODO - [ ] Warning colored note on home and about page if browser doesn't support FileSystem Access API. -- [ ] Ability to delete an item, with confirmation. - [ ] Display sub-lines of the form `key: value` immediately after item ## Bugs ## Done +- [x] Ability to delete an item, with confirmation. - [x] When the dots menu shows on a 'completed' item the stuff behind it shows through - [x] Pressing + in a column and then cancel removes the button entirely - [x] Group all indented lines after each item with the item diff --git a/index.html b/index.html index da84857..2a1e93c 100644 --- a/index.html +++ b/index.html @@ -1338,6 +1338,24 @@ chmod 755 kbtd }); } + async function deleteCard(lineNumber) { + console.log('deleteCard:', lineNumber); + await modifyFileLines(lines => { + const cardInfo = findCardByLineNumber(lineNumber); + if (!cardInfo) { + console.error('Could not find card with line number', lineNumber); + return; + } + + const card = cardInfo.card; + const nestedLineCount = card.nestedLines.length; + + lines.splice(lineNumber, 1 + nestedLineCount); + + console.log('Deleted card at line', lineNumber, 'with', nestedLineCount, 'nested lines'); + }); + } + async function moveLineInFile(fromLine, toLine, targetColumnIndex, insertPosition) { console.log('moveLineInFile: from line', fromLine, 'to line', toLine, 'targetColumnIndex:', targetColumnIndex, 'insertPosition:', insertPosition); await modifyFileLines(lines => { @@ -1941,9 +1959,22 @@ chmod 755 kbtd } }); + const deleteItem = h('button', { + className: 'card-menu-item', + textContent: 'Delete', + onclick: async (e) => { + e.stopPropagation(); + closeAllCardMenus(); + if (confirm('Are you sure you want to delete this card?')) { + const lineNum = getDataInt(cardDiv, 'lineNumber'); + await deleteCard(lineNum); + } + } + }); + const menu = h('div', { className: 'card-menu' - }, completeItem, moveItem); + }, completeItem, moveItem, deleteItem); cardDiv.append(cardHeader, menu);