-
-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
127 additions
and
44 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { cn } from '@udecode/cn'; | ||
import { PlateElement } from '@udecode/plate-common/react'; | ||
import { | ||
useTocElement, | ||
useTocElementState, | ||
} from '@udecode/plate-heading/react'; | ||
import { withRef } from '@udecode/react-utils'; | ||
import { cva } from 'class-variance-authority'; | ||
|
||
import { Button } from './button'; | ||
|
||
const headingItemVariants = cva( | ||
'block h-auto w-full cursor-pointer truncate rounded-none px-0.5 py-1.5 text-left font-medium text-muted-foreground underline decoration-[0.5px] underline-offset-4 hover:bg-accent hover:text-muted-foreground', | ||
{ | ||
variants: { | ||
depth: { | ||
1: 'pl-0.5', | ||
2: 'pl-[26px]', | ||
3: 'pl-[50px]', | ||
}, | ||
}, | ||
} | ||
); | ||
|
||
export const TocElement = withRef<typeof PlateElement>( | ||
({ children, className, ...props }, ref) => { | ||
const state = useTocElementState(); | ||
|
||
const { props: btnProps } = useTocElement(state); | ||
|
||
const { headingList } = state; | ||
|
||
return ( | ||
<PlateElement | ||
ref={ref} | ||
className={cn('relative mb-1 p-0', className)} | ||
{...props} | ||
> | ||
<nav contentEditable={false}> | ||
{headingList.map((item) => ( | ||
<Button | ||
key={item.id} | ||
variant="ghost" | ||
className={cn(headingItemVariants({ depth: item.depth as any }))} | ||
onClick={(e) => btnProps.onClick(e, item, 'smooth')} | ||
aria-current | ||
> | ||
{item.title} | ||
</Button> | ||
))} | ||
</nav> | ||
{children} | ||
</PlateElement> | ||
); | ||
} | ||
); |
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,5 +1,7 @@ | ||
# @udecode/plate-basic-elements | ||
|
||
## 38.0.12 | ||
|
||
## 38.0.1 | ||
|
||
### Patch Changes | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# @udecode/plate-docx-serializer | ||
|
||
## 38.0.12 | ||
|
||
## 38.0.10 | ||
|
||
## 38.0.8 | ||
|
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
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
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
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,5 +1,7 @@ | ||
# @udecode/plate | ||
|
||
## 38.0.12 | ||
|
||
## 38.0.11 | ||
|
||
## 38.0.10 | ||
|
Oops, something went wrong.