Ju99ernaut / grapesjs-component-code-editor

Code editor for grapesjs
MIT License
64 stars 21 forks source link

Bug: Edit main wrapper error -> Cannot read properties of undefined (reading 'indexOf') #26

Closed ilsantuzzo closed 3 years ago

ilsantuzzo commented 3 years ago

Hi, I'm back :) your code editor is working pretty well and we are using it a lot. Actually we are trying to copy and paste an intere html page but we have an issue. Here the steps to reproduce the bug: Select the main wrapper > open the code editor > edit the code > click apply > check the error in the console bug code editr

For what I can see, the main wrapper component (body) is not a valid html to edit. If you try to get the whole html with editor.getHtml(), that wrapper tag (div), is not there.

In order to edit the entire html, keep the selection on the wrapper for displaying the whole code is important. I'm wondering if it is possibile to don't display the wrapper html each time the component is selected.

Ju99ernaut commented 3 years ago

Yeah I also think the best solution is to disable editing of the wrapper.

Ju99ernaut commented 3 years ago

Another solution would be to check if the wrapper is selected, the use editor.setComponents(htmlCode) instead of the current replacement mechanism https://github.com/Ju99ernaut/grapesjs-component-code-editor/blob/3c2faec2c47ebbd5cc6d534f0e1d38279d232cee/src/code-editor/index.js#L149