mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-31 11:40:47 +08:00
Update clipboard module
This commit is contained in:
@@ -526,6 +526,14 @@ app.on('ready', () => {
|
||||
clipboard.writeText('Example String');
|
||||
clipboard.writeText('Example String', 'selection');
|
||||
console.log(clipboard.readText('selection'));
|
||||
console.log(clipboard.availableFormats());
|
||||
clipboard.clear();
|
||||
|
||||
clipboard.write({
|
||||
html: '<html></html>',
|
||||
text: 'Hello World!',
|
||||
image: clipboard.readImage()
|
||||
});
|
||||
|
||||
// crash-reporter
|
||||
// https://github.com/atom/electron/blob/master/docs/api/crash-reporter.md
|
||||
|
||||
@@ -63,6 +63,14 @@ webFrame.setSpellCheckProvider('en-US', true, {
|
||||
clipboard.writeText('Example String');
|
||||
clipboard.writeText('Example String', 'selection');
|
||||
console.log(clipboard.readText('selection'));
|
||||
console.log(clipboard.availableFormats());
|
||||
clipboard.clear();
|
||||
|
||||
clipboard.write({
|
||||
html: '<html></html>',
|
||||
text: 'Hello World!',
|
||||
image: clipboard.readImage()
|
||||
});
|
||||
|
||||
// crash-reporter
|
||||
// https://github.com/atom/electron/blob/master/docs/api/crash-reporter.md
|
||||
|
||||
+42
-8
@@ -6,37 +6,71 @@
|
||||
/// <reference path="github-electron.native-image.d.ts" />
|
||||
|
||||
declare namespace Electron {
|
||||
|
||||
/**
|
||||
* The clipboard module provides methods to perform copy and paste operations.
|
||||
*/
|
||||
interface Clipboard {
|
||||
/**
|
||||
* @returns The contents of the clipboard as plain text.
|
||||
*/
|
||||
readText(type?: string): string;
|
||||
readText(type?: ClipboardType): string;
|
||||
/**
|
||||
* Writes the text into the clipboard as plain text.
|
||||
*/
|
||||
writeText(text: string, type?: string): void;
|
||||
writeText(text: string, type?: ClipboardType): void;
|
||||
/**
|
||||
* @returns The contents of the clipboard as markup.
|
||||
*/
|
||||
readHtml(type?: ClipboardType): string;
|
||||
/**
|
||||
* Writes markup to the clipboard.
|
||||
*/
|
||||
writeHtml(markup: string, type?: ClipboardType): void;
|
||||
/**
|
||||
* @returns The contents of the clipboard as a NativeImage.
|
||||
*/
|
||||
readImage(type?: string): NativeImage;
|
||||
readImage(type?: ClipboardType): NativeImage;
|
||||
/**
|
||||
* Writes the image into the clipboard.
|
||||
*/
|
||||
writeImage(image: NativeImage, type?: string): void;
|
||||
writeImage(image: NativeImage, type?: ClipboardType): void;
|
||||
/**
|
||||
* @returns The contents of the clipboard as RTF.
|
||||
*/
|
||||
readRtf(type?: ClipboardType): string;
|
||||
/**
|
||||
* Writes the text into the clipboard in RTF.
|
||||
*/
|
||||
writeRtf(text: string, type?: ClipboardType): void;
|
||||
/**
|
||||
* Clears everything in clipboard.
|
||||
*/
|
||||
clear(type?: string): void;
|
||||
clear(type?: ClipboardType): void;
|
||||
/**
|
||||
* @returns Array available formats for the clipboard type.
|
||||
*/
|
||||
availableFormats(type?: ClipboardType): string[];
|
||||
/**
|
||||
* Returns whether the clipboard supports the format of specified data.
|
||||
* Note: This API is experimental and could be removed in future.
|
||||
* @returns Whether the clipboard has data in the specified format.
|
||||
*/
|
||||
has(format: string, type?: string): boolean;
|
||||
has(format: string, type?: ClipboardType): boolean;
|
||||
/**
|
||||
* Reads the data in the clipboard of the specified format.
|
||||
* Note: This API is experimental and could be removed in future.
|
||||
*/
|
||||
read(format: string, type?: string): any;
|
||||
read(format: string, type?: ClipboardType): any;
|
||||
/**
|
||||
* Writes data to the clipboard.
|
||||
*/
|
||||
write(data: {
|
||||
text?: string;
|
||||
rtf?: string;
|
||||
html?: string;
|
||||
image?: NativeImage;
|
||||
}, type?: ClipboardType): void;
|
||||
}
|
||||
|
||||
type ClipboardType = '' | 'selection';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user