Skip to content

Commit

Permalink
chore: lists
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Aug 16, 2023
1 parent 35b2786 commit 2195ad3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { LexicalEditor } from 'lexical'
import { INSERT_UNORDERED_LIST_COMMAND } from '@lexical/list'

export function GetBulletedListBlock(editor: LexicalEditor) {
export function GetBulletedListBlock(editor: LexicalEditor, isActive = false) {
return {
name: 'Bulleted List',
iconName: 'list-bulleted',
keywords: ['bulleted list', 'unordered list', 'ul'],
onSelect: () => editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined),
active: isActive,
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { LexicalEditor } from 'lexical'
import { INSERT_ORDERED_LIST_COMMAND } from '@lexical/list'

export function GetNumberedListBlock(editor: LexicalEditor) {
export function GetNumberedListBlock(editor: LexicalEditor, isActive = false) {
return {
name: 'Numbered List',
iconName: 'list-numbered',
keywords: ['numbered list', 'ordered list', 'ol'],
onSelect: () => editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined),
active: isActive,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ const MobileToolbarPlugin = () => {
}
}, [editor])

const { isBold, isItalic, isUnderline, isSubscript, isSuperscript, isStrikethrough } = useSelectedTextFormatInfo()
const { isBold, isItalic, isUnderline, isSubscript, isSuperscript, isStrikethrough, blockType } =
useSelectedTextFormatInfo()
const [isSelectionLink, setIsSelectionLink] = useState(false)

const [canUndo, setCanUndo] = useState(false)
Expand Down Expand Up @@ -201,8 +202,8 @@ const MobileToolbarPlugin = () => {
GetRemoteImageBlock(() => {
showModal('Insert image from URL', (onClose) => <InsertRemoteImageDialog onClose={onClose} />)
}),
GetNumberedListBlock(editor),
GetBulletedListBlock(editor),
GetNumberedListBlock(editor, blockType === 'number'),
GetBulletedListBlock(editor, blockType === 'bullet'),
GetChecklistBlock(editor),
GetQuoteBlock(editor),
GetCodeBlock(editor),
Expand All @@ -215,6 +216,7 @@ const MobileToolbarPlugin = () => {
],
[
application.keyboardService,
blockType,
canRedo,
canUndo,
editor,
Expand Down

0 comments on commit 2195ad3

Please sign in to comment.