'use client'; import React from 'react'; import { ListStyleType, someIndentList, toggleIndentList, } from '@udecode/plate-indent-list'; import { useEditorRef, useEditorSelector } from '@udecode/plate/react'; import { List, ListOrdered } from 'lucide-react'; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger, useOpenState, } from './dropdown-menu'; import { ToolbarSplitButton, ToolbarSplitButtonPrimary, ToolbarSplitButtonSecondary, } from './toolbar'; export function NumberedIndentListToolbarButton() { const editor = useEditorRef(); const openState = useOpenState(); const pressed = useEditorSelector( (editor) => someIndentList(editor, [ ListStyleType.Decimal, ListStyleType.LowerAlpha, ListStyleType.UpperAlpha, ListStyleType.LowerRoman, ListStyleType.UpperRoman, ]), [], ); return ( toggleIndentList(editor, { listStyleType: ListStyleType.Decimal, }) } data-state={pressed ? 'on' : 'off'} tooltip="Numbered List" > toggleIndentList(editor, { listStyleType: ListStyleType.Decimal, }) } > Decimal (1, 2, 3) toggleIndentList(editor, { listStyleType: ListStyleType.LowerAlpha, }) } > Lower Alpha (a, b, c) toggleIndentList(editor, { listStyleType: ListStyleType.UpperAlpha, }) } > Upper Alpha (A, B, C) toggleIndentList(editor, { listStyleType: ListStyleType.LowerRoman, }) } > Lower Roman (i, ii, iii) toggleIndentList(editor, { listStyleType: ListStyleType.UpperRoman, }) } > Upper Roman (I, II, III) ); } export function BulletedIndentListToolbarButton() { const editor = useEditorRef(); const openState = useOpenState(); const pressed = useEditorSelector( (editor) => someIndentList(editor, [ ListStyleType.Disc, ListStyleType.Circle, ListStyleType.Square, ]), [], ); return ( { toggleIndentList(editor, { listStyleType: ListStyleType.Disc, }); }} data-state={pressed ? 'on' : 'off'} tooltip="Bulleted List" > toggleIndentList(editor, { listStyleType: ListStyleType.Disc, }) } >
Default
toggleIndentList(editor, { listStyleType: ListStyleType.Circle, }) } >
Circle
toggleIndentList(editor, { listStyleType: ListStyleType.Square, }) } >
Square
); }