mui-rte icon indicating copy to clipboard operation
mui-rte copied to clipboard

Installed the dependencies and tried loading the mui-rte in the page, it shows export undefined issue

Open Bose-Coats opened this issue 3 years ago • 9 comments

image import { createTheme, ThemeProvider } from '@mui/material/styles' import MUIRichTextEditor from 'mui-rte'

const myTheme = createTheme({ // Set up your custom MUI theme here })

const change = (data) =>{ console.log(data) }

export const MaterialUIRichTextEditor =({data, setTexter}) => { return (<ThemeProvider theme={myTheme}> <MUIRichTextEditor label="Start typing..." defaultValue={data} onChange = {change} /> </ThemeProvider>) }

This is how we have added the mui-rte The ui is showing error on loading the page itself "SyntaxError : unexpected token export module.exports = require("mui-rte")

image

Bose-Coats avatar Oct 21 '21 04:10 Bose-Coats

Did you solve this? Also facing this issue

bc185168 avatar Nov 04 '21 19:11 bc185168

same here

jeromeSH26 avatar Nov 06 '21 13:11 jeromeSH26

No luck , so started using react-rte component which is working as expected

Bose-Coats avatar Nov 08 '21 04:11 Bose-Coats

in the node/mui-rte/index.js folder

replace with :

const MUIRichTextEditor = require('./dist/MUIRichTextEditor'); module.exports = MUIRichTextEditor;

it works for me :)

tristan-git avatar Nov 13 '21 11:11 tristan-git

@Bose-Coats Was this working on version 2.0.0?

niuware avatar Nov 15 '21 00:11 niuware

@niuware same error on 2.0.0 version

fnowacki avatar Nov 20 '21 17:11 fnowacki

Ditto, seems to be caused by the defaultValue parameter.

quitequinn avatar Nov 25 '21 02:11 quitequinn

To use the editor in NextJS, I was able to put the editor in a component named TextEditor. Then I used dynamic to load it in another component:

import dynamic from 'next/dynamic';
const TextEditor = dynamic(() => import('components/TextEditor'), {ssr: false });

It can take a second to show up (in dev at least), so you can put something there while it loads

import dynamic from 'next/dynamic';
const TextEditor = dynamic(() => import('components/TextEditor'), {
  ssr: false,
  // eslint-disable-next-line react/display-name
  loading: () => (
    <>
      <Skeleton variant='text' sx={{ width: '15%' }} />
      <Skeleton variant='rectangular' sx={{ width: '100%', marginBottom: 3 }} height={100} />
    </>
  ),
});

Although I came here searching for how to get this to work for a @testing-library test, so I'd love it anyone has an example of that...

kyle-apex avatar Nov 28 '21 02:11 kyle-apex

To use the editor in NextJS, I was able to put the editor in a component named TextEditor. Then I used dynamic to load it in another component:

import dynamic from 'next/dynamic';
const TextEditor = dynamic(() => import('components/TextEditor'), {ssr: false });

It can take a second to show up (in dev at least), so you can put something there while it loads

import dynamic from 'next/dynamic';
const TextEditor = dynamic(() => import('components/TextEditor'), {
  ssr: false,
  // eslint-disable-next-line react/display-name
  loading: () => (
    <>
      <Skeleton variant='text' sx={{ width: '15%' }} />
      <Skeleton variant='rectangular' sx={{ width: '100%', marginBottom: 3 }} height={100} />
    </>
  ),
});

Although I came here searching for how to get this to work for a @testing-library test, so I'd love it anyone has an example of that...

very good, it worked for me. thanks

adsuarezuci avatar Jan 04 '23 14:01 adsuarezuci