{"id":16350505,"url":"https://github.com/zspecza/textselect.js","last_synced_at":"2025-04-04T12:24:29.474Z","repository":{"id":10409437,"uuid":"12565615","full_name":"zspecza/textselect.js","owner":"zspecza","description":"Adds a `textselect` event to the DOM that triggers when text is highlighted.","archived":false,"fork":false,"pushed_at":"2013-09-05T09:33:57.000Z","size":100,"stargazers_count":2,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T22:19:57.791Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zspecza.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}},"created_at":"2013-09-03T14:14:19.000Z","updated_at":"2016-11-26T14:26:58.000Z","dependencies_parsed_at":"2022-08-29T15:41:57.664Z","dependency_job_id":null,"html_url":"https://github.com/zspecza/textselect.js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspecza%2Ftextselect.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspecza%2Ftextselect.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspecza%2Ftextselect.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspecza%2Ftextselect.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zspecza","download_url":"https://codeload.github.com/zspecza/textselect.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247176075,"owners_count":20896405,"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-10-11T01:05:13.576Z","updated_at":"2025-04-04T12:24:29.458Z","avatar_url":"https://github.com/zspecza.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"textselect.js\n=============\n\n`textselect.js` is a simple script that depends on jQuery and adds a\n`textselect` event to the document that triggers whenever any text is selected.\n\nThis event will contain information about the selected text in the form of\nan object:\n\n+ Text: the selected text content\n+ Top: the top offset of the selection relative to the viewport\n+ Bottom: the bottom offset\n+ Left: the left offset\n+ Right: the right offset\n+ Width: the width of the selection in pixels\n+ Height: the height of the selection in pixels\n\n## How to use `textselect.js`\n\nUsing `textselect.js` is simple. Just add an event listener to the element\nyou want to listen on:\n\n```javascript\n$(function() {\n  $('#my-element').on('textselect', function(e, selection) {\n    alert(selection.text);\n  });\n});\n```\n\nYou're of course going to need to make sure that jQuery is loaded on the page\nfirst.\n\n## Why is this useful?\n\nWhy isn't it useful? Here's an example of it's use: http://codepen.io/declandewet/full/kuohv\n\n## Known Issues\n\nIf any of the following issues bother you, but you are eager for them to be fixed,\nyou are more than welcome to submit a pull request or discuss them on the issues page.\n\n1. Selecting text, unselecting it and then selecting the exact same text doesn't\n  trigger the event.\n  + This is being worked on. In the meantime, it is potentially trivial to simply\n    cache the last known selection's information and use that.\n2. Coordinates and size are returning `undefined` in browser \u003cx\u003e\n  + This is because `getBoundingClientRect()` won't work on `window.getSelection.`\n    Research is being done on alternative methods for other browsers.\n3. This doesn't work with my module system\n  + This is because the script checks for the presence of `$` on the `window` object.\n    This will be changed in a later commit, but the way it works is fine for now,\n    as I do not consider this script to be stable just yet.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzspecza%2Ftextselect.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzspecza%2Ftextselect.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzspecza%2Ftextselect.js/lists"}