-
-
Notifications
You must be signed in to change notification settings - Fork 757
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 #3073 from udecode/feat/checked-marker
Feat/checked marker
- Loading branch information
Showing
8 changed files
with
148 additions
and
90 deletions.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
"@udecode/plate-indent-list": minor | ||
--- | ||
|
||
Add listStyleTypes option to custom indent list |
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
22 changes: 22 additions & 0 deletions
22
apps/www/src/registry/default/plate-ui/indent-fire-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,22 @@ | ||
import { TIndentElement } from '@udecode/plate-indent'; | ||
import { | ||
LiComponentProps, | ||
MarkerComponentProps, | ||
} from '@udecode/plate-indent-list'; | ||
|
||
export const FireMarker = (props: MarkerComponentProps) => { | ||
const { element } = props; | ||
|
||
return ( | ||
<div contentEditable={false}> | ||
<span style={{ left: -26, top: -1, position: 'absolute' }}> | ||
{(element as TIndentElement).indent % 2 === 0 ? '🔥' : '🚀'} | ||
</span> | ||
</div> | ||
); | ||
}; | ||
|
||
export const FireLiComponent = (props: LiComponentProps) => { | ||
const { children } = props; | ||
return <span>{children}</span>; | ||
}; |
43 changes: 35 additions & 8 deletions
43
apps/www/src/registry/default/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 |
---|---|---|
@@ -1,14 +1,41 @@ | ||
import { IMarkerComponentProps } from '@udecode/plate-indent-list'; | ||
import { cn } from '@udecode/cn'; | ||
import { | ||
LiComponentProps, | ||
MarkerComponentProps, | ||
} from '@udecode/plate-indent-list'; | ||
import { setNodes } from '@udecode/slate'; | ||
import { findNodePath } from '@udecode/slate-react'; | ||
|
||
import { Checkbox } from './checkbox'; | ||
|
||
export const TodoMarker = (props: IMarkerComponentProps) => { | ||
const { onChange, checked } = props; | ||
export const TodoMarker = (props: MarkerComponentProps) => { | ||
const { editor, element } = props; | ||
|
||
const onChange = (v: boolean) => { | ||
const path = findNodePath(editor, element); | ||
setNodes(editor, { checked: v }, { at: path }); | ||
}; | ||
|
||
return ( | ||
<div contentEditable={false}> | ||
<Checkbox | ||
style={{ left: -24, top: 4, position: 'absolute' }} | ||
checked={element.checked as boolean} | ||
onCheckedChange={onChange} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export const IndentTodoLiComponent = (props: LiComponentProps) => { | ||
const { element, children } = props; | ||
return ( | ||
<Checkbox | ||
style={{ left: -24, top: 4, position: 'absolute' }} | ||
onCheckedChange={onChange} | ||
checked={checked} | ||
/> | ||
<span | ||
className={cn( | ||
(element.checked as boolean) && 'text-muted-foreground line-through' | ||
)} | ||
> | ||
{children} | ||
</span> | ||
); | ||
}; |
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