Here's how I Enable Tap Event To Add a Block / Component to The Canvas on Mobile Browsers #6406
teknosains
started this conversation in
Show and tell
Replies: 1 comment
-
Hello, nice! Possibly similar to https://github.com/bgrand-ch/grapesjs-click 🤔But not SSR-friendly. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background
By default, the editor only allows to add a component/block into the canvas using the Drag n Drop event (hmm I have not found the official way to configure it, anyone ? ). When I open it on mobile browsers, it won't work.
So I start looking at the
https://github.com/GrapesJS/touch
plugin. Unfortunately, it doesn't work and is a bit difficult to implement in my SSR React-based app.I start finding a way to do it and manage to make it work. It's probably not the best way to do it, but it works for my case. The idea is to simply override the default drag & drop and add Tap / Touch or Click event to the Block on Mobile Browser, and on Dekstop its still the Drag n Drop.
Here's how i do it
Grapesjs version
0.22.3
Steps
editor.onReady()
You have a custom Block?
If you have custom blocks, you may need to add additional attribute. In my case I add another attribute
data-label
.For example you create a custom Block like this
and use it like this, as shown on the function
addBlockOnTap
abovePlugins to Try
There is this Plugin https://github.com/bgrand-ch/grapesjs-click you can try to change Drag n Drop into Click
Updates: The Official Way
I later find out its available to use Click on the BlockManager
Turns out there's this option.
Beta Was this translation helpful? Give feedback.
All reactions