megahertz / react-simple-wysiwyg

Simple and lightweight React WYSIWYG editor
https://megahertz.github.io/react-simple-wysiwyg/
MIT License
119 stars 21 forks source link

Replacing the toolbar with the custom icons #36

Closed g-wozniak closed 6 months ago

g-wozniak commented 6 months ago

Hello,

Thank you for your time on this component. I am following the documentation and try to customise the toolbar as you suggest.

My code:

      <EditorProvider>
         <Editor value={value} onChange={(e) => setHTMLValue(e.target.value)}>
            <Toolbar>
               <BtnBold/>
               <BtnItalic/>
            </Toolbar>
         </Editor>
      </EditorProvider>

but the component does not change at all as if what in "children" is not picked up at all. Any value/element there does not make a difference. Can you please help?

Screenshot 2023-12-20 at 12 33 13

g-wozniak commented 6 months ago

Ok, found my issue. For anyone who struggles with customisation, make sure you import {Editor} not as a default import.

The initial example in the docs uses DefaultEditor which does not pass children. When I moved from the simple example to the one with Provider and customised toolbar I didn't realise the Editor import has changed.