-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref: POKEMON-583
- Loading branch information
kehua
committed
Jul 24, 2023
1 parent
caa77ef
commit a49eda5
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
bricks/markdown/src/markdown-editor/components/ListItem.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,41 @@ | ||
import { useNodeViewContext } from "@prosemirror-adapter/react"; | ||
import type { FC } from "react"; | ||
import React from "react"; | ||
import classNames from "classnames"; | ||
|
||
export const ListItem: FC = () => { | ||
const { contentRef, node, setAttrs, selected } = useNodeViewContext(); | ||
const { attrs } = node; | ||
const checked = attrs?.checked; | ||
const isBullet = attrs?.listType === "bullet"; | ||
return ( | ||
<li | ||
className={classNames("checkboxLi", { | ||
"ProseMirror-selectednode": selected, | ||
})} | ||
> | ||
<span style={{ display: "flex", height: "1.5rem", alignItems: "center" }}> | ||
{checked != null ? ( | ||
<input | ||
style={{ borderRadius: "0.25rem" }} | ||
onChange={() => setAttrs({ checked: !checked })} | ||
type="checkbox" | ||
checked={checked} | ||
/> | ||
) : isBullet ? ( | ||
<span | ||
style={{ | ||
height: "0.5rem", | ||
width: "0.5rem", | ||
borderRadius: "9999px", | ||
backgroundColor: "rgb(129,161,193)", | ||
}} | ||
/> | ||
) : ( | ||
<span style={{ color: "rgb(136,192,208)" }}>{attrs?.label}</span> | ||
)} | ||
</span> | ||
<div style={{ minWidth: "0" }} ref={contentRef} /> | ||
</li> | ||
); | ||
}; |
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