{"id":16019265,"url":"https://github.com/bgrand-ch/grapesjs-click","last_synced_at":"2025-03-17T20:31:17.309Z","repository":{"id":214192232,"uuid":"735833832","full_name":"bgrand-ch/grapesjs-click","owner":"bgrand-ch","description":"GrapesJS click plugin (no more drag-and-drop)","archived":false,"fork":false,"pushed_at":"2024-08-30T14:12:04.000Z","size":101,"stargazers_count":6,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T14:59:33.949Z","etag":null,"topics":["click","dnd","drag-and-drop","drop","gjs","grab","grapesjs","grapesjs-plugin","plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bgrand-ch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-26T07:56:30.000Z","updated_at":"2024-12-24T09:45:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"9d52c4f8-931f-4043-9b35-ed1cc54a0e37","html_url":"https://github.com/bgrand-ch/grapesjs-click","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"506f70e617d774e293c079f611216ebb14252608"},"previous_names":["bgrand-ch/grapesjs-click"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgrand-ch%2Fgrapesjs-click","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgrand-ch%2Fgrapesjs-click/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgrand-ch%2Fgrapesjs-click/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bgrand-ch%2Fgrapesjs-click/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bgrand-ch","download_url":"https://codeload.github.com/bgrand-ch/grapesjs-click/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243882232,"owners_count":20363108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["click","dnd","drag-and-drop","drop","gjs","grab","grapesjs","grapesjs-plugin","plugin"],"created_at":"2024-10-08T17:03:38.570Z","updated_at":"2025-03-17T20:31:16.984Z","avatar_url":"https://github.com/bgrand-ch.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GrapesJS click plugin (no more drag-and-drop)\n\n## Installation\n\n```shell\nnpm install grapesjs grapesjs-click\n```\n\n## Usage\n\n### JavaScript\n\n```js\nimport grapesjs from 'grapesjs'\nimport grapesjsClick, { getMouseListener, showGrabbedInfo, hideGrabbedInfo } from 'grapesjs-click'\n\nconst pluginOptions = {\n  hasAutoDropped: boolean // optional, default to true\n}\nconst editor = grapesjs.init({\n  // ...\n  plugins: [\n    grapesjsClick\n  ],\n  pluginOpts: {\n    [grapesjsClick]: pluginOptions\n  }\n  // ...\n})\n```\n\n### TypeScript\n\n```ts\nimport grapesjs, { usePlugin } from 'grapesjs'\nimport grapesjsClick, { getMouseListener, showGrabbedInfo, hideGrabbedInfo } from 'grapesjs-click'\n\nimport type { PluginOptions, CommandOptions } from 'grapesjs-click'\n\nconst pluginOptions: PluginOptions = {\n  hasAutoDropped: boolean // optional, default to true\n}\nconst editor = grapesjs.init({\n  // ...\n  plugins: [\n    usePlugin(grapesjsClick, pluginOptions)\n  ]\n  // ...\n})\n```\n\n## Commands\n\n### Grab a block\n\n```ts\nconst commandOptions: CommandOptions = {\n  id: string // required, grapesjs block identifier\n}\n\neditor.runCommand('click:grab-block', commandOptions)\n```\n\n### Drop a block\n\n```ts\nconst commandOptions: CommandOptions = {\n  id: string // optional, grabbed block id by default\n}\n\neditor.runCommand('click:drop-block', commandOptions)\n```\n\n### Grab a component\n\n```ts\nconst commandOptions: CommandOptions = {\n  id: string // optional, selected component by default\n}\n\neditor.runCommand('click:grab-component', commandOptions)\n```\n\n### Drop a component\n\n```ts\nconst commandOptions: CommandOptions = {\n  id: string // optional, grabbed component id by default\n}\n\neditor.runCommand('click:drop-component', commandOptions)\n```\n\n## Events\n\n```ts\nimport type { MouseListener } from 'grapesjs-click'\n\n// Your custom HTML element to display block or component info.\nconst grabbedInfoEl = document.getElementById('grabbed-info')\n\n// An utility to make your custom HTML element follow the mouse cursor.\nconst mouseListener: MouseListener = getMouseListener(editor, grabbedInfoEl)\n```\n\n\u003e Full demonstration in the [`src/example.ts`](https://github.com/bgrand-ch/grapesjs-click/blob/main/src/example.ts) file.\n\n### On block grabbed\n\n```ts\neditor.on('click:grab-block', (block: Block) =\u003e {\n  const label = block.getLabel()\n  const category = block.getCategoryLabel()\n\n  grabbedInfoEl.textContent = `${label} (${category})`\n\n  showGrabbedInfo(grabbedInfoEl, mouseListener)\n})\n```\n\n### On block dropped\n\n```ts\neditor.on('click:drop-block', () =\u003e {\n  grabbedInfoEl.textContent = ''\n  grabbedInfoEl.style.top = '0'\n  grabbedInfoEl.style.left = '0'\n\n  hideGrabbedInfo(grabbedInfoEl, mouseListener)\n})\n```\n\n### On component grabbed\n\n```ts\neditor.on('click:grab-component', (component: Component) =\u003e {\n  const { name, type } = component.props()\n  const label = name || type\n\n  grabbedInfoEl.textContent = label\n\n  showGrabbedInfo(grabbedInfoEl, mouseListener)\n})\n```\n\n### On component dropped\n\n```ts\neditor.on('click:drop-component', (component: Component) =\u003e {\n  grabbedInfoEl.textContent = ''\n  grabbedInfoEl.style.top = '0'\n  grabbedInfoEl.style.left = '0'\n\n  hideGrabbedInfo(grabbedInfoEl, mouseListener)\n})\n```\n\n## Options\n\n```ts\n{\n  // Drop the grabbed block or component when a component is selected in the canvas.\n  hasAutoDropped: boolean // optional, default to true\n}\n```\n\n## Question? Idea?\n\nIf you have a question about how `grapesjs-click` works or an idea to improve it, the [Discussions](https://github.com/bgrand-ch/grapesjs-click/discussions) tab in GitHub is the place to be.\n\nHowever, if you get an error, you should open an [issue](https://github.com/bgrand-ch/grapesjs-click/issues).\n\n## License\n\nDistributed under the BSD 3-Clause License. See [LICENSE](https://github.com/bgrand-ch/grapesjs-click/blob/main/LICENSE.md) for more information.\n\n## Contact\n\nBenjamin Grand [@bgrand_ch](https://twitter.com/bgrand_ch)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbgrand-ch%2Fgrapesjs-click","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbgrand-ch%2Fgrapesjs-click","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbgrand-ch%2Fgrapesjs-click/lists"}