codeslayer1 / react-ckeditor

CKEditor component for React with plugin and custom event listeners support
MIT License
130 stars 34 forks source link

CKEditor in map field to loop through repeater field only loads first editor #85

Open hassnainabass opened 2 years ago

hassnainabass commented 2 years ago

CKEditor in map field to loop through repeater field only loads first editor and throughs this error Uncaught TypeError: Cannot read properties of null (reading 'unselectable')

{menu.map((item, index) => (

setMenuEn(e.editor.getData(), index, menu), "afterPaste": (e)=>setMenuEn(e.editor.getData(), index, menu), "change": (e)=>setMenuEn(e.editor.getData(), index, menu) }} />
        <div className={"col " + (lang=='fr' ? '' : 'hide')}>
            <label className="label-gen">Menu(Fr)</label>
            <CKEditor 
            activeClass="p10" 
            config = {{
                allowedContent : true
            }}
            id={'menufr'+index}
            content={item.menuFr} 
            events={{
                "blur": (e)=>setMenuFr(e.editor.getData(), index, menu),
                "afterPaste":  (e)=>setMenuFr(e.editor.getData(), index, menu),
                "change":  (e)=>setMenuFr(e.editor.getData(), index, menu),
            }}
            />
        </div>
    </div>
    <div className="row" style={{marginTop:'20px', marginBottom: "20px"}}>
        <div className="col">
            <button className="btn btn-sm btn-danger" onClick={e => delMenu(e, menu, index)}>Delete</button>
            <hr />
        </div>
    </div>
    </div>
    ))}