npm install grapesjs grapesjs-click
import grapesjs from 'grapesjs'
import grapesjsClick from 'grapesjs-click'
const pluginOptions = {
hasAutoDropped: boolean // optional, default to true
}
const editor = grapesjs.init({
// ...
plugins: [
grapesjsClick
],
pluginOpts: {
[grapesjsClick]: pluginOptions
}
// ...
})
import grapesjs, { usePlugin } from 'grapesjs'
import grapesjsClick from 'grapesjs-click'
const pluginOptions = {
hasAutoDropped: boolean // default to true
}
const editor = grapesjs.init({
// ...
plugins: [
usePlugin(grapesjsClick, pluginOptions)
]
// ...
})
const commandOptions = {
id: string // required, grapesjs block identifier
}
editor.run('click:grab-block', commandOptions)
const commandOptions = {
id: string // optional, grapesjs block identifier
}
editor.run('click:drop-block', commandOptions)
const commandOptions = {
id: string // required, grapesjs component identifier
}
editor.run('click:grab-component', commandOptions)
const commandOptions = {
id: string // optional, grapesjs component identifier
}
editor.run('click:drop-component', commandOptions)
{
// Drop the grabbed block or component when a component is selected in the canvas.
hasAutoDropped: boolean // optional, default to true
}
If you have a question about how grapesjs-click
works or an idea to improve it, the Discussions tab in GitHub is the place to be.
However, if you get an error, you should open an issue.
Distributed under the BSD 3-Clause License. See LICENSE for more information.
Benjamin Grand @bgrand_ch