Skip to content

Prevent drop things from outside of grapesjs #5242

Answered by artf
ronaldohoch asked this question in Q&A
Discussion options

You must be logged in to vote

Right now you can rely on something like canvas:dragdata and dragContent to understand if the content to drop is an external one

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. config.canvas.allowExternalDrop)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ronaldohoch
Comment options

Answer selected by ronaldohoch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants