Prevent drop things from outside of grapesjs #5242
Answered
by
artf
ronaldohoch
asked this question in
Q&A
-
Hello! I can drop things from outside of grapesjs, things like text and images. From files or other websites. Is there a way to prevent this? Thank you. |
Beta Was this translation helpful? Give feedback.
Answered by
artf
Jul 17, 2023
Replies: 1 comment 1 reply
-
Right now you can rely on something like editor.on('canvas:dragdata', (dataTransfer, result) => {
const isExternal = !editor.getModel().get('dragContent');
if (isExternal) {
// with a falsy `content`, nothing will be created
result.content = null;
}
}); The only problem is the editor would still allow to choice where to drop the content. I'll try to see if it's possible to introduce a new config option that prevents, completely, external elements (eg. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ronaldohoch
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now you can rely on something like
canvas:dragdata
anddragContent
to understand if the content to drop is an external oneThe only problem is the editor would still allow to choice where to drop the content.
I'll try to see if it's possible to introduce a new config option that prevents, completely, external elements (eg.
config.canvas.allowExternalDrop
)