{"id":23053489,"url":"https://github.com/component/clipboard-dom","last_synced_at":"2025-07-04T01:34:14.218Z","repository":{"id":4496227,"uuid":"5635576","full_name":"component/clipboard-dom","owner":"component","description":"Makes a DOM element (i.e. \u003cbutton\u003e) write to the system clipboard","archived":false,"fork":false,"pushed_at":"2015-03-12T01:42:24.000Z","size":230,"stargazers_count":34,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-29T13:44:46.515Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://component.github.io/clipboard-dom","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/component.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-01T00:35:34.000Z","updated_at":"2025-02-14T15:50:41.000Z","dependencies_parsed_at":"2022-09-26T16:20:59.478Z","dependency_job_id":null,"html_url":"https://github.com/component/clipboard-dom","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/component/clipboard-dom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fclipboard-dom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fclipboard-dom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fclipboard-dom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fclipboard-dom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/component","download_url":"https://codeload.github.com/component/clipboard-dom/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fclipboard-dom/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263431222,"owners_count":23465497,"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":[],"created_at":"2024-12-16T00:18:22.260Z","updated_at":"2025-07-04T01:34:14.184Z","avatar_url":"https://github.com/component.png","language":"JavaScript","readme":"\n# clipboard-dom\n\n  Makes a DOM element (i.e. \u0026lt;button\u0026gt;) write to the system clipboard. This\n  component is based off of the [ZeroClipboard](https://github.com/jonrohan/ZeroClipboard)\n  project, and in fact uses the same SWF Flash code.\n\n## Installation\n\n```\n$ component install component/clipboard-dom\n```\n\n## Example\n\n``` html\n\u003chtml\u003e\n  \u003cbody\u003e\n    \u003c!-- The \"copy-button\" *should* be inside a div with \"position: relative\"\n         or something else that \"has layout\". --\u003e\n    \u003cdiv style=\"position: relative;\"\u003e\n      \u003cbutton id=\"copy-button\"\u003eCopy to Clipboard\u003c/button\u003e\n    \u003c/div\u003e\n    \u003cscript src=\"build/build.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"main.js\"\u003e\u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n``` js\n// main.js\n\nvar Clip = require('clipboard-dom');\n\n// set the path to the swf file first\nClip.swf('/swf/ZeroClipboard.swf');\n\n// create a \"Clip\" instance\nvar ele = document.getElementById('copy-button');\nvar parent = ele.parentNode; // parent should \"have layout\"\nvar clip = new Clip(ele, parent);\n\n// listen for meaningful events\nclip.on('load', function(){\n  console.log('button loaded');\n});\n\nclip.on('complete', function(text){\n  console.log('copied text to the clipboard:', text);\n});\n\nclip.on('mousedown', function() {\n  // \"mousedown\" is the last chance to set the text before it gets copied\n  var input = document.getElementById('copy-text');\n  clip.text(input.value);\n});\n```\n\n## Events\n\n### \"load\"\n\nFired when the SWF movie for the clipboard instance has loaded.\n\n### \"complete\"\n\nFired when the user clicks on the button and the text has been copied.\nThe text that got copied is passed in as an argument.\n\n### \"mouseover\"\n\nFired when the user mouses over the button.\n\n### \"mouseout\"\n\nFired when the user mouses away from the button.\n\n### \"mousedown\"\n\nFired when the user pressed the mouse down on the button.\n\n### \"mouseup\"\n\nFired when the user releases the mouse from the button.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Fclipboard-dom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomponent%2Fclipboard-dom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Fclipboard-dom/lists"}