main
Last change
on this file since 5d6f37a was 5d6f37a, checked in by Naum Shapkarovski <naumshapkarovski@…>, 7 weeks ago |
add customer
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[5d6f37a] | 1 | import 'src/utils/highlight';
|
---|
| 2 | import dynamic from 'next/dynamic';
|
---|
| 3 | // @mui
|
---|
| 4 | import { alpha } from '@mui/material/styles';
|
---|
| 5 | import Skeleton from '@mui/material/Skeleton';
|
---|
| 6 | //
|
---|
| 7 | import { EditorProps } from './types';
|
---|
| 8 | import { StyledEditor } from './styles';
|
---|
| 9 | import Toolbar, { formats } from './toolbar';
|
---|
| 10 |
|
---|
| 11 | const ReactQuill = dynamic(() => import('react-quill'), {
|
---|
| 12 | ssr: false,
|
---|
| 13 | loading: () => (
|
---|
| 14 | <Skeleton
|
---|
| 15 | sx={{
|
---|
| 16 | top: 0,
|
---|
| 17 | left: 0,
|
---|
| 18 | right: 0,
|
---|
| 19 | bottom: 0,
|
---|
| 20 | height: 1,
|
---|
| 21 | position: 'absolute',
|
---|
| 22 | borderRadius: 1,
|
---|
| 23 | }}
|
---|
| 24 | />
|
---|
| 25 | ),
|
---|
| 26 | });
|
---|
| 27 |
|
---|
| 28 | // ----------------------------------------------------------------------
|
---|
| 29 |
|
---|
| 30 | export default function Editor({
|
---|
| 31 | id = 'minimal-quill',
|
---|
| 32 | error,
|
---|
| 33 | simple = false,
|
---|
| 34 | helperText,
|
---|
| 35 | sx,
|
---|
| 36 | ...other
|
---|
| 37 | }: EditorProps) {
|
---|
| 38 | const modules = {
|
---|
| 39 | toolbar: {
|
---|
| 40 | container: `#${id}`,
|
---|
| 41 | },
|
---|
| 42 | history: {
|
---|
| 43 | delay: 500,
|
---|
| 44 | maxStack: 100,
|
---|
| 45 | userOnly: true,
|
---|
| 46 | },
|
---|
| 47 | syntax: true,
|
---|
| 48 | clipboard: {
|
---|
| 49 | matchVisual: false,
|
---|
| 50 | },
|
---|
| 51 | };
|
---|
| 52 |
|
---|
| 53 | return (
|
---|
| 54 | <>
|
---|
| 55 | <StyledEditor
|
---|
| 56 | sx={{
|
---|
| 57 | ...(error && {
|
---|
| 58 | border: (theme) => `solid 1px ${theme.palette.error.main}`,
|
---|
| 59 | '& .ql-editor': {
|
---|
| 60 | bgcolor: (theme) => alpha(theme.palette.error.main, 0.08),
|
---|
| 61 | },
|
---|
| 62 | }),
|
---|
| 63 | ...sx,
|
---|
| 64 | }}
|
---|
| 65 | >
|
---|
| 66 | <Toolbar id={id} isSimple={simple} />
|
---|
| 67 |
|
---|
| 68 | <ReactQuill
|
---|
| 69 | modules={modules}
|
---|
| 70 | formats={formats}
|
---|
| 71 | placeholder="Write something awesome..."
|
---|
| 72 | {...other}
|
---|
| 73 | />
|
---|
| 74 | </StyledEditor>
|
---|
| 75 |
|
---|
| 76 | {helperText && helperText}
|
---|
| 77 | </>
|
---|
| 78 | );
|
---|
| 79 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.