Skip to content

armgit / kanzo

Public Imported from GitHub
0

Self-hosted, sharable kanban for humans and agents. One 4.7 MB binary, 5 MB of RAM, 10 to 60 tokens per agent reply, starts in 3 ms, zero setup.

Render the task description as Markdown, and edit it on click

emanuele-em40a9b19cfb38
diff --git a/src/app.js b/src/app.js
index ae1b21b..262ed46 100644
--- a/src/app.js
+++ b/src/app.js
@@ -784,6 +784,7 @@ async function refreshTask() {
for (const [field, value] of [[$("#p-title"), task.title], [$("#p-desc"), task.description], [$("#p-tags"), task.tags.join(", ")]]) {
if (document.activeElement !== field) { field.value = value; fit(field); }
}
+ showDesc();
const status = $("#p-status");
const statuses = state.board ? state.board.statuses : [task.status];
status.replaceChildren(...statuses.map((s) => el("option", { value: s }, s)));
@@ -868,7 +869,7 @@ for (const field of [$("#p-title"), $("#p-desc")]) field.addEventListener("input
$("#p-title").addEventListener("keydown", (e) => {
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) { e.preventDefault(); closeTask(); }
// The title is one line: Enter, like Tab, goes on to the description.
- else if ((e.key === "Enter" || e.key === "Tab") && !e.shiftKey) { e.preventDefault(); $("#p-desc").focus(); }
+ else if ((e.key === "Enter" || e.key === "Tab") && !e.shiftKey) { e.preventDefault(); editDesc(); }
else if (e.key === "Escape") cancelField(e, panelTask ? panelTask.title : "");
});
$("#p-title").addEventListener("blur", (e) => {
@@ -884,8 +885,31 @@ $("#p-desc").addEventListener("keydown", (e) => {
});
$("#p-desc").addEventListener("blur", (e) => {
if (panelTask && e.target.value.trim() !== panelTask.description) patchTask({ description: e.target.value });
+ showDesc();
});
+// The description shows rendered, like a comment, and turns into its textarea to edit.
+// Empty, the textarea stays, so its placeholder has something to click.
+function showDesc() {
+ const desc = $("#p-desc"), view = $("#p-desc-view");
+ const editing = document.activeElement === desc || !desc.value.trim();
+ desc.hidden = !editing;
+ view.hidden = editing;
+ if (!editing) view.innerHTML = markdown(desc.value);
+}
+
+function editDesc() {
+ const desc = $("#p-desc");
+ $("#p-desc-view").hidden = true;
+ desc.hidden = false;
+ fit(desc);
+ desc.focus();
+}
+
+// A click on a link opens it instead of editing.
+$("#p-desc-view").addEventListener("mousedown", (e) => { if (e.target.closest("a")) e.preventDefault(); });
+$("#p-desc-view").addEventListener("focus", editDesc);
+
$("#p-status").addEventListener("change", (e) => patchTask({ status: e.target.value }));
$("#p-human").addEventListener("change", (e) => patchTask({ human: e.target.checked }));
diff --git a/src/index.html b/src/index.html
index fdda427..8076bb6 100644
--- a/src/index.html
+++ b/src/index.html
@@ -249,6 +249,7 @@ header .repo-link .icon svg { width: 14px; height: 14px; }
width: calc(100% + 20px); resize: none; overflow: hidden; display: block;
}
.panel .inline:hover, .panel .inline:focus { background: var(--hover); }
+.panel .desc-view { cursor: text; }
.panel .title-input { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.props { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; align-items: center; color: var(--muted); }
.props select { width: auto; padding: 4px 30px 4px 12px; border-radius: 99px; text-transform: capitalize; }
@@ -414,6 +415,7 @@ header .repo-link .icon svg { width: 14px; height: 14px; }
<div class="section">
<h3>Description</h3>
<textarea class="inline desc-input" id="p-desc" rows="1" placeholder="Add a description (Markdown)"></textarea>
+ <div class="inline md desc-view" id="p-desc-view" tabindex="0" role="button" aria-label="Edit description" hidden></div>
<div class="thumbs" id="p-images"></div>
</div>
<div class="section">