feat: add Indent/Outdent options in Super when on mobile
This commit is contained in:
@@ -23,9 +23,12 @@ import Popover from '@/Components/Popover/Popover'
|
|||||||
import { PopoverClassNames } from '../ClassNames'
|
import { PopoverClassNames } from '../ClassNames'
|
||||||
import { GetDatetimeBlocks } from './Blocks/DateTime'
|
import { GetDatetimeBlocks } from './Blocks/DateTime'
|
||||||
import { isMobileScreen } from '@/Utils'
|
import { isMobileScreen } from '@/Utils'
|
||||||
|
import { useApplication } from '@/Components/ApplicationProvider'
|
||||||
|
import { GetIndentOutdentBlocks } from './Blocks/IndentOutdent'
|
||||||
|
|
||||||
export default function BlockPickerMenuPlugin(): JSX.Element {
|
export default function BlockPickerMenuPlugin(): JSX.Element {
|
||||||
const [editor] = useLexicalComposerContext()
|
const [editor] = useLexicalComposerContext()
|
||||||
|
const application = useApplication()
|
||||||
const [modal, showModal] = useModal()
|
const [modal, showModal] = useModal()
|
||||||
const [queryString, setQueryString] = useState<string | null>(null)
|
const [queryString, setQueryString] = useState<string | null>(null)
|
||||||
|
|
||||||
@@ -36,9 +39,12 @@ export default function BlockPickerMenuPlugin(): JSX.Element {
|
|||||||
const [popoverOpen, setPopoverOpen] = useState(true)
|
const [popoverOpen, setPopoverOpen] = useState(true)
|
||||||
|
|
||||||
const options = useMemo(() => {
|
const options = useMemo(() => {
|
||||||
|
const indentOutdentOptions = application.isNativeMobileWeb() ? GetIndentOutdentBlocks(editor) : []
|
||||||
|
|
||||||
const baseOptions = [
|
const baseOptions = [
|
||||||
GetParagraphBlock(editor),
|
GetParagraphBlock(editor),
|
||||||
...GetHeadingsBlocks(editor),
|
...GetHeadingsBlocks(editor),
|
||||||
|
...indentOutdentOptions,
|
||||||
GetTableBlock(() =>
|
GetTableBlock(() =>
|
||||||
showModal('Insert Table', (onClose) => <InsertTableDialog activeEditor={editor} onClose={onClose} />),
|
showModal('Insert Table', (onClose) => <InsertTableDialog activeEditor={editor} onClose={onClose} />),
|
||||||
),
|
),
|
||||||
@@ -70,7 +76,7 @@ export default function BlockPickerMenuPlugin(): JSX.Element {
|
|||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
: baseOptions
|
: baseOptions
|
||||||
}, [editor, queryString, showModal])
|
}, [editor, queryString, showModal, application])
|
||||||
|
|
||||||
const onSelectOption = useCallback(
|
const onSelectOption = useCallback(
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { BlockPickerOption } from '../BlockPickerOption'
|
||||||
|
import { INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, LexicalEditor } from 'lexical'
|
||||||
|
|
||||||
|
export function GetIndentOutdentBlocks(editor: LexicalEditor) {
|
||||||
|
return [
|
||||||
|
new BlockPickerOption('Indent', {
|
||||||
|
iconName: 'arrow-right',
|
||||||
|
keywords: ['indent'],
|
||||||
|
onSelect: () => editor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined),
|
||||||
|
}),
|
||||||
|
new BlockPickerOption('Outdent', {
|
||||||
|
iconName: 'arrow-left',
|
||||||
|
keywords: ['outdent'],
|
||||||
|
onSelect: () => editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined),
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user