Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(md): task filters and progress for document checklists (#7705)

Eric Hayese2bd582d5f99
diff --git a/apps/web/src/features/entity/index.ts b/apps/web/src/features/entity/index.ts
index 8db2f7114c..8406898d0e 100644
--- a/apps/web/src/features/entity/index.ts
+++ b/apps/web/src/features/entity/index.ts
@@ -71,6 +71,7 @@ export {
COMPANY_STAGE_OPTIONS,
getPropertyOptionLabel,
getTaskAssigneeIds,
+ getTaskPriorityOptionId,
getTaskReferencedEntityIds,
getTaskStatusOptionId,
} from './utils/task-properties';
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/task-list/TaskListControls.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/task-list/TaskListControls.tsx
new file mode 100644
index 0000000000..edd4a74f36
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/task-list/TaskListControls.tsx
@@ -0,0 +1,406 @@
+/**
+ * @file Inline task-list controls for markdown check lists. TaskListNode
+ * leaves a non-lexical mount at the top of each check list's `<ul>`; this
+ * renderer portals a thin control line into it — the completed count for every
+ * check list, plus a hover-revealed filter menu when the list contains tasks.
+ *
+ * Items that are task mentions resolve their real task properties (status,
+ * priority, assignees, due date); plain checkbox items fall back to inline
+ * mentions and trailing `!` markers. Filters persist on the list node and dim
+ * excluded items in place.
+ */
+import {
+ ListFilterDropdown,
+ type ListFilterGroup,
+} from '@app/components/view-shell';
+import { combine, literal, NIL_UUID } from '@app/features/soup';
+import { UserIcon } from '@core/component/UserIcon';
+import {
+ getTaskAssigneeIds,
+ getTaskPriorityOptionId,
+ getTaskStatusOptionId,
+ isTaskEntity,
+ type TaskEntityWithProperties,
+} from '@entity';
+import CalendarBlank from '@phosphor/calendar-blank.svg';
+import Flag from '@phosphor/flag.svg';
+import { PropertyValueIcon } from '@property/component/propertyValue/PropertyValueIcon';
+import { SYSTEM_PROPERTY_IDS } from '@property/constants';
+import { useContacts } from '@queries/contacts/contacts';
+import { useSoupAstItemsQuery } from '@queries/soup/items';
+import { cn } from '@ui';
+import type { LexicalEditor, NodeKey } from 'lexical';
+import {
+ createEffect,
+ createMemo,
+ createSignal,
+ For,
+ onCleanup,
+ Show,
+} from 'solid-js';
+import { Portal } from 'solid-js/web';
+import {
+ applyChecklistDom,
+ clearChecklistDom,
+} from '../../plugins/checklist-controls/applyChecklistDom';
+import {
+ type ChecklistControlsData,
+ type ChecklistMountEntry,
+ setTaskListSettings,
+} from '../../plugins/checklist-controls/checklistControlsPlugin';
+import {
+ type ChecklistPlan,
+ countActiveFilters,
+ DUE_LABELS,
+ DUE_ORDER,
+ type EffectiveItem,
+ effectiveItem,
+ type NormalizedSettings,
+ normalizeSettings,
+ PRIORITY_LABELS,
+ PRIORITY_OPTION_ID,
+ PRIORITY_ORDER,
+ planChecklist,
+ STATUS_LABELS,
+ STATUS_OPTION_ID,
+ STATUS_ORDER,
+ type TaskInfo,
+} from '../../plugins/checklist-controls/model';
+
+/** Pin every non-document soup target so the query returns tasks only. */
+const NON_TASK_TARGETS = {
+ calf: literal('id', NIL_UUID),
+ callf: literal('CallId', NIL_UUID),
+ ccf: literal('id', NIL_UUID),
+ cf: literal('cid', NIL_UUID),
+ chanf: literal('ChannelId', NIL_UUID),
+ cthf: literal('ThreadId', NIL_UUID),
+ ef: literal('ThreadId', NIL_UUID),
+ fef: literal('id', NIL_UUID),
+ pf: literal('pid', NIL_UUID),
+};
+
+export function TaskListControlsRenderer(props: {
+ editor: LexicalEditor;
+ data: ChecklistControlsData;
+}) {
+ const contacts = useContacts();
+ const nameById = createMemo(
+ () => new Map(contacts().map((user) => [user.id, user.name ?? user.email]))
+ );
+ const resolveName = (id: string) => nameById().get(id) ?? 'Unknown';
+
+ const taskIds = createMemo(() => {
+ const ids = new Set<string>();
+ for (const meta of Object.values(props.data.meta)) {
+ for (const item of meta.items) {
+ if (item.taskId) ids.add(item.taskId);
+ }
+ }
+ return [...ids].sort();
+ });
+
+ // One soup query covers every task the document mentions.
+ const tasksQuery = useSoupAstItemsQuery(
+ () => ({
+ params: {
+ expand: true,
+ limit: 200,
+ sort_method: 'updated_at',
+ sort_direction: 'desc',
+ },
+ body: {
+ ...NON_TASK_TARGETS,
+ df:
+ combine(
+ '|',
+ taskIds().map((id) => literal('id', id))
+ ) ?? literal('id', NIL_UUID),
+ },
+ }),
+ () => ({ enabled: taskIds().length > 0 })
+ );
+
+ const taskInfo = createMemo((): Record<string, TaskInfo> => {
+ const map: Record<string, TaskInfo> = {};
+ if (tasksQuery.isPending) return map;
+ for (const entity of tasksQuery.data?.entities ?? []) {
+ if (!isTaskEntity(entity)) continue;
+ const task = entity as TaskEntityWithProperties;
+ map[task.id] = {
+ statusOptionId: getTaskStatusOptionId(task) ?? null,
+ priorityOptionId: getTaskPriorityOptionId(task) ?? null,
+ assigneeIds: getTaskAssigneeIds(task),
+ due: getTaskDueDate(task),
+ };
+ }
+ return map;
+ });
+
+ const lists = createMemo(() =>
+ Object.values(props.data.mounts).filter(
+ (entry) => props.data.meta[entry.listKey]
+ )
+ );
+
+ return (
+ <For each={lists()}>
+ {(entry) => (
+ <TaskListEntryControls
+ editor={props.editor}
+ data={props.data}
+ entry={entry}
+ taskInfo={taskInfo()}
+ resolveName={resolveName}
+ />
+ )}
+ </For>
+ );
+}
+
+function getTaskDueDate(task: TaskEntityWithProperties): string | null {
+ const property = task.properties?.find(
+ (p) => p.definition.id === SYSTEM_PROPERTY_IDS.DUE_DATE
+ );
+ const value = property?.value;
+ if (!value || value.type !== 'Date') return null;
+ return typeof value.value === 'string' ? value.value : null;
+}
+
+function TaskListEntryControls(props: {
+ editor: LexicalEditor;
+ data: ChecklistControlsData;
+ entry: ChecklistMountEntry;
+ taskInfo: Record<string, TaskInfo>;
+ resolveName: (id: string) => string;
+}) {
+ const meta = () => props.data.meta[props.entry.listKey];
+ const settings = createMemo(() => normalizeSettings(meta()?.settings));
+ const hasTasks = createMemo(() =>
+ (meta()?.items ?? []).some((item) => item.taskId !== null)
+ );
+ const items = createMemo(() =>
+ (meta()?.items ?? []).map((item) =>
+ effectiveItem(
+ item,
+ item.taskId ? props.taskInfo[item.taskId] : undefined,
+ props.resolveName
+ )
+ )
+ );
+ const plan = createMemo(() => planChecklist(items(), settings(), new Date()));
+
+ const update = (patch: Partial<NormalizedSettings>) => {
+ setTaskListSettings(props.editor, props.entry.listKey, {
+ ...settings(),
+ ...patch,
+ });
+ };
+
+ // The filter control reveals on hover over the list (the mount's parent).
+ const [hovered, setHovered] = createSignal(false);
+ const enter = () => setHovered(true);
+ const leave = () => setHovered(false);
+ const list = props.entry.bar.parentElement;
+ list?.addEventListener('pointerenter', enter);
+ list?.addEventListener('pointerleave', leave);
+ onCleanup(() => {
+ list?.removeEventListener('pointerenter', enter);
+ list?.removeEventListener('pointerleave', leave);
+ });
+
+ // Write the plan onto the list's DOM, and re-apply after reconciliations.
+ let appliedKeys: NodeKey[] = [];
+ createEffect(() => {
+ props.data.domVersion();
+ const p = plan();
+ clearChecklistDom(props.editor, appliedKeys);
+ applyChecklistDom(props.editor, p);
+ appliedKeys = p.rows.map((row) => row.key);
+ });
+ onCleanup(() => {
+ clearChecklistDom(props.editor, appliedKeys);
+ });
+
+ return (
+ <Portal mount={props.entry.bar}>
+ <TaskListBar
+ plan={plan}
+ settings={settings}
+ items={items}
+ hasTasks={hasTasks}
+ hovered={hovered}
+ update={update}
+ />
+ </Portal>
+ );
+}
+
+type TaskListFilterGroupId = 'status' | 'priority' | 'assignees' | 'due';
+
+function TaskListBar(props: {
+ plan: () => ChecklistPlan;
+ settings: () => NormalizedSettings;
+ items: () => EffectiveItem[];
+ hasTasks: () => boolean;
+ hovered: () => boolean;
+ update: (patch: Partial<NormalizedSettings>) => void;
+}) {
+ const [menuOpen, setMenuOpen] = createSignal(false);
+ const activeFilterCount = () => countActiveFilters(props.settings().filters);
+ const filterVisible = () =>
+ props.hovered() || menuOpen() || activeFilterCount() > 0;
+
+ const setFilterValue = (
+ facet: keyof NormalizedSettings['filters'],
+ value: string,
+ selected: boolean
+ ) => {
+ const filters = props.settings().filters;
+ const current = filters[facet];
+ props.update({
+ filters: {
+ ...filters,
+ [facet]: selected
+ ? [...current, value]
+ : current.filter((v) => v !== value),
+ },
+ });
+ };
+
+ const assigneeOptions = createMemo(() => {
+ const seen = new Map<string, string>();
+ for (const item of props.items()) {
+ for (const assignee of item.assignees) {
+ if (!seen.has(assignee.id)) seen.set(assignee.id, assignee.name);
+ }
+ }
+ return [...seen.entries()]
+ .map(([id, name]) => ({ id, name }))
+ .sort((a, b) => a.name.localeCompare(b.name));
+ });
+
+ const filterGroups = createMemo(
+ (): ListFilterGroup<TaskListFilterGroupId, string>[] => [
+ {
+ id: 'status',
+ label: 'Status',
+ options: STATUS_ORDER.map((status) => ({
+ id: status,
+ label: STATUS_LABELS[status],
+ icon: () => (
+ <PropertyValueIcon
+ optionId={STATUS_OPTION_ID[status]}
+ class="size-3.5"
+ />
+ ),
+ })),
+ },
+ {
+ id: 'priority',
+ label: 'Priority',
+ options: PRIORITY_ORDER.map((priority) => ({
+ id: priority,
+ label: PRIORITY_LABELS[priority],
+ icon: () =>
+ priority === 'none' ? (
+ <Flag class="size-3.5 text-ink-extra-muted" />
+ ) : (
+ <PropertyValueIcon
+ optionId={PRIORITY_OPTION_ID[priority]}
+ class="size-3.5"
+ />
+ ),
+ })),
+ },
+ ...(assigneeOptions().length > 0
+ ? [
+ {
+ id: 'assignees' as const,
+ label: 'Assignee',
+ searchPlaceholder: 'Search assignees...',
+ options: [
+ ...assigneeOptions().map((option) => ({
+ id: option.id,
+ label: option.name,
+ icon: () => (
+ <UserIcon
+ id={option.id}
+ size="sm"
+ class="size-3.5"
+ suppressClick
+ showTooltip={false}
+ />
+ ),
+ })),
+ { id: 'unassigned', label: 'Unassigned' },
+ ],
+ },
+ ]
+ : []),
+ {
+ id: 'due',
+ label: 'Due date',
+ options: DUE_ORDER.map((due) => ({
+ id: due,
+ label: DUE_LABELS[due],
+ icon: () => <CalendarBlank class="size-3.5 text-ink-extra-muted" />,
+ })),
+ },
+ ]
+ );
+
+ const isSelected = (groupId: TaskListFilterGroupId, optionId: string) =>
+ props.settings().filters[groupId].includes(optionId);
+
+ const progressPct = () => {
+ const progress = props.plan().progress;
+ if (progress.total === 0) return '0%';
+ return `${Math.round((progress.done / progress.total) * 100)}%`;
+ };
+
+ return (
+ <div class="mdtl-bar flex h-6 items-center gap-2 font-sans text-xs text-ink-extra-muted select-none">
+ <span class="shrink-0 tabular-nums">
+ {props.plan().progress.done}/{props.plan().progress.total}
+ </span>
+ <div class="h-1 w-16 shrink-0 overflow-hidden rounded-full bg-edge-muted">
+ <div
+ class="h-full rounded-full bg-accent transition-[width] duration-200"
+ style={{ width: progressPct() }}
+ />
+ </div>
+ <Show when={props.hasTasks()}>
+ <div
+ class={cn(
+ 'relative shrink-0 transition-opacity duration-150',
+ filterVisible() ? 'opacity-100' : 'pointer-events-none opacity-0'
+ )}
+ >
+ <ListFilterDropdown
+ label="Filter tasks"
+ open={menuOpen()}
+ onOpenChange={setMenuOpen}
+ groups={filterGroups()}
+ isSelected={isSelected}
+ onSelectionChange={setFilterValue}
+ onClear={() =>
+ props.update({
+ filters: { status: [], priority: [], assignees: [], due: [] },
+ })
+ }
+ class={cn(
+ 'size-6 shrink-0 p-1',
+ activeFilterCount() > 0 ? 'text-accent' : 'text-ink-extra-muted'
+ )}
+ />
+ <Show when={activeFilterCount() > 0}>
+ <span class="pointer-events-none absolute -top-0.5 right-0 z-10 flex size-3.5 translate-x-1/2 items-center justify-center rounded-full bg-accent text-xxs font-medium leading-none text-surface">
+ {activeFilterCount()}
+ </span>
+ </Show>
+ </div>
+ </Show>
+ </div>
+ );
+}
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/editing/MarkdownEditingOverlays.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/editing/MarkdownEditingOverlays.tsx
index 521b6d29e6..75cfcf12dc 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/editing/MarkdownEditingOverlays.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/editing/MarkdownEditingOverlays.tsx
@@ -17,6 +17,7 @@ import { TableDeleteButtons } from '../component/misc/TableDeleteButtons';
import { TableInsertButton } from '../component/misc/TableInsertButton';
import { TableMoveHandle } from '../component/misc/TableMoveHandle';
import { TableSelectionActionBar } from '../component/misc/TableSelectionActionBar';
+import { TaskListControlsRenderer } from '../component/task-list/TaskListControls';
import { FloatingMenuGroup } from '../context/FloatingMenuContext';
import type {
MarkdownEditing,
@@ -48,6 +49,10 @@ export function MarkdownEditingOverlays(props: {
<>
<DecoratorRenderer editor={props.editor} />
<NodeAccessoryRenderer editor={props.editor} store={accessoryStore} />
+ <TaskListControlsRenderer
+ editor={props.editor}
+ data={props.editing.checklistControls}
+ />
<DragInsertIndicator state={dragInsertStore} active={props.canEdit()} />
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/editing/registerMarkdownEditing.test.ts b/apps/web/src/lib/core/component/LexicalMarkdown/editing/registerMarkdownEditing.test.ts
index 3e3708a43b..0e50517f9f 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/editing/registerMarkdownEditing.test.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/editing/registerMarkdownEditing.test.ts
@@ -58,6 +58,12 @@ vi.mock('../plugins/checkbox-to-task', () => ({
CONVERT_CHECKBOXES_TO_TASKS: 'convert',
checkboxToTaskPlugin: factory('checkboxToTask'),
}));
+vi.mock('../plugins/checklist-controls', () => ({
+ createChecklistControls: () => ({
+ data: {},
+ plugin: factory('checklistControls')(),
+ }),
+}));
vi.mock('../plugins/code/codePlugin', () => ({ codePlugin: factory('code') }));
vi.mock('../plugins/emojis/emojisPlugin', () => ({
emojisPlugin: factory('emojis'),
@@ -171,6 +177,7 @@ describe('registerMarkdownEditing', () => {
'diff',
'generate',
'code',
+ 'checklistControls',
'listToTable',
]);
});
@@ -184,6 +191,7 @@ describe('registerMarkdownEditing', () => {
'await',
'peerId',
'code',
+ 'checklistControls',
'listToTable',
]);
});
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/editing/registerMarkdownEditing.ts b/apps/web/src/lib/core/component/LexicalMarkdown/editing/registerMarkdownEditing.ts
index b58fa648e1..77147e818c 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/editing/registerMarkdownEditing.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/editing/registerMarkdownEditing.ts
@@ -51,6 +51,7 @@ import {
CONVERT_CHECKBOXES_TO_TASKS,
checkboxToTaskPlugin,
} from '../plugins/checkbox-to-task';
+import { createChecklistControls } from '../plugins/checklist-controls';
import { codePlugin } from '../plugins/code/codePlugin';
import { emojisPlugin } from '../plugins/emojis/emojisPlugin';
import { iosCursorScrollPlugin } from '../plugins/ios-cursor-scroll';
@@ -238,6 +239,7 @@ export function registerMarkdownEditing(options: MarkdownEditingOptions) {
);
}
useAll(slots?.beforeCode?.(accessories));
+ const checklistControls = createChecklistControls();
plugins
.use(
codePlugin({
@@ -245,6 +247,7 @@ export function registerMarkdownEditing(options: MarkdownEditingOptions) {
setAccessories: setAccessoryStore,
})
)
+ .use(checklistControls.plugin)
.use(listToTablePlugin());
return {
@@ -252,6 +255,7 @@ export function registerMarkdownEditing(options: MarkdownEditingOptions) {
dragInsert,
draggableBlock,
accessories,
+ checklistControls: checklistControls.data,
/** Whether an inline menu owns the arrow and enter keys. */
isInlineMenuOpen: () =>
menus.mentions.isOpen() ||
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/applyChecklistDom.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/applyChecklistDom.ts
new file mode 100644
index 0000000000..49461edc8b
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/applyChecklistDom.ts
@@ -0,0 +1,23 @@
+/**
+ * @file Writes a checklist plan onto the live DOM: the dim class filters
+ * produce. Only touches the DOM — never Lexical state — so it is safe to
+ * re-run after every reconciliation.
+ */
+import type { LexicalEditor, NodeKey } from 'lexical';
+import type { ChecklistPlan } from './model';
+
+export function applyChecklistDom(editor: LexicalEditor, plan: ChecklistPlan) {
+ for (const row of plan.rows) {
+ const el = editor.getElementByKey(row.key);
+ if (!el) continue;
+ el.classList.toggle('mdtl-dim', row.dimmed);
+ }
+}
+
+export function clearChecklistDom(editor: LexicalEditor, rowKeys: NodeKey[]) {
+ for (const key of rowKeys) {
+ const el = editor.getElementByKey(key);
+ if (!el) continue;
+ el.classList.remove('mdtl-dim');
+ }
+}
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/checklistControlsPlugin.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/checklistControlsPlugin.ts
new file mode 100644
index 0000000000..4cd79e5b12
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/checklistControlsPlugin.ts
@@ -0,0 +1,117 @@
+/**
+ * @file Gives top-level check lists containing tasks a tasks-view-style control line:
+ * filters that dim excluded items, grouping with collapsible
+ * thin-line group headers, and a progress readout. The view settings persist
+ * on the list node itself (see TaskListNode) so they travel with the document.
+ *
+ * The TaskListNode carries two non-lexical mount elements inside its `<ul>`;
+ * this plugin tracks them (and the collected metadata) in stores, and the
+ * TaskListControlsRenderer portals the actual UI into the mounts from inside
+ * the app tree, keeping query and user context available.
+ */
+import { ListNode } from '@lexical/list';
+import { mergeRegister } from '@lexical/utils';
+import {
+ $setTaskListViewSettings,
+ TASK_LIST_BAR_CLASS,
+ TaskListNode,
+ type TaskListViewSettings,
+} from '@macro-inc/lexical-core';
+import { $getNodeByKey, type LexicalEditor, type NodeKey } from 'lexical';
+import { type Accessor, createSignal } from 'solid-js';
+import { createStore, reconcile, type Store } from 'solid-js/store';
+import { registerMutationListener } from '../shared/utils';
+import { $collectChecklistMeta } from './collect';
+import type { ChecklistMeta } from './model';
+
+export type ChecklistMountEntry = {
+ listKey: NodeKey;
+ bar: HTMLElement;
+};
+
+export type ChecklistControlsData = {
+ meta: Store<Record<NodeKey, ChecklistMeta>>;
+ mounts: Store<Record<NodeKey, ChecklistMountEntry>>;
+ /** Bumped after every committed update so DOM-reading effects re-run. */
+ domVersion: Accessor<number>;
+};
+
+/** Persist a list's view settings onto its node (undoable, collab-synced). */
+export function setTaskListSettings(
+ editor: LexicalEditor,
+ listKey: NodeKey,
+ settings: TaskListViewSettings
+) {
+ // Deep-clone through JSON so no solid store proxies (whose symbol-keyed
+ // internals break the Loro sync serializer) end up in node state.
+ const plain = JSON.parse(JSON.stringify(settings)) as TaskListViewSettings;
+ editor.update(() => {
+ const node = $getNodeByKey(listKey);
+ if (node) $setTaskListViewSettings(node, plain);
+ });
+}
+
+export function createChecklistControls() {
+ const [meta, setMeta] = createStore<Record<NodeKey, ChecklistMeta>>({});
+ const [mounts, setMounts] = createStore<Record<NodeKey, ChecklistMountEntry>>(
+ {}
+ );
+ const [domVersion, setDomVersion] = createSignal(0);
+
+ const data: ChecklistControlsData = { meta, mounts, domVersion };
+
+ const plugin = (editor: LexicalEditor) => {
+ const syncMounts = (key: NodeKey) => {
+ const element = editor.getElementByKey(key);
+ const bar = element?.querySelector<HTMLElement>(
+ `:scope > .${TASK_LIST_BAR_CLASS}`
+ );
+ const existing = mounts[key];
+ if (!bar) {
+ if (existing) setMounts(key, undefined!);
+ return;
+ }
+ // Only replace the entry when the element actually changed, so portals
+ // are not remounted on every list mutation.
+ if (existing?.bar === bar) return;
+ setMounts(key, { listKey: key, bar });
+ };
+
+ const recollect = () => {
+ setMeta(
+ reconcile(editor.getEditorState().read($collectChecklistMeta), {
+ key: 'listKey',
+ })
+ );
+ setDomVersion((v) => v + 1);
+ };
+ recollect();
+
+ return mergeRegister(
+ editor.registerMutationListener(
+ ListNode,
+ (mutations) => {
+ for (const [key, mutation] of mutations) {
+ if (mutation === 'destroyed') setMounts(key, undefined!);
+ else syncMounts(key);
+ }
+ },
+ { skipInitialization: false }
+ ),
+ // JSON import ($parseSerializedNode) bypasses node replacement, so
+ // lists arriving from collab peers are plain ListNodes; upgrade them.
+ editor.registerNodeTransform(ListNode, (node) => {
+ if (node instanceof TaskListNode) return;
+ const replacement = new TaskListNode(
+ node.getListType(),
+ node.getStart()
+ );
+ replacement.updateFromJSON(node.exportJSON());
+ node.replace(replacement, true);
+ }),
+ registerMutationListener(editor, recollect)
+ );
+ };
+
+ return { data, plugin };
+}
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/collect.test.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/collect.test.ts
new file mode 100644
index 0000000000..45e5701dbc
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/collect.test.ts
@@ -0,0 +1,211 @@
+import {
+ $createListItemNode,
+ $createListNode,
+ ListItemNode,
+ ListNode,
+} from '@lexical/list';
+import {
+ $createDocumentMentionNode,
+ $setTaskListViewSettings,
+ DocumentMentionNode,
+} from '@macro-inc/lexical-core';
+import { PROPERTY_OPTION_IDS } from '@property/constants';
+import {
+ $createParagraphNode,
+ $createTextNode,
+ $getRoot,
+ createEditor,
+} from 'lexical';
+import { describe, expect, it } from 'vitest';
+import { $collectChecklistMeta } from './collect';
+import { effectiveItem, normalizeSettings, planChecklist } from './model';
+
+function makeEditor() {
+ return createEditor({
+ nodes: [ListNode, ListItemNode, DocumentMentionNode],
+ onError: (error) => {
+ throw error;
+ },
+ });
+}
+
+describe('task-list controls', () => {
+ it('collects every checklist, but only task mentions make items tasks', () => {
+ const editor = makeEditor();
+ editor.update(
+ () => {
+ const list = $createListNode('check').append(
+ $createListItemNode(true).append(
+ $createTextNode('Plain checkbox !!!')
+ ),
+ $createListItemNode(false).append(
+ $createDocumentMentionNode({
+ documentId: 'document-id',
+ documentName: 'Document',
+ blockName: 'md',
+ })
+ )
+ );
+ $setTaskListViewSettings(list, { filters: { status: ['done'] } });
+ $getRoot().append(
+ list,
+ $createParagraphNode(),
+ $createListNode('check').append(
+ $createListItemNode(false).append($createTextNode('Another list'))
+ )
+ );
+ },
+ { discrete: true }
+ );
+
+ const lists = Object.values(editor.read($collectChecklistMeta));
+ expect(lists).toHaveLength(2);
+ // A plain document mention is not a task, so no item qualifies the list
+ // for the filter control.
+ expect(
+ lists.every((meta) => meta.items.every((item) => item.taskId === null))
+ ).toBe(true);
+ expect(lists[0].settings).toEqual({ filters: { status: ['done'] } });
+ });
+
+ it('marks only items that mention a task', () => {
+ const editor = makeEditor();
+ editor.update(
+ () => {
+ $getRoot().append(
+ $createListNode('check').append(
+ $createListItemNode(false).append($createTextNode('Ordinary list'))
+ ),
+ $createParagraphNode(),
+ $createListNode('check').append(
+ $createListItemNode(false).append($createTextNode('Plain item')),
+ $createListItemNode(false).append(
+ $createDocumentMentionNode({
+ documentId: 'task-id',
+ documentName: 'Task',
+ blockName: 'task',
+ })
+ )
+ )
+ );
+ },
+ { discrete: true }
+ );
+
+ const lists = Object.values(editor.read($collectChecklistMeta));
+ expect(lists).toHaveLength(2);
+ const taskIds = lists.map((meta) => meta.items.map((item) => item.taskId));
+ expect(taskIds).toContainEqual([null]);
+ expect(taskIds).toContainEqual([null, 'task-id']);
+ });
+
+ it('drops the task marker when the mention is replaced with plain text', () => {
+ const editor = makeEditor();
+ editor.update(
+ () => {
+ $getRoot().append(
+ $createListNode('check').append(
+ $createListItemNode(false).append(
+ $createDocumentMentionNode({
+ documentId: 'task-id',
+ documentName: 'Task',
+ blockName: 'task',
+ })
+ )
+ )
+ );
+ },
+ { discrete: true }
+ );
+ const before = Object.values(editor.read($collectChecklistMeta));
+ expect(before[0].items.map((item) => item.taskId)).toEqual(['task-id']);
+
+ editor.update(
+ () => {
+ const list = $getRoot().getFirstChildOrThrow<ListNode>();
+ list
+ .getFirstChildOrThrow<ListItemNode>()
+ .clear()
+ .append($createTextNode('Plain item'));
+ },
+ { discrete: true }
+ );
+
+ const after = Object.values(editor.read($collectChecklistMeta));
+ expect(after).toHaveLength(1);
+ expect(after[0].items.map((item) => item.taskId)).toEqual([null]);
+ });
+
+ it('counts a ticked checkbox as done even when its task status lags', () => {
+ const base = {
+ leadingKeys: [],
+ attachedKeys: [],
+ mentionAssignees: [],
+ mentionDue: null,
+ markerPriority: null,
+ taskId: 'task-id',
+ };
+ const notStartedTask = {
+ statusOptionId: PROPERTY_OPTION_IDS.STATUS.NOT_STARTED,
+ priorityOptionId: null,
+ assigneeIds: [],
+ due: null,
+ };
+ const items = [
+ effectiveItem(
+ { ...base, key: 'ticked', checked: true, text: 'Ticked' },
+ notStartedTask,
+ (id) => id
+ ),
+ effectiveItem(
+ { ...base, key: 'open', checked: false, text: 'Open' },
+ notStartedTask,
+ (id) => id
+ ),
+ effectiveItem(
+ {
+ ...base,
+ key: 'closed',
+ checked: false,
+ text: 'Closed in tasks view',
+ },
+ {
+ ...notStartedTask,
+ statusOptionId: PROPERTY_OPTION_IDS.STATUS.COMPLETED,
+ },
+ (id) => id
+ ),
+ ];
+
+ const plan = planChecklist(items, normalizeSettings(null), new Date());
+ expect(plan.progress).toEqual({ done: 2, total: 3 });
+ });
+
+ it('dims filtered items even when an older saved setting requests hiding them', () => {
+ // `hideFiltered` was written by an older build; hiding was removed.
+ const legacySettings = {
+ filters: { status: ['done'] },
+ hideFiltered: true,
+ };
+ const settings = normalizeSettings(legacySettings);
+ const item = effectiveItem(
+ {
+ key: 'item',
+ leadingKeys: [],
+ attachedKeys: [],
+ checked: false,
+ text: 'Task',
+ mentionAssignees: [],
+ mentionDue: null,
+ markerPriority: null,
+ taskId: 'task-id',
+ },
+ undefined,
+ (id) => id
+ );
+
+ expect(planChecklist([item], settings, new Date()).rows).toEqual([
+ { key: 'item', dimmed: true },
+ ]);
+ });
+});
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/collect.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/collect.ts
new file mode 100644
index 0000000000..1b6c5f0956
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/collect.ts
@@ -0,0 +1,106 @@
+/**
+ * @file Collects task-list metadata from the editor state: one entry per
+ * top-level check list, with per-item checked state, assignee and date
+ * mentions, trailing `!` priority markers, task-mention links, and the list's
+ * persisted view settings.
+ */
+import {
+ $isListItemNode,
+ $isListNode,
+ type ListItemNode,
+ type ListNode,
+} from '@lexical/list';
+import {
+ $getTaskListViewSettings,
+ $isDateMentionNode,
+ $isDocumentMentionNode,
+ $isUserMentionNode,
+} from '@macro-inc/lexical-core';
+import {
+ $getRoot,
+ $isElementNode,
+ type LexicalNode,
+ type NodeKey,
+} from 'lexical';
+import {
+ type ChecklistAssignee,
+ type ChecklistItemMeta,
+ type ChecklistMeta,
+ parseMarkerPriority,
+} from './model';
+
+export function $collectChecklistMeta(): Record<NodeKey, ChecklistMeta> {
+ const lists: Record<NodeKey, ChecklistMeta> = {};
+ for (const child of $getRoot().getChildren()) {
+ if (!$isListNode(child) || child.getListType() !== 'check') continue;
+ lists[child.getKey()] = $collectList(child);
+ }
+ return lists;
+}
+
+function $collectList(list: ListNode): ChecklistMeta {
+ const items: ChecklistItemMeta[] = [];
+ let leading: NodeKey[] = [];
+ for (const child of list.getChildren()) {
+ if (!$isListItemNode(child)) continue;
+ if (child.getChildren().some($isListNode)) {
+ // A nested sub-list wrapper travels with the item it belongs to.
+ const last = items.at(-1);
+ if (last) last.attachedKeys.push(child.getKey());
+ else leading.push(child.getKey());
+ continue;
+ }
+ const item = $collectItem(child);
+ if (leading.length > 0) {
+ item.leadingKeys = leading;
+ leading = [];
+ }
+ items.push(item);
+ }
+ return {
+ listKey: list.getKey(),
+ items,
+ settings: $getTaskListViewSettings(list),
+ };
+}
+
+function $collectItem(li: ListItemNode): ChecklistItemMeta {
+ const mentionAssignees: ChecklistAssignee[] = [];
+ let mentionDue: string | null = null;
+ let taskId: string | null = null;
+ const visit = (node: LexicalNode) => {
+ if ($isUserMentionNode(node)) {
+ if (!mentionAssignees.some((a) => a.id === node.getUserId())) {
+ mentionAssignees.push({
+ id: node.getUserId(),
+ name: node.getDisplayName(),
+ });
+ }
+ return;
+ }
+ if ($isDateMentionNode(node)) {
+ mentionDue ??= node.getDate();
+ return;
+ }
+ if ($isDocumentMentionNode(node)) {
+ if (node.getBlockName() === 'task') taskId ??= node.getDocumentId();
+ return;
+ }
+ if ($isElementNode(node)) {
+ for (const child of node.getChildren()) visit(child);
+ }
+ };
+ visit(li);
+ const text = li.getTextContent().trim();
+ return {
+ key: li.getKey(),
+ leadingKeys: [],
+ attachedKeys: [],
+ checked: li.getChecked() === true,
+ text,
+ mentionAssignees,
+ mentionDue,
+ markerPriority: parseMarkerPriority(text),
+ taskId,
+ };
+}
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/index.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/index.ts
new file mode 100644
index 0000000000..357be7849c
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/index.ts
@@ -0,0 +1,2 @@
+export * from './checklistControlsPlugin';
+export * from './model';
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/model.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/model.ts
new file mode 100644
index 0000000000..2b2f0f16c8
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checklist-controls/model.ts
@@ -0,0 +1,311 @@
+/**
+ * @file Pure data model for task-list controls: the per-item metadata
+ * collected from a check list, the effective task fields after real task
+ * properties are merged in, and the planner that turns the persisted filters
+ * into row styling. No Lexical or DOM access here so the logic stays
+ * unit-testable.
+ */
+
+import type { TaskListViewSettings } from '@macro-inc/lexical-core';
+import { PROPERTY_OPTION_IDS } from '@property/constants';
+import { differenceInCalendarDays } from 'date-fns';
+import type { NodeKey } from 'lexical';
+
+export type TaskStatusBucket =
+ | 'not-started'
+ | 'in-progress'
+ | 'in-review'
+ | 'done'
+ | 'canceled';
+export type TaskPriorityBucket = 'urgent' | 'high' | 'medium' | 'low';
+export type TaskDueBucket = 'overdue' | 'today' | 'week' | 'later';
+
+export type ChecklistAssignee = { id: string; name: string };
+
+/** Raw per-item facts read from the editor state. */
+export type ChecklistItemMeta = {
+ key: NodeKey;
+ /** Nested sub-list wrappers before the item that travel with it. */
+ leadingKeys: NodeKey[];
+ /** Nested sub-list wrappers after the item that travel with it. */
+ attachedKeys: NodeKey[];
+ checked: boolean;
+ text: string;
+ /** From inline user mentions. */
+ mentionAssignees: ChecklistAssignee[];
+ /** ISO date string of the first date mention, if any. */
+ mentionDue: string | null;
+ /** From trailing `!` markers: `!` medium, `!!` high, `!!!` urgent. */
+ markerPriority: TaskPriorityBucket | null;
+ /** The real task this item points at, when it is a task mention. */
+ taskId: string | null;
+};
+
+export type ChecklistMeta = {
+ listKey: NodeKey;
+ items: ChecklistItemMeta[];
+ settings: TaskListViewSettings | null;
+};
+
+/** Task properties resolved for a task mention. */
+export type TaskInfo = {
+ statusOptionId: string | null;
+ priorityOptionId: string | null;
+ assigneeIds: string[];
+ /** ISO date string. */
+ due: string | null;
+};
+
+/** An item with its task data merged in — what the filters see. */
+export type EffectiveItem = {
+ key: NodeKey;
+ leadingKeys: NodeKey[];
+ attachedKeys: NodeKey[];
+ text: string;
+ /** The checkbox state in the document, regardless of task status. */
+ checked: boolean;
+ status: TaskStatusBucket;
+ priority: TaskPriorityBucket | null;
+ assignees: ChecklistAssignee[];
+ due: string | null;
+};
+
+export type TaskListFilters = {
+ status: string[];
+ priority: string[];
+ assignees: string[];
+ due: string[];
+};
+
+export type NormalizedSettings = {
+ filters: TaskListFilters;
+};
+
+export function normalizeSettings(
+ settings: TaskListViewSettings | null | undefined
+): NormalizedSettings {
+ const filters = settings?.filters;
+ return {
+ filters: {
+ status: filters?.status ?? [],
+ priority: filters?.priority ?? [],
+ assignees: filters?.assignees ?? [],
+ due: filters?.due ?? [],
+ },
+ };
+}
+
+const TRAILING_PRIORITY = /(!{1,3})\s*$/;
+
+export function parseMarkerPriority(text: string): TaskPriorityBucket | null {
+ const match = TRAILING_PRIORITY.exec(text);
+ if (!match) return null;
+ if (match[1].length >= 3) return 'urgent';
+ return match[1].length === 2 ? 'high' : 'medium';
+}
+
+const STATUS_BY_OPTION_ID: Record<string, TaskStatusBucket> = {
+ [PROPERTY_OPTION_IDS.STATUS.NOT_STARTED]: 'not-started',
+ [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS]: 'in-progress',
+ [PROPERTY_OPTION_IDS.STATUS.IN_REVIEW]: 'in-review',
+ [PROPERTY_OPTION_IDS.STATUS.COMPLETED]: 'done',
+ [PROPERTY_OPTION_IDS.STATUS.CANCELED]: 'canceled',
+};
+
+const PRIORITY_BY_OPTION_ID: Record<string, TaskPriorityBucket> = {
+ [PROPERTY_OPTION_IDS.PRIORITY.URGENT]: 'urgent',
+ [PROPERTY_OPTION_IDS.PRIORITY.HIGH]: 'high',
+ [PROPERTY_OPTION_IDS.PRIORITY.MEDIUM]: 'medium',
+ [PROPERTY_OPTION_IDS.PRIORITY.LOW]: 'low',
+};
+
+export const STATUS_OPTION_ID: Record<TaskStatusBucket, string> = {
+ 'not-started': PROPERTY_OPTION_IDS.STATUS.NOT_STARTED,
+ 'in-progress': PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS,
+ 'in-review': PROPERTY_OPTION_IDS.STATUS.IN_REVIEW,
+ done: PROPERTY_OPTION_IDS.STATUS.COMPLETED,
+ canceled: PROPERTY_OPTION_IDS.STATUS.CANCELED,
+};
+
+export const PRIORITY_OPTION_ID: Record<TaskPriorityBucket, string> = {
+ urgent: PROPERTY_OPTION_IDS.PRIORITY.URGENT,
+ high: PROPERTY_OPTION_IDS.PRIORITY.HIGH,
+ medium: PROPERTY_OPTION_IDS.PRIORITY.MEDIUM,
+ low: PROPERTY_OPTION_IDS.PRIORITY.LOW,
+};
+
+export const STATUS_LABELS: Record<TaskStatusBucket, string> = {
+ 'not-started': 'Not started',
+ 'in-progress': 'In progress',
+ 'in-review': 'In review',
+ done: 'Done',
+ canceled: 'Canceled',
+};
+
+export const PRIORITY_LABELS: Record<TaskPriorityBucket | 'none', string> = {
+ urgent: 'Urgent',
+ high: 'High',
+ medium: 'Medium',
+ low: 'Low',
+ none: 'No priority',
+};
+
+export const DUE_LABELS: Record<TaskDueBucket | 'none', string> = {
+ overdue: 'Overdue',
+ today: 'Today',
+ week: 'This week',
+ later: 'Later',
+ none: 'No date',
+};
+
+export const STATUS_ORDER: TaskStatusBucket[] = [
+ 'not-started',
+ 'in-progress',
+ 'in-review',
+ 'done',
+ 'canceled',
+];
+export const PRIORITY_ORDER: Array<TaskPriorityBucket | 'none'> = [
+ 'urgent',
+ 'high',
+ 'medium',
+ 'low',
+ 'none',
+];
+export const DUE_ORDER: Array<TaskDueBucket | 'none'> = [
+ 'overdue',
+ 'today',
+ 'week',
+ 'later',
+ 'none',
+];
+
+/**
+ * Merge an item's raw facts with its resolved task properties. Task data wins;
+ * inline mentions and `!` markers back-fill plain checkbox items.
+ */
+export function effectiveItem(
+ item: ChecklistItemMeta,
+ task: TaskInfo | undefined,
+ resolveName: (userId: string) => string
+): EffectiveItem {
+ const taskStatus = task?.statusOptionId
+ ? STATUS_BY_OPTION_ID[task.statusOptionId]
+ : undefined;
+ const taskPriority = task?.priorityOptionId
+ ? PRIORITY_BY_OPTION_ID[task.priorityOptionId]
+ : undefined;
+ const assignees =
+ task && task.assigneeIds.length > 0
+ ? task.assigneeIds.map((id) => ({ id, name: resolveName(id) }))
+ : item.mentionAssignees;
+ return {
+ key: item.key,
+ leadingKeys: item.leadingKeys,
+ attachedKeys: item.attachedKeys,
+ text: item.text,
+ checked: item.checked,
+ status: taskStatus ?? (item.checked ? 'done' : 'not-started'),
+ priority: taskPriority ?? item.markerPriority,
+ assignees,
+ due: task?.due ?? item.mentionDue,
+ };
+}
+
+export function dueBucket(
+ due: string | null,
+ now: Date
+): TaskDueBucket | 'none' {
+ if (!due) return 'none';
+ const date = new Date(due);
+ if (Number.isNaN(date.getTime())) return 'none';
+ const days = differenceInCalendarDays(date, now);
+ if (days < 0) return 'overdue';
+ if (days === 0) return 'today';
+ return days <= 7 ? 'week' : 'later';
+}
+
+export function countActiveFilters(filters: TaskListFilters): number {
+ return (
+ filters.status.length +
+ filters.priority.length +
+ filters.assignees.length +
+ filters.due.length
+ );
+}
+
+export function itemMatchesFilters(
+ item: EffectiveItem,
+ filters: TaskListFilters,
+ now: Date
+): boolean {
+ if (filters.status.length > 0 && !filters.status.includes(item.status)) {
+ return false;
+ }
+ if (
+ filters.priority.length > 0 &&
+ !filters.priority.includes(item.priority ?? 'none')
+ ) {
+ return false;
+ }
+ if (filters.assignees.length > 0) {
+ const matches =
+ item.assignees.length === 0
+ ? filters.assignees.includes('unassigned')
+ : item.assignees.some((a) => filters.assignees.includes(a.id));
+ if (!matches) return false;
+ }
+ if (
+ filters.due.length > 0 &&
+ !filters.due.includes(dueBucket(item.due, now))
+ ) {
+ return false;
+ }
+ return true;
+}
+
+export type ChecklistRowPlan = {
+ key: NodeKey;
+ dimmed: boolean;
+};
+
+export type ChecklistPlan = {
+ rows: ChecklistRowPlan[];
+ /** Any filter engaged — keeps the control visible without hover. */
+ active: boolean;
+ progress: { done: number; total: number };
+};
+
+function progressOf(items: EffectiveItem[]): { done: number; total: number } {
+ let done = 0;
+ let total = 0;
+ for (const item of items) {
+ if (item.text === '') continue;
+ total += 1;
+ // The checkbox the user toggles in the document always counts; a task
+ // whose status is closed counts even when its checkbox was never ticked.
+ if (item.checked || item.status === 'done' || item.status === 'canceled') {
+ done += 1;
+ }
+ }
+ return { done, total };
+}
+
+export function planChecklist(
+ items: EffectiveItem[],
+ settings: NormalizedSettings,
+ now: Date
+): ChecklistPlan {
+ const filterActive = countActiveFilters(settings.filters) > 0;
+ const rows: ChecklistRowPlan[] = [];
+
+ for (const item of items) {
+ const dimmed =
+ filterActive && !itemMatchesFilters(item, settings.filters, now);
+ for (const key of [...item.leadingKeys, item.key, ...item.attachedKeys]) {
+ rows.push({ key, dimmed });
+ }
+ }
+
+ return { rows, active: filterActive, progress: progressOf(items) };
+}
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/styles.css b/apps/web/src/lib/core/component/LexicalMarkdown/styles.css
index 58d7c7ef34..53bcfc4ae8 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/styles.css
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/styles.css
@@ -143,6 +143,26 @@
display: none;
}
+/* Task-list controls. Filtered-out items dim in place. */
+.md-list.md-check > li.mdtl-dim {
+ opacity: 0.35;
+}
+
+/*
+* TaskListNode's non-lexical control-line mount inside the <ul>. The negative
+* margin is computed here, in the list's own font size, so the line's left
+* edge sits exactly on the checkbox column. Solid portals always add a
+* wrapper div, so render it transparently.
+*/
+.md-list.md-check > .mdtl-bar-mount {
+ margin-left: var(--md-marker-left);
+ user-select: none;
+}
+
+.md-list.md-check > .mdtl-bar-mount > div {
+ display: contents;
+}
+
/* Handle nested numbered lists up to depth 6. This could be done in 3 lines with variable counters,
* but this approach support safari. */
ol.static-md {
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/version.ts b/apps/web/src/lib/core/component/LexicalMarkdown/version.ts
index 5046ca90b5..2e9abe5316 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/version.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/version.ts
@@ -28,5 +28,8 @@
* Version 6.0 - Oct 2026. Added source-only DatabaseQueryNode: a live database answer pointing at a saved query (`queryId`), with its table, title, and table or chart display (bar, line, area, scatter, pie; optional `color` and `stack`).
* Version 6.1 - Oct 2026. ReplyTargetNode accepts call, initiative, and CRM message parents.
* Version 6.2 - Oct 2026. DocumentCardNode preview data can reserve poll height using its option count.
+ * Version 7.0 - Oct 2026. Added TaskListNode: replaces ListNode at runtime, serializes as
+ * `task-list` with the `list` wire shape plus optional `$.taskListView` node state
+ * (persisted check-list task filters).
*/
-export const MARKDOWN_VERSION_COUNTER = 6.2;
+export const MARKDOWN_VERSION_COUNTER = 7.0;
diff --git a/docs/AGENT_GUIDE/documents.md b/docs/AGENT_GUIDE/documents.md
index 69decce2af..efa638990b 100644
--- a/docs/AGENT_GUIDE/documents.md
+++ b/docs/AGENT_GUIDE/documents.md
@@ -1924,6 +1924,13 @@ nodes — use the snapshot itself to verify content. For formatting checks, run
Body placeholder advertises: `/` for block commands, `@` to reference files, `;` for snippets.
Markdown auto-format works while typing (`#` heading, `[]` checklist, `>` quote).
+
+Every top-level checklist shows a completed count and progress meter on a thin
+line above its items, left-aligned with the checkboxes. Checklists containing
+an actual task mention additionally get a filter menu (status, priority,
+assignee, due date) that reveals on hover and stays while filters are active;
+filters dim unmatched items in place and persist with the document. Plain
+checkbox lists have no filter, and removing the last task mention removes it.
On Android, use the software keyboard to check `:` emoji, `/` commands, `;`
snippets, and `#` tags where enabled. Each should open once and filter as you
type. Tapping an emoji or command applies it; a second `#` closes the tags menu
diff --git a/packages/lexical-core/index.ts b/packages/lexical-core/index.ts
index 53000d0bc9..33b2d20c07 100644
--- a/packages/lexical-core/index.ts
+++ b/packages/lexical-core/index.ts
@@ -35,6 +35,7 @@ export * from './nodes/PullRequestMentionNode';
export * from './nodes/ReplyTargetNode';
export * from './nodes/SnapshotNode';
export * from './nodes/TagMentionNode';
+export * from './nodes/TaskListNode';
export * from './nodes/ThemeMentionNode';
export * from './nodes/UnknownMentionNode';
export * from './nodes/UnlinkedTextNode';
diff --git a/packages/lexical-core/node-list.ts b/packages/lexical-core/node-list.ts
index 1b82eafd36..d0bc81ca6f 100644
--- a/packages/lexical-core/node-list.ts
+++ b/packages/lexical-core/node-list.ts
@@ -44,6 +44,7 @@ import { ReplyTargetNode } from './nodes/ReplyTargetNode';
import { SearchMatchNode } from './nodes/SearchMatchNode';
import { SnapshotNode } from './nodes/SnapshotNode';
import { TagMentionNode } from './nodes/TagMentionNode';
+import { TaskListNode } from './nodes/TaskListNode';
import { ThemeMentionNode } from './nodes/ThemeMentionNode';
import { UnknownMentionNode } from './nodes/UnknownMentionNode';
import { UnlinkedTextNode } from './nodes/UnlinkedTextNode';
@@ -78,6 +79,7 @@ export const SupportedNodeTypes = [
LinkNode,
AutoLinkNode,
ListNode,
+ TaskListNode,
ListItemNode,
QuoteNode,
LineBreakNode,
@@ -130,6 +132,11 @@ export const NodeReplacements: LexicalNodeReplacement[] = [
with: (node: CodeNode) => new CustomCodeNode(node.getLanguage()),
withKlass: CustomCodeNode,
},
+ {
+ replace: ListNode,
+ with: (node: ListNode) => new TaskListNode(node.getListType()),
+ withKlass: TaskListNode,
+ },
];
function exclude(exclusions: ValidNode[]) {
diff --git a/packages/lexical-core/nodes/TaskListNode.ts b/packages/lexical-core/nodes/TaskListNode.ts
new file mode 100644
index 0000000000..d4b0b503ca
--- /dev/null
+++ b/packages/lexical-core/nodes/TaskListNode.ts
@@ -0,0 +1,117 @@
+import { ListNode, type SerializedListNode } from '@lexical/list';
+import {
+ $getState,
+ $setState,
+ createState,
+ type EditorConfig,
+ type LexicalEditor,
+ type LexicalNode,
+ type LexicalUpdateJSON,
+ setDOMUnmanaged,
+} from 'lexical';
+
+/**
+ * Persisted display settings for a task check list: how the document shows the
+ * list, not what the list contains. Stored as node state so it rides the
+ * shared `$` bag through serialization, collab sync, and history.
+ */
+export type TaskListViewSettings = {
+ filters?: {
+ status?: string[];
+ priority?: string[];
+ assignees?: string[];
+ due?: string[];
+ };
+};
+
+export const taskListViewState = createState('taskListView', {
+ parse: (value): TaskListViewSettings | null =>
+ value && typeof value === 'object' && !Array.isArray(value)
+ ? (value as TaskListViewSettings)
+ : null,
+});
+
+export function $getTaskListViewSettings(
+ node: LexicalNode
+): TaskListViewSettings | null {
+ return $getState(node, taskListViewState);
+}
+
+export function $setTaskListViewSettings(
+ node: LexicalNode,
+ settings: TaskListViewSettings | null
+) {
+ $setState(node, taskListViewState, settings);
+}
+
+/** The non-lexical chrome mount a check list carries inside its own element. */
+export const TASK_LIST_BAR_CLASS = 'mdtl-bar-mount';
+
+/**
+ * Drop-in replacement for ListNode. Check lists additionally carry one
+ * non-lexical mount element inside the `<ul>` — a control line before the
+ * items — anchored off the managed child range through `getDOMSlot`, so the
+ * reconciler never touches it. The app portals its task-list controls into
+ * this mount.
+ *
+ * Serializes as `task-list` with the exact `list` wire shape; legacy `list`
+ * nodes import through the ListNode replacement, so both types deserialize to
+ * this class.
+ */
+export class TaskListNode extends ListNode {
+ static getType() {
+ return 'task-list';
+ }
+
+ static clone(node: TaskListNode) {
+ return new TaskListNode(node.__listType, node.__start, node.__key);
+ }
+
+ static importJSON(serializedNode: SerializedListNode) {
+ return new TaskListNode(
+ serializedNode.listType,
+ serializedNode.start
+ ).updateFromJSON(serializedNode as LexicalUpdateJSON<SerializedListNode>);
+ }
+
+ static importDOM() {
+ return ListNode.importDOM?.() ?? null;
+ }
+
+ createDOM(config: EditorConfig): HTMLElement {
+ const element = super.createDOM(config);
+ if (this.getListType() === 'check') {
+ const bar = document.createElement('div');
+ bar.className = TASK_LIST_BAR_CLASS;
+ bar.contentEditable = 'false';
+ setDOMUnmanaged(bar);
+ // insertBefore rather than prepend: Cloudflare's HTMLRewriter types
+ // (ambient in lexical-service) merge an incompatible Element#prepend.
+ element.insertBefore(bar, element.firstChild);
+ }
+ return element;
+ }
+
+ exportDOM(editor: LexicalEditor) {
+ // ListNode.exportDOM reuses createDOM; keep the chrome mount out of
+ // exported (clipboard) HTML.
+ const output = super.exportDOM(editor);
+ const element = output.element;
+ if (element instanceof HTMLElement) {
+ element.querySelector(`:scope > .${TASK_LIST_BAR_CLASS}`)?.remove();
+ }
+ return output;
+ }
+
+ getDOMSlot(element: HTMLElement) {
+ const slot = super.getDOMSlot(element);
+ const bar = element.querySelector(`:scope > .${TASK_LIST_BAR_CLASS}`);
+ return bar ? slot.withAfter(bar) : slot;
+ }
+}
+
+export function $isTaskListNode(
+ node: LexicalNode | null | undefined
+): node is TaskListNode {
+ return node instanceof TaskListNode;
+}
diff --git a/packages/lexical-core/transformers/xml/codecs.ts b/packages/lexical-core/transformers/xml/codecs.ts
index 54faee8511..e1fb098ef3 100644
--- a/packages/lexical-core/transformers/xml/codecs.ts
+++ b/packages/lexical-core/transformers/xml/codecs.ts
@@ -67,6 +67,7 @@ const KNOWN_TYPES: Record<KnownNode['type'], 1> = {
heading: 1,
quote: 1,
list: 1,
+ 'task-list': 1,
listitem: 1,
table: 1,
tablerow: 1,
@@ -225,7 +226,7 @@ export function serializeNode(node: SerNode): FxpNode {
...(n.checked && { checked: 'true' }),
})
)
- .with({ type: 'list' }, (n) =>
+ .with({ type: 'list' }, { type: 'task-list' }, (n) =>
container(n.listType === 'number' ? 'ol' : 'ul', n, {
...(n.listType === 'check' && { listType: 'check' }),
...(n.start !== 1 && { start: String(n.start) }),
diff --git a/packages/lexical-core/transformers/xml/nodes.ts b/packages/lexical-core/transformers/xml/nodes.ts
index 13c47c0057..d20d83b89a 100644
--- a/packages/lexical-core/transformers/xml/nodes.ts
+++ b/packages/lexical-core/transformers/xml/nodes.ts
@@ -41,7 +41,8 @@ export type QuoteNode = EleBase & {
};
export type ListNode = EleBase & {
- type: 'list';
+ /** `task-list` is the runtime ListNode replacement; identical wire shape. */
+ type: 'list' | 'task-list';
children: SerNode[];
listType: 'bullet' | 'number' | 'check';
start: number;