-
-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3572 from udecode/todo
Add todo to playground template
- Loading branch information
Showing
7 changed files
with
4,463 additions
and
3,494 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
apps/www/src/registry/default/plate-ui/indent-todo-toolbar-button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7,877 changes: 4,384 additions & 3,493 deletions
7,877
templates/plate-playground-template/pnpm-lock.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
templates/plate-playground-template/src/components/plate-ui/indent-todo-marker-component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { cn } from '@udecode/cn'; | ||
import { | ||
useIndentTodoListElement, | ||
useIndentTodoListElementState, | ||
} from '@udecode/plate-indent-list/react'; | ||
|
||
import { Checkbox } from './checkbox'; | ||
|
||
import type { PlateRenderElementProps } from '@udecode/plate-common/react'; | ||
|
||
export const TodoMarker = ({ | ||
element, | ||
}: Omit<PlateRenderElementProps, 'children'>) => { | ||
const state = useIndentTodoListElementState({ element }); | ||
const { checkboxProps } = useIndentTodoListElement(state); | ||
|
||
return ( | ||
<div contentEditable={false}> | ||
<Checkbox | ||
style={{ left: -24, position: 'absolute', top: 4 }} | ||
{...checkboxProps} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export const TodoLi = (props: PlateRenderElementProps) => { | ||
const { children, element } = props; | ||
|
||
return ( | ||
<span | ||
className={cn( | ||
(element.checked as boolean) && 'text-muted-foreground line-through' | ||
)} | ||
> | ||
{children} | ||
</span> | ||
); | ||
}; |
22 changes: 22 additions & 0 deletions
22
templates/plate-playground-template/src/components/plate-ui/indent-todo-toolbar-button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { | ||
useIndentTodoToolBarButton, | ||
useIndentTodoToolBarButtonState, | ||
} from '@udecode/plate-indent-list/react'; | ||
import { withRef } from '@udecode/cn'; | ||
|
||
import { Icons } from '@/components/icons'; | ||
|
||
import { ToolbarButton } from './toolbar'; | ||
|
||
export const IndentTodoToolbarButton = withRef<typeof ToolbarButton>( | ||
(rest, ref) => { | ||
const state = useIndentTodoToolBarButtonState({ nodeType: 'todo' }); | ||
const { props } = useIndentTodoToolBarButton(state); | ||
|
||
return ( | ||
<ToolbarButton ref={ref} tooltip="Todo" {...props} {...rest}> | ||
<Icons.todo /> | ||
</ToolbarButton> | ||
); | ||
} | ||
); |