@pritzlaff/agile 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +149 -73
- package/bin/agile.mjs +55 -48
- package/card.html +202 -0
- package/card.js +129 -0
- package/index.html +1873 -0
- package/package.json +8 -6
- package/support.js +3 -3
- package/Main.dc.html +0 -4176
package/index.html
ADDED
|
@@ -0,0 +1,1873 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Gantt viewer</title>
|
|
6
|
+
<script src="./vendor/react.js"></script>
|
|
7
|
+
<script src="./vendor/react-dom.js"></script>
|
|
8
|
+
<style>x-dc{display:none}</style>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<x-dc>
|
|
12
|
+
<helmet>
|
|
13
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap">
|
|
14
|
+
<style>
|
|
15
|
+
/* Themes: each sets the colour tokens the page uses. The markdown pane stays dark in every theme. */
|
|
16
|
+
.g-root,.g-root[data-theme="paper"]{--bg:#F6F5F2;--surface:#FFFFFF;--surface-2:#FAFAF8;--seg-bg:#F1EFEA;--hover:#EFEDE8;--rule:#E3E1DC;--rule-soft:#EEECE7;--control:#D9D6CF;--control-strong:#B9B5AC;--ink:#17181A;--on-ink:#FFFFFF;--ink-2:#3D4046;--muted:#5E6168;--faint:#8A8D93;--arrow:#A3A6AC;--accent:#2F5BD3;--link:#2445A8;--today:#C62828;--bad:#B42318;--bad-strong:#8A1C1C;--bad-bg:#FDECEC;--bad-border:#F1C7C7;--danger:#B42318;--danger-hover:#9A1C14;--info-bg:#E3EAFB;--info-fg:#1E3A8A;--pin-bg:#FCEBDD;--pin-fg:#8A3E06;--warn-bg:#FFF3E6;--warn-fg:#7A3A06;--warn-dot:#E0782A;--ok-bg:#EAF5EE;--ok-fg:#1E5631;--ok-dot:#2E9E5B;--sel-bg:#EEF2FC;--sel-lane:rgba(47,91,211,.06);--rel:#2F5BD3;--fixed:#E0782A;--on-rel:#FFFFFF;--on-fixed:#17181A;--backdrop:rgba(23,24,26,.42);--shadow:rgba(23,24,26,.18)}
|
|
17
|
+
.g-root[data-theme="night"]{--bg:#111316;--surface:#1A1D21;--surface-2:#20242A;--seg-bg:#23272D;--hover:#262A30;--rule:#2E333A;--rule-soft:#262A30;--control:#444B53;--control-strong:#5A626B;--ink:#ECEFED;--on-ink:#111316;--ink-2:#C9CED2;--muted:#A9B0B6;--faint:#7D848B;--arrow:#6B737B;--accent:#8FB0FF;--link:#8FB0FF;--today:#FF6B6B;--bad:#FF8A9A;--bad-strong:#FFC2CA;--bad-bg:#3A1D22;--bad-border:#5A2A32;--info-bg:#1E2A44;--info-fg:#A9C1FF;--pin-bg:#3A2A1A;--pin-fg:#FFC08A;--warn-bg:#3A2E15;--warn-fg:#F0C77A;--warn-dot:#E0782A;--ok-bg:#12342E;--ok-fg:#A6EBDC;--ok-dot:#5FD0B8;--sel-bg:#1E2635;--sel-lane:rgba(143,176,255,.08);--rel:#5B86F0;--fixed:#E0782A;--on-rel:#FFFFFF;--on-fixed:#17181A;--backdrop:rgba(0,0,0,.6);--shadow:rgba(0,0,0,.45)}
|
|
18
|
+
.g-root[data-theme="blueprint"]{--bg:#0F2747;--surface:#133059;--surface-2:#17386A;--seg-bg:#0C2240;--hover:#1C4479;--rule:#2A4F84;--rule-soft:#234775;--control:#4A74B0;--control-strong:#7FA3D6;--ink:#F1F6FF;--on-ink:#0F2747;--ink-2:#CFDDF5;--muted:#B4C8E8;--faint:#8FA9D0;--arrow:#7FA3D6;--accent:#FFB347;--link:#9CC8FF;--today:#FF7A7A;--bad:#FF9DA8;--bad-strong:#FFD0D6;--bad-bg:#4A1F33;--bad-border:#7A3550;--info-bg:#1C4479;--info-fg:#D6E6FF;--pin-bg:#4A3A1A;--pin-fg:#FFD08A;--warn-bg:#4A3A1A;--warn-fg:#FFD08A;--warn-dot:#FFB347;--ok-bg:#12403F;--ok-fg:#B4F0DE;--ok-dot:#7EE0C3;--sel-bg:#1C4479;--sel-lane:rgba(255,179,71,.08);--rel:#9CC8FF;--fixed:#FFB347;--on-rel:#0F2747;--on-fixed:#0F2747;--backdrop:rgba(4,14,30,.6);--shadow:rgba(0,0,0,.4)}
|
|
19
|
+
.g-root[data-theme="warm"]{--bg:#F5F0E6;--surface:#FFFDF8;--surface-2:#F9F4EA;--seg-bg:#EDE5D6;--hover:#EDE5D6;--rule:#DDD2BE;--rule-soft:#E8DFCF;--control:#C9BBA3;--control-strong:#A8987D;--ink:#231C14;--on-ink:#FFF8EE;--ink-2:#4A3F33;--muted:#5C5044;--faint:#8F806A;--arrow:#B5A68E;--accent:#8A3B1F;--link:#8A3B1F;--today:#B3261E;--bad:#9E2A2A;--bad-strong:#7A1F1F;--bad-bg:#F3DCD6;--bad-border:#E5C0B6;--info-bg:#E6E9F3;--info-fg:#2E3A6B;--pin-bg:#F7E3CF;--pin-fg:#7A3A06;--warn-bg:#F7EBDD;--warn-fg:#7A3A06;--warn-dot:#C8642B;--ok-bg:#E0EBD9;--ok-fg:#23502B;--ok-dot:#2F6B3A;--sel-bg:#F7EBDD;--sel-lane:rgba(138,59,31,.06);--rel:#3E5C76;--fixed:#C8642B;--on-rel:#FFFFFF;--on-fixed:#231C14;--backdrop:rgba(35,28,20,.42);--shadow:rgba(35,28,20,.18)}
|
|
20
|
+
body{margin:0;background:#F6F5F2}
|
|
21
|
+
a{color:var(--link)}a:hover{color:var(--ink)}
|
|
22
|
+
button{font-family:inherit}
|
|
23
|
+
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
|
|
24
|
+
button:disabled{cursor:not-allowed;opacity:.45}
|
|
25
|
+
.tb:hover:not(:disabled){background:var(--hover)}
|
|
26
|
+
.bar:hover{filter:brightness(1.06)}
|
|
27
|
+
.rs{opacity:0}.bar:hover .rs{opacity:1}
|
|
28
|
+
.grip:hover{background:var(--hover);color:var(--ink)}
|
|
29
|
+
.secdel{opacity:0}.sec:hover .secdel,.secdel:focus-visible{opacity:1}
|
|
30
|
+
.tedit{opacity:0}.thead:hover .tedit,.tedit:focus-visible{opacity:1}
|
|
31
|
+
@media (hover:none){.tedit{opacity:1}}
|
|
32
|
+
.opt:hover{border-color:var(--faint) !important}
|
|
33
|
+
.danger:hover:not(:disabled){background:var(--danger-hover) !important}
|
|
34
|
+
.drop.on{border-color:var(--accent) !important;background:var(--sel-bg) !important}
|
|
35
|
+
input[placeholder="Section name"]:hover{border-color:var(--control)}
|
|
36
|
+
input[placeholder="Section name"]:focus{background:var(--surface);border-color:var(--accent);outline:none}
|
|
37
|
+
input,select,textarea{background:var(--surface);color:var(--ink)}
|
|
38
|
+
</style>
|
|
39
|
+
</helmet>
|
|
40
|
+
<div class="g-root" data-theme="{{theme}}" style="height: 100vh; display: flex; flex-direction: column; font-family: 'Instrument Sans', system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 13px">
|
|
41
|
+
|
|
42
|
+
<header style="display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 20px; border-bottom: 1px solid var(--rule); background: var(--surface)">
|
|
43
|
+
<div style="display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 0 245px">
|
|
44
|
+
<svg aria-hidden="true" width="22" height="22" viewBox="0 0 22 22"><rect x="2" y="3" width="10" height="4" rx="1.5" style="fill: var(--rel)"></rect><rect x="8" y="9" width="12" height="4" rx="1.5" style="fill: var(--fixed)"></rect><rect x="4" y="15" width="7" height="4" rx="1.5" style="fill: var(--ink)"></rect></svg>
|
|
45
|
+
<sc-if value="{{titleView}}" hint-placeholder-val="{{true}}">
|
|
46
|
+
<div class="thead" style="display: flex; align-items: center; gap: 2px; min-width: 0">
|
|
47
|
+
<h1 style="margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis">{{title}}</h1>
|
|
48
|
+
<button class="tb tedit" onClick="{{editTitle}}" aria-label="Rename the plan" title="Rename the plan" style="flex: none; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; padding: 0">
|
|
49
|
+
<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20h4L19 9l-4-4L4 16v4z"></path></svg>
|
|
50
|
+
</button>
|
|
51
|
+
</div>
|
|
52
|
+
</sc-if>
|
|
53
|
+
<sc-if value="{{titleEditing}}" hint-placeholder-val="{{false}}">
|
|
54
|
+
<label for="plan-title" style="position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0)">Plan title</label>
|
|
55
|
+
<input id="plan-title" value="{{titleDraft}}" onChange="{{onTitleDraft}}" onKeyDown="{{onTitleKey}}" onBlur="{{onTitleBlur}}" autoFocus="{{true}}" autocomplete="off" style="width: min(420px, 60vw); height: 32px; padding: 0 8px; border: 1px solid var(--accent); border-radius: 8px; font: inherit; font-size: 16px; font-weight: 600">
|
|
56
|
+
</sc-if>
|
|
57
|
+
</div>
|
|
58
|
+
<div onKeyDown="{{onFileKey}}" style="position: relative; flex: none">
|
|
59
|
+
<button class="tb" onClick="{{toggleFile}}" aria-haspopup="true" aria-expanded="{{fileOpen}}" title="New, open, save, download or share the plan" style="height: 32px; display: flex; align-items: center; gap: 6px; padding: 0 8px 0 10px; border: 1px solid var(--control); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer">
|
|
60
|
+
File<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"></path></svg>
|
|
61
|
+
</button>
|
|
62
|
+
<sc-if value="{{fileOpen}}" hint-placeholder-val="{{false}}">
|
|
63
|
+
<div onClick="{{closeFile}}" style="position: fixed; inset: 0; z-index: 39"></div>
|
|
64
|
+
<div role="menu" aria-label="File" style="position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: 260px; max-width: calc(100vw - 32px); box-sizing: border-box; display: flex; flex-direction: column; gap: 2px; padding: 6px; background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 12px 32px var(--shadow)">
|
|
65
|
+
<button role="menuitem" class="tb" style="width: 100%; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 13px; text-align: left; cursor: pointer" onClick="{{newPlan}}">
|
|
66
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex: none; color: var(--muted)"><path d="M14 3H6v18h12V7z"></path><path d="M14 3v4h4M12 11v6M9 14h6"></path></svg><span style="flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">New</span>
|
|
67
|
+
</button>
|
|
68
|
+
<button role="menuitem" class="tb" style="width: 100%; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 13px; text-align: left; cursor: pointer" onClick="{{showOpen}}">
|
|
69
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex: none; color: var(--muted)"><path d="M3 6h6l2 2h10v11H3z"></path></svg><span style="flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">Open…</span>
|
|
70
|
+
</button>
|
|
71
|
+
<sc-if value="{{canSaveFile}}" hint-placeholder-val="{{false}}">
|
|
72
|
+
<button role="menuitem" class="tb" style="width: 100%; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 13px; text-align: left; cursor: pointer" onClick="{{saveFile}}">
|
|
73
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex: none; color: var(--muted)"><path d="M5 3h11l3 3v15H5z"></path><path d="M8 3v5h7V3M8 21v-7h8v7"></path></svg><span style="flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">Save to {{saveFileName}}</span>
|
|
74
|
+
</button>
|
|
75
|
+
</sc-if>
|
|
76
|
+
<button role="menuitem" class="tb" style="width: 100%; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 13px; text-align: left; cursor: pointer" onClick="{{toggleSave}}" aria-expanded="{{saveOpen}}">
|
|
77
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex: none; color: var(--muted)"><path d="M5 3h11l3 3v15H5z"></path><path d="M8 3v5h7V3M8 21v-7h8v7"></path></svg><span style="flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">Save in this browser…</span>
|
|
78
|
+
</button>
|
|
79
|
+
<button role="menuitem" class="tb" style="width: 100%; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 13px; text-align: left; cursor: pointer" onClick="{{download}}">
|
|
80
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex: none; color: var(--muted)"><path d="M12 4v11M7 10l5 5 5-5M5 20h14"></path></svg><span style="flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">Download {{fileName}}</span>
|
|
81
|
+
</button>
|
|
82
|
+
<button role="menuitem" class="tb" style="width: 100%; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 13px; text-align: left; cursor: pointer" onClick="{{copyLink}}">
|
|
83
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex: none; color: var(--muted)"><path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"></path><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"></path></svg><span style="flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">Copy link</span>
|
|
84
|
+
</button>
|
|
85
|
+
<button role="menuitem" class="tb" style="width: 100%; height: 34px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 13px; text-align: left; cursor: pointer" onClick="{{designCard}}">
|
|
86
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex: none; color: var(--muted)"><rect x="3" y="5" width="18" height="14" rx="2"></rect><path d="M7 15v-3M11 15V9M15 15v-5"></path></svg><span style="flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">Design card…</span>
|
|
87
|
+
</button>
|
|
88
|
+
<sc-if value="{{hasLinkNote}}" hint-placeholder-val="{{false}}"><span role="status" style="padding: 6px 10px 4px; font-size: 12px; line-height: 1.45; color: {{linkNoteColor}}">{{linkNote}}</span></sc-if>
|
|
89
|
+
<sc-if value="{{saveOpen}}" hint-placeholder-val="{{false}}">
|
|
90
|
+
<div style="display: flex; flex-direction: column; gap: 8px; margin-top: 4px; padding: 8px 4px 4px; border-top: 1px solid var(--rule-soft)">
|
|
91
|
+
<label for="save-name" style="font-size: 12px; font-weight: 600; color: var(--muted)">Save in this browser as</label>
|
|
92
|
+
<div style="display: flex; gap: 6px">
|
|
93
|
+
<input id="save-name" value="{{saveName}}" onChange="{{onSaveName}}" autoFocus="{{true}}" autocomplete="off" style="flex: 1; min-width: 0; height: 32px; padding: 0 8px; border: 1px solid var(--control); border-radius: 8px; font: inherit; font-size: 13px">
|
|
94
|
+
<button onClick="{{doSave}}" style="height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--ink); color: var(--on-ink); font-size: 13px; font-weight: 600; cursor: pointer">{{saveLabel}}</button>
|
|
95
|
+
</div>
|
|
96
|
+
<sc-if value="{{hasSaveError}}" hint-placeholder-val="{{false}}"><span role="alert" style="font-size: 12px; color: var(--bad)">{{saveError}}</span></sc-if>
|
|
97
|
+
<span style="font-size: 11.5px; line-height: 1.45; color: var(--muted)">Kept in this browser only, so reopen it from <strong>Open</strong> here. Download the file to keep it anywhere else.</span>
|
|
98
|
+
</div>
|
|
99
|
+
</sc-if>
|
|
100
|
+
</div>
|
|
101
|
+
</sc-if>
|
|
102
|
+
</div>
|
|
103
|
+
<div style="display: flex; align-items: center; gap: 8px; flex: 1 1 340px; min-width: 0; height: 32px; padding: 0 4px 0 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--bg); font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px">
|
|
104
|
+
<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" style="flex: none; color: var(--muted)"><circle cx="11" cy="11" r="7"></circle><path d="M20 20l-3.5-3.5"></path></svg>
|
|
105
|
+
<label for="task-filter" style="position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0)">Filter tasks</label>
|
|
106
|
+
<input id="task-filter" type="search" value="{{query}}" onChange="{{onQuery}}" onKeyDown="{{onQueryKey}}" placeholder="Filter tasks by name, id or section…" spellcheck="false" autocomplete="off" style="flex: 1; min-width: 0; height: 28px; padding: 0; border: 0; background: transparent; color: var(--ink); font-family: 'Instrument Sans', system-ui, sans-serif; font-size: 13px; outline: none">
|
|
107
|
+
<sc-if value="{{hasFilter}}" hint-placeholder-val="{{false}}">
|
|
108
|
+
<span style="flex: none; color: var(--muted)">{{matchNote}}</span>
|
|
109
|
+
</sc-if>
|
|
110
|
+
<sc-if value="{{hasQuery}}" hint-placeholder-val="{{false}}">
|
|
111
|
+
<button class="tb" onClick="{{clearQuery}}" aria-label="Clear filter" title="Clear filter" style="flex: none; width: 24px; height: 24px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; padding: 0">
|
|
112
|
+
<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M6 6l12 12M18 6 6 18"></path></svg>
|
|
113
|
+
</button>
|
|
114
|
+
</sc-if>
|
|
115
|
+
<span title="{{srcTitle}}. {{statusTip}}" style="flex: none; display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: 6px; font-family: 'Instrument Sans', system-ui, sans-serif; font-size: 12px; font-weight: 500; background: {{statusBg}}; color: {{statusFg}}">
|
|
116
|
+
<span style="width: 6px; height: 6px; border-radius: 3px; background: {{statusDot}}"></span>{{statusLabel}}
|
|
117
|
+
</span>
|
|
118
|
+
</div>
|
|
119
|
+
<div onKeyDown="{{onTagsKey}}" style="position: relative; flex: none">
|
|
120
|
+
<div role="group" style="display: flex; align-items: center; height: 32px; border: 1px solid {{tagsBd}}; border-radius: 8px; background: var(--surface)">
|
|
121
|
+
<button class="tb" onClick="{{toggleTags}}" aria-haspopup="true" aria-expanded="{{tagsExpanded}}" title="Filter tasks by tag" style="height: 30px; display: flex; align-items: center; gap: 6px; padding: 0 8px 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer">
|
|
122
|
+
<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12V4h8l10 10-8 8z"></path><circle cx="7.5" cy="8.5" r="1.2"></circle></svg>{{tagsLabel}}
|
|
123
|
+
<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"></path></svg>
|
|
124
|
+
</button>
|
|
125
|
+
<sc-if value="{{hasTagFilter}}" hint-placeholder-val="{{false}}">
|
|
126
|
+
<button class="tb" onClick="{{clearTags}}" aria-label="Clear the tag filter" title="Clear the tag filter" style="width: 26px; height: 26px; margin-right: 2px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; padding: 0">
|
|
127
|
+
<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M6 6l12 12M18 6 6 18"></path></svg>
|
|
128
|
+
</button>
|
|
129
|
+
</sc-if>
|
|
130
|
+
</div>
|
|
131
|
+
<sc-if value="{{tagsOpen}}" hint-placeholder-val="{{false}}">
|
|
132
|
+
<div onClick="{{closeTags}}" style="position: fixed; inset: 0; z-index: 39"></div>
|
|
133
|
+
<div role="group" aria-label="Tags to show" style="position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: 240px; max-height: 320px; overflow: auto; box-sizing: border-box; padding: 6px; background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 12px 32px var(--shadow)">
|
|
134
|
+
<sc-for list="{{tagOptions}}" as="tg" hint-placeholder-count="4">
|
|
135
|
+
<label for="{{tg.inputId}}" class="tb" style="display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 8px; border-radius: 6px; font-size: 13px; cursor: pointer">
|
|
136
|
+
<input type="checkbox" id="{{tg.inputId}}" checked="{{tg.checked}}" onChange="{{tg.toggle}}" style="margin: 0; accent-color: var(--ink)">
|
|
137
|
+
<span style="flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">{{tg.tag}}</span>
|
|
138
|
+
<span style="font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px; color: var(--muted)">{{tg.count}}</span>
|
|
139
|
+
</label>
|
|
140
|
+
</sc-for>
|
|
141
|
+
<sc-if value="{{noTags}}" hint-placeholder-val="{{false}}">
|
|
142
|
+
<p style="margin: 0; padding: 8px; font-size: 12px; color: var(--muted)">No tags yet. Add them to tasks in the inspector.</p>
|
|
143
|
+
</sc-if>
|
|
144
|
+
<sc-if value="{{hasTagFilter}}" hint-placeholder-val="{{false}}">
|
|
145
|
+
<button class="tb" onClick="{{clearTags}}" style="width: 100%; height: 30px; margin-top: 4px; border: 0; border-top: 1px solid var(--rule-soft); border-radius: 0 0 6px 6px; background: transparent; color: var(--ink); font-size: 12px; font-weight: 600; cursor: pointer">Clear</button>
|
|
146
|
+
</sc-if>
|
|
147
|
+
</div>
|
|
148
|
+
</sc-if>
|
|
149
|
+
</div>
|
|
150
|
+
<div style="display: flex; flex-wrap: wrap; align-items: center; gap: 8px">
|
|
151
|
+
<div role="group" aria-label="Theme" style="display: flex; align-items: center; gap: 4px">
|
|
152
|
+
<sc-for list="{{themes}}" as="th" hint-placeholder-count="4">
|
|
153
|
+
<button class="tb" onClick="{{th.pick}}" aria-pressed="{{th.pressed}}" aria-label="{{th.label}} theme" title="{{th.label}}" style="height: 32px; display: flex; align-items: center; gap: 6px; padding: 0 6px; border: 1px solid {{th.bd}}; border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 600; cursor: pointer">
|
|
154
|
+
<span aria-hidden="true" style="position: relative; width: 18px; height: 18px; border-radius: 4px; background: {{th.bg}}; border: 1px solid var(--rule); overflow: hidden"><span style="position: absolute; left: 3px; top: 3px; width: 8px; height: 8px; border-radius: 2px; background: {{th.ink}}"></span><span style="position: absolute; right: 2px; bottom: 2px; width: 6px; height: 6px; border-radius: 3px; background: {{th.accent}}"></span></span>
|
|
155
|
+
<sc-if value="{{th.on}}" hint-placeholder-val="{{false}}"><span>{{th.label}}</span></sc-if>
|
|
156
|
+
</button>
|
|
157
|
+
</sc-for>
|
|
158
|
+
</div>
|
|
159
|
+
<div style="display: flex; gap: 4px">
|
|
160
|
+
<button class="tb" onClick="{{undo}}" disabled="{{cantUndo}}" aria-label="Undo" title="Undo" style="width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--control); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; padding: 0">
|
|
161
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 14 4 9l5-5"></path><path d="M4 9h10a6 6 0 0 1 0 12h-3"></path></svg>
|
|
162
|
+
</button>
|
|
163
|
+
<button class="tb" onClick="{{redo}}" disabled="{{cantRedo}}" aria-label="Redo" title="Redo" style="width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--control); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; padding: 0">
|
|
164
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m15 14 5-5-5-5"></path><path d="M20 9H10a6 6 0 0 0 0 12h3"></path></svg>
|
|
165
|
+
</button>
|
|
166
|
+
</div>
|
|
167
|
+
<div role="group" aria-label="Zoom" style="display: flex; padding: 2px; border: 1px solid var(--control); border-radius: 8px; background: var(--surface)">
|
|
168
|
+
<button onClick="{{zoomDay}}" aria-pressed="{{zoomDayPressed}}" style="height: 26px; padding: 0 10px; border: 0; border-radius: 6px; font-size: 12px; font-weight: 500; cursor: pointer; background: {{zoomDayBg}}; color: {{zoomDayFg}}">Days</button>
|
|
169
|
+
<button onClick="{{zoomWeek}}" aria-pressed="{{zoomWeekPressed}}" style="height: 26px; padding: 0 10px; border: 0; border-radius: 6px; font-size: 12px; font-weight: 500; cursor: pointer; background: {{zoomWeekBg}}; color: {{zoomWeekFg}}">Weeks</button>
|
|
170
|
+
</div>
|
|
171
|
+
<div role="group" aria-label="Layout" style="display: flex; padding: 2px; border: 1px solid var(--control); border-radius: 8px; background: var(--surface)">
|
|
172
|
+
<button onClick="{{viewChart}}" aria-pressed="{{viewChartPressed}}" style="height: 26px; padding: 0 10px; border: 0; border-radius: 6px; font-size: 12px; font-weight: 500; cursor: pointer; background: {{viewChartBg}}; color: {{viewChartFg}}">Chart</button>
|
|
173
|
+
<button onClick="{{viewSplit}}" aria-pressed="{{viewSplitPressed}}" style="height: 26px; padding: 0 10px; border: 0; border-radius: 6px; font-size: 12px; font-weight: 500; cursor: pointer; background: {{viewSplitBg}}; color: {{viewSplitFg}}">Chart + Markdown</button>
|
|
174
|
+
</div>
|
|
175
|
+
<button onClick="{{addTask}}" title="{{addTitle}}" style="height: 32px; display: flex; align-items: center; gap: 6px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--ink); color: var(--on-ink); font-size: 13px; font-weight: 600; cursor: pointer">
|
|
176
|
+
<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M12 5v14M5 12h14"></path></svg>{{addLabel}}
|
|
177
|
+
</button>
|
|
178
|
+
</div>
|
|
179
|
+
</header>
|
|
180
|
+
|
|
181
|
+
<div style="flex: 1; min-height: 0; display: flex; flex-wrap: wrap">
|
|
182
|
+
<section aria-label="Timeline" style="flex: 999 1 560px; min-width: 0; min-height: 0; height: 100%; position: relative; display: flex; flex-direction: column">
|
|
183
|
+
<div onPointerMove="{{onMove}}" onPointerUp="{{onUp}}" onPointerCancel="{{onUp}}" style="flex: 1; min-height: 0; overflow: auto; background: var(--surface); user-select: none; touch-action: pan-y">
|
|
184
|
+
<div style="display: flex; width: {{totalW}}px; min-height: 100%">
|
|
185
|
+
|
|
186
|
+
<div style="position: sticky; left: 0; z-index: 3; width: 280px; flex: none; background: var(--surface); border-right: 1px solid var(--rule)">
|
|
187
|
+
<div style="position: sticky; top: 0; z-index: 4; height: 56px; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 0 8px 6px 16px; box-sizing: border-box; background: var(--surface); border-bottom: 1px solid var(--rule)">
|
|
188
|
+
<span style="padding-bottom: 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted)">Task</span>
|
|
189
|
+
<button class="tb" onClick="{{addSection}}" title="Add a ## section at the end of the plan" style="height: 28px; display: flex; align-items: center; gap: 4px; padding: 0 8px; border: 1px solid var(--control); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 600; cursor: pointer">
|
|
190
|
+
<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round"><path d="M12 5v14M5 12h14"></path></svg>New section
|
|
191
|
+
</button>
|
|
192
|
+
</div>
|
|
193
|
+
<sc-for list="{{rows}}" as="r" hint-placeholder-count="14">
|
|
194
|
+
<sc-if value="{{r.isGroup}}" hint-placeholder-val="{{false}}">
|
|
195
|
+
<div class="sec" style="height: 32px; display: flex; align-items: center; gap: 2px; padding: 0 6px 0 10px; box-sizing: border-box; background: var(--bg); border-bottom: 1px solid var(--rule)">
|
|
196
|
+
<label for="{{r.inputId}}" style="position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0)">Section name</label>
|
|
197
|
+
<input id="{{r.inputId}}" value="{{r.name}}" onChange="{{r.onRename}}" onFocus="{{r.onFocusSel}}" autoFocus="{{r.autoFocus}}" placeholder="Section name" style="flex: 1; min-width: 0; height: 26px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; font-family: inherit; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2)">
|
|
198
|
+
<button class="tb" onClick="{{r.onAdd}}" aria-label="{{r.addLabel}}" title="{{r.addLabel}}" style="flex: none; width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); cursor: pointer; padding: 0">
|
|
199
|
+
<svg aria-hidden="true" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M12 5v14M5 12h14"></path></svg>
|
|
200
|
+
</button>
|
|
201
|
+
<button class="tb secdel" onClick="{{r.onDelete}}" aria-label="{{r.delLabel}}" title="{{r.delLabel}}" style="flex: none; width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--bad); cursor: pointer; padding: 0">
|
|
202
|
+
<svg aria-hidden="true" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13"></path></svg>
|
|
203
|
+
</button>
|
|
204
|
+
</div>
|
|
205
|
+
</sc-if>
|
|
206
|
+
<sc-if value="{{r.isTask}}" hint-placeholder-val="{{true}}">
|
|
207
|
+
<div style="height: 40px; display: flex; align-items: center; gap: 6px; padding: 0 8px 0 2px; box-sizing: border-box; border-bottom: 1px solid var(--rule-soft); background: {{r.listBg}}; opacity: {{r.opacity}}">
|
|
208
|
+
<button class="grip" onPointerDown="{{r.onGrip}}" onKeyDown="{{r.onGripKey}}" aria-label="{{r.gripLabel}}" title="Drag to reorder" style="flex: none; width: 20px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--faint); cursor: grab; padding: 0; touch-action: none">
|
|
209
|
+
<svg aria-hidden="true" width="10" height="16" viewBox="0 0 10 16" fill="currentColor"><circle cx="3" cy="3" r="1.4"></circle><circle cx="7" cy="3" r="1.4"></circle><circle cx="3" cy="8" r="1.4"></circle><circle cx="7" cy="8" r="1.4"></circle><circle cx="3" cy="13" r="1.4"></circle><circle cx="7" cy="13" r="1.4"></circle></svg>
|
|
210
|
+
</button>
|
|
211
|
+
<input type="checkbox" checked="{{r.done}}" onChange="{{r.toggleDone}}" aria-label="{{r.doneLabel}}" style="width: 15px; height: 15px; margin: 0; accent-color: var(--ink); flex: none">
|
|
212
|
+
<button onClick="{{r.select}}" onKeyDown="{{r.onKey}}" style="flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; display: flex; flex-direction: column; gap: 1px; color: inherit">
|
|
213
|
+
<span style="font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; text-decoration: {{r.strike}}; color: {{r.nameColor}}">{{r.name}}</span>
|
|
214
|
+
<span style="font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; color: {{r.metaColor}}">{{r.meta}}</span>
|
|
215
|
+
</button>
|
|
216
|
+
<button class="tb" onClick="{{r.toggleAnchor}}" disabled="{{r.anchorDisabled}}" aria-pressed="{{r.anchoredStr}}" aria-label="{{r.anchorLabel}}" title="{{r.anchorLabel}}" style="flex: none; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; cursor: pointer; padding: 0; color: {{r.pinColor}}; background: {{r.pinBg}}">
|
|
217
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 3h6l-1 6 3 3v2H7v-2l3-3-1-6z"></path><path d="M12 14v7"></path></svg>
|
|
218
|
+
</button>
|
|
219
|
+
</div>
|
|
220
|
+
</sc-if>
|
|
221
|
+
</sc-for>
|
|
222
|
+
<sc-if value="{{reorder.showLine}}" hint-placeholder-val="{{false}}">
|
|
223
|
+
<div aria-hidden="true" style="position: absolute; z-index: 5; left: 8px; right: 8px; top: {{reorder.lineY}}px; height: 2px; border-radius: 1px; background: var(--accent); pointer-events: none">
|
|
224
|
+
<span style="position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 4px; background: var(--accent)"></span>
|
|
225
|
+
</div>
|
|
226
|
+
</sc-if>
|
|
227
|
+
<sc-if value="{{isReordering}}" hint-placeholder-val="{{false}}">
|
|
228
|
+
<div aria-hidden="true" style="position: absolute; z-index: 6; left: 6px; right: 6px; top: {{reorder.ghostY}}px; height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 12px; box-sizing: border-box; border-radius: 8px; background: var(--surface); box-shadow: 0 10px 24px var(--shadow), 0 0 0 1px var(--control); font-size: 13px; font-weight: 600; pointer-events: none; cursor: grabbing">
|
|
229
|
+
<svg width="10" height="16" viewBox="0 0 10 16" style="fill: var(--faint)"><circle cx="3" cy="3" r="1.4"></circle><circle cx="7" cy="3" r="1.4"></circle><circle cx="3" cy="8" r="1.4"></circle><circle cx="7" cy="8" r="1.4"></circle><circle cx="3" cy="13" r="1.4"></circle><circle cx="7" cy="13" r="1.4"></circle></svg>
|
|
230
|
+
<span style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">{{reorder.name}}</span>
|
|
231
|
+
</div>
|
|
232
|
+
</sc-if>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
<div style="position: relative; flex: none; width: {{tlW}}px">
|
|
236
|
+
<div style="position: sticky; top: 0; z-index: 2; height: 56px; background: var(--surface); border-bottom: 1px solid var(--rule)">
|
|
237
|
+
<sc-for list="{{months}}" as="m" hint-placeholder-count="3">
|
|
238
|
+
<div style="position: absolute; top: 8px; left: {{m.x}}px; padding-left: 8px; font-size: 12px; font-weight: 600; white-space: nowrap; border-left: 1px solid var(--control); height: 18px; line-height: 18px">{{m.label}}</div>
|
|
239
|
+
</sc-for>
|
|
240
|
+
<sc-for list="{{ticks}}" as="k" hint-placeholder-count="30">
|
|
241
|
+
<div style="position: absolute; top: 32px; left: {{k.x}}px; width: {{k.w}}px; text-align: {{k.align}}; font-size: 11px; font-family: 'JetBrains Mono', ui-monospace, monospace; color: {{k.color}}; box-sizing: border-box; padding-left: {{k.pad}}px">{{k.label}}</div>
|
|
242
|
+
</sc-for>
|
|
243
|
+
<div style="position: absolute; top: 4px; left: {{todayChipX}}px; height: 18px; padding: 0 6px; border-radius: 4px; background: var(--today); color: #FFFFFF; font-size: 11px; font-weight: 600; line-height: 18px; white-space: nowrap">Today</div>
|
|
244
|
+
</div>
|
|
245
|
+
|
|
246
|
+
<div style="position: relative; height: {{bodyH}}px">
|
|
247
|
+
<sc-for list="{{weekends}}" as="w" hint-placeholder-count="10">
|
|
248
|
+
<div style="position: absolute; top: 0; bottom: 0; left: {{w.x}}px; width: {{w.w}}px; background: var(--bg)"></div>
|
|
249
|
+
</sc-for>
|
|
250
|
+
<sc-for list="{{rows}}" as="r" hint-placeholder-count="14">
|
|
251
|
+
<div style="position: absolute; left: 0; right: 0; top: {{r.y}}px; height: {{r.h}}px; box-sizing: border-box; border-bottom: 1px solid var(--rule-soft); background: {{r.laneBg}}"></div>
|
|
252
|
+
</sc-for>
|
|
253
|
+
<div style="position: absolute; top: 0; bottom: 0; left: {{todayX}}px; width: 0; border-left: 1.5px solid var(--today); z-index: 1"></div>
|
|
254
|
+
|
|
255
|
+
<sc-for list="{{groupBars}}" as="g" hint-placeholder-count="4">
|
|
256
|
+
<div style="position: absolute; left: {{g.x}}px; top: {{g.y}}px; width: {{g.w}}px; height: 6px; border-radius: 3px; background: var(--ink); opacity: .8"></div>
|
|
257
|
+
</sc-for>
|
|
258
|
+
|
|
259
|
+
<sc-for list="{{segs}}" as="s" hint-placeholder-count="12">
|
|
260
|
+
<div style="position: absolute; z-index: 1; pointer-events: none; left: {{s.x}}px; top: {{s.y}}px; width: {{s.w}}px; height: {{s.h}}px; border-top: {{s.bt}}; border-left: {{s.bl}}"></div>
|
|
261
|
+
</sc-for>
|
|
262
|
+
<sc-for list="{{heads}}" as="hd" hint-placeholder-count="12">
|
|
263
|
+
<div style="position: absolute; z-index: 1; pointer-events: none; left: {{hd.x}}px; top: {{hd.y}}px; width: 0; height: 0; border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 6px solid {{hd.c}}"></div>
|
|
264
|
+
</sc-for>
|
|
265
|
+
|
|
266
|
+
<sc-if value="{{hasGhost}}" hint-placeholder-val="{{false}}">
|
|
267
|
+
<div style="position: absolute; z-index: 1; left: {{ghost.x}}px; top: {{ghost.y}}px; width: {{ghost.w}}px; height: 24px; box-sizing: border-box; border: 1.5px dashed var(--faint); border-radius: 6px"></div>
|
|
268
|
+
</sc-if>
|
|
269
|
+
|
|
270
|
+
<sc-for list="{{bars}}" as="b" hint-placeholder-count="10">
|
|
271
|
+
<sc-if value="{{b.isBar}}" hint-placeholder-val="{{true}}">
|
|
272
|
+
<button class="bar" onPointerDown="{{b.onDown}}" onClick="{{b.select}}" onKeyDown="{{b.onKey}}" aria-label="{{b.aria}}" style="position: absolute; z-index: 2; left: {{b.x}}px; top: {{b.y}}px; width: {{b.w}}px; height: 24px; box-sizing: border-box; border: 0; border-radius: 6px; padding: 0 8px; display: flex; align-items: center; gap: 5px; overflow: hidden; font-size: 12px; font-weight: 600; white-space: nowrap; text-align: left; cursor: grab; background: {{b.bg}}; color: {{b.fg}}; box-shadow: {{b.ring}}; opacity: {{b.dim}}">
|
|
273
|
+
<sc-if value="{{b.fixed}}" hint-placeholder-val="{{false}}">
|
|
274
|
+
<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" style="flex: none"><path d="M9 3h6l-1 6 3 3v2H7v-2l3-3-1-6z"></path><path d="M12 14v7"></path></svg>
|
|
275
|
+
</sc-if>
|
|
276
|
+
<sc-if value="{{b.labelInside}}" hint-placeholder-val="{{true}}">
|
|
277
|
+
<span style="overflow: hidden; text-overflow: ellipsis">{{b.name}}</span>
|
|
278
|
+
</sc-if>
|
|
279
|
+
<span class="rs" aria-hidden="true" onPointerDown="{{b.onResize}}" style="position: absolute; right: 0; top: 0; bottom: 0; width: 10px; cursor: ew-resize; display: grid; place-items: center"><span style="width: 2px; height: 12px; border-radius: 1px; background: currentColor; opacity: .7"></span></span>
|
|
280
|
+
</button>
|
|
281
|
+
</sc-if>
|
|
282
|
+
<sc-if value="{{b.isMilestone}}" hint-placeholder-val="{{false}}">
|
|
283
|
+
<button class="bar" onPointerDown="{{b.onDown}}" onClick="{{b.select}}" onKeyDown="{{b.onKey}}" aria-label="{{b.aria}}" style="position: absolute; z-index: 2; left: {{b.mx}}px; top: {{b.my}}px; width: 18px; height: 18px; border: 0; padding: 0; border-radius: 3px; transform: rotate(45deg); cursor: grab; background: {{b.bg}}; box-shadow: {{b.ring}}; opacity: {{b.dim}}"></button>
|
|
284
|
+
</sc-if>
|
|
285
|
+
<sc-if value="{{b.labelOutside}}" hint-placeholder-val="{{false}}">
|
|
286
|
+
<span style="position: absolute; z-index: 2; pointer-events: none; left: {{b.lx}}px; top: {{b.ly}}px; font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--ink); opacity: {{b.dim}}">{{b.name}}</span>
|
|
287
|
+
</sc-if>
|
|
288
|
+
</sc-for>
|
|
289
|
+
</div>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
|
|
294
|
+
<footer style="flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 8px 16px; border-top: 1px solid var(--rule); background: var(--surface); font-size: 12px; color: var(--muted)">
|
|
295
|
+
<div style="display: flex; flex-wrap: wrap; align-items: center; gap: 14px">
|
|
296
|
+
<span style="display: flex; align-items: center; gap: 6px"><span style="width: 18px; height: 10px; border-radius: 3px; background: {{relColor}}"></span>Relative</span>
|
|
297
|
+
<span style="display: flex; align-items: center; gap: 6px"><span style="width: 18px; height: 10px; border-radius: 3px; background: {{fixedColor}}"></span>Fixed date</span>
|
|
298
|
+
<span style="display: flex; align-items: center; gap: 6px"><span style="width: 9px; height: 9px; border-radius: 2px; transform: rotate(45deg); background: var(--ink)"></span>Milestone</span>
|
|
299
|
+
<span style="display: flex; align-items: center; gap: 6px"><span style="width: 18px; height: 10px; border-radius: 3px; box-shadow: 0 0 0 2px var(--today)"></span>Conflict</span>
|
|
300
|
+
</div>
|
|
301
|
+
<span style="flex: 1; min-width: 200px; text-align: right; color: {{hintColor}}; font-weight: {{hintWeight}}">{{hint}}</span>
|
|
302
|
+
</footer>
|
|
303
|
+
|
|
304
|
+
<sc-if value="{{hasInsp}}" hint-placeholder-val="{{false}}">
|
|
305
|
+
<aside aria-label="Task inspector" style="position: absolute; z-index: 6; top: 68px; right: 16px; width: 320px; max-width: calc(100% - 32px); max-height: calc(100% - 132px); overflow: auto; box-sizing: border-box; background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; box-shadow: 0 12px 32px var(--shadow), 0 2px 6px var(--shadow); display: flex; flex-direction: column">
|
|
306
|
+
<div style="display: flex; align-items: center; gap: 8px; padding: 12px 12px 0 16px">
|
|
307
|
+
<span style="flex: 1; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted)">{{insp.kind}}</span>
|
|
308
|
+
<button class="tb" onClick="{{insp.close}}" aria-label="Close inspector" style="width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; padding: 0">
|
|
309
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12M18 6 6 18"></path></svg>
|
|
310
|
+
</button>
|
|
311
|
+
</div>
|
|
312
|
+
<div style="padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 16px">
|
|
313
|
+
<div style="display: flex; flex-direction: column; gap: 4px">
|
|
314
|
+
<label for="insp-name" style="font-size: 12px; font-weight: 500; color: var(--muted)">Name</label>
|
|
315
|
+
<input id="insp-name" value="{{insp.name}}" onChange="{{insp.onName}}" style="height: 36px; padding: 0 10px; border: 1px solid var(--control); border-radius: 8px; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink)">
|
|
316
|
+
<sc-if value="{{insp.hasNameError}}" hint-placeholder-val="{{false}}">
|
|
317
|
+
<span style="font-size: 12px; color: var(--bad)">{{insp.nameError}}</span>
|
|
318
|
+
</sc-if>
|
|
319
|
+
</div>
|
|
320
|
+
|
|
321
|
+
<div style="display: flex; flex-direction: column; gap: 8px">
|
|
322
|
+
<span style="font-size: 12px; font-weight: 500; color: var(--muted)">Start</span>
|
|
323
|
+
<div role="group" aria-label="Scheduling mode" style="display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 3px; border-radius: 10px; background: var(--seg-bg)">
|
|
324
|
+
<button onClick="{{insp.setRel}}" disabled="{{insp.relDisabled}}" aria-pressed="{{insp.relPressed}}" title="{{insp.relHint}}" style="height: 32px; border: 0; border-radius: 7px; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; background: {{insp.relBg}}; color: {{insp.relFg}}; box-shadow: {{insp.relShadow}}">
|
|
325
|
+
<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-1 1"></path><path d="M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l1-1"></path></svg>Relative
|
|
326
|
+
</button>
|
|
327
|
+
<button onClick="{{insp.setFixed}}" aria-pressed="{{insp.fixedPressed}}" style="height: 32px; border: 0; border-radius: 7px; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; background: {{insp.fixedBg}}; color: {{insp.fixedFg}}; box-shadow: {{insp.fixedShadow}}">
|
|
328
|
+
<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 3h6l-1 6 3 3v2H7v-2l3-3-1-6z"></path><path d="M12 14v7"></path></svg>Fixed date
|
|
329
|
+
</button>
|
|
330
|
+
</div>
|
|
331
|
+
<sc-if value="{{insp.isFixed}}" hint-placeholder-val="{{false}}">
|
|
332
|
+
<div style="display: flex; flex-direction: column; gap: 4px">
|
|
333
|
+
<label for="insp-start" style="font-size: 12px; color: var(--muted)">Anchored to</label>
|
|
334
|
+
<input id="insp-start" type="date" value="{{insp.startIso}}" onChange="{{insp.onStart}}" style="height: 36px; padding: 0 10px; border: 1px solid var(--control); border-radius: 8px; font: inherit; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; color: var(--ink)">
|
|
335
|
+
</div>
|
|
336
|
+
</sc-if>
|
|
337
|
+
<sc-if value="{{insp.isRel}}" hint-placeholder-val="{{true}}">
|
|
338
|
+
<div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap">
|
|
339
|
+
<label for="insp-offset" style="font-size: 13px">Starts</label>
|
|
340
|
+
<input id="insp-offset" type="number" step="1" value="{{insp.offset}}" onChange="{{insp.onOffset}}" style="width: 64px; height: 32px; padding: 0 8px; border: 1px solid var(--control); border-radius: 8px; font: inherit; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; color: var(--ink)">
|
|
341
|
+
<span style="font-size: 13px">days after the latest dependency</span>
|
|
342
|
+
</div>
|
|
343
|
+
</sc-if>
|
|
344
|
+
<span style="font-size: 12px; color: var(--muted); font-family: 'JetBrains Mono', ui-monospace, monospace">{{insp.syntax}}</span>
|
|
345
|
+
</div>
|
|
346
|
+
|
|
347
|
+
<div style="display: flex; flex-direction: column; gap: 8px">
|
|
348
|
+
<span style="font-size: 12px; font-weight: 500; color: var(--muted)">{{insp.depsTitle}}</span>
|
|
349
|
+
<div style="display: flex; flex-wrap: wrap; gap: 6px">
|
|
350
|
+
<sc-for list="{{insp.deps}}" as="d" hint-placeholder-count="1">
|
|
351
|
+
<span style="display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 2px 0 10px; border-radius: 14px; background: var(--info-bg); color: var(--info-fg); font-size: 12px; font-weight: 500">{{d.name}}
|
|
352
|
+
<button onClick="{{d.flip}}" aria-label="{{d.flipLabel}}" title="{{d.flipLabel}}" style="height: 20px; padding: 0 6px; border: 1px solid currentColor; border-radius: 10px; background: transparent; color: inherit; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; cursor: pointer; opacity: .85">{{d.anchor}}</button>
|
|
353
|
+
<button onClick="{{d.remove}}" aria-label="{{d.removeLabel}}" style="width: 24px; height: 24px; display: grid; place-items: center; border: 0; border-radius: 12px; background: transparent; color: inherit; cursor: pointer; padding: 0">
|
|
354
|
+
<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M6 6l12 12M18 6 6 18"></path></svg>
|
|
355
|
+
</button>
|
|
356
|
+
</span>
|
|
357
|
+
</sc-for>
|
|
358
|
+
<sc-if value="{{insp.noDeps}}" hint-placeholder-val="{{false}}">
|
|
359
|
+
<span style="font-size: 12px; color: var(--muted)">None — this task stands on its own.</span>
|
|
360
|
+
</sc-if>
|
|
361
|
+
</div>
|
|
362
|
+
<sc-if value="{{insp.hasDepOptions}}" hint-placeholder-val="{{true}}">
|
|
363
|
+
<label for="insp-adddep" style="position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0)">Add dependency</label>
|
|
364
|
+
<select id="insp-adddep" value="" onChange="{{insp.addDep}}" style="height: 32px; padding: 0 8px; border: 1px dashed var(--control-strong); border-radius: 8px; background: var(--surface); font: inherit; font-size: 13px; color: var(--ink); cursor: pointer">
|
|
365
|
+
<option value="">+ Add dependency…</option>
|
|
366
|
+
<sc-for list="{{insp.depOptions}}" as="o" hint-placeholder-count="4">
|
|
367
|
+
<option value="{{o.value}}">{{o.name}}</option>
|
|
368
|
+
</sc-for>
|
|
369
|
+
</select>
|
|
370
|
+
</sc-if>
|
|
371
|
+
<sc-if value="{{insp.hasDropHint}}" hint-placeholder-val="{{false}}">
|
|
372
|
+
<span style="font-size: 12px; color: var(--muted)">Removing the last dependency anchors this task where it is.</span>
|
|
373
|
+
</sc-if>
|
|
374
|
+
</div>
|
|
375
|
+
|
|
376
|
+
<div style="display: flex; flex-direction: column; gap: 8px">
|
|
377
|
+
<label for="insp-tag" style="font-size: 12px; font-weight: 500; color: var(--muted)">Tags</label>
|
|
378
|
+
<sc-if value="{{insp.hasTags}}" hint-placeholder-val="{{false}}">
|
|
379
|
+
<div style="display: flex; flex-wrap: wrap; gap: 6px">
|
|
380
|
+
<sc-for list="{{insp.tags}}" as="tg" hint-placeholder-count="2">
|
|
381
|
+
<span style="display: inline-flex; align-items: center; gap: 2px; height: 26px; padding: 0 2px 0 8px; border: 1px solid var(--rule); border-radius: 13px; background: var(--surface-2); font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px">{{tg.tag}}
|
|
382
|
+
<button onClick="{{tg.remove}}" aria-label="{{tg.removeLabel}}" title="{{tg.removeLabel}}" style="width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer; padding: 0">
|
|
383
|
+
<svg aria-hidden="true" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M6 6l12 12M18 6 6 18"></path></svg>
|
|
384
|
+
</button>
|
|
385
|
+
</span>
|
|
386
|
+
</sc-for>
|
|
387
|
+
</div>
|
|
388
|
+
</sc-if>
|
|
389
|
+
<input id="insp-tag" value="{{insp.tagDraft}}" onChange="{{insp.onTagDraft}}" onKeyDown="{{insp.onTagKey}}" onBlur="{{insp.onTagBlur}}" placeholder="Add a tag, then Enter" autocomplete="off" style="height: 32px; padding: 0 8px; border: 1px solid var(--control); border-radius: 8px; font: inherit; font-size: 13px">
|
|
390
|
+
</div>
|
|
391
|
+
|
|
392
|
+
<div style="display: flex; flex-direction: column; gap: 8px">
|
|
393
|
+
<span style="font-size: 12px; font-weight: 500; color: var(--muted)">Links</span>
|
|
394
|
+
<sc-if value="{{insp.hasLinks}}" hint-placeholder-val="{{false}}">
|
|
395
|
+
<div style="display: flex; flex-direction: column; gap: 4px">
|
|
396
|
+
<sc-for list="{{insp.links}}" as="lk" hint-placeholder-count="2">
|
|
397
|
+
<div style="display: flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 2px 0 10px; border: 1px solid var(--rule); border-radius: 8px">
|
|
398
|
+
<svg aria-hidden="true" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex: none; color: var(--muted)"><path d="M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-1 1"></path><path d="M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l1-1"></path></svg>
|
|
399
|
+
<sc-if value="{{lk.safe}}" hint-placeholder-val="{{true}}"><a href="{{lk.href}}" target="_blank" rel="noopener noreferrer" title="{{lk.url}}" style="flex: 1; min-width: 0; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis">{{lk.label}}</a></sc-if>
|
|
400
|
+
<sc-if value="{{lk.unsafe}}" hint-placeholder-val="{{false}}"><span title="{{lk.url}}" style="flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis">{{lk.label}}</span></sc-if>
|
|
401
|
+
<button onClick="{{lk.remove}}" aria-label="{{lk.removeLabel}}" title="{{lk.removeLabel}}" style="flex: none; width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; padding: 0">
|
|
402
|
+
<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M6 6l12 12M18 6 6 18"></path></svg>
|
|
403
|
+
</button>
|
|
404
|
+
</div>
|
|
405
|
+
</sc-for>
|
|
406
|
+
</div>
|
|
407
|
+
</sc-if>
|
|
408
|
+
<div style="display: flex; flex-wrap: wrap; gap: 6px">
|
|
409
|
+
<label for="insp-link-name" style="position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0)">Link name</label>
|
|
410
|
+
<input id="insp-link-name" value="{{insp.linkName}}" onChange="{{insp.onLinkName}}" onKeyDown="{{insp.onLinkKey}}" placeholder="Name, e.g. Figma" autocomplete="off" style="flex: 1 1 90px; min-width: 0; height: 32px; padding: 0 8px; border: 1px solid var(--control); border-radius: 8px; font: inherit; font-size: 13px">
|
|
411
|
+
<label for="insp-link-url" style="position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0)">Link URL</label>
|
|
412
|
+
<input id="insp-link-url" type="url" value="{{insp.linkUrl}}" onChange="{{insp.onLinkUrl}}" onKeyDown="{{insp.onLinkKey}}" placeholder="https://…" spellcheck="false" autocomplete="off" style="flex: 2 1 140px; min-width: 0; height: 32px; padding: 0 8px; border: 1px solid var(--control); border-radius: 8px; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px">
|
|
413
|
+
<button class="tb" onClick="{{insp.addLink}}" style="flex: none; height: 32px; padding: 0 10px; border: 1px solid var(--control); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer">Add</button>
|
|
414
|
+
</div>
|
|
415
|
+
<sc-if value="{{insp.hasLinkError}}" hint-placeholder-val="{{false}}"><span role="alert" style="font-size: 12px; color: var(--bad)">{{insp.linkError}}</span></sc-if>
|
|
416
|
+
</div>
|
|
417
|
+
<div style="display: flex; align-items: center; gap: 8px">
|
|
418
|
+
<label for="insp-dur" style="font-size: 12px; font-weight: 500; color: var(--muted); width: 64px">Duration</label>
|
|
419
|
+
<input id="insp-dur" type="number" min="0" step="1" value="{{insp.dur}}" onChange="{{insp.onDur}}" style="width: 64px; height: 32px; padding: 0 8px; border: 1px solid var(--control); border-radius: 8px; font: inherit; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; color: var(--ink)">
|
|
420
|
+
<span style="font-size: 13px">{{insp.durUnit}}</span>
|
|
421
|
+
</div>
|
|
422
|
+
|
|
423
|
+
<div style="display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px; border-radius: 10px; background: var(--bg)">
|
|
424
|
+
<div style="display: flex; flex-direction: column; gap: 2px"><span style="font-size: 11px; color: var(--muted)">Starts</span><span style="font-size: 13px; font-weight: 600">{{insp.startLabel}}</span></div>
|
|
425
|
+
<div style="display: flex; flex-direction: column; gap: 2px"><span style="font-size: 11px; color: var(--muted)">Ends</span><span style="font-size: 13px; font-weight: 600">{{insp.endLabel}}</span></div>
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
<sc-if value="{{insp.conflict}}" hint-placeholder-val="{{false}}">
|
|
429
|
+
<div role="alert" style="display: flex; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); color: var(--bad-strong); font-size: 12px; line-height: 1.45">
|
|
430
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex: none; margin-top: 1px"><path d="M12 3 2 21h20L12 3z"></path><path d="M12 10v5M12 18h.01"></path></svg>
|
|
431
|
+
<span>{{insp.conflictText}}</span>
|
|
432
|
+
</div>
|
|
433
|
+
</sc-if>
|
|
434
|
+
|
|
435
|
+
<div style="display: flex; gap: 8px">
|
|
436
|
+
<button class="tb" onClick="{{insp.addFollower}}" style="flex: 1; height: 36px; border: 1px solid var(--control); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer">Add follow-on task</button>
|
|
437
|
+
<button onClick="{{insp.del}}" aria-label="Delete task" title="Delete task" style="width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--bad-border); border-radius: 8px; background: var(--surface); color: var(--bad); cursor: pointer; padding: 0">
|
|
438
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13"></path></svg>
|
|
439
|
+
</button>
|
|
440
|
+
</div>
|
|
441
|
+
</div>
|
|
442
|
+
</aside>
|
|
443
|
+
</sc-if>
|
|
444
|
+
</section>
|
|
445
|
+
|
|
446
|
+
<sc-if value="{{isSplit}}" hint-placeholder-val="{{true}}">
|
|
447
|
+
<section aria-label="Markdown source" style="position: relative; flex: 0 0 {{mdW}}px; max-width: 100%; min-width: 0; height: 100%; min-height: 320px; display: flex; flex-direction: column; background: #1B1C1F; color: #E6E4DF; border-left: 1px solid #0E0F10">
|
|
448
|
+
<div role="separator" aria-orientation="vertical" aria-label="Resize the markdown panel" aria-valuenow="{{mdW}}" tabIndex="0" onPointerDown="{{mdResizeDown}}" onPointerMove="{{mdResizeMove}}" onPointerUp="{{mdResizeUp}}" onPointerCancel="{{mdResizeUp}}" onKeyDown="{{mdResizeKey}}" style="position: absolute; z-index: 3; top: 0; bottom: 0; left: -4px; width: 8px; cursor: col-resize; touch-action: none"></div>
|
|
449
|
+
<div style="flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid #2C2D31">
|
|
450
|
+
<span style="flex: 1; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; font-weight: 600">{{fileName}}</span>
|
|
451
|
+
<sc-if value="{{notEditing}}" hint-placeholder-val="{{true}}">
|
|
452
|
+
<div style="display: flex; gap: 6px">
|
|
453
|
+
<button onClick="{{startEdit}}" style="height: 30px; padding: 0 10px; border: 1px solid #3A3B40; border-radius: 7px; background: transparent; color: #E6E4DF; font-size: 12px; font-weight: 600; cursor: pointer">Edit source</button>
|
|
454
|
+
<button onClick="{{copyMd}}" style="height: 30px; display: flex; align-items: center; gap: 6px; padding: 0 10px; border: 0; border-radius: 7px; background: #E6E4DF; color: #17181A; font-size: 12px; font-weight: 600; cursor: pointer">
|
|
455
|
+
<svg aria-hidden="true" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="12" height="12" rx="2"></rect><path d="M5 15V5a2 2 0 0 1 2-2h10"></path></svg>{{copyLabel}}
|
|
456
|
+
</button>
|
|
457
|
+
</div>
|
|
458
|
+
</sc-if>
|
|
459
|
+
<sc-if value="{{editing}}" hint-placeholder-val="{{false}}">
|
|
460
|
+
<div style="display: flex; gap: 6px">
|
|
461
|
+
<button onClick="{{cancelEdit}}" style="height: 30px; padding: 0 10px; border: 1px solid #3A3B40; border-radius: 7px; background: transparent; color: #E6E4DF; font-size: 12px; font-weight: 600; cursor: pointer">Cancel</button>
|
|
462
|
+
<button onClick="{{applyEdit}}" disabled="{{draftInvalid}}" style="height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: #8FB0FF; color: #0E1A3A; font-size: 12px; font-weight: 700; cursor: pointer">Apply to chart</button>
|
|
463
|
+
</div>
|
|
464
|
+
</sc-if>
|
|
465
|
+
</div>
|
|
466
|
+
|
|
467
|
+
<sc-if value="{{notEditing}}" hint-placeholder-val="{{true}}">
|
|
468
|
+
<div style="flex: 1; min-height: 0; overflow: auto; padding: 10px 0; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; line-height: 22px">
|
|
469
|
+
<sc-for list="{{mdLines}}" as="l" hint-placeholder-count="20">
|
|
470
|
+
<div style="display: flex; background: {{l.bg}}">
|
|
471
|
+
<span aria-hidden="true" style="flex: none; width: 44px; padding-right: 12px; box-sizing: border-box; text-align: right; color: {{l.numColor}}">{{l.n}}</span>
|
|
472
|
+
<span aria-hidden="true" style="flex: none; width: 10px; color: #8FB0FF">{{l.mark}}</span>
|
|
473
|
+
<span style="flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; padding-right: 16px"><sc-for list="{{l.tokens}}" as="t" hint-placeholder-count="3"><span style="color: {{t.color}}; font-weight: {{t.weight}}; background: {{t.bg}}; border-radius: 3px">{{t.text}}</span></sc-for></span>
|
|
474
|
+
</div>
|
|
475
|
+
</sc-for>
|
|
476
|
+
</div>
|
|
477
|
+
</sc-if>
|
|
478
|
+
<sc-if value="{{editing}}" hint-placeholder-val="{{false}}">
|
|
479
|
+
<label for="md-src" style="position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0)">Markdown source</label>
|
|
480
|
+
<textarea id="md-src" value="{{draft}}" onChange="{{onDraft}}" spellcheck="false" style="flex: 1; min-height: 0; resize: none; border: 0; margin: 0; padding: 10px 16px; background: #141518; color: #E6E4DF; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; line-height: 22px; tab-size: 2"></textarea>
|
|
481
|
+
</sc-if>
|
|
482
|
+
|
|
483
|
+
<div style="flex: none; display: flex; gap: 8px; align-items: flex-start; padding: 10px 16px; border-top: 1px solid #2C2D31; font-size: 12px; line-height: 1.45; background: {{mdFootBg}}; color: {{mdFootFg}}">
|
|
484
|
+
<span style="width: 6px; height: 6px; border-radius: 3px; margin-top: 6px; flex: none; background: {{mdFootDot}}"></span>
|
|
485
|
+
<span>{{mdFoot}}</span>
|
|
486
|
+
</div>
|
|
487
|
+
</section>
|
|
488
|
+
</sc-if>
|
|
489
|
+
</div>
|
|
490
|
+
|
|
491
|
+
<sc-if value="{{openOpen}}" hint-placeholder-val="{{false}}">
|
|
492
|
+
<div onKeyDown="{{onOpenKey}}" style="position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: var(--backdrop)">
|
|
493
|
+
<div role="dialog" aria-modal="true" aria-labelledby="open-title" style="width: 560px; max-width: 100%; max-height: calc(100vh - 32px); overflow: auto; box-sizing: border-box; display: flex; flex-direction: column; gap: 16px; padding: 24px; background: var(--surface); color: var(--ink); border-radius: 16px; box-shadow: 0 24px 64px var(--shadow)">
|
|
494
|
+
<div style="display: flex; align-items: center; gap: 8px">
|
|
495
|
+
<h2 id="open-title" style="flex: 1; margin: 0; font-size: 18px; font-weight: 600">Open a plan</h2>
|
|
496
|
+
<button class="tb" onClick="{{closeOpen}}" aria-label="Close" autoFocus="{{true}}" style="width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; padding: 0">
|
|
497
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12M18 6 6 18"></path></svg>
|
|
498
|
+
</button>
|
|
499
|
+
</div>
|
|
500
|
+
<div class="{{dropClass}}" onDragOver="{{onDragOver}}" onDragLeave="{{onDragLeave}}" onDrop="{{onDrop}}" style="display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; min-height: 130px; padding: 20px; box-sizing: border-box; border: 2px dashed var(--control); border-radius: 12px; color: var(--muted); text-align: center">
|
|
501
|
+
<svg aria-hidden="true" width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20V9M7 14l5-5 5 5M5 4h14"></path></svg>
|
|
502
|
+
<span style="font-size: 13px">Drop a .md file here, or</span>
|
|
503
|
+
<label class="tb" style="position: relative; height: 36px; display: inline-flex; align-items: center; padding: 0 14px; border: 1px solid var(--control); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer">Choose file…<input type="file" accept=".md,.markdown,.txt,text/markdown,text/plain" onChange="{{onPickFile}}" style="position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden"></label>
|
|
504
|
+
</div>
|
|
505
|
+
<sc-if value="{{hasLocalSaves}}" hint-placeholder-val="{{false}}">
|
|
506
|
+
<div style="display: flex; flex-direction: column; gap: 6px">
|
|
507
|
+
<span style="font-size: 12px; font-weight: 600; color: var(--muted)">Saved in this browser</span>
|
|
508
|
+
<div style="display: flex; flex-direction: column; max-height: 220px; overflow: auto; border: 1px solid var(--rule); border-radius: 10px">
|
|
509
|
+
<sc-for list="{{localSaves}}" as="ls" hint-placeholder-count="3">
|
|
510
|
+
<div style="display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--rule-soft)">
|
|
511
|
+
<span style="flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px">
|
|
512
|
+
<span style="font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis">{{ls.name}}</span>
|
|
513
|
+
<span style="font-size: 11.5px; color: var(--muted)">{{ls.meta}}</span>
|
|
514
|
+
</span>
|
|
515
|
+
<button class="tb" onClick="{{ls.open}}" aria-label="{{ls.openLabel}}" style="flex: none; height: 30px; padding: 0 12px; border: 1px solid var(--control); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 600; cursor: pointer">Open</button>
|
|
516
|
+
<button class="tb" onClick="{{ls.del}}" aria-label="{{ls.delLabel}}" title="{{ls.delLabel}}" style="flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--bad); cursor: pointer; padding: 0">
|
|
517
|
+
<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13"></path></svg>
|
|
518
|
+
</button>
|
|
519
|
+
</div>
|
|
520
|
+
</sc-for>
|
|
521
|
+
</div>
|
|
522
|
+
</div>
|
|
523
|
+
</sc-if>
|
|
524
|
+
<div style="display: flex; flex-direction: column; gap: 6px">
|
|
525
|
+
<label for="open-url" style="font-size: 12px; font-weight: 600; color: var(--muted)">Or open from a URL</label>
|
|
526
|
+
<div style="display: flex; gap: 8px">
|
|
527
|
+
<input id="open-url" type="url" value="{{openUrl}}" onChange="{{onOpenUrlInput}}" onKeyDown="{{onOpenUrlKey}}" placeholder="https://…/ROADMAP.md" spellcheck="false" autocomplete="off" style="flex: 1; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--control); border-radius: 8px; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px">
|
|
528
|
+
<button onClick="{{openFromUrl}}" disabled="{{openUrlDisabled}}" style="height: 36px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--ink); color: var(--on-ink); font-size: 13px; font-weight: 600; cursor: pointer">{{openUrlLabel}}</button>
|
|
529
|
+
</div>
|
|
530
|
+
<span style="font-size: 12px; color: var(--muted)">The address bar keeps a URL as ?src=, so the link can be shared. Opened files replace the plan shown here.</span>
|
|
531
|
+
</div>
|
|
532
|
+
<sc-if value="{{hasOpenError}}" hint-placeholder-val="{{false}}">
|
|
533
|
+
<div role="alert" style="padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); color: var(--bad-strong); font-size: 12.5px; line-height: 1.45; white-space: pre-wrap">{{openError}}</div>
|
|
534
|
+
</sc-if>
|
|
535
|
+
</div>
|
|
536
|
+
</div>
|
|
537
|
+
</sc-if>
|
|
538
|
+
|
|
539
|
+
<sc-if value="{{hasDlg}}" hint-placeholder-val="{{false}}">
|
|
540
|
+
<div onKeyDown="{{dlg.onKey}}" style="position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: var(--backdrop)">
|
|
541
|
+
<div role="dialog" aria-modal="true" aria-labelledby="del-title" aria-describedby="del-lead" style="width: 520px; max-width: 100%; max-height: calc(100vh - 32px); overflow: auto; box-sizing: border-box; display: flex; flex-direction: column; gap: 18px; padding: 24px; background: var(--surface); border-radius: 16px; box-shadow: 0 24px 64px var(--shadow)">
|
|
542
|
+
<div style="display: flex; gap: 14px; align-items: flex-start">
|
|
543
|
+
<span style="flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--bad-bg); color: var(--bad)">
|
|
544
|
+
<svg aria-hidden="true" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13"></path></svg>
|
|
545
|
+
</span>
|
|
546
|
+
<div style="display: flex; flex-direction: column; gap: 4px; min-width: 0">
|
|
547
|
+
<h2 id="del-title" style="margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; text-wrap: pretty">{{dlg.title}}</h2>
|
|
548
|
+
<p id="del-lead" style="margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink-2)">{{dlg.lead}}</p>
|
|
549
|
+
</div>
|
|
550
|
+
</div>
|
|
551
|
+
|
|
552
|
+
<sc-if value="{{dlg.isSection}}" hint-placeholder-val="{{false}}">
|
|
553
|
+
<fieldset style="margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 8px">
|
|
554
|
+
<legend style="padding: 0; margin-bottom: 8px; font-size: 12px; font-weight: 600; color: var(--muted)">The section’s tasks</legend>
|
|
555
|
+
<sc-for list="{{dlg.modeOpts}}" as="o" hint-placeholder-count="2">
|
|
556
|
+
<label class="opt" for="{{o.inputId}}" style="display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid {{o.border}}; border-radius: 10px; background: {{o.bg}}; cursor: pointer">
|
|
557
|
+
<input type="radio" id="{{o.inputId}}" name="del-mode" checked="{{o.checked}}" onChange="{{o.onPick}}" style="margin: 2px 0 0; accent-color: var(--ink); flex: none">
|
|
558
|
+
<span style="display: flex; flex-direction: column; gap: 2px"><span style="font-size: 13px; font-weight: 600">{{o.title}}</span><span style="font-size: 12px; line-height: 1.45; color: var(--muted)">{{o.desc}}</span></span>
|
|
559
|
+
</label>
|
|
560
|
+
</sc-for>
|
|
561
|
+
</fieldset>
|
|
562
|
+
</sc-if>
|
|
563
|
+
|
|
564
|
+
<sc-if value="{{dlg.showPolicy}}" hint-placeholder-val="{{true}}">
|
|
565
|
+
<fieldset style="margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 8px">
|
|
566
|
+
<legend style="padding: 0; margin-bottom: 8px; font-size: 12px; font-weight: 600; color: var(--muted)">Tasks that depend on it</legend>
|
|
567
|
+
<sc-for list="{{dlg.policyOpts}}" as="o" hint-placeholder-count="3">
|
|
568
|
+
<label class="opt" for="{{o.inputId}}" style="display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid {{o.border}}; border-radius: 10px; background: {{o.bg}}; opacity: {{o.opacity}}; cursor: pointer">
|
|
569
|
+
<input type="radio" id="{{o.inputId}}" name="del-policy" checked="{{o.checked}}" disabled="{{o.disabled}}" onChange="{{o.onPick}}" style="margin: 2px 0 0; accent-color: var(--ink); flex: none">
|
|
570
|
+
<span style="display: flex; flex-direction: column; gap: 2px"><span style="font-size: 13px; font-weight: 600">{{o.title}}</span><span style="font-size: 12px; line-height: 1.45; color: var(--muted)">{{o.desc}}</span></span>
|
|
571
|
+
</label>
|
|
572
|
+
</sc-for>
|
|
573
|
+
</fieldset>
|
|
574
|
+
</sc-if>
|
|
575
|
+
|
|
576
|
+
<sc-if value="{{dlg.hasRows}}" hint-placeholder-val="{{true}}">
|
|
577
|
+
<div style="display: flex; flex-direction: column; border: 1px solid var(--rule); border-radius: 10px; overflow: hidden">
|
|
578
|
+
<div style="display: grid; grid-template-columns: minmax(0, 1.2fr) 88px minmax(0, 1.6fr); gap: 10px; padding: 8px 12px; background: var(--bg); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted)">
|
|
579
|
+
<span>Task</span><span>Now</span><span>After delete</span>
|
|
580
|
+
</div>
|
|
581
|
+
<sc-for list="{{dlg.rows}}" as="p" hint-placeholder-count="3">
|
|
582
|
+
<div style="display: grid; grid-template-columns: minmax(0, 1.2fr) 88px minmax(0, 1.6fr); gap: 10px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--rule-soft); font-size: 12.5px">
|
|
583
|
+
<span style="font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis">{{p.name}}</span>
|
|
584
|
+
<span style="font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11.5px; color: var(--muted)">{{p.was}}</span>
|
|
585
|
+
<span style="justify-self: start; max-width: 100%; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: {{p.bg}}; color: {{p.fg}}">{{p.effect}}</span>
|
|
586
|
+
</div>
|
|
587
|
+
</sc-for>
|
|
588
|
+
<sc-if value="{{dlg.hasMore}}" hint-placeholder-val="{{false}}">
|
|
589
|
+
<div style="padding: 8px 12px; border-top: 1px solid var(--rule-soft); font-size: 12px; color: var(--muted)">{{dlg.more}}</div>
|
|
590
|
+
</sc-if>
|
|
591
|
+
</div>
|
|
592
|
+
</sc-if>
|
|
593
|
+
|
|
594
|
+
<div style="display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted)">
|
|
595
|
+
<sc-if value="{{dlg.hasRipple}}" hint-placeholder-val="{{false}}">
|
|
596
|
+
<span style="color: var(--info-fg); font-weight: 500">{{dlg.ripple}}</span>
|
|
597
|
+
</sc-if>
|
|
598
|
+
<span style="font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11.5px">{{dlg.lines}}</span>
|
|
599
|
+
</div>
|
|
600
|
+
|
|
601
|
+
<div style="display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap">
|
|
602
|
+
<button class="tb" onClick="{{dlg.cancel}}" autoFocus="{{true}}" style="height: 40px; padding: 0 16px; border: 1px solid var(--control); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer">Cancel</button>
|
|
603
|
+
<button class="danger" onClick="{{dlg.confirm}}" disabled="{{dlg.confirmDisabled}}" style="height: 40px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--danger); color: #FFFFFF; font-size: 13px; font-weight: 600; cursor: pointer">{{dlg.confirmLabel}}</button>
|
|
604
|
+
</div>
|
|
605
|
+
</div>
|
|
606
|
+
</div>
|
|
607
|
+
</sc-if>
|
|
608
|
+
</div>
|
|
609
|
+
</x-dc>
|
|
610
|
+
<script type="text/x-dc" data-dc-script>
|
|
611
|
+
/* ---------------------------------------------------------------------------
|
|
612
|
+
* Pure core: parse → schedule → serialize, plus doc → doc operations.
|
|
613
|
+
* No IO, no clock: "today" arrives as an explicit argument.
|
|
614
|
+
* Markdown model: one item per source line, so non-task lines round-trip
|
|
615
|
+
* byte-for-byte and edits only touch the lines they change.
|
|
616
|
+
* ------------------------------------------------------------------------- */
|
|
617
|
+
const G = (() => {
|
|
618
|
+
const DAY_MS = 86400000;
|
|
619
|
+
const KEYS = ['id', 'start', 'after', 'with', 'dur', 'tags'];
|
|
620
|
+
/* A tag: any text without backticks or commas. */
|
|
621
|
+
const TAG_RE = /^[^`,]+$/;
|
|
622
|
+
/* A named resource link after the attributes: [Figma](https://…). */
|
|
623
|
+
const LINK_RE = /\[([^\]]+)\]\(([^)\s]+)\)/g;
|
|
624
|
+
const ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
625
|
+
const TASK_RE = /^(\s*)[-*]\s+(?:\[([ xX])\]\s+)?(.*)$/;
|
|
626
|
+
const ATTR_RE = /`([A-Za-z]+):([^`]*)`/g;
|
|
627
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
628
|
+
const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
629
|
+
|
|
630
|
+
const parseError = (line, detail) => Object.assign(new Error(`line ${line}: ${detail}`), { line, detail });
|
|
631
|
+
const at = (line, fn) => { try { return fn(); } catch (e) { throw e.line ? e : parseError(line, e.message); } };
|
|
632
|
+
|
|
633
|
+
const dayFromIso = (iso) => {
|
|
634
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso);
|
|
635
|
+
if (!m) throw new Error(`invalid date "${iso}" — expected YYYY-MM-DD`);
|
|
636
|
+
const t = Date.UTC(+m[1], +m[2] - 1, +m[3]);
|
|
637
|
+
if (new Date(t).getUTCDate() !== +m[3]) throw new Error(`"${iso}" is not a real calendar date`);
|
|
638
|
+
return t / DAY_MS;
|
|
639
|
+
};
|
|
640
|
+
const isoFromDay = (n) => new Date(n * DAY_MS).toISOString().slice(0, 10);
|
|
641
|
+
const dow = (n) => (((n + 4) % 7) + 7) % 7;
|
|
642
|
+
const parts = (n) => { const d = new Date(n * DAY_MS); return { y: d.getUTCFullYear(), m: d.getUTCMonth(), d: d.getUTCDate() }; };
|
|
643
|
+
const fmt = (n) => { const p = parts(n); return `${DOW[dow(n)]} ${p.d} ${MON[p.m]}`; };
|
|
644
|
+
|
|
645
|
+
const parseSpan = (s, key) => {
|
|
646
|
+
const m = /^([+-]?\d+)([dw])$/.exec(s.trim());
|
|
647
|
+
if (!m) throw new Error(`\`${key}:${s}\` — expected a span like 3d or 2w`);
|
|
648
|
+
return +m[1] * (m[2] === 'w' ? 7 : 1);
|
|
649
|
+
};
|
|
650
|
+
/* "a,b+2d" → ids and an offset; used by after: (their ends) and with: (their starts). */
|
|
651
|
+
const parseDeps = (v, key) => {
|
|
652
|
+
const m = /^(.*?)([+-]\d+[dw])?$/.exec(v.trim());
|
|
653
|
+
const ids = m[1].split(',').map((s) => s.trim());
|
|
654
|
+
ids.forEach((id) => { if (!ID_RE.test(id)) throw new Error(`\`${key}:\` has an invalid task id "${id}"`); });
|
|
655
|
+
return { ids, offset: m[2] ? parseSpan(m[2], key) : 0 };
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
const parseTask = (t) => {
|
|
659
|
+
const body = t[3];
|
|
660
|
+
const tick = body.indexOf('`');
|
|
661
|
+
const name = body.slice(0, tick).trim();
|
|
662
|
+
if (!name) throw new Error('task has no name before its attributes');
|
|
663
|
+
const attrs = {};
|
|
664
|
+
const links = [];
|
|
665
|
+
const leftover = body.slice(tick).replace(ATTR_RE, (_, k, v) => {
|
|
666
|
+
if (!KEYS.includes(k)) throw new Error(`unknown attribute \`${k}:\` — expected one of ${KEYS.join(', ')}`);
|
|
667
|
+
if (k in attrs) throw new Error(`duplicate attribute \`${k}:\``);
|
|
668
|
+
attrs[k] = v.trim();
|
|
669
|
+
return '';
|
|
670
|
+
}).replace(LINK_RE, (_, label, url) => { links.push({ label: label.trim(), url }); return ''; });
|
|
671
|
+
if (leftover.trim()) throw new Error(`unexpected text "${leftover.trim()}" after the attributes (only [name](url) links may follow them)`);
|
|
672
|
+
if (!ID_RE.test(attrs.id)) throw new Error(`invalid id "${attrs.id}" — letters, digits, - and _`);
|
|
673
|
+
if (attrs.dur === undefined) throw new Error('missing `dur:` (e.g. `dur:3d`; `dur:0d` is a milestone)');
|
|
674
|
+
const dur = parseSpan(attrs.dur, 'dur');
|
|
675
|
+
if (dur < 0) throw new Error('`dur:` cannot be negative');
|
|
676
|
+
const after = attrs.after === undefined ? { ids: [], offset: 0 } : parseDeps(attrs.after, 'after');
|
|
677
|
+
const withs = attrs.with === undefined ? { ids: [], offset: 0 } : parseDeps(attrs.with, 'with');
|
|
678
|
+
if (after.offset !== 0 && withs.offset !== 0) throw new Error('put the offset on `after:` or on `with:`, not both — it applies to the task\'s start either way');
|
|
679
|
+
const both = after.ids.find((id) => withs.ids.includes(id));
|
|
680
|
+
if (both) throw new Error(`"${both}" is in both \`after:\` and \`with:\` — keep it in one`);
|
|
681
|
+
const offset = after.offset || withs.offset;
|
|
682
|
+
const start = attrs.start === undefined ? null : dayFromIso(attrs.start);
|
|
683
|
+
if (start === null && after.ids.length === 0 && withs.ids.length === 0) throw new Error('needs `start:` (fixed date), `after:` (when other tasks end) or `with:` (when they start)');
|
|
684
|
+
if (start !== null && offset !== 0) throw new Error('an offset has no effect when `start:` anchors the task — drop one of them');
|
|
685
|
+
const tags = attrs.tags === undefined ? [] : [...new Set(attrs.tags.split(',').map((x) => x.trim()).filter(Boolean))];
|
|
686
|
+
return { id: attrs.id, name, done: t[2] === 'x' || t[2] === 'X', box: t[2] !== undefined, indent: t[1], start, after: after.ids, with: withs.ids, offset, dur, tags, links };
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
const tasksOf = (doc) => doc.items.filter((i) => i.kind === 'task').map((i) => i.task);
|
|
690
|
+
/* Every task this one depends on, whether on its end (after:) or its start (with:). */
|
|
691
|
+
const depsOf = (t) => [...t.after, ...t.with];
|
|
692
|
+
|
|
693
|
+
const schedule = (doc) => {
|
|
694
|
+
const byId = new Map(tasksOf(doc).map((t) => [t.id, t]));
|
|
695
|
+
const out = new Map();
|
|
696
|
+
const visit = (id, path) => {
|
|
697
|
+
if (out.has(id)) return out.get(id);
|
|
698
|
+
if (path.includes(id)) throw new Error(`dependency cycle: ${[...path.slice(path.indexOf(id)), id].join(' → ')}`);
|
|
699
|
+
const t = byId.get(id);
|
|
700
|
+
if (!t) throw new Error(`bug: unknown task "${id}" reached the scheduler`);
|
|
701
|
+
/* The reference point: the latest end of an after: task, or start of a with: task. */
|
|
702
|
+
const refs = [...t.after.map((d) => visit(d, [...path, id]).end), ...t.with.map((d) => visit(d, [...path, id]).start)];
|
|
703
|
+
const depsEnd = refs.length ? Math.max(...refs) : null;
|
|
704
|
+
if (t.start === null && depsEnd === null) throw new Error(`bug: "${id}" has neither a start nor dependencies`);
|
|
705
|
+
const start = t.start !== null ? t.start : depsEnd + t.offset;
|
|
706
|
+
const s = { start, end: start + t.dur, depsEnd, conflict: t.start !== null && depsEnd !== null && t.start < depsEnd };
|
|
707
|
+
out.set(id, s);
|
|
708
|
+
return s;
|
|
709
|
+
};
|
|
710
|
+
byId.forEach((_, id) => visit(id, []));
|
|
711
|
+
return out;
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
/* Display preferences ride on the title line as attributes: "# Plan `theme:night` `view:chart`". */
|
|
715
|
+
const PREF_KEYS = ['theme', 'view'];
|
|
716
|
+
const PREF_RE = /\s*`(theme|view):([^`\s]+)`/g;
|
|
717
|
+
const parseTitle = (text) => {
|
|
718
|
+
const prefs = {};
|
|
719
|
+
for (const m of text.matchAll(PREF_RE)) prefs[m[1]] = m[2];
|
|
720
|
+
return { text: text.replace(PREF_RE, '').trim(), prefs };
|
|
721
|
+
};
|
|
722
|
+
const prefsOf = (doc) => (doc.items.find((i) => i.kind === 'title') || { prefs: {} }).prefs;
|
|
723
|
+
|
|
724
|
+
const parse = (md) => {
|
|
725
|
+
if (typeof md !== 'string') throw new Error('bug: parse expects a string');
|
|
726
|
+
const items = md.split('\n').map((text, i) => {
|
|
727
|
+
const line = i + 1;
|
|
728
|
+
const h = /^(#{1,2})\s+(.*)$/.exec(text);
|
|
729
|
+
if (h && h[1] === '#') return { kind: 'title', ...parseTitle(h[2]), line };
|
|
730
|
+
if (h) return { kind: 'group', text: h[2].trim(), line };
|
|
731
|
+
const t = TASK_RE.exec(text);
|
|
732
|
+
if (!t || !t[3].includes('`id:')) return { kind: 'raw', text, line };
|
|
733
|
+
return { kind: 'task', line, task: at(line, () => parseTask(t)) };
|
|
734
|
+
});
|
|
735
|
+
const seen = new Map();
|
|
736
|
+
items.filter((i) => i.kind === 'task').forEach(({ task, line }) => {
|
|
737
|
+
if (seen.has(task.id)) throw parseError(line, `duplicate id "${task.id}" (first used on line ${seen.get(task.id)})`);
|
|
738
|
+
seen.set(task.id, line);
|
|
739
|
+
});
|
|
740
|
+
items.filter((i) => i.kind === 'task').forEach(({ task, line }) => depsOf(task).forEach((d) => {
|
|
741
|
+
if (d === task.id) throw parseError(line, `"${d}" cannot depend on itself`);
|
|
742
|
+
if (!seen.has(d)) throw parseError(line, `\`${task.after.includes(d) ? 'after' : 'with'}:\` references unknown task "${d}"`);
|
|
743
|
+
}));
|
|
744
|
+
const doc = { items };
|
|
745
|
+
schedule(doc);
|
|
746
|
+
return doc;
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
const serializeTask = (t) => {
|
|
750
|
+
const off = t.start === null && t.offset !== 0 ? `${t.offset > 0 ? '+' : ''}${t.offset}d` : '';
|
|
751
|
+
const attrs = [`\`id:${t.id}\``];
|
|
752
|
+
if (t.start !== null) attrs.push(`\`start:${isoFromDay(t.start)}\``);
|
|
753
|
+
/* The offset goes on after: when there is one, else on with:. */
|
|
754
|
+
if (t.after.length) attrs.push(`\`after:${t.after.join(',')}${off}\``);
|
|
755
|
+
if (t.with.length) attrs.push(`\`with:${t.with.join(',')}${t.after.length ? '' : off}\``);
|
|
756
|
+
attrs.push(`\`dur:${t.dur}d\``);
|
|
757
|
+
if (t.tags.length) attrs.push(`\`tags:${t.tags.join(',')}\``);
|
|
758
|
+
const links = t.links.map((l) => ` [${l.label}](${l.url})`).join('');
|
|
759
|
+
return `${t.indent}- ${t.box ? `[${t.done ? 'x' : ' '}] ` : ''}${t.name} ${attrs.join(' ')}${links}`;
|
|
760
|
+
};
|
|
761
|
+
const serialize = (doc) => doc.items.map((i) => {
|
|
762
|
+
if (i.kind === 'title') return [`# ${i.text}`, ...PREF_KEYS.filter((k) => i.prefs[k]).map((k) => `\`${k}:${i.prefs[k]}\``)].join(' ');
|
|
763
|
+
if (i.kind === 'group') return `## ${i.text}`;
|
|
764
|
+
if (i.kind === 'raw') return i.text;
|
|
765
|
+
if (i.kind === 'task') return serializeTask(i.task);
|
|
766
|
+
throw new Error(`bug: unknown item kind "${i.kind}"`);
|
|
767
|
+
}).join('\n');
|
|
768
|
+
|
|
769
|
+
const mapTask = (doc, id, f) => {
|
|
770
|
+
if (!doc.items.some((i) => i.kind === 'task' && i.task.id === id)) throw new Error(`bug: no task "${id}"`);
|
|
771
|
+
return { ...doc, items: doc.items.map((i) => (i.kind === 'task' && i.task.id === id ? { ...i, task: f(i.task) } : i)) };
|
|
772
|
+
};
|
|
773
|
+
const findTask = (doc, id) => tasksOf(doc).find((t) => t.id === id);
|
|
774
|
+
const dependsOn = (doc, a, b) => {
|
|
775
|
+
const byId = new Map(tasksOf(doc).map((t) => [t.id, t]));
|
|
776
|
+
const walk = (id, seen) => id === b || (!seen.has(id) && depsOf(byId.get(id)).some((d) => walk(d, new Set([...seen, id]))));
|
|
777
|
+
return walk(a, new Set());
|
|
778
|
+
};
|
|
779
|
+
const nextId = (doc) => { const ids = new Set(tasksOf(doc).map((t) => t.id)); const go = (n) => (ids.has(`task-${n}`) ? go(n + 1) : `task-${n}`); return go(1); };
|
|
780
|
+
const isBlank = (i) => i.kind === 'raw' && i.text.trim() === '';
|
|
781
|
+
const taskIndex = (doc, id) => {
|
|
782
|
+
const idx = doc.items.findIndex((i) => i.kind === 'task' && i.task.id === id);
|
|
783
|
+
if (idx < 0) throw new Error(`bug: no task "${id}"`);
|
|
784
|
+
return idx;
|
|
785
|
+
};
|
|
786
|
+
const insertItems = (doc, at2, add) => ({ ...doc, items: [...doc.items.slice(0, at2), ...add, ...doc.items.slice(at2)] });
|
|
787
|
+
const endIndex = (doc) => { const k = [...doc.items].reverse().findIndex((i) => !isBlank(i)); return k < 0 ? 0 : doc.items.length - k; };
|
|
788
|
+
const backOverBlanks = (doc, idx) => (idx > 0 && isBlank(doc.items[idx - 1]) ? backOverBlanks(doc, idx - 1) : idx);
|
|
789
|
+
/* Tasks outside `ids` that directly depend on one of them. */
|
|
790
|
+
const dependentsOf = (doc, ids) => tasksOf(doc).filter((t) => !ids.has(t.id) && depsOf(t).some((d) => ids.has(d))).map((t) => t.id);
|
|
791
|
+
/* `ids` plus everything that transitively depends on them. */
|
|
792
|
+
const downstream = (doc, ids) => { const more = dependentsOf(doc, ids); return more.length ? downstream(doc, new Set([...ids, ...more])) : ids; };
|
|
793
|
+
/* Nearest predecessors of `ids` that are not themselves in `ids`. */
|
|
794
|
+
const predecessorsOf = (doc, ids) => {
|
|
795
|
+
const byId = new Map(tasksOf(doc).map((t) => [t.id, t]));
|
|
796
|
+
const walk = (id) => depsOf(byId.get(id)).flatMap((d) => (ids.has(d) ? walk(d) : [d]));
|
|
797
|
+
return [...new Set([...ids].flatMap(walk))];
|
|
798
|
+
};
|
|
799
|
+
/* Task ids, dependencies first. */
|
|
800
|
+
const topo = (doc) => {
|
|
801
|
+
const byId = new Map(tasksOf(doc).map((t) => [t.id, t]));
|
|
802
|
+
const out = [];
|
|
803
|
+
const seen = new Set();
|
|
804
|
+
const visit = (id) => { if (seen.has(id)) return; seen.add(id); depsOf(byId.get(id)).forEach(visit); out.push(id); };
|
|
805
|
+
byId.forEach((_, id) => visit(id));
|
|
806
|
+
return out;
|
|
807
|
+
};
|
|
808
|
+
/* Item range [start, end) of the section whose heading is item `idx`. */
|
|
809
|
+
const sectionRange = (doc, idx) => {
|
|
810
|
+
if (!doc.items[idx] || doc.items[idx].kind !== 'group') throw new Error(`bug: item ${idx} is not a section`);
|
|
811
|
+
const next = doc.items.findIndex((i, k) => k > idx && i.kind === 'group');
|
|
812
|
+
return { start: idx, end: next < 0 ? doc.items.length : next };
|
|
813
|
+
};
|
|
814
|
+
const sectionTaskIds = (doc, idx) => { const r = sectionRange(doc, idx); return new Set(doc.items.slice(r.start + 1, r.end).filter((i) => i.kind === 'task').map((i) => i.task.id)); };
|
|
815
|
+
const newTask = (doc, fields) => ({ kind: 'task', line: null, task: { id: nextId(doc), name: 'New task', done: false, box: true, indent: '', offset: 0, dur: 3, with: [], tags: [], links: [], ...fields } });
|
|
816
|
+
|
|
817
|
+
/* Rows of the task column: one per section heading and task, in document order. */
|
|
818
|
+
const layout = (doc) => doc.items.reduce((acc, it, idx) => {
|
|
819
|
+
if (it.kind === 'group') return { y: acc.y + 32, group: idx, list: [...acc.list, { kind: 'group', name: it.text, y: acc.y, h: 32, idx }] };
|
|
820
|
+
if (it.kind === 'task') return { ...acc, y: acc.y + 40, list: [...acc.list, { kind: 'task', task: it.task, y: acc.y, h: 40, idx, group: acc.group }] };
|
|
821
|
+
return acc;
|
|
822
|
+
}, { y: 0, group: null, list: [] });
|
|
823
|
+
|
|
824
|
+
/* Where a dragged task lands for pointer height `py`: the item index to insert before, and the indicator's y. */
|
|
825
|
+
const dropSlot = (doc, rows, id, py) => {
|
|
826
|
+
const cand = rows.filter((r) => !(r.kind === 'task' && r.task.id === id));
|
|
827
|
+
if (!cand.length) return { to: taskIndex(doc, id), y: 0, noop: true };
|
|
828
|
+
const hit = cand.find((r) => py < r.y + r.h / 2);
|
|
829
|
+
const last = cand[cand.length - 1];
|
|
830
|
+
const raw = hit ? hit.idx : last.idx + 1;
|
|
831
|
+
const to = hit && hit.kind === 'group' ? backOverBlanks(doc, raw) : raw;
|
|
832
|
+
const from = taskIndex(doc, id);
|
|
833
|
+
return { to, y: hit ? hit.y : last.y + last.h, noop: to === from || to === from + 1 };
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
const ops = {
|
|
837
|
+
patch: (doc, id, fields) => mapTask(doc, id, (t) => ({ ...t, ...fields })),
|
|
838
|
+
move: (doc, id, delta) => mapTask(doc, id, (t) => (t.start !== null ? { ...t, start: t.start + delta } : { ...t, offset: t.offset + delta })),
|
|
839
|
+
resize: (doc, id, delta) => mapTask(doc, id, (t) => ({ ...t, dur: Math.max(1, t.dur + delta) })),
|
|
840
|
+
anchor: (doc, sched, id) => mapTask(doc, id, (t) => {
|
|
841
|
+
if (t.start !== null) throw new Error(`bug: "${id}" is already anchored`);
|
|
842
|
+
return { ...t, start: sched.get(id).start, offset: 0 };
|
|
843
|
+
}),
|
|
844
|
+
unanchor: (doc, sched, id) => mapTask(doc, id, (t) => {
|
|
845
|
+
if (t.start === null) throw new Error(`bug: "${id}" is already relative`);
|
|
846
|
+
if (!depsOf(t).length) throw new Error(`bug: "${id}" has no dependency to be relative to`);
|
|
847
|
+
return { ...t, start: null, offset: t.start - sched.get(id).depsEnd };
|
|
848
|
+
}),
|
|
849
|
+
/* kind 'after' follows the dependency's end; 'with' its start. */
|
|
850
|
+
addDep: (doc, id, depId, kind = 'after') => {
|
|
851
|
+
if (kind !== 'after' && kind !== 'with') throw new Error(`bug: unknown dependency kind "${kind}"`);
|
|
852
|
+
if (dependsOn(doc, depId, id)) throw new Error(`bug: "${id}" ${kind} "${depId}" would create a cycle`);
|
|
853
|
+
return mapTask(doc, id, (t) => ({ ...t, [kind]: [...t[kind], depId] }));
|
|
854
|
+
},
|
|
855
|
+
/* Switches a dependency between following its end and its start; the plan keeps the same links. */
|
|
856
|
+
flipDep: (doc, id, depId) => mapTask(doc, id, (t) => {
|
|
857
|
+
if (t.after.includes(depId)) return { ...t, after: t.after.filter((d) => d !== depId), with: [...t.with, depId] };
|
|
858
|
+
if (t.with.includes(depId)) return { ...t, with: t.with.filter((d) => d !== depId), after: [...t.after, depId] };
|
|
859
|
+
throw new Error(`bug: "${id}" does not depend on "${depId}"`);
|
|
860
|
+
}),
|
|
861
|
+
removeDep: (doc, sched, id, depId) => mapTask(doc, id, (t) => {
|
|
862
|
+
const after = t.after.filter((d) => d !== depId);
|
|
863
|
+
const withs = t.with.filter((d) => d !== depId);
|
|
864
|
+
return t.start === null && after.length === 0 && withs.length === 0 ? { ...t, after, with: withs, start: sched.get(id).start, offset: 0 } : { ...t, after, with: withs };
|
|
865
|
+
}),
|
|
866
|
+
addTag: (doc, id, tag) => {
|
|
867
|
+
if (!TAG_RE.test(tag.trim())) throw new Error(`bug: invalid tag "${tag}"`);
|
|
868
|
+
return mapTask(doc, id, (t) => (t.tags.includes(tag.trim()) ? t : { ...t, tags: [...t.tags, tag.trim()] }));
|
|
869
|
+
},
|
|
870
|
+
removeTag: (doc, id, tag) => mapTask(doc, id, (t) => ({ ...t, tags: t.tags.filter((x) => x !== tag) })),
|
|
871
|
+
/* Renames the plan: rewrites the first "# " line, or adds one (and a blank line) at the top. */
|
|
872
|
+
setTitle: (doc, text) => {
|
|
873
|
+
const k = doc.items.findIndex((i) => i.kind === 'title');
|
|
874
|
+
if (k >= 0) return { ...doc, items: doc.items.map((i, j) => (j === k ? { ...i, text } : i)) };
|
|
875
|
+
return insertItems(doc, 0, [{ kind: 'title', text, prefs: {}, line: null }, { kind: 'raw', text: '', line: null }]);
|
|
876
|
+
},
|
|
877
|
+
/* Sets a display preference on the title line, adding an "Untitled plan" title if there is none. */
|
|
878
|
+
setPref: (doc, key, value) => {
|
|
879
|
+
const d = doc.items.some((i) => i.kind === 'title') ? doc : ops.setTitle(doc, 'Untitled plan');
|
|
880
|
+
return { ...d, items: d.items.map((i) => (i.kind === 'title' && i === d.items.find((x) => x.kind === 'title') ? { ...i, prefs: { ...i.prefs, [key]: value } } : i)) };
|
|
881
|
+
},
|
|
882
|
+
addLink: (doc, id, label, url) => mapTask(doc, id, (t) => ({ ...t, links: [...t.links, { label, url }] })),
|
|
883
|
+
removeLink: (doc, id, index) => mapTask(doc, id, (t) => ({ ...t, links: t.links.filter((_, k) => k !== index) })),
|
|
884
|
+
addTask: (doc, { afterId, today }) => {
|
|
885
|
+
if (afterId) {
|
|
886
|
+
const idx = taskIndex(doc, afterId);
|
|
887
|
+
const item = newTask(doc, { start: null, after: [afterId] });
|
|
888
|
+
return { doc: insertItems(doc, idx + 1, [item]), id: item.task.id };
|
|
889
|
+
}
|
|
890
|
+
const item = newTask(doc, { start: today, after: [] });
|
|
891
|
+
return { doc: insertItems(doc, endIndex(doc), [item]), id: item.task.id };
|
|
892
|
+
},
|
|
893
|
+
/* Adds a task at the end of a section: following its last task, or fixed to today when the section is empty. */
|
|
894
|
+
addTaskToGroup: (doc, groupIdx, today) => {
|
|
895
|
+
if (!doc.items[groupIdx] || doc.items[groupIdx].kind !== 'group') throw new Error(`bug: item ${groupIdx} is not a section`);
|
|
896
|
+
const next = doc.items.findIndex((i, k) => k > groupIdx && i.kind === 'group');
|
|
897
|
+
const end = next < 0 ? doc.items.length : next;
|
|
898
|
+
const last = doc.items.slice(groupIdx + 1, end).filter((i) => i.kind === 'task').pop();
|
|
899
|
+
if (last) return ops.addTask(doc, { afterId: last.task.id, today });
|
|
900
|
+
const item = newTask(doc, { start: today, after: [] });
|
|
901
|
+
return { doc: insertItems(doc, groupIdx + 1, [item]), id: item.task.id };
|
|
902
|
+
},
|
|
903
|
+
/* Appends "## <name>" (preceded by a blank line) before any trailing blank lines. */
|
|
904
|
+
addGroup: (doc) => {
|
|
905
|
+
const names = new Set(doc.items.filter((i) => i.kind === 'group').map((i) => i.text));
|
|
906
|
+
const pick = (n) => { const c = n === 1 ? 'New section' : `New section ${n}`; return names.has(c) ? pick(n + 1) : c; };
|
|
907
|
+
const at2 = endIndex(doc);
|
|
908
|
+
const add = [...(at2 === 0 ? [] : [{ kind: 'raw', text: '', line: null }]), { kind: 'group', text: pick(1), line: null }];
|
|
909
|
+
return { doc: insertItems(doc, at2, add), index: at2 + add.length - 1 };
|
|
910
|
+
},
|
|
911
|
+
renameGroup: (doc, idx, text) => {
|
|
912
|
+
if (!doc.items[idx] || doc.items[idx].kind !== 'group') throw new Error(`bug: item ${idx} is not a section`);
|
|
913
|
+
return { ...doc, items: doc.items.map((i, k) => (k === idx ? { ...i, text } : i)) };
|
|
914
|
+
},
|
|
915
|
+
/* Moves a task line so it sits before item index `to` (indices in the doc before the move). */
|
|
916
|
+
moveTask: (doc, id, to) => {
|
|
917
|
+
const from = taskIndex(doc, id);
|
|
918
|
+
if (to < 0 || to > doc.items.length) throw new Error(`bug: move target ${to} out of range`);
|
|
919
|
+
const rest = doc.items.filter((_, k) => k !== from);
|
|
920
|
+
const at2 = to > from ? to - 1 : to;
|
|
921
|
+
return { ...doc, items: [...rest.slice(0, at2), doc.items[from], ...rest.slice(at2)] };
|
|
922
|
+
},
|
|
923
|
+
/*
|
|
924
|
+
* Deletes the tasks in `ids`. `policy` says what happens to tasks that depend on them:
|
|
925
|
+
* - 'unlink' : drop the link, keep every remaining task's dates exactly (tasks left with no links get pinned)
|
|
926
|
+
* - 'relink' : depend on the deleted tasks' own predecessors instead (keeps offsets, so chains close up)
|
|
927
|
+
* - 'cascade' : delete everything downstream too
|
|
928
|
+
*/
|
|
929
|
+
deleteTasks: (doc, ids, policy) => {
|
|
930
|
+
if (!['unlink', 'relink', 'cascade'].includes(policy)) throw new Error(`bug: unknown delete policy "${policy}"`);
|
|
931
|
+
ids.forEach((id) => taskIndex(doc, id));
|
|
932
|
+
const old = schedule(doc);
|
|
933
|
+
const gone = policy === 'cascade' ? downstream(doc, ids) : ids;
|
|
934
|
+
const kept = { ...doc, items: doc.items.filter((i) => !(i.kind === 'task' && gone.has(i.task.id))) };
|
|
935
|
+
if (policy === 'cascade') return kept;
|
|
936
|
+
const byOld = new Map(tasksOf(doc).map((t) => [t.id, t]));
|
|
937
|
+
const predsOf = (id) => depsOf(byOld.get(id)).flatMap((d) => (gone.has(d) ? predsOf(d) : [d]));
|
|
938
|
+
const affected = new Set(dependentsOf(doc, gone));
|
|
939
|
+
const swap = (list) => [...new Set(list.flatMap((a) => (gone.has(a) ? (policy === 'relink' ? predsOf(a) : []) : [a])))];
|
|
940
|
+
const relinked = [...affected].reduce((d, id) => mapTask(d, id, (x) => {
|
|
941
|
+
const after = swap(x.after);
|
|
942
|
+
const withs = swap(x.with).filter((w) => !after.includes(w));
|
|
943
|
+
return x.start === null && after.length === 0 && withs.length === 0 ? { ...x, after, with: withs, start: old.get(id).start, offset: 0 } : { ...x, after, with: withs };
|
|
944
|
+
}), kept);
|
|
945
|
+
if (policy === 'relink') return relinked;
|
|
946
|
+
return topo(relinked).filter((id) => affected.has(id)).reduce((d, id) => {
|
|
947
|
+
if (findTask(d, id).start !== null) return d;
|
|
948
|
+
const drift = old.get(id).start - schedule(d).get(id).start;
|
|
949
|
+
return drift === 0 ? d : mapTask(d, id, (x) => ({ ...x, offset: x.offset + drift }));
|
|
950
|
+
}, relinked);
|
|
951
|
+
},
|
|
952
|
+
/*
|
|
953
|
+
* Deletes the "## section" heading at item `idx`.
|
|
954
|
+
* - mode 'keep' : only the heading (and the blank line before it) goes; its tasks join the section above
|
|
955
|
+
* - mode 'delete' : the heading and every line under it go; dependents outside follow `policy` (see deleteTasks)
|
|
956
|
+
*/
|
|
957
|
+
deleteSection: (doc, idx, mode, policy) => {
|
|
958
|
+
const { start, end } = sectionRange(doc, idx);
|
|
959
|
+
if (mode === 'keep') {
|
|
960
|
+
const from = start > 0 && isBlank(doc.items[start - 1]) ? start - 1 : start;
|
|
961
|
+
return { ...doc, items: doc.items.filter((_, k) => k < from || k > start) };
|
|
962
|
+
}
|
|
963
|
+
if (mode !== 'delete') throw new Error(`bug: unknown section delete mode "${mode}"`);
|
|
964
|
+
const lines = new Set(doc.items.slice(start, end));
|
|
965
|
+
const ids = sectionTaskIds(doc, idx);
|
|
966
|
+
const d = ids.size ? ops.deleteTasks(doc, ids, policy) : doc;
|
|
967
|
+
return { ...d, items: d.items.filter((i) => !lines.has(i)) };
|
|
968
|
+
},
|
|
969
|
+
applyDelete: (doc, confirm, policy, sectionMode) => {
|
|
970
|
+
if (confirm.kind === 'task') return ops.deleteTasks(doc, new Set([confirm.id]), policy);
|
|
971
|
+
if (confirm.kind === 'section') return ops.deleteSection(doc, confirm.idx, sectionMode, policy);
|
|
972
|
+
throw new Error(`bug: unknown delete target "${confirm.kind}"`);
|
|
973
|
+
},
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
const applyDrag = (doc, drag) => {
|
|
977
|
+
if (drag.mode === 'move') return ops.move(doc, drag.id, drag.delta);
|
|
978
|
+
if (drag.mode === 'resize') return ops.resize(doc, drag.id, drag.delta);
|
|
979
|
+
throw new Error(`bug: unknown drag mode "${drag.mode}"`);
|
|
980
|
+
};
|
|
981
|
+
|
|
982
|
+
/* Lines in `next` that are not part of the longest common subsequence with `prev`. */
|
|
983
|
+
const changedLines = (prev, next) => {
|
|
984
|
+
const a = prev.split('\n'); const b = next.split('\n');
|
|
985
|
+
const L = Array.from({ length: a.length + 1 }, () => new Array(b.length + 1).fill(0));
|
|
986
|
+
for (let i = a.length - 1; i >= 0; i--) for (let j = b.length - 1; j >= 0; j--) L[i][j] = a[i] === b[j] ? L[i + 1][j + 1] + 1 : Math.max(L[i + 1][j], L[i][j + 1]);
|
|
987
|
+
const changed = new Array(b.length).fill(true);
|
|
988
|
+
for (let i = 0, j = 0; i < a.length && j < b.length;) {
|
|
989
|
+
if (a[i] === b[j]) { changed[j] = false; i++; j++; } else if (L[i + 1][j] >= L[i][j + 1]) i++; else j++;
|
|
990
|
+
}
|
|
991
|
+
return changed;
|
|
992
|
+
};
|
|
993
|
+
|
|
994
|
+
const tok = (text, color, weight, bg) => ({ text, color, weight, bg });
|
|
995
|
+
const ATTR_COLORS = { start: ['#FFC08A', 'rgba(224,120,42,.16)'], after: ['#A9C1FF', 'rgba(143,176,255,.14)'], with: ['#C9B6FF', 'rgba(170,140,255,.14)'], tags: ['#8FD3B8', 'rgba(143,211,184,.12)'], id: ['#C9C6BF', 'rgba(255,255,255,.06)'], dur: ['#C9C6BF', 'rgba(255,255,255,.06)'] };
|
|
996
|
+
const tokenize = (text) => {
|
|
997
|
+
if (/^#\s/.test(text)) return [tok(text, '#FFFFFF', 700, 'transparent')];
|
|
998
|
+
if (/^##\s/.test(text)) return [tok(text, '#FFFFFF', 600, 'transparent')];
|
|
999
|
+
const m = /^(\s*[-*]\s+(?:\[[ xX]\]\s+)?)(.*)$/.exec(text);
|
|
1000
|
+
if (!m || !m[2].includes('`id:')) return [tok(text || ' ', '#9A9890', 400, 'transparent')];
|
|
1001
|
+
return [tok(m[1], '#8A877F', 400, 'transparent'), ...m[2].split(/(`[^`]*`|\[[^\]]+\]\([^)\s]+\))/).filter(Boolean).map((p) => {
|
|
1002
|
+
if (p.startsWith('[')) return tok(p, '#8FD3B8', 400, 'transparent');
|
|
1003
|
+
if (!p.startsWith('`')) return tok(p, '#E6E4DF', 500, 'transparent');
|
|
1004
|
+
const key = (/^`([A-Za-z]+):/.exec(p) || [])[1];
|
|
1005
|
+
const c = ATTR_COLORS[key] || ['#FF9C9C', 'rgba(255,80,80,.14)'];
|
|
1006
|
+
return tok(p, c[0], 400, c[1]);
|
|
1007
|
+
})];
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
return { parse, serialize, prefsOf, schedule, ops, applyDrag, tasksOf, depsOf, TAG_RE, layout, dropSlot, dependentsOf, downstream, predecessorsOf, sectionTaskIds, findTask, dependsOn, changedLines, tokenize, dayFromIso, isoFromDay, dow, parts, fmt, MON };
|
|
1011
|
+
})();
|
|
1012
|
+
|
|
1013
|
+
/** A blank plan: what the page opens with when there is no ?src=, and what New plan starts. */
|
|
1014
|
+
const newPlanMd = (today) => `# Untitled plan\n\n## Tasks\n- [ ] First task \`id:task-1\` \`start:${G.isoFromDay(today)}\` \`dur:3d\`\n`;
|
|
1015
|
+
|
|
1016
|
+
/* ---------- Start-up: the fetched plan (or a blank one), today, and the address-bar settings ---------- */
|
|
1017
|
+
const BOOT = window.GANTT_BOOT ?? { md: null, src: null, error: null };
|
|
1018
|
+
const QUERY = new URLSearchParams(location.search);
|
|
1019
|
+
const localIso = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
|
1020
|
+
/** ?today=YYYY-MM-DD pins "today" (handy for screenshots); otherwise it is the local date. */
|
|
1021
|
+
const TODAY = (() => { const t = QUERY.get('today'); try { return G.dayFromIso(t ?? ''); } catch (e) { return G.dayFromIso(localIso(new Date())); } })();
|
|
1022
|
+
const THEMES = [
|
|
1023
|
+
{ id: 'paper', label: 'Graph paper', bg: '#F6F5F2', ink: '#17181A', accent: '#2F5BD3' },
|
|
1024
|
+
{ id: 'night', label: 'Night shift', bg: '#111316', ink: '#ECEFED', accent: '#5B86F0' },
|
|
1025
|
+
{ id: 'blueprint', label: 'Blueprint', bg: '#0F2747', ink: '#F1F6FF', accent: '#FFB347' },
|
|
1026
|
+
{ id: 'warm', label: 'Warm ledger', bg: '#F5F0E6', ink: '#7A2E1C', accent: '#C8642B' },
|
|
1027
|
+
];
|
|
1028
|
+
const THEME_KEY = 'gantt:theme';
|
|
1029
|
+
const storedTheme = () => { try { return localStorage.getItem(THEME_KEY); } catch (e) { return null; } };
|
|
1030
|
+
const pick = (v, ids, dflt) => (ids.includes(v) ? v : dflt);
|
|
1031
|
+
/* Named saves in this browser: { name: { md, savedAt } } under one key. Storage can be unavailable (private mode). */
|
|
1032
|
+
const SAVES_KEY = 'gantt:saves';
|
|
1033
|
+
const readSaves = () => { try { const v = JSON.parse(localStorage.getItem(SAVES_KEY) || '{}'); return v && typeof v === 'object' ? v : {}; } catch (e) { return {}; } };
|
|
1034
|
+
const writeSaves = (saves) => localStorage.setItem(SAVES_KEY, JSON.stringify(saves));
|
|
1035
|
+
/* The markdown panel's width, remembered in this browser and kept between 240px and leaving the timeline 320px. */
|
|
1036
|
+
const MD_W_KEY = 'gantt:md-width';
|
|
1037
|
+
const clampMdW = (w) => Math.round(Math.max(240, Math.min(w, window.innerWidth - 320)));
|
|
1038
|
+
const storedMdW = () => { try { return Number(localStorage.getItem(MD_W_KEY)) || 380; } catch (e) { return 380; } };
|
|
1039
|
+
/** The plan to start from: the ?src= file if it parses, else an empty plan with the error shown in the Open dialog. */
|
|
1040
|
+
const START = (() => {
|
|
1041
|
+
const md = BOOT.md ?? newPlanMd(TODAY);
|
|
1042
|
+
if (BOOT.error !== null) return { doc: G.parse(''), md: '', error: BOOT.error };
|
|
1043
|
+
try { const doc = G.parse(md); return { doc, md: G.serialize(doc), error: null }; } catch (e) { return { doc: G.parse(''), md: '', error: `Can’t show ${BOOT.src ?? 'the plan'} — ${e.message}` }; }
|
|
1044
|
+
})();
|
|
1045
|
+
/** Mirrors theme, zoom, view and the selected task into the address bar (defaults left out), keeping ?src= and the rest. */
|
|
1046
|
+
const syncQuery = (st) => {
|
|
1047
|
+
const q = new URLSearchParams(location.search);
|
|
1048
|
+
[['q', st.query.trim(), ''], ['tags', st.tagFilter.join(','), ''], ['theme', st.theme, 'paper'], ['zoom', st.zoom, 'day'], ['view', st.layout, 'split'], ['task', st.selectedId, null]].forEach(([k, v, d]) => { if (v === d || v === null) q.delete(k); else q.set(k, v); });
|
|
1049
|
+
if (st.srcParam === null) q.delete('src'); else q.set('src', st.srcParam);
|
|
1050
|
+
const qs = q.toString().replace(/%2F/gi, '/').replace(/%3A/gi, ':').replace(/%2C/gi, ',');
|
|
1051
|
+
const url = location.pathname + (qs ? '?' + qs : '') + location.hash;
|
|
1052
|
+
if (url !== location.pathname + location.search + location.hash) history.replaceState(null, '', url);
|
|
1053
|
+
};
|
|
1054
|
+
/** A share link with the plan deflated and base64url'd into #md= (the hash never reaches a server). The loader decodes it. */
|
|
1055
|
+
const LINK_WARN = 2048; /* the classic URL ceiling: some apps, emails and servers cut links longer than this */
|
|
1056
|
+
const planLink = async (md) => {
|
|
1057
|
+
const bytes = new Uint8Array(await new Response(new Blob([md]).stream().pipeThrough(new CompressionStream('deflate-raw'))).arrayBuffer());
|
|
1058
|
+
let bin = ''; for (let i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]);
|
|
1059
|
+
const q = new URLSearchParams(location.search); q.delete('src');
|
|
1060
|
+
const qs = q.toString();
|
|
1061
|
+
return location.origin + location.pathname + (qs ? '?' + qs : '') + '#md=' + btoa(bin).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
1062
|
+
};
|
|
1063
|
+
const REL_TEXT = 'var(--on-rel)';
|
|
1064
|
+
const FIX_TEXT = 'var(--on-fixed)';
|
|
1065
|
+
|
|
1066
|
+
class Component extends DCLogic {
|
|
1067
|
+
state = {
|
|
1068
|
+
doc: START.doc, past: [], future: [], prevMd: START.md, lastKey: null, baseMd: START.md,
|
|
1069
|
+
/* srcLabel: what the header shows (a URL, or a file name); srcParam: the ?src= to keep in the address bar. */
|
|
1070
|
+
srcLabel: BOOT.src ?? (BOOT.shared ? 'shared link' : 'untitled.md'), srcParam: BOOT.src,
|
|
1071
|
+
theme: pick(QUERY.get('theme') ?? G.prefsOf(START.doc).theme ?? storedTheme(), THEMES.map((t) => t.id), 'paper'),
|
|
1072
|
+
query: QUERY.get('q') ?? '',
|
|
1073
|
+
linkName: '', linkUrl: '', linkError: '',
|
|
1074
|
+
titleEditing: false, titleDraft: '', tagDraft: '', tagsOpen: false,
|
|
1075
|
+
fileOpen: false, linkNote: null, saveUrl: BOOT.writable ? new URL(BOOT.src, location.href).href : null, saveOpen: false, saveName: '', saveError: '', savedName: null,
|
|
1076
|
+
tagFilter: (QUERY.get('tags') ?? '').split(',').map((x) => x.trim()).filter(Boolean),
|
|
1077
|
+
openOpen: START.error !== null, openUrl: '', openError: START.error ?? '', openBusy: false, dropActive: false,
|
|
1078
|
+
selectedId: QUERY.get('task'), drag: null, reorder: null, newGroupIdx: null,
|
|
1079
|
+
zoom: pick(QUERY.get('zoom'), ['day', 'week'], 'day'), layout: pick(QUERY.get('view') ?? G.prefsOf(START.doc).view, ['chart', 'split'], 'split'),
|
|
1080
|
+
confirm: null, policy: 'unlink', sectionMode: 'keep',
|
|
1081
|
+
editing: false, draft: '', copied: null, nameError: null,
|
|
1082
|
+
mdW: clampMdW(storedMdW()), mdResize: null,
|
|
1083
|
+
};
|
|
1084
|
+
|
|
1085
|
+
/** Theme and view to switch to when the plan's own preferences change from `prev` to `next` (all of them when prev is null). */
|
|
1086
|
+
prefState(prev, next) {
|
|
1087
|
+
const a = prev ? G.prefsOf(prev) : {}; const b = G.prefsOf(next); const out = {};
|
|
1088
|
+
if (b.theme !== a.theme && THEMES.some((t) => t.id === b.theme)) out.theme = b.theme;
|
|
1089
|
+
if (b.view !== a.view && ['chart', 'split'].includes(b.view)) out.layout = b.view;
|
|
1090
|
+
return out;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
commit(next, key, extra) {
|
|
1094
|
+
const s = this.state;
|
|
1095
|
+
const coalesce = key !== null && key === s.lastKey;
|
|
1096
|
+
this.setState({
|
|
1097
|
+
doc: next,
|
|
1098
|
+
past: coalesce ? s.past : [...s.past, s.doc],
|
|
1099
|
+
future: [],
|
|
1100
|
+
prevMd: coalesce ? s.prevMd : G.serialize(s.doc),
|
|
1101
|
+
lastKey: key,
|
|
1102
|
+
copied: null,
|
|
1103
|
+
newGroupIdx: null,
|
|
1104
|
+
...this.prefState(s.doc, next),
|
|
1105
|
+
...(extra || {}),
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
today() { return TODAY; }
|
|
1110
|
+
/** Adds a task, selects it and puts the cursor in its name, ready to type over. */
|
|
1111
|
+
commitNewTask(r2) {
|
|
1112
|
+
this.commit(r2.doc, null, { selectedId: r2.id });
|
|
1113
|
+
setTimeout(() => { const el = document.getElementById('insp-name'); if (el) { el.focus(); el.select(); } });
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/* Open: replace the plan with a parsed file. A file that does not parse leaves the plan alone and shows why. */
|
|
1117
|
+
openText(text, label, fromUrl, writable = false) {
|
|
1118
|
+
let doc;
|
|
1119
|
+
try { doc = G.parse(text.replace(/\r\n?/g, '\n')); } catch (e) {
|
|
1120
|
+
this.setState({ openOpen: true, openBusy: false, dropActive: false, openError: `Can’t open ${label} — ${e.message}` });
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
const md = G.serialize(doc);
|
|
1124
|
+
this.setState({
|
|
1125
|
+
doc, past: [], future: [], prevMd: md, baseMd: md, lastKey: null, srcLabel: label, srcParam: fromUrl ? label : null, saveUrl: fromUrl && writable ? new URL(label, location.href).href : null, savedName: null,
|
|
1126
|
+
selectedId: null, drag: null, reorder: null, confirm: null, editing: false, draft: '', copied: `Opened ${label}`, nameError: null,
|
|
1127
|
+
openOpen: false, openBusy: false, openError: '', openUrl: '', dropActive: false, ...this.prefState(null, doc),
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
openFiles(files) {
|
|
1131
|
+
const f = files && files[0];
|
|
1132
|
+
if (!f) { this.setState({ openError: 'Drop or choose a .md file.', dropActive: false }); return; }
|
|
1133
|
+
f.text().then((t) => this.openText(t, f.name, false), (e) => this.setState({ openError: `Can’t read ${f.name} — ${e.message}`, dropActive: false }));
|
|
1134
|
+
}
|
|
1135
|
+
openUrl() {
|
|
1136
|
+
const raw = this.state.openUrl.trim();
|
|
1137
|
+
if (raw === '' || this.state.openBusy) return;
|
|
1138
|
+
let url;
|
|
1139
|
+
try { url = new URL(raw, location.href); } catch (e) { this.setState({ openError: `“${raw}” is not a URL` }); return; }
|
|
1140
|
+
this.setState({ openBusy: true, openError: '' });
|
|
1141
|
+
fetch(url).then((res) => { if (!res.ok) throw new Error('HTTP ' + res.status); return res.text().then((t) => [t, res.headers.get('x-agile-writable') === '1']); }).then(
|
|
1142
|
+
([t, writable]) => this.openText(t, raw, true, writable),
|
|
1143
|
+
(e) => this.setState({ openBusy: false, openError: `Could not open ${raw}: ${e.message}. A URL on another site must allow cross-origin requests (GitHub Pages and raw.githubusercontent.com do).` }),
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
/* New: a one-task plan starting today. Unsaved edits are only dropped after a yes. */
|
|
1147
|
+
newPlan() {
|
|
1148
|
+
const dirty = G.serialize(this.state.doc) !== this.state.baseMd;
|
|
1149
|
+
if (dirty && typeof confirm === 'function' && !confirm('Start a new plan? Your unsaved edits will be lost (download or copy them first).')) return;
|
|
1150
|
+
this.openText(newPlanMd(TODAY), 'untitled.md', false);
|
|
1151
|
+
this.setState({ fileOpen: false });
|
|
1152
|
+
}
|
|
1153
|
+
/* Copies a link carrying the whole plan; it is copied even when long, with a warning. */
|
|
1154
|
+
copyLink(md) {
|
|
1155
|
+
if (!navigator.clipboard || typeof CompressionStream !== 'function') { this.setState({ linkNote: { text: 'This browser can’t copy a link here — use Download instead.', bad: true } }); return; }
|
|
1156
|
+
planLink(md).then((url) => navigator.clipboard.writeText(url).then(() => url)).then(
|
|
1157
|
+
(url) => this.setState({ linkNote: url.length > LINK_WARN
|
|
1158
|
+
? { text: `Link copied, but it is ${url.length.toLocaleString()} characters — some apps and emails cut links over ${LINK_WARN.toLocaleString()}. Download the file to be safe.`, bad: true }
|
|
1159
|
+
: { text: `Link copied (${url.length.toLocaleString()} characters). It contains the plan as it is now.`, bad: false } }),
|
|
1160
|
+
(e) => this.setState({ linkNote: { text: `Couldn’t copy the link: ${e.message}`, bad: true } }),
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
download(fileName, md) {
|
|
1164
|
+
const a = document.createElement('a');
|
|
1165
|
+
a.href = URL.createObjectURL(new Blob([md], { type: 'text/markdown' }));
|
|
1166
|
+
a.download = fileName;
|
|
1167
|
+
a.click();
|
|
1168
|
+
setTimeout(() => URL.revokeObjectURL(a.href), 0);
|
|
1169
|
+
this.setState({ copied: `Downloaded ${fileName}`, fileOpen: false });
|
|
1170
|
+
}
|
|
1171
|
+
/* Adds a [name](url) link to a task; only http(s) addresses, and the name defaults to the site. */
|
|
1172
|
+
addLink(id) {
|
|
1173
|
+
const raw = this.state.linkUrl.trim();
|
|
1174
|
+
let url;
|
|
1175
|
+
try { url = new URL(raw); } catch (e) { this.setState({ linkError: raw === '' ? 'Enter a URL.' : `“${raw}” is not a full URL (start it with https://).` }); return; }
|
|
1176
|
+
if (!/^https?:$/.test(url.protocol)) { this.setState({ linkError: 'Links must be http or https.' }); return; }
|
|
1177
|
+
const label = (this.state.linkName.trim() || url.hostname).replace(/[\[\]`]/g, '');
|
|
1178
|
+
this.commit(G.ops.addLink(this.state.doc, id, label, url.href.replace(/[()\s]/g, encodeURIComponent)), null, { linkName: '', linkUrl: '', linkError: '' });
|
|
1179
|
+
}
|
|
1180
|
+
/* Save to the file itself, when the local `agile` server said it may be written (x-agile-writable). */
|
|
1181
|
+
saveFile(md) {
|
|
1182
|
+
const s = this.state;
|
|
1183
|
+
if (s.saveUrl === null) return;
|
|
1184
|
+
fetch(s.saveUrl, { method: 'PUT', body: md, headers: { 'content-type': 'text/markdown;charset=utf-8' } }).then((res) => {
|
|
1185
|
+
if (!res.ok) throw new Error('HTTP ' + res.status);
|
|
1186
|
+
this.setState({ baseMd: md, savedName: null, fileOpen: false, copied: `Saved ${s.srcLabel}` });
|
|
1187
|
+
}).catch((e) => this.setState({ linkNote: { text: `Couldn’t save ${s.srcLabel}: ${e.message}. Download it instead.`, bad: true } }));
|
|
1188
|
+
}
|
|
1189
|
+
/* The card designer, in a new tab so unsaved edits here survive: the plan goes along as ?src= or, when edited, as #md=. */
|
|
1190
|
+
designCard(md) {
|
|
1191
|
+
const s = this.state;
|
|
1192
|
+
const u = new URL('card.html', location.href);
|
|
1193
|
+
if (s.srcParam !== null) u.searchParams.set('src', s.srcParam);
|
|
1194
|
+
const w = window.open('', '_blank');
|
|
1195
|
+
const go = (hash) => { u.hash = hash; if (w) w.location.href = u.href; else location.href = u.href; };
|
|
1196
|
+
if (s.srcParam !== null && md === s.baseMd) go('');
|
|
1197
|
+
else planLink(md).then((link) => go(new URL(link).hash), () => go(''));
|
|
1198
|
+
this.setState({ fileOpen: false });
|
|
1199
|
+
}
|
|
1200
|
+
/* Save in this browser under a name; the badge then compares against that save. */
|
|
1201
|
+
saveLocal() {
|
|
1202
|
+
const name = this.state.saveName.trim();
|
|
1203
|
+
if (name === '') { this.setState({ saveError: 'Give the save a name.' }); return; }
|
|
1204
|
+
const md = G.serialize(this.state.doc);
|
|
1205
|
+
try { writeSaves({ ...readSaves(), [name]: { md, savedAt: new Date().toISOString() } }); } catch (e) {
|
|
1206
|
+
this.setState({ saveError: `This browser won’t store it (${e.message}). Download the file instead.` });
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
this.setState({ baseMd: md, savedName: name, saveOpen: false, fileOpen: false, saveError: '', copied: `Saved “${name}” in this browser` });
|
|
1210
|
+
}
|
|
1211
|
+
openLocal(name) {
|
|
1212
|
+
const save = readSaves()[name];
|
|
1213
|
+
if (!save) { this.setState({ openError: `There is no save called “${name}” in this browser any more.` }); return; }
|
|
1214
|
+
this.openText(save.md, name, false);
|
|
1215
|
+
if (this.state.srcLabel === name) this.setState({ savedName: name, copied: `Opened “${name}” from this browser` });
|
|
1216
|
+
}
|
|
1217
|
+
deleteLocal(name) {
|
|
1218
|
+
if (typeof confirm === 'function' && !confirm(`Delete the save “${name}” from this browser?`)) return;
|
|
1219
|
+
const { [name]: _, ...rest } = readSaves();
|
|
1220
|
+
try { writeSaves(rest); } catch (e) { this.setState({ openError: `Couldn’t delete it: ${e.message}` }); return; }
|
|
1221
|
+
this.setState({ savedName: this.state.savedName === name ? null : this.state.savedName, openError: '' });
|
|
1222
|
+
}
|
|
1223
|
+
saveTitle() {
|
|
1224
|
+
const s = this.state;
|
|
1225
|
+
if (!s.titleEditing) return;
|
|
1226
|
+
const text = s.titleDraft.replace(/\s+/g, ' ').trim();
|
|
1227
|
+
const cur = (s.doc.items.find((i) => i.kind === 'title') || { text: null }).text;
|
|
1228
|
+
if (text === '' || text === cur) { this.setState({ titleEditing: false, titleDraft: '' }); return; }
|
|
1229
|
+
this.commit(G.ops.setTitle(s.doc, text), null, { titleEditing: false, titleDraft: '' });
|
|
1230
|
+
}
|
|
1231
|
+
addTags(id, raw) {
|
|
1232
|
+
const tags = raw.split(',').map((x) => x.replace(/^#/, '').trim()).filter((x) => x !== '' && G.TAG_RE.test(x));
|
|
1233
|
+
if (tags.length === 0) { this.setState({ tagDraft: '' }); return; }
|
|
1234
|
+
this.commit(tags.reduce((d, t) => G.ops.addTag(d, id, t), this.state.doc), null, { tagDraft: '' });
|
|
1235
|
+
}
|
|
1236
|
+
setTheme(id) {
|
|
1237
|
+
try { localStorage.setItem(THEME_KEY, id); } catch (e) { /* not remembered; the address bar still carries it */ }
|
|
1238
|
+
this.commit(G.ops.setPref(this.state.doc, 'theme', id), null, { theme: id });
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
askDeleteTask(id) { this.setState({ confirm: { kind: 'task', id }, policy: 'unlink', drag: null, reorder: null }); }
|
|
1242
|
+
askDeleteSection(idx) { this.setState({ confirm: { kind: 'section', idx }, policy: 'unlink', sectionMode: 'keep', drag: null, reorder: null }); }
|
|
1243
|
+
/** Delete/Backspace on a task: gone at once (undo restores it) unless other tasks depend on it, which needs the dialog's choice. */
|
|
1244
|
+
deleteKey(id, e) {
|
|
1245
|
+
if (e.key !== 'Delete' && e.key !== 'Backspace') return;
|
|
1246
|
+
e.preventDefault();
|
|
1247
|
+
const ids = new Set([id]);
|
|
1248
|
+
if (G.dependentsOf(this.state.doc, ids).length) { this.askDeleteTask(id); return; }
|
|
1249
|
+
this.commit(G.ops.deleteTasks(this.state.doc, ids, 'unlink'), null, { selectedId: null, copied: 'Task deleted · undo restores it' });
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
setMdW(w) {
|
|
1253
|
+
const mdW = clampMdW(w);
|
|
1254
|
+
try { localStorage.setItem(MD_W_KEY, String(mdW)); } catch (e) { /* not remembered */ }
|
|
1255
|
+
this.setState({ mdW });
|
|
1256
|
+
}
|
|
1257
|
+
mdResizeDown(e) {
|
|
1258
|
+
if (e.button !== 0) return;
|
|
1259
|
+
e.preventDefault();
|
|
1260
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1261
|
+
this.setState({ mdResize: { x0: e.clientX, w0: this.state.mdW } });
|
|
1262
|
+
}
|
|
1263
|
+
/* The panel sits on the right, so dragging its left edge leftwards widens it. */
|
|
1264
|
+
mdResizeMove(e) { const r = this.state.mdResize; if (r) this.setMdW(r.w0 - (e.clientX - r.x0)); }
|
|
1265
|
+
mdResizeKey(e) {
|
|
1266
|
+
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
|
|
1267
|
+
e.preventDefault();
|
|
1268
|
+
this.setMdW(this.state.mdW + (e.key === 'ArrowLeft' ? 24 : -24));
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
barDown(id, mode, dw, e) {
|
|
1272
|
+
if (e.button !== 0) return;
|
|
1273
|
+
e.preventDefault();
|
|
1274
|
+
e.stopPropagation();
|
|
1275
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1276
|
+
this.setState({ selectedId: id, nameError: null, drag: { id, mode, x0: e.clientX, dw, delta: 0 } });
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
rowDown(id, rowY, e) {
|
|
1280
|
+
if (e.button !== 0) return;
|
|
1281
|
+
e.preventDefault();
|
|
1282
|
+
e.stopPropagation();
|
|
1283
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1284
|
+
this.setState({ selectedId: id, nameError: null, reorder: { id, y0: e.clientY, rowY, dy: 0 } });
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
/* Arrow keys on a row's handle: move the task one slot up or down, crossing section boundaries. */
|
|
1288
|
+
rowKey(id, e) {
|
|
1289
|
+
if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return;
|
|
1290
|
+
e.preventDefault();
|
|
1291
|
+
const doc = this.state.doc;
|
|
1292
|
+
const rows = G.layout(doc).list;
|
|
1293
|
+
const k = rows.findIndex((r) => r.kind === 'task' && r.task.id === id);
|
|
1294
|
+
const nb = rows[e.key === 'ArrowUp' ? k - 1 : k + 1];
|
|
1295
|
+
if (!nb) return;
|
|
1296
|
+
const slot = G.dropSlot(doc, rows, id, e.key === 'ArrowUp' ? nb.y + nb.h / 2 - 1 : nb.y + nb.h / 2 + 1);
|
|
1297
|
+
if (!slot.noop) this.commit(G.ops.moveTask(doc, id, slot.to), null, { selectedId: id });
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
onMove(e) {
|
|
1301
|
+
const r = this.state.reorder;
|
|
1302
|
+
if (r) {
|
|
1303
|
+
const dy = e.clientY - r.y0;
|
|
1304
|
+
if (dy !== r.dy) this.setState({ reorder: { ...r, dy } });
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
const d = this.state.drag;
|
|
1308
|
+
if (!d) return;
|
|
1309
|
+
const delta = Math.round((e.clientX - d.x0) / d.dw);
|
|
1310
|
+
if (delta !== d.delta) this.setState({ drag: { ...d, delta } });
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
onUp() {
|
|
1314
|
+
const r = this.state.reorder;
|
|
1315
|
+
if (r) {
|
|
1316
|
+
const doc = this.state.doc;
|
|
1317
|
+
const slot = G.dropSlot(doc, G.layout(doc).list, r.id, r.rowY + 20 + r.dy);
|
|
1318
|
+
if (slot.noop) { this.setState({ reorder: null }); return; }
|
|
1319
|
+
this.commit(G.ops.moveTask(doc, r.id, slot.to), null, { reorder: null });
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1322
|
+
const d = this.state.drag;
|
|
1323
|
+
if (!d) return;
|
|
1324
|
+
if (d.delta === 0) { this.setState({ drag: null }); return; }
|
|
1325
|
+
this.commit(G.applyDrag(this.state.doc, d), null, { drag: null });
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
renderVals() {
|
|
1329
|
+
const s = this.state;
|
|
1330
|
+
const rel = 'var(--rel)';
|
|
1331
|
+
const fix = 'var(--fixed)';
|
|
1332
|
+
const src = s.srcLabel ?? 'untitled.md';
|
|
1333
|
+
const today = this.today();
|
|
1334
|
+
const dw = s.zoom === 'day' ? 32 : 12;
|
|
1335
|
+
const committed = G.schedule(s.doc);
|
|
1336
|
+
const view = s.drag && s.drag.delta !== 0 ? G.applyDrag(s.doc, s.drag) : s.doc;
|
|
1337
|
+
const sched = view === s.doc ? committed : G.schedule(view);
|
|
1338
|
+
const md = G.serialize(s.doc);
|
|
1339
|
+
const tasks = G.tasksOf(view);
|
|
1340
|
+
const byId = new Map(tasks.map((t) => [t.id, t]));
|
|
1341
|
+
const nameOf = (id) => byId.get(id).name;
|
|
1342
|
+
|
|
1343
|
+
/* Time axis, from the committed plan so the axis stays still while dragging. */
|
|
1344
|
+
const starts = [...committed.values()].map((v) => v.start).concat([today]);
|
|
1345
|
+
const ends = [...committed.values()].map((v) => v.end).concat([today]);
|
|
1346
|
+
const rough = Math.min(...starts) - 4;
|
|
1347
|
+
const day0 = rough - ((G.dow(rough) + 6) % 7);
|
|
1348
|
+
const nDays = Math.ceil((Math.max(...ends) + 14 - day0) / 7) * 7;
|
|
1349
|
+
const X = (n) => (n - day0) * dw;
|
|
1350
|
+
const tlW = nDays * dw;
|
|
1351
|
+
const days = Array.from({ length: nDays }, (_, i) => day0 + i);
|
|
1352
|
+
|
|
1353
|
+
const months = days.filter((n, i) => i === 0 || G.parts(n).d === 1).map((n) => ({ x: X(n), label: `${G.MON[G.parts(n).m]} ${G.parts(n).y}` }));
|
|
1354
|
+
const ticks = s.zoom === 'day'
|
|
1355
|
+
? days.map((n) => ({ x: X(n), w: dw, align: 'center', pad: 0, label: String(G.parts(n).d), color: G.dow(n) % 6 === 0 ? 'var(--faint)' : (n === today ? 'var(--today)' : 'var(--ink-2)') }))
|
|
1356
|
+
: days.filter((n) => G.dow(n) === 1).map((n) => ({ x: X(n), w: dw * 7, align: 'left', pad: 6, label: `${G.parts(n).d}`, color: 'var(--ink-2)' }));
|
|
1357
|
+
const weekends = days.filter((n) => G.dow(n) === 6).map((n) => ({ x: X(n), w: dw * 2 }));
|
|
1358
|
+
|
|
1359
|
+
/* Rows: one per group heading and task, in document order. */
|
|
1360
|
+
const sel = s.selectedId && byId.has(s.selectedId) ? s.selectedId : null;
|
|
1361
|
+
syncQuery({ ...s, selectedId: sel });
|
|
1362
|
+
const rowsRaw = G.layout(view);
|
|
1363
|
+
const groupOf = new Map(rowsRaw.list.filter((r) => r.kind === 'task').map((r) => [r.task.id, r.group]));
|
|
1364
|
+
const ro = s.reorder;
|
|
1365
|
+
/* Filter: every word must appear in the task's name, id or section. Non-matching tasks are dimmed, not hidden, so rows keep their places. */
|
|
1366
|
+
const terms = s.query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
1367
|
+
const sectionOf = (id) => { const g = groupOf.get(id); return g === null || g === undefined ? '' : view.items[g].text; };
|
|
1368
|
+
/* The tag filter keeps tasks carrying any chosen tag; it combines with the text filter. */
|
|
1369
|
+
const matches = (t) => terms.every((w) => `${t.name} ${t.id} ${sectionOf(t.id)} ${t.tags.join(' ')}`.toLowerCase().includes(w))
|
|
1370
|
+
&& (s.tagFilter.length === 0 || t.tags.some((x) => s.tagFilter.includes(x)));
|
|
1371
|
+
const filterOn = terms.length > 0 || s.tagFilter.length > 0;
|
|
1372
|
+
const hits = new Set(tasks.filter(matches).map((t) => t.id));
|
|
1373
|
+
const dimOf = (id) => (!filterOn || hits.has(id) ? 1 : 0.28);
|
|
1374
|
+
const slot = ro ? G.dropSlot(s.doc, rowsRaw.list, ro.id, ro.rowY + 20 + ro.dy) : null;
|
|
1375
|
+
const bodyH = Math.max(rowsRaw.y + 80, 420);
|
|
1376
|
+
const midY = new Map(rowsRaw.list.filter((r) => r.kind === 'task').map((r) => [r.task.id, r.y + 20]));
|
|
1377
|
+
|
|
1378
|
+
/* A task's reference points: the end of each after: task and the start of each with: task; the latest wins. */
|
|
1379
|
+
const refsOf = (t, sch) => [...t.after.map((d) => ({ id: d, kind: 'after', at: sch.get(d).end })), ...t.with.map((d) => ({ id: d, kind: 'with', at: sch.get(d).start }))];
|
|
1380
|
+
const latestRef = (t, sch) => refsOf(t, sch).reduce((a, r) => (r.at > a.at ? r : a));
|
|
1381
|
+
const depText = (t, names) => [t.after.length ? `after ${t.after.map(names).join(', ')}` : '', t.with.length ? `with ${t.with.map(names).join(', ')}` : ''].filter(Boolean).join(' · ');
|
|
1382
|
+
const cap = (x) => x.charAt(0).toUpperCase() + x.slice(1);
|
|
1383
|
+
const linksTxt = (t) => (t.links.length ? ` · ${t.links.length} link${t.links.length === 1 ? '' : 's'}` : '') + (t.tags.length ? ` · ${t.tags.map((x) => '#' + x).join(' ')}` : '');
|
|
1384
|
+
const metaFor = (t) => {
|
|
1385
|
+
const sc = sched.get(t.id);
|
|
1386
|
+
const durTxt = t.dur === 0 ? 'Milestone' : `${t.dur}d`;
|
|
1387
|
+
if (sc.conflict) {
|
|
1388
|
+
const late = latestRef(t, sched);
|
|
1389
|
+
return { text: `Conflict · starts ${sc.depsEnd - sc.start}d before ${nameOf(late.id)} ${late.kind === 'after' ? 'ends' : 'starts'}`, color: 'var(--bad)' };
|
|
1390
|
+
}
|
|
1391
|
+
if (t.start !== null) return { text: `Fixed ${G.fmt(t.start)}${G.depsOf(t).length ? ' · ' + depText(t, nameOf) : ''} · ${durTxt}${linksTxt(t)}`, color: 'var(--muted)' };
|
|
1392
|
+
const off = t.offset === 0 ? '' : ` ${t.offset > 0 ? '+' : '−'}${Math.abs(t.offset)}d`;
|
|
1393
|
+
return { text: `${cap(depText(t, nameOf))}${off} · ${durTxt}${linksTxt(t)}`, color: 'var(--muted)' };
|
|
1394
|
+
};
|
|
1395
|
+
|
|
1396
|
+
const toggleAnchor = (t) => () => {
|
|
1397
|
+
const doc = s.doc;
|
|
1398
|
+
const sc = G.schedule(doc);
|
|
1399
|
+
const cur = G.findTask(doc, t.id);
|
|
1400
|
+
this.commit(cur.start === null ? G.ops.anchor(doc, sc, t.id) : G.ops.unanchor(doc, sc, t.id), null, { selectedId: t.id });
|
|
1401
|
+
};
|
|
1402
|
+
|
|
1403
|
+
const rows = rowsRaw.list.map((r) => {
|
|
1404
|
+
if (r.kind === 'group') {
|
|
1405
|
+
return {
|
|
1406
|
+
isGroup: true, isTask: false, name: r.name, y: r.y, h: r.h, laneBg: 'var(--bg)',
|
|
1407
|
+
inputId: `section-${r.idx}`, autoFocus: r.idx === s.newGroupIdx,
|
|
1408
|
+
addLabel: `Add a task to ${r.name || 'this section'}`,
|
|
1409
|
+
onRename: (e) => this.commit(G.ops.renameGroup(s.doc, r.idx, e.target.value), `group:${r.idx}`),
|
|
1410
|
+
onAdd: () => this.commitNewTask(G.ops.addTaskToGroup(s.doc, r.idx, today)),
|
|
1411
|
+
onFocusSel: (e) => { if (r.idx === s.newGroupIdx) e.target.select(); },
|
|
1412
|
+
delLabel: `Delete section ${r.name || '(unnamed)'}`,
|
|
1413
|
+
onDelete: () => this.askDeleteSection(r.idx),
|
|
1414
|
+
opacity: !filterOn || tasks.some((t) => groupOf.get(t.id) === r.idx && hits.has(t.id)) ? 1 : 0.4,
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
const t = r.task;
|
|
1418
|
+
const meta = metaFor(t);
|
|
1419
|
+
const fixed = t.start !== null;
|
|
1420
|
+
const canRel = G.depsOf(t).length > 0;
|
|
1421
|
+
return {
|
|
1422
|
+
isGroup: false, isTask: true, name: t.name, y: r.y, h: r.h,
|
|
1423
|
+
laneBg: t.id === sel ? 'var(--sel-lane)' : 'transparent',
|
|
1424
|
+
listBg: t.id === sel ? 'var(--sel-bg)' : 'var(--surface)',
|
|
1425
|
+
meta: meta.text, metaColor: meta.color,
|
|
1426
|
+
done: t.done, doneLabel: `Mark “${t.name}” ${t.done ? 'not done' : 'done'}`,
|
|
1427
|
+
strike: t.done ? 'line-through' : 'none', nameColor: t.done ? 'var(--muted)' : 'var(--ink)',
|
|
1428
|
+
anchoredStr: fixed ? 'true' : 'false',
|
|
1429
|
+
anchorDisabled: fixed && !canRel,
|
|
1430
|
+
anchorLabel: fixed ? (canRel ? 'Unpin — follow dependencies again' : 'Pinned: add a dependency to make it relative') : 'Pin to its current date',
|
|
1431
|
+
pinColor: fixed ? 'var(--pin-fg)' : 'var(--faint)', pinBg: fixed ? 'var(--pin-bg)' : 'transparent',
|
|
1432
|
+
select: () => this.setState({ selectedId: t.id, nameError: null, linkName: '', linkUrl: '', linkError: '', tagDraft: '' }),
|
|
1433
|
+
onKey: (e) => this.deleteKey(t.id, e),
|
|
1434
|
+
toggleDone: () => this.commit(G.ops.patch(s.doc, t.id, { done: !G.findTask(s.doc, t.id).done }), null),
|
|
1435
|
+
toggleAnchor: toggleAnchor(t),
|
|
1436
|
+
opacity: ro && ro.id === t.id ? 0.35 : dimOf(t.id),
|
|
1437
|
+
gripLabel: `Reorder “${t.name}” — drag, or use the arrow keys`,
|
|
1438
|
+
onGrip: (e) => this.rowDown(t.id, r.y, e),
|
|
1439
|
+
onGripKey: (e) => this.rowKey(t.id, e),
|
|
1440
|
+
};
|
|
1441
|
+
});
|
|
1442
|
+
const roTask = ro ? G.findTask(s.doc, ro.id) : null;
|
|
1443
|
+
const reorderView = ro ? {
|
|
1444
|
+
name: roTask.name,
|
|
1445
|
+
ghostY: 56 + ro.rowY + ro.dy,
|
|
1446
|
+
lineY: 56 + slot.y - 1,
|
|
1447
|
+
showLine: !slot.noop,
|
|
1448
|
+
} : { name: '', ghostY: 0, lineY: 0, showLine: false };
|
|
1449
|
+
|
|
1450
|
+
/* Group summary bars. */
|
|
1451
|
+
const groupBars = rowsRaw.list.filter((r) => r.kind === 'group').map((r) => {
|
|
1452
|
+
const ids = tasks.filter((t) => groupOf.get(t.id) === r.idx).map((t) => t.id);
|
|
1453
|
+
if (!ids.length) return null;
|
|
1454
|
+
const a = Math.min(...ids.map((id) => sched.get(id).start));
|
|
1455
|
+
const b = Math.max(...ids.map((id) => sched.get(id).end));
|
|
1456
|
+
return { x: X(a), w: Math.max((b - a) * dw, 4), y: r.y + 13 };
|
|
1457
|
+
}).filter(Boolean);
|
|
1458
|
+
|
|
1459
|
+
/* Bars. */
|
|
1460
|
+
const moved = (id) => s.drag && s.drag.delta !== 0 && id !== s.drag.id && committed.get(id).start !== sched.get(id).start;
|
|
1461
|
+
const bars = tasks.map((t) => {
|
|
1462
|
+
const sc = sched.get(t.id);
|
|
1463
|
+
const fixed = t.start !== null;
|
|
1464
|
+
const color = fixed ? fix : rel;
|
|
1465
|
+
const x = X(sc.start);
|
|
1466
|
+
const w = Math.max(t.dur * dw, 6);
|
|
1467
|
+
const y = midY.get(t.id) - 12;
|
|
1468
|
+
const isMilestone = t.dur === 0;
|
|
1469
|
+
const labelInside = !isMilestone && w >= 100;
|
|
1470
|
+
const ring = t.id === sel ? '0 0 0 2px var(--surface), 0 0 0 4px var(--ink)'
|
|
1471
|
+
: sc.conflict ? '0 0 0 2px var(--surface), 0 0 0 4px var(--today)'
|
|
1472
|
+
: moved(t.id) ? '0 0 0 2px var(--faint)' : 'none';
|
|
1473
|
+
return {
|
|
1474
|
+
isBar: !isMilestone, isMilestone, fixed, labelInside, labelOutside: !labelInside, dim: dimOf(t.id),
|
|
1475
|
+
name: t.name, x, w, y,
|
|
1476
|
+
mx: x - 9, my: y + 3,
|
|
1477
|
+
lx: isMilestone ? x + 16 : x + w + 8, ly: y + 4,
|
|
1478
|
+
bg: t.done ? `color-mix(in oklab, ${color} 32%, var(--surface))` : (isMilestone ? 'var(--ink)' : color),
|
|
1479
|
+
fg: t.done || fixed ? FIX_TEXT : REL_TEXT,
|
|
1480
|
+
ring,
|
|
1481
|
+
aria: `${t.name}, ${G.fmt(sc.start)}${isMilestone ? '' : ' to ' + G.fmt(sc.end - 1)}, ${fixed ? 'fixed' : 'relative'}`,
|
|
1482
|
+
select: () => this.setState({ selectedId: t.id, nameError: null, linkName: '', linkUrl: '', linkError: '', tagDraft: '' }),
|
|
1483
|
+
onKey: (e) => this.deleteKey(t.id, e),
|
|
1484
|
+
onDown: (e) => this.barDown(t.id, 'move', dw, e),
|
|
1485
|
+
onResize: (e) => this.barDown(t.id, 'resize', dw, e),
|
|
1486
|
+
};
|
|
1487
|
+
});
|
|
1488
|
+
|
|
1489
|
+
/* Dependency arrows as orthogonal segments. */
|
|
1490
|
+
const route = (x1, y1, x2, y2) => {
|
|
1491
|
+
const pts = x2 - x1 >= 14
|
|
1492
|
+
? [[x1, y1], [x1 + 6, y1], [x1 + 6, y2], [x2, y2]]
|
|
1493
|
+
: [[x1, y1], [x1 + 6, y1], [x1 + 6, y2 > y1 ? y2 - 20 : y2 + 20], [x2 - 12, y2 > y1 ? y2 - 20 : y2 + 20], [x2 - 12, y2], [x2, y2]];
|
|
1494
|
+
return pts.slice(1).map(([bx, by], i) => ({ ax: pts[i][0], ay: pts[i][1], bx, by }));
|
|
1495
|
+
};
|
|
1496
|
+
/* Start-to-start (with:) arrows leave from the left of the dependency's bar and come back round to the task's start. */
|
|
1497
|
+
const routeStart = (x1, y1, x2, y2) => {
|
|
1498
|
+
const lane = Math.min(x1, x2) - 8;
|
|
1499
|
+
const pts = [[x1, y1], [lane, y1], [lane, y2], [x2, y2]];
|
|
1500
|
+
return pts.slice(1).map(([bx, by], i) => ({ ax: pts[i][0], ay: pts[i][1], bx, by }));
|
|
1501
|
+
};
|
|
1502
|
+
const arrows = tasks.flatMap((t) => [...t.after.map((d) => ({ d, kind: 'after' })), ...t.with.map((d) => ({ d, kind: 'with' }))].map(({ d, kind }) => {
|
|
1503
|
+
const sd = sched.get(d); const st = sched.get(t.id);
|
|
1504
|
+
const milestone = byId.get(d).dur === 0;
|
|
1505
|
+
const x1 = kind === 'after' ? X(sd.end) + (milestone ? 10 : 0) : X(sd.start) - (milestone ? 10 : 0);
|
|
1506
|
+
const x2 = X(st.start) - (t.dur === 0 ? 11 : 1);
|
|
1507
|
+
const hot = sel !== null && (t.id === sel || d === sel);
|
|
1508
|
+
const c = st.conflict ? 'var(--today)' : hot ? 'var(--ink)' : 'var(--arrow)';
|
|
1509
|
+
const style = t.start !== null ? 'dashed' : 'solid';
|
|
1510
|
+
return { c, style, x2, y2: midY.get(t.id), segs: (kind === 'after' ? route : routeStart)(x1, midY.get(d), x2, midY.get(t.id)) };
|
|
1511
|
+
}));
|
|
1512
|
+
const segs = arrows.flatMap((a) => a.segs.map((g) => (g.ay === g.by
|
|
1513
|
+
? { x: Math.min(g.ax, g.bx), y: g.ay - 0.75, w: Math.abs(g.bx - g.ax), h: 0, bt: `1.5px ${a.style} ${a.c}`, bl: 'none' }
|
|
1514
|
+
: { x: g.ax - 0.75, y: Math.min(g.ay, g.by), w: 0, h: Math.abs(g.by - g.ay), bt: 'none', bl: `1.5px ${a.style} ${a.c}` })));
|
|
1515
|
+
const heads = arrows.map((a) => ({ x: a.x2 - 5, y: a.y2 - 4, c: a.c }));
|
|
1516
|
+
|
|
1517
|
+
/* Ghost of the dragged bar at its committed position. */
|
|
1518
|
+
const ghostT = s.drag && s.drag.delta !== 0 ? G.findTask(s.doc, s.drag.id) : null;
|
|
1519
|
+
const ghost = ghostT ? { x: X(committed.get(ghostT.id).start), y: midY.get(ghostT.id) - 12, w: Math.max(ghostT.dur * dw, 6) } : { x: 0, y: 0, w: 0 };
|
|
1520
|
+
|
|
1521
|
+
/* Footer hint. */
|
|
1522
|
+
const hint = (() => {
|
|
1523
|
+
if (ro) return { text: slot.noop ? `Reordering “${roTask.name}”` : `Drop to move “${roTask.name}” — its dates don’t change, only its line in the markdown`, color: 'var(--ink)', weight: 600 };
|
|
1524
|
+
if (!s.drag || s.drag.delta === 0) return { text: s.copied || 'Drag a bar to move it · drag its right edge to change duration · drag ⋮⋮ to reorder · pin to anchor a date', color: 'var(--muted)', weight: 400 };
|
|
1525
|
+
const t = byId.get(s.drag.id); const sc = sched.get(t.id);
|
|
1526
|
+
const sign = s.drag.delta > 0 ? '+' : '−';
|
|
1527
|
+
if (s.drag.mode === 'resize') return { text: `“${t.name}” ${t.dur}d · ends ${G.fmt(sc.end - 1)}`, color: 'var(--ink)', weight: 600 };
|
|
1528
|
+
const k = tasks.filter((o) => moved(o.id)).length;
|
|
1529
|
+
return { text: `“${t.name}” ${sign}${Math.abs(s.drag.delta)}d → ${G.fmt(sc.start)}${k ? ` · ${k} dependent task${k > 1 ? 's' : ''} follow` : ''}`, color: 'var(--ink)', weight: 600 };
|
|
1530
|
+
})();
|
|
1531
|
+
|
|
1532
|
+
/* Inspector (always against the committed doc). */
|
|
1533
|
+
const selT = sel ? G.findTask(s.doc, sel) : null;
|
|
1534
|
+
const insp = selT ? (() => {
|
|
1535
|
+
const sc = committed.get(selT.id);
|
|
1536
|
+
const fixed = selT.start !== null;
|
|
1537
|
+
const seg = (on) => ({ bg: on ? 'var(--surface)' : 'transparent', fg: on ? 'var(--ink)' : 'var(--muted)', shadow: on ? '0 1px 2px var(--shadow)' : 'none' });
|
|
1538
|
+
const r = seg(!fixed); const f = seg(fixed);
|
|
1539
|
+
const all = G.tasksOf(s.doc);
|
|
1540
|
+
const late = G.depsOf(selT).length ? latestRef(selT, committed) : null;
|
|
1541
|
+
const nameIn = (id) => G.findTask(s.doc, id).name;
|
|
1542
|
+
const intNum = (e) => { const v = e.target.value; return v === '' || v === '-' ? null : parseInt(v, 10); };
|
|
1543
|
+
return {
|
|
1544
|
+
kind: fixed ? 'Fixed task' : 'Relative task',
|
|
1545
|
+
name: selT.name, hasNameError: !!s.nameError, nameError: s.nameError || '',
|
|
1546
|
+
onName: (e) => {
|
|
1547
|
+
const v = e.target.value;
|
|
1548
|
+
if (v.includes('`')) { this.setState({ nameError: 'Names can’t contain backticks — they delimit attributes.' }); return; }
|
|
1549
|
+
if (!v.trim()) { this.setState({ nameError: 'A task needs a name.' }); return; }
|
|
1550
|
+
this.commit(G.ops.patch(s.doc, selT.id, { name: v }), `name:${selT.id}`, { nameError: null });
|
|
1551
|
+
},
|
|
1552
|
+
isFixed: fixed, isRel: !fixed,
|
|
1553
|
+
relDisabled: G.depsOf(selT).length === 0, relHint: G.depsOf(selT).length ? 'Follow dependencies' : 'Add a dependency first',
|
|
1554
|
+
relPressed: fixed ? 'false' : 'true', fixedPressed: fixed ? 'true' : 'false',
|
|
1555
|
+
relBg: r.bg, relFg: r.fg, relShadow: r.shadow, fixedBg: f.bg, fixedFg: f.fg, fixedShadow: f.shadow,
|
|
1556
|
+
setRel: () => { if (fixed) this.commit(G.ops.unanchor(s.doc, committed, selT.id), null); },
|
|
1557
|
+
setFixed: () => { if (!fixed) this.commit(G.ops.anchor(s.doc, committed, selT.id), null); },
|
|
1558
|
+
startIso: G.isoFromDay(sc.start),
|
|
1559
|
+
onStart: (e) => { if (e.target.value) this.commit(G.ops.patch(s.doc, selT.id, { start: G.dayFromIso(e.target.value) }), `start:${selT.id}`); },
|
|
1560
|
+
offset: String(selT.offset),
|
|
1561
|
+
onOffset: (e) => { const n = intNum(e); if (n !== null) this.commit(G.ops.patch(s.doc, selT.id, { offset: n }), `offset:${selT.id}`); },
|
|
1562
|
+
syntax: (G.serialize({ items: [{ kind: 'task', task: { ...selT, indent: '', box: false } }] }).match(/`(start|after|with):[^`]*`/g) || []).join(' '),
|
|
1563
|
+
depsTitle: fixed ? 'Must be ready first (checked, doesn’t move it)' : 'Follows',
|
|
1564
|
+
/* Each dependency anchors to the other task's end (after:) or its start (with:); the chip's toggle switches it. */
|
|
1565
|
+
deps: [...selT.after.map((d) => ({ d, kind: 'after' })), ...selT.with.map((d) => ({ d, kind: 'with' }))].map(({ d, kind }) => ({
|
|
1566
|
+
name: nameIn(d), anchor: kind === 'after' ? 'ends' : 'starts',
|
|
1567
|
+
flipLabel: kind === 'after' ? `Start when ${nameIn(d)} starts instead` : `Start when ${nameIn(d)} ends instead`,
|
|
1568
|
+
flip: () => this.commit(G.ops.flipDep(s.doc, selT.id, d), null),
|
|
1569
|
+
removeLabel: `Remove dependency on ${nameIn(d)}`, remove: () => this.commit(G.ops.removeDep(s.doc, committed, selT.id, d), null),
|
|
1570
|
+
})),
|
|
1571
|
+
noDeps: G.depsOf(selT).length === 0,
|
|
1572
|
+
hasDropHint: !fixed && G.depsOf(selT).length === 1,
|
|
1573
|
+
depOptions: all.filter((o) => o.id !== selT.id && !G.depsOf(selT).includes(o.id) && !G.dependsOn(s.doc, o.id, selT.id))
|
|
1574
|
+
.flatMap((o) => [{ value: `after:${o.id}`, name: `${o.name} — when it ends` }, { value: `with:${o.id}`, name: `${o.name} — when it starts` }]),
|
|
1575
|
+
hasDepOptions: true,
|
|
1576
|
+
addDep: (e) => { const v = e.target.value; if (v) { const [kind, id] = [v.slice(0, v.indexOf(':')), v.slice(v.indexOf(':') + 1)]; this.commit(G.ops.addDep(s.doc, selT.id, id, kind), null); } },
|
|
1577
|
+
/* Named resource links, written after the task's attributes as [name](url). */
|
|
1578
|
+
links: selT.links.map((l, k) => ({
|
|
1579
|
+
label: l.label, url: l.url, href: /^https?:\/\//i.test(l.url) ? l.url : '', safe: /^https?:\/\//i.test(l.url), unsafe: !/^https?:\/\//i.test(l.url),
|
|
1580
|
+
removeLabel: `Remove link ${l.label}`, remove: () => this.commit(G.ops.removeLink(s.doc, selT.id, k), null),
|
|
1581
|
+
})),
|
|
1582
|
+
hasLinks: selT.links.length > 0,
|
|
1583
|
+
tags: selT.tags.map((t) => ({ tag: '#' + t, removeLabel: `Remove tag ${t}`, remove: () => this.commit(G.ops.removeTag(s.doc, selT.id, t), null) })),
|
|
1584
|
+
hasTags: selT.tags.length > 0, tagDraft: s.tagDraft,
|
|
1585
|
+
onTagDraft: (e) => this.setState({ tagDraft: e.target.value }),
|
|
1586
|
+
onTagKey: (e) => {
|
|
1587
|
+
if (e.key === 'Enter' || e.key === ',') { e.preventDefault(); this.addTags(selT.id, s.tagDraft); }
|
|
1588
|
+
else if (e.key === 'Backspace' && s.tagDraft === '' && selT.tags.length) this.commit(G.ops.removeTag(s.doc, selT.id, selT.tags[selT.tags.length - 1]), null);
|
|
1589
|
+
},
|
|
1590
|
+
onTagBlur: () => { if (s.tagDraft.trim()) this.addTags(selT.id, s.tagDraft); },
|
|
1591
|
+
linkName: s.linkName, linkUrl: s.linkUrl, linkError: s.linkError, hasLinkError: s.linkError !== '',
|
|
1592
|
+
onLinkName: (e) => this.setState({ linkName: e.target.value, linkError: '' }),
|
|
1593
|
+
onLinkUrl: (e) => this.setState({ linkUrl: e.target.value, linkError: '' }),
|
|
1594
|
+
onLinkKey: (e) => { if (e.key === 'Enter') { e.preventDefault(); this.addLink(selT.id); } },
|
|
1595
|
+
addLink: () => this.addLink(selT.id),
|
|
1596
|
+
dur: String(selT.dur), durUnit: selT.dur === 0 ? 'days · milestone' : (selT.dur === 1 ? 'day' : 'days'),
|
|
1597
|
+
onDur: (e) => { const n = intNum(e); if (n !== null && n >= 0) this.commit(G.ops.patch(s.doc, selT.id, { dur: n }), `dur:${selT.id}`); },
|
|
1598
|
+
startLabel: G.fmt(sc.start),
|
|
1599
|
+
endLabel: selT.dur === 0 ? '—' : G.fmt(sc.end - 1),
|
|
1600
|
+
conflict: sc.conflict,
|
|
1601
|
+
conflictText: sc.conflict ? (late.kind === 'after'
|
|
1602
|
+
? `Pinned ${sc.depsEnd - sc.start} day${sc.depsEnd - sc.start > 1 ? 's' : ''} before “${nameIn(late.id)}” finishes on ${G.fmt(sc.depsEnd - 1)}. Move the date, or unpin to follow it.`
|
|
1603
|
+
: `Pinned ${sc.depsEnd - sc.start} day${sc.depsEnd - sc.start > 1 ? 's' : ''} before “${nameIn(late.id)}” starts on ${G.fmt(sc.depsEnd)}. Move the date, or unpin to follow it.`) : '',
|
|
1604
|
+
addFollower: () => this.commitNewTask(G.ops.addTask(s.doc, { afterId: selT.id, today })),
|
|
1605
|
+
del: () => this.askDeleteTask(selT.id),
|
|
1606
|
+
close: () => this.setState({ selectedId: null, nameError: null }),
|
|
1607
|
+
};
|
|
1608
|
+
})() : null;
|
|
1609
|
+
if (insp) insp.hasDepOptions = insp.depOptions.length > 0;
|
|
1610
|
+
|
|
1611
|
+
/* Delete confirmation: the chosen action is previewed by running it on the doc. */
|
|
1612
|
+
const dlg = s.confirm ? (() => {
|
|
1613
|
+
const doc = s.doc;
|
|
1614
|
+
const cf = s.confirm;
|
|
1615
|
+
const isTask = cf.kind === 'task';
|
|
1616
|
+
const nm = (d, id) => G.findTask(d, id).name;
|
|
1617
|
+
const secName = isTask ? '' : (doc.items[cf.idx].text || '(unnamed)');
|
|
1618
|
+
const targets = isTask ? new Set([cf.id]) : G.sectionTaskIds(doc, cf.idx);
|
|
1619
|
+
const removing = isTask || s.sectionMode === 'delete';
|
|
1620
|
+
const deps = removing ? G.dependentsOf(doc, targets) : [];
|
|
1621
|
+
const preds = G.predecessorsOf(doc, targets).map((id) => nm(doc, id));
|
|
1622
|
+
const allDown = [...G.downstream(doc, targets)].filter((id) => !targets.has(id));
|
|
1623
|
+
const result = G.ops.applyDelete(doc, cf, s.policy, s.sectionMode);
|
|
1624
|
+
const ns = G.schedule(result);
|
|
1625
|
+
const shiftTxt = (a, b) => (a === b ? `stays ${G.fmt(a)}` : `${G.fmt(b)} (${b > a ? '+' : '−'}${Math.abs(b - a)}d)`);
|
|
1626
|
+
const describe = (id) => {
|
|
1627
|
+
const before = G.findTask(doc, id);
|
|
1628
|
+
const after = G.findTask(result, id);
|
|
1629
|
+
if (!after) return { name: before.name, was: G.fmt(committed.get(id).start), effect: 'Deleted', fg: 'var(--bad)', bg: 'var(--bad-bg)' };
|
|
1630
|
+
const a = committed.get(id).start; const b = ns.get(id).start;
|
|
1631
|
+
const base = { name: before.name, was: G.fmt(a) };
|
|
1632
|
+
if (before.start === null && after.start !== null) return { ...base, effect: `Pinned · ${G.fmt(b)}`, fg: 'var(--pin-fg)', bg: 'var(--pin-bg)' };
|
|
1633
|
+
if (after.start !== null) return { ...base, effect: `Stays pinned${ns.get(id).conflict ? ' · conflict' : ''}${G.depsOf(after).length ? ' · ' + depText(after, (d) => nm(result, d)) : ''}`, fg: ns.get(id).conflict ? 'var(--bad)' : 'var(--ink-2)', bg: 'var(--seg-bg)' };
|
|
1634
|
+
return { ...base, effect: `${cap(depText(after, (d) => nm(result, d)))} · ${shiftTxt(a, b)}`, fg: a === b ? 'var(--ink-2)' : 'var(--info-fg)', bg: a === b ? 'var(--seg-bg)' : 'var(--info-bg)' };
|
|
1635
|
+
};
|
|
1636
|
+
const listed = removing
|
|
1637
|
+
? [...targets, ...(s.policy === 'cascade' ? allDown : deps)]
|
|
1638
|
+
: [...targets];
|
|
1639
|
+
const rowsAll = removing
|
|
1640
|
+
? listed.map(describe)
|
|
1641
|
+
: listed.map((id) => ({ name: nm(doc, id), was: G.fmt(committed.get(id).start), effect: 'Moves section · dates unchanged', fg: 'var(--ink-2)', bg: 'var(--seg-bg)' }));
|
|
1642
|
+
const shown = rowsAll.slice(0, 7);
|
|
1643
|
+
const listedSet = new Set(listed);
|
|
1644
|
+
const ripple = G.tasksOf(result).filter((t) => !listedSet.has(t.id) && ns.get(t.id).start !== committed.get(t.id).start).length;
|
|
1645
|
+
const removedCount = G.tasksOf(doc).length - G.tasksOf(result).length;
|
|
1646
|
+
const lineDelta = md.split('\n').length - G.serialize(result).split('\n').length;
|
|
1647
|
+
const pick = (p) => () => this.setState({ policy: p });
|
|
1648
|
+
const card = (on, disabled) => ({ border: on ? 'var(--ink)' : 'var(--rule)', bg: on ? 'var(--surface-2)' : 'var(--surface)', opacity: disabled ? 0.5 : 1 });
|
|
1649
|
+
const policyOpts = [
|
|
1650
|
+
{ id: 'unlink', title: 'Keep their dates', desc: 'Remove the link. Tasks left with no other link are pinned where they are.', disabled: false },
|
|
1651
|
+
{ id: 'relink', title: preds.length ? `Reconnect to ${preds.join(', ')}` : 'Reconnect to its predecessors', desc: preds.length ? 'They follow what came before instead, keeping their offsets — the chain closes up.' : 'Nothing comes before it, so there is nothing to reconnect to.', disabled: preds.length === 0 },
|
|
1652
|
+
{ id: 'cascade', title: `Delete them too`, desc: `Also deletes everything downstream — ${allDown.length} task${allDown.length === 1 ? '' : 's'}.`, disabled: false },
|
|
1653
|
+
].map((o) => ({ ...o, checked: s.policy === o.id, onPick: pick(o.id), inputId: `pol-${o.id}`, ...card(s.policy === o.id, o.disabled) }));
|
|
1654
|
+
const prevGroup = isTask ? null : [...doc.items.slice(0, cf.idx)].reverse().find((i) => i.kind === 'group');
|
|
1655
|
+
const modeOpts = isTask ? [] : [
|
|
1656
|
+
{ id: 'keep', title: 'Keep its tasks', desc: targets.size ? (prevGroup ? `${targets.size} task${targets.size === 1 ? '' : 's'} join “${prevGroup.text}”. Only the heading line is removed.` : `${targets.size} task${targets.size === 1 ? '' : 's'} become ungrouped. Only the heading line is removed.`) : 'Only the heading line is removed.' },
|
|
1657
|
+
{ id: 'delete', title: `Delete the section and its ${targets.size} task${targets.size === 1 ? '' : 's'}`, desc: 'Removes the heading and every line under it.' },
|
|
1658
|
+
].map((o) => ({ ...o, checked: s.sectionMode === o.id, onPick: () => this.setState({ sectionMode: o.id }), inputId: `mode-${o.id}`, disabled: false, ...card(s.sectionMode === o.id, false) }));
|
|
1659
|
+
const policyInvalid = s.policy === 'relink' && preds.length === 0 && deps.length > 0;
|
|
1660
|
+
return {
|
|
1661
|
+
title: isTask ? `Delete “${nm(doc, cf.id)}”?` : `Delete section “${secName}”?`,
|
|
1662
|
+
lead: removing
|
|
1663
|
+
? (deps.length ? `${deps.length} task${deps.length === 1 ? '' : 's'} outside ${isTask ? 'it' : 'this section'} depend${deps.length === 1 ? 's' : ''} on ${isTask ? 'it' : 'its tasks'}. What should happen to ${deps.length === 1 ? 'it' : 'them'}?`
|
|
1664
|
+
: `Nothing else depends on ${isTask ? 'it' : 'these tasks'}.`)
|
|
1665
|
+
: 'Choose what happens to the tasks under it.',
|
|
1666
|
+
isSection: !isTask, modeOpts,
|
|
1667
|
+
showPolicy: removing && deps.length > 0, policyOpts,
|
|
1668
|
+
rows: shown, more: rowsAll.length > shown.length ? `and ${rowsAll.length - shown.length} more` : '', hasMore: rowsAll.length > shown.length,
|
|
1669
|
+
hasRows: shown.length > 0,
|
|
1670
|
+
ripple: ripple ? `${ripple} later task${ripple === 1 ? '' : 's'} shift as a result.` : '', hasRipple: ripple > 0,
|
|
1671
|
+
lines: `Removes ${lineDelta} line${lineDelta === 1 ? '' : 's'} from ${s.srcLabel === null ? 'the markdown' : s.srcLabel.split('/').pop()} · undo restores it`,
|
|
1672
|
+
confirmLabel: removedCount ? `Delete ${removedCount} task${removedCount === 1 ? '' : 's'}` : 'Delete section',
|
|
1673
|
+
confirmDisabled: policyInvalid,
|
|
1674
|
+
cancel: () => this.setState({ confirm: null }),
|
|
1675
|
+
onKey: (e) => { if (e.key === 'Escape') { e.stopPropagation(); this.setState({ confirm: null }); } },
|
|
1676
|
+
confirm: () => {
|
|
1677
|
+
const keepSel = sel && G.findTask(result, sel) ? sel : null;
|
|
1678
|
+
this.commit(result, null, { confirm: null, selectedId: keepSel });
|
|
1679
|
+
},
|
|
1680
|
+
};
|
|
1681
|
+
})() : null;
|
|
1682
|
+
|
|
1683
|
+
/* Markdown pane. */
|
|
1684
|
+
const changed = G.changedLines(s.prevMd, md);
|
|
1685
|
+
const selLine = sel ? s.doc.items.findIndex((i) => i.kind === 'task' && i.task.id === sel) : -1;
|
|
1686
|
+
const mdLines = md.split('\n').map((text, i) => ({
|
|
1687
|
+
n: i + 1,
|
|
1688
|
+
mark: changed[i] && s.past.length ? '●' : '',
|
|
1689
|
+
numColor: changed[i] && s.past.length ? '#8FB0FF' : '#5C5D62',
|
|
1690
|
+
bg: changed[i] && s.past.length ? 'rgba(143,176,255,.12)' : (i === selLine ? 'rgba(255,255,255,.05)' : 'transparent'),
|
|
1691
|
+
tokens: G.tokenize(text),
|
|
1692
|
+
}));
|
|
1693
|
+
const draftCheck = (() => {
|
|
1694
|
+
if (!s.editing) return null;
|
|
1695
|
+
try { const d = G.parse(s.draft); return { ok: true, n: G.tasksOf(d).length }; } catch (e) { return { ok: false, msg: e.message }; }
|
|
1696
|
+
})();
|
|
1697
|
+
const changedCount = changed.filter(Boolean).length;
|
|
1698
|
+
const mdFoot = s.editing
|
|
1699
|
+
? (draftCheck.ok ? { t: `Valid · ${draftCheck.n} tasks. Apply to redraw the chart.`, bg: '#1B1C1F', fg: '#C9C6BF', dot: '#6FCF97' }
|
|
1700
|
+
: { t: `Can’t apply — ${draftCheck.msg}`, bg: '#3A1618', fg: '#FFC9C9', dot: '#FF6B6B' })
|
|
1701
|
+
: (s.past.length && changedCount ? { t: `Last edit rewrote ${changedCount} line${changedCount > 1 ? 's' : ''}. Other lines are untouched.`, bg: '#1B1C1F', fg: '#C9C6BF', dot: '#8FB0FF' }
|
|
1702
|
+
: { t: 'Chart edits are written back here as you make them.', bg: '#1B1C1F', fg: '#9A9890', dot: '#5C5D62' });
|
|
1703
|
+
|
|
1704
|
+
const seg = (on) => ({ bg: on ? 'var(--ink)' : 'transparent', fg: on ? 'var(--on-ink)' : 'var(--ink-2)', pressed: on ? 'true' : 'false' });
|
|
1705
|
+
const zd = seg(s.zoom === 'day'); const zw = seg(s.zoom === 'week');
|
|
1706
|
+
const vc = seg(s.layout === 'chart'); const vsp = seg(s.layout === 'split');
|
|
1707
|
+
const dirty = md !== s.baseMd;
|
|
1708
|
+
const title = (s.doc.items.find((i) => i.kind === 'title') || { text: 'Untitled plan' }).text;
|
|
1709
|
+
/* Named after the plan's title, minus characters file systems reject. */
|
|
1710
|
+
const fileName = `${title.replace(/[\\/:*?"<>|\x00-\x1f]/g, '').trim() || 'plan'}.md`;
|
|
1711
|
+
|
|
1712
|
+
return {
|
|
1713
|
+
title, src, fileName, relColor: rel, fixedColor: fix,
|
|
1714
|
+
theme: s.theme, srcTitle: s.srcLabel === null ? 'Showing a new plan' : s.savedName === s.srcLabel ? `Showing “${s.srcLabel}” saved in this browser` : `Showing ${s.srcLabel}`,
|
|
1715
|
+
query: s.query, hasQuery: terms.length > 0, hasFilter: filterOn, matchNote: `${hits.size} of ${tasks.length}`,
|
|
1716
|
+
/* Tags filter: every tag in the plan (and any chosen one that has gone), with how many tasks carry it. */
|
|
1717
|
+
tagsOpen: s.tagsOpen, tagsExpanded: String(s.tagsOpen), hasTagFilter: s.tagFilter.length > 0,
|
|
1718
|
+
tagsLabel: s.tagFilter.length === 0 ? 'Tags' : s.tagFilter.length === 1 ? `#${s.tagFilter[0]}` : `${s.tagFilter.length} tags`,
|
|
1719
|
+
tagsBd: s.tagFilter.length ? 'var(--ink)' : 'var(--rule)',
|
|
1720
|
+
toggleTags: () => this.setState({ tagsOpen: !s.tagsOpen }),
|
|
1721
|
+
closeTags: () => this.setState({ tagsOpen: false }),
|
|
1722
|
+
onTagsKey: (e) => { if (e.key === 'Escape') { e.stopPropagation(); this.setState({ tagsOpen: false }); } },
|
|
1723
|
+
clearTags: () => this.setState({ tagFilter: [], tagsOpen: false }),
|
|
1724
|
+
tagOptions: [...new Set([...tasks.flatMap((t) => t.tags), ...s.tagFilter])].sort((a, b) => a.localeCompare(b)).map((tag) => ({
|
|
1725
|
+
tag: '#' + tag, count: tasks.filter((t) => t.tags.includes(tag)).length, checked: s.tagFilter.includes(tag), inputId: `tagf-${tag}`,
|
|
1726
|
+
toggle: () => this.setState({ tagFilter: s.tagFilter.includes(tag) ? s.tagFilter.filter((x) => x !== tag) : [...s.tagFilter, tag] }),
|
|
1727
|
+
})),
|
|
1728
|
+
noTags: tasks.every((t) => t.tags.length === 0) && s.tagFilter.length === 0,
|
|
1729
|
+
/* Plan title: a pencil on hover turns it into an input; Enter or leaving saves, Esc cancels. */
|
|
1730
|
+
titleEditing: s.titleEditing, titleView: !s.titleEditing, titleDraft: s.titleDraft,
|
|
1731
|
+
editTitle: () => this.setState({ titleEditing: true, titleDraft: title }),
|
|
1732
|
+
onTitleDraft: (e) => this.setState({ titleDraft: e.target.value }),
|
|
1733
|
+
onTitleKey: (e) => {
|
|
1734
|
+
if (e.key === 'Enter') { e.preventDefault(); this.saveTitle(); }
|
|
1735
|
+
else if (e.key === 'Escape') { e.preventDefault(); this.setState({ titleEditing: false, titleDraft: '' }); }
|
|
1736
|
+
},
|
|
1737
|
+
onTitleBlur: () => this.saveTitle(),
|
|
1738
|
+
onQuery: (e) => this.setState({ query: e.target.value }),
|
|
1739
|
+
onQueryKey: (e) => { if (e.key === 'Escape') { e.preventDefault(); this.setState({ query: '' }); } },
|
|
1740
|
+
clearQuery: () => this.setState({ query: '' }),
|
|
1741
|
+
newPlan: () => this.newPlan(),
|
|
1742
|
+
download: () => this.download(fileName, md),
|
|
1743
|
+
themes: THEMES.map((t) => ({ label: t.label, bg: t.bg, ink: t.ink, accent: t.accent, pressed: String(t.id === s.theme), on: t.id === s.theme, bd: t.id === s.theme ? 'var(--ink)' : 'var(--control)', pick: () => this.setTheme(t.id) })),
|
|
1744
|
+
showOpen: () => this.setState({ openOpen: true, openError: '', dropActive: false, fileOpen: false, saveOpen: false }),
|
|
1745
|
+
openOpen: s.openOpen, openError: s.openError, hasOpenError: s.openError !== '', openUrl: s.openUrl, dropClass: s.dropActive ? 'drop on' : 'drop',
|
|
1746
|
+
openUrlDisabled: s.openUrl.trim() === '' || s.openBusy, openUrlLabel: s.openBusy ? 'Opening…' : 'Open',
|
|
1747
|
+
closeOpen: () => this.setState({ openOpen: false, openError: '', dropActive: false }),
|
|
1748
|
+
onOpenKey: (e) => { if (e.key === 'Escape') { e.stopPropagation(); this.setState({ openOpen: false, openError: '', dropActive: false }); } },
|
|
1749
|
+
onDragOver: (e) => { e.preventDefault(); if (!s.dropActive) this.setState({ dropActive: true }); },
|
|
1750
|
+
onDragLeave: () => this.setState({ dropActive: false }),
|
|
1751
|
+
onDrop: (e) => { e.preventDefault(); this.setState({ dropActive: false }); this.openFiles(e.dataTransfer && e.dataTransfer.files); },
|
|
1752
|
+
onPickFile: (e) => { const files = e.target.files; this.openFiles(files); e.target.value = ''; },
|
|
1753
|
+
onOpenUrlInput: (e) => this.setState({ openUrl: e.target.value, openError: '' }),
|
|
1754
|
+
onOpenUrlKey: (e) => { if (e.key === 'Enter') { e.preventDefault(); this.openUrl(); } },
|
|
1755
|
+
openFromUrl: () => this.openUrl(),
|
|
1756
|
+
/* Compared with the last save in this browser, or with the file as loaded. */
|
|
1757
|
+
statusLabel: dirty ? 'Unsaved changes' : s.savedName !== null ? `Saved as “${s.savedName}”` : 'No unsaved changes',
|
|
1758
|
+
statusTip: dirty
|
|
1759
|
+
? (s.saveUrl !== null ? 'Changes are only in this tab. File → Save writes them to the file.' : 'Changes are only in this tab. Save keeps them in this browser; Download or Copy keeps the file.')
|
|
1760
|
+
: s.savedName !== null ? `Matches the save “${s.savedName}” in this browser.` : 'Matches the plan as it was opened.',
|
|
1761
|
+
saveOpen: s.saveOpen, saveName: s.saveName, saveError: s.saveError, hasSaveError: s.saveError !== '',
|
|
1762
|
+
saveExists: Object.prototype.hasOwnProperty.call(readSaves(), s.saveName.trim()),
|
|
1763
|
+
saveLabel: Object.prototype.hasOwnProperty.call(readSaves(), s.saveName.trim()) ? 'Replace' : 'Save',
|
|
1764
|
+
fileOpen: s.fileOpen,
|
|
1765
|
+
toggleFile: () => this.setState({ fileOpen: !s.fileOpen, saveOpen: false, saveError: '', linkNote: null }),
|
|
1766
|
+
closeFile: () => this.setState({ fileOpen: false, saveOpen: false, saveError: '' }),
|
|
1767
|
+
onFileKey: (e) => { if (e.key === 'Escape') { e.stopPropagation(); this.setState({ fileOpen: false, saveOpen: false }); } else if (e.key === 'Enter' && e.target.id === 'save-name') { e.preventDefault(); this.saveLocal(); } },
|
|
1768
|
+
copyLink: () => this.copyLink(md),
|
|
1769
|
+
canSaveFile: s.saveUrl !== null, saveFileName: s.srcLabel.split('/').pop(), saveFile: () => this.saveFile(md),
|
|
1770
|
+
designCard: () => this.designCard(md),
|
|
1771
|
+
hasLinkNote: s.linkNote !== null, linkNote: s.linkNote?.text ?? '', linkNoteColor: s.linkNote?.bad ? 'var(--bad)' : 'var(--muted)',
|
|
1772
|
+
toggleSave: () => this.setState({ saveOpen: !s.saveOpen, saveError: '', saveName: s.saveName || s.savedName || title }),
|
|
1773
|
+
onSaveName: (e) => this.setState({ saveName: e.target.value, saveError: '' }),
|
|
1774
|
+
doSave: () => this.saveLocal(),
|
|
1775
|
+
localSaves: Object.entries(readSaves()).sort((a, b) => String(b[1].savedAt).localeCompare(String(a[1].savedAt))).map(([name, v]) => {
|
|
1776
|
+
let n = null;
|
|
1777
|
+
try { n = G.tasksOf(G.parse(v.md)).length; } catch (e) { n = null; }
|
|
1778
|
+
const when = new Date(v.savedAt);
|
|
1779
|
+
return {
|
|
1780
|
+
name, meta: `${n === null ? 'can’t be read' : `${n} task${n === 1 ? '' : 's'}`} · saved ${isNaN(when) ? '' : `${when.getDate()} ${G.MON[when.getMonth()]} ${String(when.getHours()).padStart(2, '0')}:${String(when.getMinutes()).padStart(2, '0')}`}`,
|
|
1781
|
+
open: () => this.openLocal(name), del: () => this.deleteLocal(name), delLabel: `Delete the save ${name}`, openLabel: `Open ${name}`,
|
|
1782
|
+
};
|
|
1783
|
+
}),
|
|
1784
|
+
hasLocalSaves: Object.keys(readSaves()).length > 0,
|
|
1785
|
+
statusBg: dirty ? 'var(--warn-bg)' : 'var(--ok-bg)', statusFg: dirty ? 'var(--warn-fg)' : 'var(--ok-fg)', statusDot: dirty ? 'var(--warn-dot)' : 'var(--ok-dot)',
|
|
1786
|
+
mdW: s.mdW,
|
|
1787
|
+
mdResizeDown: (e) => this.mdResizeDown(e), mdResizeMove: (e) => this.mdResizeMove(e), mdResizeKey: (e) => this.mdResizeKey(e),
|
|
1788
|
+
mdResizeUp: () => this.setState({ mdResize: null }),
|
|
1789
|
+
undo: () => {
|
|
1790
|
+
const p = s.past; if (!p.length) return;
|
|
1791
|
+
this.setState({ doc: p[p.length - 1], past: p.slice(0, -1), future: [s.doc, ...s.future], prevMd: md, lastKey: null, nameError: null, ...this.prefState(s.doc, p[p.length - 1]) });
|
|
1792
|
+
},
|
|
1793
|
+
redo: () => {
|
|
1794
|
+
const f = s.future; if (!f.length) return;
|
|
1795
|
+
this.setState({ doc: f[0], future: f.slice(1), past: [...s.past, s.doc], prevMd: md, lastKey: null, nameError: null, ...this.prefState(s.doc, f[0]) });
|
|
1796
|
+
},
|
|
1797
|
+
cantUndo: s.past.length === 0, cantRedo: s.future.length === 0,
|
|
1798
|
+
zoomDay: () => this.setState({ zoom: 'day' }), zoomWeek: () => this.setState({ zoom: 'week' }),
|
|
1799
|
+
zoomDayBg: zd.bg, zoomDayFg: zd.fg, zoomDayPressed: zd.pressed, zoomWeekBg: zw.bg, zoomWeekFg: zw.fg, zoomWeekPressed: zw.pressed,
|
|
1800
|
+
viewChart: () => this.commit(G.ops.setPref(s.doc, 'view', 'chart'), null, { layout: 'chart' }), viewSplit: () => this.commit(G.ops.setPref(s.doc, 'view', 'split'), null, { layout: 'split' }),
|
|
1801
|
+
viewChartBg: vc.bg, viewChartFg: vc.fg, viewChartPressed: vc.pressed, viewSplitBg: vsp.bg, viewSplitFg: vsp.fg, viewSplitPressed: vsp.pressed,
|
|
1802
|
+
addLabel: selT ? 'Add after selected' : 'Add task',
|
|
1803
|
+
addTitle: selT ? `New task starting after “${selT.name}”` : 'New task anchored to today',
|
|
1804
|
+
addTask: () => this.commitNewTask(G.ops.addTask(s.doc, { afterId: selT ? selT.id : null, today })),
|
|
1805
|
+
onMove: (e) => this.onMove(e), onUp: () => this.onUp(),
|
|
1806
|
+
isReordering: !!ro, reorder: reorderView,
|
|
1807
|
+
hasDlg: !!dlg, dlg: dlg || {},
|
|
1808
|
+
addSection: () => { const r2 = G.ops.addGroup(s.doc); this.commit(r2.doc, null, { newGroupIdx: r2.index }); },
|
|
1809
|
+
totalW: 280 + tlW, tlW, bodyH, months, ticks, weekends,
|
|
1810
|
+
todayX: X(today) + dw / 2, todayChipX: X(today) + dw / 2 - 22,
|
|
1811
|
+
rows, groupBars, bars, segs, heads,
|
|
1812
|
+
hasGhost: !!ghostT, ghost,
|
|
1813
|
+
hint: hint.text, hintColor: hint.color, hintWeight: hint.weight,
|
|
1814
|
+
hasInsp: !!insp, insp: insp || {},
|
|
1815
|
+
isSplit: s.layout === 'split', editing: s.editing, notEditing: !s.editing,
|
|
1816
|
+
mdLines, draft: s.draft,
|
|
1817
|
+
startEdit: () => this.setState({ editing: true, draft: md }),
|
|
1818
|
+
cancelEdit: () => this.setState({ editing: false, draft: '' }),
|
|
1819
|
+
onDraft: (e) => this.setState({ draft: e.target.value }),
|
|
1820
|
+
draftInvalid: !!draftCheck && !draftCheck.ok,
|
|
1821
|
+
applyEdit: () => this.commit(G.parse(s.draft), null, { editing: false, draft: '' }),
|
|
1822
|
+
copyLabel: s.copied === 'Markdown copied to clipboard' ? 'Copied' : 'Copy',
|
|
1823
|
+
copyMd: () => {
|
|
1824
|
+
if (!navigator.clipboard) { this.setState({ copied: 'Clipboard isn’t available in this context — select the text instead' }); return; }
|
|
1825
|
+
navigator.clipboard.writeText(md).then(
|
|
1826
|
+
() => this.setState({ copied: 'Markdown copied to clipboard' }),
|
|
1827
|
+
(err) => this.setState({ copied: `Copy failed: ${err.message}` }),
|
|
1828
|
+
);
|
|
1829
|
+
},
|
|
1830
|
+
mdFoot: mdFoot.t, mdFootBg: mdFoot.bg, mdFootFg: mdFoot.fg, mdFootDot: mdFoot.dot,
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
</script>
|
|
1835
|
+
<script>
|
|
1836
|
+
/* Loader: fetch the plan named by ?src= (absolute, or relative to this page), then boot the runtime.
|
|
1837
|
+
With no ?src= a blank plan is shown. */
|
|
1838
|
+
(async () => {
|
|
1839
|
+
const src = new URLSearchParams(location.search).get('src');
|
|
1840
|
+
const boot = { md: null, src: null, error: null };
|
|
1841
|
+
const packed = /^#md=([\w-]+)$/.exec(location.hash);
|
|
1842
|
+
if (packed) {
|
|
1843
|
+
try {
|
|
1844
|
+
const bin = atob(packed[1].replace(/-/g, '+').replace(/_/g, '/'));
|
|
1845
|
+
const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));
|
|
1846
|
+
boot.md = await new Response(new Blob([bytes]).stream().pipeThrough(new DecompressionStream('deflate-raw'))).text();
|
|
1847
|
+
boot.shared = true;
|
|
1848
|
+
} catch (e) {
|
|
1849
|
+
boot.error = 'Could not read the plan in this link (' + e.message + '). It may have been cut off when it was shared.';
|
|
1850
|
+
}
|
|
1851
|
+
/* The plan now lives in the page, so the address bar no longer pretends to hold it. */
|
|
1852
|
+
history.replaceState(null, '', location.pathname + location.search);
|
|
1853
|
+
} else if (src !== null && src.trim() !== '') {
|
|
1854
|
+
try {
|
|
1855
|
+
const res = await fetch(new URL(src, location.href));
|
|
1856
|
+
if (!res.ok) throw new Error('HTTP ' + res.status);
|
|
1857
|
+
boot.md = await res.text();
|
|
1858
|
+
boot.src = src;
|
|
1859
|
+
/* Set by the `agile` CLI, which accepts a PUT of the file back to the same URL (File → Save). */
|
|
1860
|
+
boot.writable = res.headers.get('x-agile-writable') === '1';
|
|
1861
|
+
} catch (e) {
|
|
1862
|
+
boot.error = 'Could not load ' + src + ': ' + e.message + '. A URL on another site must allow cross-origin requests (GitHub Pages and raw.githubusercontent.com do).';
|
|
1863
|
+
boot.src = src;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
window.GANTT_BOOT = boot;
|
|
1867
|
+
const s = document.createElement('script');
|
|
1868
|
+
s.src = './support.js';
|
|
1869
|
+
document.head.append(s);
|
|
1870
|
+
})();
|
|
1871
|
+
</script>
|
|
1872
|
+
</body>
|
|
1873
|
+
</html>
|