grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

QUESTION: How to add javascript in the html without sanitization?

Open theSC0RP opened this issue 5 years ago • 4 comments

Hey @artf, I am taking javascript input from the user. I need to add this javascript inside the template HTML but it gets sanitized. Is there a way that I can turn off the sanitization? (I don't have an issue with the problems you mentioned in #3245 ) or can you add a property in the editor like allowSanitization: false If not, then how can I add the javascript to the canvas?

theSC0RP avatar Feb 12 '21 08:02 theSC0RP

I tried adding the script to the iframe in which the canvas renders by adding a <script> tag at the end of the body of the iframe. This works to some extent. The problem here is that when I need to update the js inside the script I will need to refresh the iframe (to remove any event listeners if present) and doing so gives me the following error: Screenshot from 2021-02-18 10-54-24

theSC0RP avatar Feb 18 '21 05:02 theSC0RP

Can you provide a reproducible demo of your issue, please?

artf avatar Feb 19 '21 21:02 artf

Thanks for the reply @artf. I was doing a mistake while updating the iframe so now my problem is solved! Just another question, is there any built-in method to refresh the iframe?

theSC0RP avatar Feb 23 '21 21:02 theSC0RP

Obrigado pela resposta@artf. Eu estava cometendo um erro ao atualizar o iframe, então agora meu problema está resolvido! Apenas outra pergunta, existe algum método interno para atualizar o iframe?

Hello, @theSC0RP. How did you add the script, could you show it? Thanks

LeonardoAraujoLisboa avatar Mar 16 '23 15:03 LeonardoAraujoLisboa