
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
node-selection
Advanced tools
Get current selected text by using system accessibility APIs
Get current selected text by using system accessibility APIs
npm i node-selection
macOS requires accessibility permissions to be granted before a program can control the Mac by using accessibility features.
checkAccessibilityPermissions([options])
options
: <Object>
prompt
: <boolean>
Default: false
Returns: <Promise>
Fullfills upon success with a boolean indicating
whether accessibility permissions have been granted to this program.
If prompt
is true
, a prompt window will be shown when accessibility
permissions have not been granted.
If this method is invoked on non-macOS platform, it always returns true
.
import { checkAccessibilityPermissions } from 'node-selection';
if (!(await checkAccessibilityPermissions({ prompt: true }))) {
console.log('grant accessibility permissions and restart this program');
process.exit(1);
}
getSelection()
Returns: <Promise>
Fullfills upon success with an object with one property:
text
: <string>
| <undefined>
Current selected text.process
: Object
| <undefined>
pid
: <number>
| <undefined>
The process ID.name
: <string>
| <undefined>
The filename of the process.bundleIdentifier
: <string>
| <undefined>
The bundle identifier of the process (macOS only).import { getSelection } from 'node-selection';
try {
const { text, process } = await getSelection();
console.log('current selection:', { text, process });
} catch (error) {
// no valid selection
console.error('error', error);
}
FAQs
Get current selected text by using system accessibility APIs
The npm package node-selection receives a total of 1,355 weekly downloads. As such, node-selection popularity was classified as popular.
We found that node-selection demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.