diff --git a/patches/@tasknotes__calendar@0.1.10.patch b/patches/@tasknotes__calendar@0.1.10.patch
index 7dac5ab0..75fd5e0a 100644
--- a/patches/@tasknotes__calendar@0.1.10.patch
+++ b/patches/@tasknotes__calendar@0.1.10.patch
@@ -34,7 +34,7 @@ index 26a210211cd31a79c1559769ae989031e73e6090..2d1718cf66965e5ba21aff951854c814
placements.push({
item: n,
diff --git a/dist/cjs/index.cjs b/dist/cjs/index.cjs
-index 2105bb83c461a809fa3d35d588909be5521b33f6..9632c47a23126202dbef6901912144198bb4ea0f 100644
+index 2105bb83c461a809fa3d35d588909be5521b33f6..a476009ca3c34c3cdda954edb52027a9a16a8bff 100644
--- a/dist/cjs/index.cjs
+++ b/dist/cjs/index.cjs
@@ -593,20 +593,21 @@ function layoutRow(items, days, order = defaultOrder) {
@@ -69,7 +69,53 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..9632c47a23126202dbef690191214419
for (let c = startCol; c < endCol; c++) countByCol[c]++;
placements.push({
item: n,
-@@ -1504,7 +1505,7 @@ var ListView = class {
+@@ -1218,7 +1219,10 @@ var DayGridView = class {
+ this.topPx = this.weeks[0]?.cells[0]?.querySelector(".tnc-dg-top")?.offsetHeight || px(cs, "--tnc-dg-top-h", 24);
+ this.morePx = this.measureMore(cs);
+ this.lastHeights = this.sizeKey();
+- for (const w of this.weeks) {
++ // Read the week geometry together, before placing bars and overflow links.
++ const limits = this.dotsMode ? [] : this.weeks.map((week) => this.limitFor(week));
++ const compact = this.dotsMode ? [] : this.weeks.map((week) => week.row.clientWidth / week.days.length < 72);
++ for (const [index, w] of this.weeks.entries()) {
+ for (const cell of w.cells) {
+ if (this.dotsMode) cell.tabIndex = 0;
+ else cell.removeAttribute("tabindex");
+@@ -1236,7 +1240,7 @@ var DayGridView = class {
+ cell.pool.begin();
+ cell.pool.end();
+ }
+- this.renderWeek(w);
++ this.renderWeek(w, limits[index], compact[index]);
+ }
+ }
+ }
+@@ -1285,10 +1289,9 @@ var DayGridView = class {
+ }
+ return out;
+ }
+- renderWeek(w) {
++ renderWeek(w, limit, compact) {
+ const { ctx } = this;
+ const row = layoutRow(this.itemsFor(w), w.days, ctx.order);
+- const limit = this.limitFor(w);
+ const visible = (col) => !limit ? Infinity : (row.countByCol[col] ?? 0) > limit.fit ? limit.withMore : limit.fit;
+ const n = w.days.length;
+ const hidden = new Array(n).fill([]).map(() => []);
+@@ -1340,8 +1343,10 @@ var DayGridView = class {
+ w.more.append(link);
+ }
+ existing.delete(key);
+- link.setAttribute("aria-label", ctx.text.more(items.length));
+- link.textContent = w.row.clientWidth / n < 72 ? `+${new Intl.NumberFormat(ctx.opts.locale).format(items.length)}` : ctx.text.more(items.length);
++ const label = ctx.text.more(items.length);
++ const text = compact ? `+${new Intl.NumberFormat(ctx.opts.locale).format(items.length)}` : label;
++ link.setAttribute("aria-label", label);
++ if (link.textContent !== text) link.textContent = text;
+ setStyle(link, {
+ left: `calc(${pct(col / n)} + 2px)`,
+ width: `calc(${pct(1 / n)} - 4px)`,
+@@ -1504,7 +1509,7 @@ var ListView = class {
const inLead = /* @__PURE__ */ new Set();
const keep = /* @__PURE__ */ new Set();
let itemCount = 0;
@@ -78,7 +124,7 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..9632c47a23126202dbef690191214419
for (const day of days) {
let items = this.itemsOn(day);
if (includes) {
-@@ -1531,13 +1532,13 @@ var ListView = class {
+@@ -1531,13 +1536,13 @@ var ListView = class {
section = h(doc, "div", "tnc-list-section", { role: "listitem", "aria-label": ctx.fmt.longDate(day), "data-date": arg.dateStr }, heading, rows);
if (agenda && opts.listAddText !== null) section.append(this.addRow(day));
opts.dayHeaderDidMount?.({ ...arg, el: heading });
@@ -94,7 +140,7 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..9632c47a23126202dbef690191214419
if (prev ? prev.nextSibling !== section : this.body.firstChild !== section) {
if (prev) prev.after(section);
else this.body.prepend(section);
-@@ -1568,18 +1569,29 @@ var ListView = class {
+@@ -1568,18 +1573,29 @@ var ListView = class {
this.loader.observe(this.sentinel);
}
}
@@ -129,7 +175,7 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..9632c47a23126202dbef690191214419
}
renderLead(items) {
const { ctx } = this;
-@@ -1598,12 +1610,12 @@ var ListView = class {
+@@ -1598,12 +1614,12 @@ var ListView = class {
const heading = h(doc, "div", "tnc-list-day tnc-list-lead-head", null, h(doc, "span", "tnc-list-lead-title", null, title), slot);
const rows = h(doc, "div", "tnc-list-rows", { role: "group" });
const section = h(doc, "div", "tnc-list-section tnc-list-lead", { role: "listitem", "aria-label": title }, heading, rows);
@@ -145,7 +191,7 @@ index 2105bb83c461a809fa3d35d588909be5521b33f6..9632c47a23126202dbef690191214419
addRow(day) {
const { ctx } = this;
diff --git a/dist/cjs/react.cjs b/dist/cjs/react.cjs
-index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..1bfef54ec7e2cd41bf3dd26300c7621a8befccf1 100644
+index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..39a8ccefd106ad41cebf58908071f355188f99a9 100644
--- a/dist/cjs/react.cjs
+++ b/dist/cjs/react.cjs
@@ -929,20 +929,21 @@ function layoutRow(items, days, order = defaultOrder) {
@@ -180,7 +226,53 @@ index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..1bfef54ec7e2cd41bf3dd26300c7621a
for (let c = startCol; c < endCol; c++) countByCol[c]++;
placements.push({
item: n,
-@@ -1412,7 +1413,7 @@ var ListView = class {
+@@ -1126,7 +1127,10 @@ var DayGridView = class {
+ this.topPx = this.weeks[0]?.cells[0]?.querySelector(".tnc-dg-top")?.offsetHeight || px(cs, "--tnc-dg-top-h", 24);
+ this.morePx = this.measureMore(cs);
+ this.lastHeights = this.sizeKey();
+- for (const w of this.weeks) {
++ // Read the week geometry together, before placing bars and overflow links.
++ const limits = this.dotsMode ? [] : this.weeks.map((week) => this.limitFor(week));
++ const compact = this.dotsMode ? [] : this.weeks.map((week) => week.row.clientWidth / week.days.length < 72);
++ for (const [index, w] of this.weeks.entries()) {
+ for (const cell of w.cells) {
+ if (this.dotsMode) cell.tabIndex = 0;
+ else cell.removeAttribute("tabindex");
+@@ -1144,7 +1148,7 @@ var DayGridView = class {
+ cell.pool.begin();
+ cell.pool.end();
+ }
+- this.renderWeek(w);
++ this.renderWeek(w, limits[index], compact[index]);
+ }
+ }
+ }
+@@ -1193,10 +1197,9 @@ var DayGridView = class {
+ }
+ return out;
+ }
+- renderWeek(w) {
++ renderWeek(w, limit, compact) {
+ const { ctx } = this;
+ const row = layoutRow(this.itemsFor(w), w.days, ctx.order);
+- const limit = this.limitFor(w);
+ const visible = (col) => !limit ? Infinity : (row.countByCol[col] ?? 0) > limit.fit ? limit.withMore : limit.fit;
+ const n = w.days.length;
+ const hidden = new Array(n).fill([]).map(() => []);
+@@ -1248,8 +1251,10 @@ var DayGridView = class {
+ w.more.append(link);
+ }
+ existing.delete(key);
+- link.setAttribute("aria-label", ctx.text.more(items.length));
+- link.textContent = w.row.clientWidth / n < 72 ? `+${new Intl.NumberFormat(ctx.opts.locale).format(items.length)}` : ctx.text.more(items.length);
++ const label = ctx.text.more(items.length);
++ const text = compact ? `+${new Intl.NumberFormat(ctx.opts.locale).format(items.length)}` : label;
++ link.setAttribute("aria-label", label);
++ if (link.textContent !== text) link.textContent = text;
+ setStyle(link, {
+ left: `calc(${pct(col / n)} + 2px)`,
+ width: `calc(${pct(1 / n)} - 4px)`,
+@@ -1412,7 +1417,7 @@ var ListView = class {
const inLead = /* @__PURE__ */ new Set();
const keep = /* @__PURE__ */ new Set();
let itemCount = 0;
@@ -189,7 +281,7 @@ index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..1bfef54ec7e2cd41bf3dd26300c7621a
for (const day of days) {
let items = this.itemsOn(day);
if (includes) {
-@@ -1439,13 +1440,13 @@ var ListView = class {
+@@ -1439,13 +1444,13 @@ var ListView = class {
section = h(doc, "div", "tnc-list-section", { role: "listitem", "aria-label": ctx.fmt.longDate(day), "data-date": arg.dateStr }, heading, rows);
if (agenda && opts.listAddText !== null) section.append(this.addRow(day));
opts.dayHeaderDidMount?.({ ...arg, el: heading });
@@ -205,7 +297,7 @@ index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..1bfef54ec7e2cd41bf3dd26300c7621a
if (prev ? prev.nextSibling !== section : this.body.firstChild !== section) {
if (prev) prev.after(section);
else this.body.prepend(section);
-@@ -1476,18 +1477,29 @@ var ListView = class {
+@@ -1476,18 +1481,29 @@ var ListView = class {
this.loader.observe(this.sentinel);
}
}
@@ -240,7 +332,7 @@ index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..1bfef54ec7e2cd41bf3dd26300c7621a
}
renderLead(items) {
const { ctx } = this;
-@@ -1506,12 +1518,12 @@ var ListView = class {
+@@ -1506,12 +1522,12 @@ var ListView = class {
const heading = h(doc, "div", "tnc-list-day tnc-list-lead-head", null, h(doc, "span", "tnc-list-lead-title", null, title), slot);
const rows = h(doc, "div", "tnc-list-rows", { role: "group" });
const section = h(doc, "div", "tnc-list-section tnc-list-lead", { role: "listitem", "aria-label": title }, heading, rows);
@@ -256,10 +348,56 @@ index a5a8509780257de49aa2fe2e4aa006cd5bd005ca..1bfef54ec7e2cd41bf3dd26300c7621a
addRow(day) {
const { ctx } = this;
diff --git a/dist/esm/chunk-5PHSJK36.js b/dist/esm/chunk-5PHSJK36.js
-index c2b76d29621fe4cc981794d2d24147b580d35d87..5d9e7cab85e9731e569632a33ada6c14b302ec0b 100644
+index c2b76d29621fe4cc981794d2d24147b580d35d87..0a81e525692ec40fd1624591921c69833e64eac4 100644
--- a/dist/esm/chunk-5PHSJK36.js
+++ b/dist/esm/chunk-5PHSJK36.js
-@@ -789,7 +789,7 @@ var ListView = class {
+@@ -503,7 +503,10 @@ var DayGridView = class {
+ this.topPx = this.weeks[0]?.cells[0]?.querySelector(".tnc-dg-top")?.offsetHeight || px(cs, "--tnc-dg-top-h", 24);
+ this.morePx = this.measureMore(cs);
+ this.lastHeights = this.sizeKey();
+- for (const w of this.weeks) {
++ // Read the week geometry together, before placing bars and overflow links.
++ const limits = this.dotsMode ? [] : this.weeks.map((week) => this.limitFor(week));
++ const compact = this.dotsMode ? [] : this.weeks.map((week) => week.row.clientWidth / week.days.length < 72);
++ for (const [index, w] of this.weeks.entries()) {
+ for (const cell of w.cells) {
+ if (this.dotsMode) cell.tabIndex = 0;
+ else cell.removeAttribute("tabindex");
+@@ -521,7 +524,7 @@ var DayGridView = class {
+ cell.pool.begin();
+ cell.pool.end();
+ }
+- this.renderWeek(w);
++ this.renderWeek(w, limits[index], compact[index]);
+ }
+ }
+ }
+@@ -570,10 +573,9 @@ var DayGridView = class {
+ }
+ return out;
+ }
+- renderWeek(w) {
++ renderWeek(w, limit, compact) {
+ const { ctx } = this;
+ const row = layoutRow(this.itemsFor(w), w.days, ctx.order);
+- const limit = this.limitFor(w);
+ const visible = (col) => !limit ? Infinity : (row.countByCol[col] ?? 0) > limit.fit ? limit.withMore : limit.fit;
+ const n = w.days.length;
+ const hidden = new Array(n).fill([]).map(() => []);
+@@ -625,8 +627,10 @@ var DayGridView = class {
+ w.more.append(link);
+ }
+ existing.delete(key);
+- link.setAttribute("aria-label", ctx.text.more(items.length));
+- link.textContent = w.row.clientWidth / n < 72 ? `+${new Intl.NumberFormat(ctx.opts.locale).format(items.length)}` : ctx.text.more(items.length);
++ const label = ctx.text.more(items.length);
++ const text = compact ? `+${new Intl.NumberFormat(ctx.opts.locale).format(items.length)}` : label;
++ link.setAttribute("aria-label", label);
++ if (link.textContent !== text) link.textContent = text;
+ setStyle(link, {
+ left: `calc(${pct(col / n)} + 2px)`,
+ width: `calc(${pct(1 / n)} - 4px)`,
+@@ -789,7 +793,7 @@ var ListView = class {
const inLead = /* @__PURE__ */ new Set();
const keep = /* @__PURE__ */ new Set();
let itemCount = 0;
@@ -268,7 +406,7 @@ index c2b76d29621fe4cc981794d2d24147b580d35d87..5d9e7cab85e9731e569632a33ada6c14
for (const day of days) {
let items = this.itemsOn(day);
if (includes) {
-@@ -816,13 +816,13 @@ var ListView = class {
+@@ -816,13 +820,13 @@ var ListView = class {
section = h(doc, "div", "tnc-list-section", { role: "listitem", "aria-label": ctx.fmt.longDate(day), "data-date": arg.dateStr }, heading, rows);
if (agenda && opts.listAddText !== null) section.append(this.addRow(day));
opts.dayHeaderDidMount?.({ ...arg, el: heading });
@@ -284,7 +422,7 @@ index c2b76d29621fe4cc981794d2d24147b580d35d87..5d9e7cab85e9731e569632a33ada6c14
if (prev ? prev.nextSibling !== section : this.body.firstChild !== section) {
if (prev) prev.after(section);
else this.body.prepend(section);
-@@ -853,18 +853,29 @@ var ListView = class {
+@@ -853,18 +857,29 @@ var ListView = class {
this.loader.observe(this.sentinel);
}
}
@@ -319,7 +457,7 @@ index c2b76d29621fe4cc981794d2d24147b580d35d87..5d9e7cab85e9731e569632a33ada6c14
}
renderLead(items) {
const { ctx } = this;
-@@ -883,12 +894,12 @@ var ListView = class {
+@@ -883,12 +898,12 @@ var ListView = class {
const heading = h(doc, "div", "tnc-list-day tnc-list-lead-head", null, h(doc, "span", "tnc-list-lead-title", null, title), slot);
const rows = h(doc, "div", "tnc-list-rows", { role: "group" });
const section = h(doc, "div", "tnc-list-section tnc-list-lead", { role: "listitem", "aria-label": title }, heading, rows);
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index fd056fb8..98b2d63f 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -15,7 +15,7 @@ catalogs:
patchedDependencies:
'@tasknotes/calendar@0.1.10':
- hash: 4e0550b03c6c5f719561614606c580279554ebd3b2d9133e1a07576c3f573895
+ hash: ea5b19bba1f57b77ee224b7f30f32dba2c23c05f19a62c6928c45269e2800fbc
path: patches/@tasknotes__calendar@0.1.10.patch
importers:
@@ -99,7 +99,7 @@ importers:
version: 3.14.11(react-dom@19.2.8(react@19.2.8))(react@19.2.8)
'@tasknotes/calendar':
specifier: 0.1.10
- version: 0.1.10(patch_hash=4e0550b03c6c5f719561614606c580279554ebd3b2d9133e1a07576c3f573895)(react@19.2.8)
+ version: 0.1.10(patch_hash=ea5b19bba1f57b77ee224b7f30f32dba2c23c05f19a62c6928c45269e2800fbc)(react@19.2.8)
'@tasknotes/direct-sdk':
specifier: file:vendor/sdk-self-hosted-9df3f92db395da1a1c61744f74846f756b6852511619e696c7c6bb9c32a7308f.tgz
version: '@mdbase-dev/sdk@file:vendor/sdk-self-hosted-9df3f92db395da1a1c61744f74846f756b6852511619e696c7c6bb9c32a7308f.tgz'
@@ -6368,7 +6368,7 @@ snapshots:
'@tanstack/virtual-core@3.17.9': {}
- '@tasknotes/calendar@0.1.10(patch_hash=4e0550b03c6c5f719561614606c580279554ebd3b2d9133e1a07576c3f573895)(react@19.2.8)':
+ '@tasknotes/calendar@0.1.10(patch_hash=ea5b19bba1f57b77ee224b7f30f32dba2c23c05f19a62c6928c45269e2800fbc)(react@19.2.8)':
optionalDependencies:
react: 19.2.8
diff --git a/src/app/search-screen.test.tsx b/src/app/search-screen.test.tsx
index adbae8d1..5ddabf9c 100644
--- a/src/app/search-screen.test.tsx
+++ b/src/app/search-screen.test.tsx
@@ -80,6 +80,35 @@ it("submits a chosen tag immediately and debounces further typing", () => {
);
});
+it("searches a whole inserted fragment immediately and still coalesces a single character", () => {
+ fixture.query.mockReturnValue({ tasks: [], retry: fixture.retry });
+ render();
+ const input = screen.getByRole("searchbox");
+ fireEvent.input(input, {
+ target: { value: "project meeting" },
+ inputType: "insertFromPaste",
+ data: "project meeting",
+ });
+ expect(fixture.query).toHaveBeenLastCalledWith(
+ expect.objectContaining({ search: "project meeting" }),
+ );
+ fireEvent.input(input, {
+ target: { value: "project meetings" },
+ inputType: "insertText",
+ data: "s",
+ });
+ expect(fixture.query).toHaveBeenLastCalledWith(
+ expect.objectContaining({ search: "project meeting" }),
+ );
+ fireEvent.input(input, {
+ target: { value: "" },
+ inputType: "deleteContentBackward",
+ });
+ expect(fixture.query).toHaveBeenLastCalledWith(
+ expect.objectContaining({ search: "" }),
+ );
+});
+
it("keeps browse groups expanded when the display language changes", async () => {
fixture.query.mockReturnValue({
tasks: Array.from({ length: 6 }, (_, index) => ({
diff --git a/src/app/search-screen.tsx b/src/app/search-screen.tsx
index 6fdeb638..98ba7a2f 100644
--- a/src/app/search-screen.tsx
+++ b/src/app/search-screen.tsx
@@ -200,7 +200,20 @@ export function SearchScreen({
: undefined
}
value={query}
- onChange={(event) => editQuery(event.target.value)}
+ onChange={(event) => {
+ const input = event.nativeEvent as InputEvent;
+ // Paste, dictation and replacement insert a whole fragment at once.
+ // Keep coalescing individual keystrokes and in-progress composition.
+ const committed =
+ !input.isComposing &&
+ (input.inputType === "insertFromPaste" ||
+ input.inputType === "insertReplacementText" ||
+ (input.inputType === "insertText" &&
+ (input.data?.length ?? 0) > 1));
+ if (committed || !event.target.value)
+ chooseQuery(event.target.value);
+ else editQuery(event.target.value);
+ }}
onKeyDown={(event) => {
if (["Enter", "ArrowDown", "ArrowUp", "Tab"].includes(event.key))
setKeyboardNavigation(true);
diff --git a/src/app/task-calendar-view.tsx b/src/app/task-calendar-view.tsx
index 25c3fa3e..61b98ac0 100644
--- a/src/app/task-calendar-view.tsx
+++ b/src/app/task-calendar-view.tsx
@@ -5,6 +5,7 @@ import { useLingui, Trans } from "@lingui/react/macro";
import { OverdueScheduleActions } from "../components/overdue-schedule-actions";
import { TaskListSection } from "../components/task-list-section";
import { missedDeadlineCount } from "../domain/task-list-sections";
+import { dateFormatter } from "../i18n/date-formatter";
import { appLocale } from "../i18n/app";
import { calendarText } from "../i18n/calendar-locale";
import { countLabel } from "../i18n/default-labels";
@@ -1552,7 +1553,7 @@ function calendarEventLabel(item: TaskCalendarItem, timezone?: string): string {
const date =
day === todayString(new Date(), timezone)
? t`Today`
- : new Intl.DateTimeFormat(appLocale(), {
+ : dateFormatter({
weekday: "long",
month: "long",
day: "numeric",
@@ -1560,7 +1561,7 @@ function calendarEventLabel(item: TaskCalendarItem, timezone?: string): string {
}).format(item.allDay ? new Date(`${day}T00:00:00Z`) : start);
const time = item.allDay
? ""
- : `, ${new Intl.DateTimeFormat(appLocale(), {
+ : `, ${dateFormatter({
hour: "numeric",
minute: "2-digit",
timeZone: timezone,
@@ -1569,7 +1570,7 @@ function calendarEventLabel(item: TaskCalendarItem, timezone?: string): string {
}
function listDayLabel(date: Date, timezone: string): string {
- const label = new Intl.DateTimeFormat(appLocale(), {
+ const label = dateFormatter({
weekday: "long",
month: "long",
day: "numeric",
@@ -1656,7 +1657,7 @@ function initialRange(
function agendaLabel(value: string): string {
const date = dateFromStorage(value);
return date
- ? new Intl.DateTimeFormat(appLocale(), {
+ ? dateFormatter({
weekday: "long",
day: "numeric",
month: "long",
diff --git a/src/components/task-notes-editor.tsx b/src/components/task-notes-editor.tsx
index 8849bd95..ee78896c 100644
--- a/src/components/task-notes-editor.tsx
+++ b/src/components/task-notes-editor.tsx
@@ -15,7 +15,7 @@ import {
} from "@mdbase-dev/i18n/codemirror";
import { livePreview } from "@mdbase-dev/ui/live-preview";
import "@mdbase-dev/ui/live-preview.css";
-import { useLayoutEffect, useRef } from "react";
+import { useLayoutEffect, useMemo, useRef } from "react";
import { taskNotesMarkdown } from "./task-notes-markdown";
const incoming = Annotation.define();
@@ -24,6 +24,15 @@ const labelledNotes = EditorView.contentAttributes.of({
"aria-multiline": "true",
});
+const notesExtensions = [
+ labelledNotes,
+ EditorView.lineWrapping,
+ history(),
+ keymap.of([...defaultKeymap, ...historyKeymap]),
+ markdown({ base: markdownLanguage }),
+ livePreview(),
+];
+
export function TaskNotesEditor({
source,
onChange,
@@ -46,6 +55,15 @@ export function TaskNotesEditor({
const missing = t`Image unavailable offline`;
const failed = t`Image preview unavailable`;
+ const contentExtensions = useMemo(
+ () => [
+ placeholder(hint),
+ taskNotesMarkdown(resolveImage, { attached, loading, missing, failed }),
+ ],
+ [resolveImage, hint, attached, loading, missing, failed],
+ );
+ const initialContent = useRef(contentExtensions);
+
useLayoutEffect(() => {
latest.current = { source, onChange };
const view = viewRef.current;
@@ -75,17 +93,12 @@ export function TaskNotesEditor({
useLayoutEffect(() => {
if (!host.current) return;
const view = new EditorView({
- parent: host.current,
+ root: host.current.getRootNode() as Document | ShadowRoot,
state: EditorState.create({
doc: latest.current.source,
extensions: [
- labelledNotes,
- EditorView.lineWrapping,
- history(),
- keymap.of([...defaultKeymap, ...historyKeymap]),
- markdown({ base: markdownLanguage }),
- livePreview(),
- presentation.current.of([]),
+ notesExtensions,
+ presentation.current.of(initialContent.current),
language.current.of(EditorState.phrases.of(englishCodeMirrorPhrases)),
EditorView.updateListener.of((update) => {
if (
@@ -104,6 +117,8 @@ export function TaskNotesEditor({
],
}),
});
+ // Install the configured editable subtree in one DOM write.
+ host.current.append(view.dom);
viewRef.current = view;
return () => {
viewRef.current = null;
@@ -112,13 +127,12 @@ export function TaskNotesEditor({
}, []);
useLayoutEffect(() => {
- viewRef.current?.dispatch({
- effects: presentation.current.reconfigure([
- placeholder(hint),
- taskNotesMarkdown(resolveImage, { attached, loading, missing, failed }),
- ]),
- });
- }, [resolveImage, hint, attached, loading, missing, failed]);
+ const view = viewRef.current;
+ if (view && presentation.current.get(view.state) !== contentExtensions)
+ view.dispatch({
+ effects: presentation.current.reconfigure(contentExtensions),
+ });
+ }, [contentExtensions]);
useLayoutEffect(() => {
let active = true;
diff --git a/src/domain/task-relationships.test.ts b/src/domain/task-relationships.test.ts
index 7cf3976d..c9d86d55 100644
--- a/src/domain/task-relationships.test.ts
+++ b/src/domain/task-relationships.test.ts
@@ -54,6 +54,23 @@ describe("task relationships", () => {
expect(project.frontmatter).not.toHaveProperty("blocking");
expect(project.frontmatter).not.toHaveProperty("subtasks");
});
+
+ it("prefers an exact ID, then a root path, then the first matching basename", () => {
+ const first = task("one", "A/Shared.md");
+ const second = task("two", "B/Shared.md");
+ const root = task("three", "Shared.md");
+ const byId = task("Shared", "Other.md");
+ const child = task("child", "Child.md", { projects: ["Shared"] });
+ for (const [candidates, expected] of [
+ [[first, second], first],
+ [[first, root, second], root],
+ [[first, root, byId], byId],
+ ] as const) {
+ expect(
+ taskRelationships(child, [child, ...candidates]).projectTasks,
+ ).toEqual([expected]);
+ }
+ });
});
function task(id: string, path: string, patch: Partial = {}): Task {
diff --git a/src/domain/task-relationships.ts b/src/domain/task-relationships.ts
index 4617cfe7..2414ee78 100644
--- a/src/domain/task-relationships.ts
+++ b/src/domain/task-relationships.ts
@@ -22,21 +22,14 @@ export function taskRelationships(
current: TaskSummary,
tasks: readonly TaskSummary[],
): TaskRelationships {
- const taskById = new Map(tasks.map((task) => [task.id, task]));
+ // A drawer only needs forward lookups for its own project and blocker links.
+ const links = new Set([
+ ...(current.projects ?? []),
+ ...(current.blockedBy ?? []).map(({ uid }) => uid),
+ ]);
+ const targets = new Set([...links].map(normalizeLinkTarget));
+ const taskById = new Map();
const taskByPath = new Map();
- for (const task of tasks) {
- const normalized = normalizeLinkTarget(task.path);
- taskByPath.set(normalized, task);
- const basename = normalized.split("/").at(-1);
- if (basename && !taskByPath.has(basename)) taskByPath.set(basename, task);
- }
- const resolve = (value: string) =>
- taskById.get(value) ?? taskByPath.get(normalizeLinkTarget(value));
-
- const blockedBy = (current.blockedBy ?? []).map((dependency) => ({
- dependency,
- task: resolve(dependency.uid),
- }));
const blocking: TaskSummary[] = [];
const subtasks: TaskSummary[] = [];
@@ -53,6 +46,14 @@ export function taskRelationships(
}
for (const candidate of tasks) {
+ if (links.has(candidate.id)) taskById.set(candidate.id, candidate);
+ if (targets.size) {
+ const path = normalizeLinkTarget(candidate.path);
+ if (targets.has(path)) taskByPath.set(path, candidate);
+ const name = path.slice(path.lastIndexOf("/") + 1);
+ if (name && targets.has(name) && !taskByPath.has(name))
+ taskByPath.set(name, candidate);
+ }
if (candidate.id === current.id) continue;
if (
(candidate.blockedBy ?? []).some(
@@ -65,8 +66,13 @@ export function taskRelationships(
subtasks.push(candidate);
}
+ const resolve = (value: string) =>
+ taskById.get(value) ?? taskByPath.get(normalizeLinkTarget(value));
return {
- blockedBy,
+ blockedBy: (current.blockedBy ?? []).map((dependency) => ({
+ dependency,
+ task: resolve(dependency.uid),
+ })),
blocking,
subtasks,
projectTasks: (current.projects ?? []).flatMap((project) => {