Ju99ernaut / grapesjs-script-editor

Edit or attach script to selected component
MIT License
27 stars 15 forks source link

Script characters are not decoded when loaded. #5

Closed cederron closed 2 years ago

cederron commented 2 years ago

Hi, I'm using grapes 0.18.41 with grapesjs-script-editor and grapesjs-template-manager. When loading data from backend containing grapesjs-script-editor scripts, characters are not decoded. For example symbol '&lt' is not decoded to '<' so the script errors out. This only happens with grapesjs-script-editor scripts. Scripts written in the component definition are loaded just fine for example. Only found one similar issue commented and the guy was told to go checkout StorageManager setup, I don't see how this helps, besides, at least in my project, storage seems well configured as everythings saves/loads fine except grapesjs-script-editor scripts.

Any clue what can be happening and how to fix it ? Thanks.

Ju99ernaut commented 2 years ago

Hi, unfortunately I don't know what could be causing this issue.

cederron commented 2 years ago

I did a quick hack , adding this code to grapesjs pagemanager in function _onPageChange

var txt = document.createElement("textarea"); txt.innerHTML = mainComp.attributes.script; mainComp.attributes.script = txt.value;

Now it works.