mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #28154 from 43081j/clipboard-api
add clipboard-api w3c draft
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
const clipboard = navigator.clipboard;
|
||||
|
||||
let text: string;
|
||||
|
||||
clipboard.writeText('foo');
|
||||
clipboard.readText().then((val) => {
|
||||
text = val;
|
||||
});
|
||||
|
||||
const transfer = new DataTransfer();
|
||||
transfer.setData('text/plain', 'foo');
|
||||
|
||||
clipboard.write(transfer);
|
||||
clipboard.read().then((tf) => {
|
||||
text = tf.getData('text/plain');
|
||||
});
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Type definitions for w3c Clipboard API 1.0
|
||||
// Project: https://w3c.github.io/clipboard-apis/
|
||||
// Definitions by: James Garbutt <https://github.com/43081j>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Clipboard extends EventTarget {
|
||||
read(): Promise<DataTransfer>;
|
||||
readText(): Promise<string>;
|
||||
write(data: DataTransfer): Promise<void>;
|
||||
writeText(data: string): Promise<void>;
|
||||
}
|
||||
|
||||
interface Navigator {
|
||||
readonly clipboard: Clipboard;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"dom-clipboard-api-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user