{"id":17654735,"url":"https://github.com/lujjjh/node-selection","last_synced_at":"2025-04-28T15:53:21.416Z","repository":{"id":38365524,"uuid":"476277273","full_name":"lujjjh/node-selection","owner":"lujjjh","description":"Get current selected text by using system accessibility APIs","archived":false,"fork":false,"pushed_at":"2024-05-16T16:03:31.000Z","size":1103,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-28T15:53:11.375Z","etag":null,"topics":["accessibility","macos","nodejs","windows"],"latest_commit_sha":null,"homepage":"","language":"C++","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/lujjjh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-03-31T11:32:54.000Z","updated_at":"2024-10-25T08:23:18.000Z","dependencies_parsed_at":"2024-11-02T01:01:33.301Z","dependency_job_id":null,"html_url":"https://github.com/lujjjh/node-selection","commit_stats":{"total_commits":29,"total_committers":1,"mean_commits":29.0,"dds":0.0,"last_synced_commit":"368dbd3d97a34e4ecfebc1152d73196cb64527a8"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujjjh%2Fnode-selection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujjjh%2Fnode-selection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujjjh%2Fnode-selection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujjjh%2Fnode-selection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lujjjh","download_url":"https://codeload.github.com/lujjjh/node-selection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251342718,"owners_count":21574243,"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":["accessibility","macos","nodejs","windows"],"created_at":"2024-10-23T12:35:56.864Z","updated_at":"2025-04-28T15:53:21.399Z","avatar_url":"https://github.com/lujjjh.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-selection\n\n\u003e Get current selected text by using system accessibility APIs\n\n## Installation\n\n```sh\nnpm i node-selection\n```\n\n## Usage\n\n### Accessibility permissions\n\nmacOS requires accessibility permissions to be granted before a program\ncan control the Mac by using accessibility features.\n\n#### `checkAccessibilityPermissions([options])`\n\n- `options`: `\u003cObject\u003e`\n  - `prompt`: `\u003cboolean\u003e` **Default:** `false`\n\nReturns: `\u003cPromise\u003e` Fullfills upon success with a boolean indicating\nwhether accessibility permissions have been granted to this program.\n\nIf `prompt` is `true`, a prompt window will be shown when accessibility\npermissions have not been granted.\n\nIf this method is invoked on non-macOS platform, it always returns `true`.\n\n```js\nimport { checkAccessibilityPermissions } from 'node-selection';\n\nif (!(await checkAccessibilityPermissions({ prompt: true }))) {\n  console.log('grant accessibility permissions and restart this program');\n  process.exit(1);\n}\n```\n\n### Selection\n\n#### `getSelection()`\n\nReturns: `\u003cPromise\u003e` Fullfills upon success with an object with one property:\n\n- `text`: `\u003cstring\u003e` | `\u003cundefined\u003e` Current selected text.\n- `process`: `Object` | `\u003cundefined\u003e`\n  - `pid`: `\u003cnumber\u003e` | `\u003cundefined\u003e` The process ID.\n  - `name`: `\u003cstring\u003e` | `\u003cundefined\u003e` The filename of the process.\n  - `bundleIdentifier`: `\u003cstring\u003e` | `\u003cundefined\u003e` The bundle identifier of the process (macOS only).\n\n```js\nimport { getSelection } from 'node-selection';\n\ntry {\n  const { text, process } = await getSelection();\n  console.log('current selection:', { text, process });\n} catch (error) {\n  // no valid selection\n  console.error('error', error);\n}\n```\n\n## Examples\n\n- [Node](example/node-example)\n- [Electron](example/electron-example)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flujjjh%2Fnode-selection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flujjjh%2Fnode-selection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flujjjh%2Fnode-selection/lists"}