Save and load task notes

This commit is contained in:
2026-02-27 23:42:44 +01:00
parent deb8c86d0d
commit 13f6fe2c3f
5 changed files with 29 additions and 8 deletions
+5 -2
View File
@@ -33,13 +33,16 @@ export default function Router({
switch (entity.type) {
case "todo": {
const createTask = (statusId: string) => {
const now = new Date().getTime();
const task: Task = {
id: id("task"),
title: "New task",
statusId,
tagIds: [],
createdAt: new Date().getTime(),
updatedAt: new Date().getTime(),
// initialize empty rich document notes
doc: { version: "2.28.0", time: now, blocks: [] },
createdAt: now,
updatedAt: now,
};
updateEntity(entityId, (e) => ({
+11 -6
View File
@@ -26,11 +26,16 @@ export default function DocDialog({
tags: Record<TagId, Tag>;
children: React.ReactNode;
}) {
const [doc, setDoc] = useState<OutputData>({
version: "2.28.0",
time: Date.now(),
blocks: [],
});
// if there is an existing document on the task use it, otherwise start with a blank one
const doc = task.doc || { version: "2.28.0", time: Date.now(), blocks: [] };
const handleDocChange = (newDoc: OutputData) => {
setTask({
...task,
doc: newDoc,
updatedAt: Date.now(),
});
};
return (
<Dialog>
@@ -62,7 +67,7 @@ export default function DocDialog({
</DialogHeader>
<ScrollArea className="h-[60vh]">
<DocView key={0} doc={doc} setDoc={setDoc} />
<DocView key={task.id} doc={doc} setDoc={handleDocChange} />
</ScrollArea>
</DialogContent>
</Dialog>