diff --git a/packages/editor/src/extensions/task-list/component.tsx b/packages/editor/src/extensions/task-list/component.tsx index b9a7ee798..0ff1b1964 100644 --- a/packages/editor/src/extensions/task-list/component.tsx +++ b/packages/editor/src/extensions/task-list/component.tsx @@ -21,17 +21,22 @@ import { Box, Flex, Input, Text } from "@theme-ui/components"; import { useMemo } from "react"; import { ToolButton } from "../../toolbar/components/tool-button"; import { ReactNodeViewProps } from "../react"; -import { type TaskListAttributes } from "./task-list"; +import { toggleChildren, type TaskListAttributes } from "./task-list"; import { replaceDateTime } from "../date-time"; import { deleteCheckedItems, sortList } from "./utils"; import TaskList from "@tiptap/extension-task-list"; import TaskItem from "@tiptap/extension-task-item"; +import { useIsMobile } from "../../toolbar/stores/toolbar-store"; +import { Icons } from "../../toolbar/icons"; +import { Icon } from "@notesnook/ui"; export function TaskListComponent( props: ReactNodeViewProps ) { const { editor, getPos, node, updateAttributes, forwardRef, pos } = props; const { title, textDirection, readonly, stats } = node.attrs; + const isMobile = useIsMobile(); + const checked = stats.total === stats.checked; const isNested = useMemo(() => { if (!pos) return false; @@ -68,6 +73,41 @@ export function TaskListComponent( transition: "width 250ms ease-out" }} /> + {editor.isEditable ? ( + { + const parentPos = getPos(); + editor.current?.commands.command(({ tr }) => { + const node = tr.doc.nodeAt(parentPos); + if (!node) return false; + toggleChildren(tr, node, !checked, parentPos); + return true; + }); + }} + color={checked ? "accent" : "icon"} + size={isMobile ? "1.70ch" : "1.46ch"} + /> + ) : null}