How to use the clipboardy.read function in clipboardy

To help you get started, we’ve selected a few clipboardy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mlewand / win-clipboard / test / index.js View on Github external
it( 'Sets correctly UTF8', () => {
			const utfString = 'Foo ¥£€ûл身śĆ🙀🙊';

			let res = winClipboard.setText( utfString );

			return clipboardy.read()
				.then( ( data ) => {
					expect( data ).to.be.eql( utfString );
					expect( res ).to.be.eql( 34 );
				} );
		} );
github dat-land / dat-desktop / tests / index.js View on Github external
.then(() =>
      clipboard
        .read()
        .then(text =>
          t.ok(
            text.match(/^dat:\/\/[0-9a-f]{32}/),
            'link copied to clipboard: ' + text
          )
        )
    )
github fernandoescolar / vscode-solution-explorer / src / commands / PasteCommand.ts View on Github external
protected async runCommand(item: TreeItem, args: string[]): Promise {    
        let data = await clipboardy.read();
        if (!data) return;     
        
        if (!(await fs.exists(data))) return;

        let targetpath: string = item.path;
        if (!item.contextValue.startsWith(ContextValues.ProjectFolder)){
            targetpath = path.dirname(targetpath);
        }

        let stat = await fs.lstat(data);
        if (stat.isDirectory()){
            this.copyDirectory(item, data, targetpath);
        } else {
            this.copyFile(item, data, targetpath);
        }
    }
github quicktype / quicktype-vscode / src / extension.ts View on Github external
let indentation: string;
    if (editor.options.insertSpaces) {
        const tabSize = editor.options.tabSize as number;
        indentation = " ".repeat(tabSize);
    } else {
        indentation = "\t";
    }

    const language = await getTargetLanguage(editor);
    if (language.cancelled) {
        return;
    }

    let content: string;
    try {
        content = await readClipboard();
    } catch (e) {
        vscode.window.showErrorMessage("Could not get clipboard contents");
        return;
    }

    if (kind !== "typescript" && !jsonIsValid(content)) {
        vscode.window.showErrorMessage("Clipboard does not contain valid JSON.");
        return;
    }

    let topLevelName: string;
    if (kind === "typescript") {
        topLevelName = "input";
    } else {
        const tln = await promptTopLevelName();
        if (tln.cancelled) {

clipboardy

Access the system clipboard (copy/paste)

MIT
Latest version published 7 months ago

Package Health Score

81 / 100
Full package analysis