BUG: Inline event declarations like onclick event on a buttons are getting removed
Question
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
Chrome
Reproducible demo link
https://jsfiddle.net/6bn43a05/
Describe the bug
How to reproduce the bug?
- Add a onclick event for a html tag
What is the expected behavior? It should not remove the event after getting loaded in to the editor
What is the current behavior? It removes the onclick event from html
If is necessary to execute some code in order to reproduce the bug, paste it here below:
// no need to include extra code
Same issue reported here : https://stackoverflow.com/questions/78496572/grapesjs-removes-onclick-attributes-how-to-prevent-it-to-do-it
Code of Conduct
- I agree to follow this project's Code of Conduct
Answers (1)
This is intentional for security reasons, but you can disable it with the option config.parser.optionsHtml.allowUnsafeAttr (at your own risk): https://github.com/GrapesJS/grapesjs/blob/819bfcf44bb23d51990eba3b4330e9932df59cde/src/parser/config/config.ts#L116
Related Questions and Answers
Continue research with similar issue discussions.
Issue #6409
BUG: Cannot drag to move components on mobile
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v133 Reproducible demo link https:/...
Issue #6116
BUG: asDocument not working as expected
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome 128 Reproducible demo link https://...
Issue #5020
BUG: Changing Title Attribute on Views Panel Buttons Doesn't Persist
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? ChromeReproducible demo link https://jsfiddl...
Issue #4242
BUG: Set name for page doesn't work
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v100 Reproducible demo link https:/...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.