Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quill editor: Make toolbar visible on long texts #1464

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/components/common/form/FormRichTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { Typography } from '@mui/material'

import { translateError } from 'common/form/useForm'
import { TranslatableField } from 'common/form/validation'
import { styled } from '@mui/material/styles'

import 'react-quill/dist/quill.snow.css'

import ReactQuill, { Quill } from 'react-quill'

import BlotFormatter from 'quill-blot-formatter/'
Expand All @@ -27,6 +27,15 @@ export type FormRichTextFieldProps = {
name: string
}

const StyledGrid = styled('div')(() => ({
['& .ql-toolbar.ql-snow']: {
position: 'sticky',
top: 0,
zIndex: 1,
backgroundColor: 'white',
},
}))

export default function FormRichTextField({ name }: FormRichTextFieldProps) {
const { t } = useTranslation()
const [, meta] = useField(name)
Expand Down Expand Up @@ -96,13 +105,15 @@ export default function FormRichTextField({ name }: FormRichTextFieldProps) {
)}
<Field name={name}>
{({ field }: { field: FieldInputProps<string> }) => (
<ReactQuill
ref={reactQuillRef}
modules={modules}
theme="snow"
value={field.value}
onChange={field.onChange(field.name)}
/>
<StyledGrid>
<ReactQuill
ref={reactQuillRef}
modules={modules}
theme="snow"
value={field.value}
onChange={field.onChange(field.name)}
/>
</StyledGrid>
)}
</Field>
{meta.touched && meta.error && (
Expand Down
64 changes: 0 additions & 64 deletions src/components/common/navigation/AdminAppBar.tsx

This file was deleted.

41 changes: 28 additions & 13 deletions src/components/common/navigation/AdminLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import { items } from './adminMenu'
import HoverMenu from './HoverMenu'
import PanelFooter from './PanelFooter'
import CustomListItem from './CustomListItem'
import { AdminAppBar } from './AdminAppBar'
import AdminMenu from 'components/client/layout/nav/AdminMenu'
import Link from 'next/link'
import { routes } from 'common/routes'
import PictureLogo from '/public/android-chrome-192x192.png'
import Image from 'next/image'

const PREFIX = 'AdminLayout'
const drawerWidth = 200
Expand All @@ -32,7 +35,6 @@ const StyledBox = styled(Box)({
[`& .${classes.appbarHeader}`]: {
width: `calc(100% - ${drawerWidth}px)`,
height: 64,
marginLeft: '6rem',
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
Expand Down Expand Up @@ -67,6 +69,7 @@ const DrawerHeader = styled('div')(({ theme }) => ({
alignItems: 'center',
justifyContent: 'flex-end',
padding: theme.spacing(0, 1),

// necessary for content to be below app bar
...theme.mixins.toolbar,
}))
Expand Down Expand Up @@ -114,17 +117,20 @@ export default function AdminLayout({ children }: Props) {
const toggleMenu = useCallback(() => setOpen((open) => !open), [])
return (
<StyledBox className={classes.wrapper}>
<AdminAppBar isOpen={open}>
<Box className={classes.appbarHeader}>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<IconButton>
<Notifications color="info" />
</IconButton>
<AdminMenu />
</Box>
</Box>
</AdminAppBar>
<Drawer variant="permanent" open={open} theme={theme}>
<Box
sx={{
display: 'flex',
position: 'absolute',
left: 5,
top: 9,
padding: theme.spacing(0, 1),
}}>
<Link href={routes.admin.index} passHref>
{/* A11Y TODO: Translate alt text */}
<Image src={PictureLogo} width={40} height={40} alt={'logo'} />
</Link>
</Box>
<DrawerHeader />
<List sx={{ p: '2rem .5rem', height: '100%', position: 'relative' }}>
{items.map(({ items, menu, icon }, index) => (
Expand All @@ -140,7 +146,16 @@ export default function AdminLayout({ children }: Props) {
</Drawer>

<Box component="main" sx={{ flexGrow: 1 }}>
<DrawerHeader />
<DrawerHeader>
<Box className={classes.appbarHeader}>
<Box sx={{ display: 'flex', alignItems: 'center', paddingRight: 15 }}>
<IconButton>
<Notifications color="info" />
</IconButton>
<AdminMenu />
</Box>
</Box>
</DrawerHeader>
{children}
</Box>
<PanelFooter>
Expand Down