restore clipboard.has api and fix docs
This commit is contained in:
parent
5584e3fd49
commit
4d56281972
3 changed files with 25 additions and 3 deletions
|
@ -45,6 +45,12 @@ std::vector<base::string16> AvailableFormats(ui::ClipboardType type) {
|
||||||
return format_types;
|
return format_types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Has(const std::string& format_string, ui::ClipboardType type) {
|
||||||
|
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
||||||
|
ui::Clipboard::FormatType format(ui::Clipboard::GetFormatType(format_string));
|
||||||
|
return clipboard->IsFormatAvailable(format, type);
|
||||||
|
}
|
||||||
|
|
||||||
std::string Read(const std::string& format_string,
|
std::string Read(const std::string& format_string,
|
||||||
ui::ClipboardType type) {
|
ui::ClipboardType type) {
|
||||||
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
||||||
|
@ -102,6 +108,7 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Context> context, void* priv) {
|
||||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("_availableFormats", &AvailableFormats);
|
dict.SetMethod("_availableFormats", &AvailableFormats);
|
||||||
|
dict.SetMethod("_has", &Has);
|
||||||
dict.SetMethod("_read", &Read);
|
dict.SetMethod("_read", &Read);
|
||||||
dict.SetMethod("_readText", &ReadText);
|
dict.SetMethod("_readText", &ReadText);
|
||||||
dict.SetMethod("_writeText", &WriteText);
|
dict.SetMethod("_writeText", &WriteText);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
binding = process.atomBinding 'clipboard'
|
binding = process.atomBinding 'clipboard'
|
||||||
module.exports =
|
module.exports =
|
||||||
availableFormats: (type='standard') -> binding._availableFormats type
|
availableFormats: (type='standard') -> binding._availableFormats type
|
||||||
|
has: (format, type='standard') -> binding._has format, type
|
||||||
read: (format, type='standard') -> binding._read format, type
|
read: (format, type='standard') -> binding._read format, type
|
||||||
readText: (type='standard') -> binding._readText type
|
readText: (type='standard') -> binding._readText type
|
||||||
writeText: (text, type='standard') -> binding._writeText text, type
|
writeText: (text, type='standard') -> binding._writeText text, type
|
||||||
|
|
|
@ -66,11 +66,25 @@ Clears everything in clipboard.
|
||||||
|
|
||||||
Returns an array of supported `format` for the clipboard `type`.
|
Returns an array of supported `format` for the clipboard `type`.
|
||||||
|
|
||||||
## clipboard.read(format[, type])
|
## clipboard.has(data[, type])
|
||||||
|
|
||||||
* `format` String
|
* `data` String
|
||||||
* `type` String
|
* `type` String
|
||||||
|
|
||||||
Reads the data in clipboard of the `format`.
|
Returns whether clipboard supports the format of specified `data`.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var clipboard = require('clipboard');
|
||||||
|
console.log(clipboard.has('<p>selection</p>'));
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** This API is experimental and could be removed in future.
|
||||||
|
|
||||||
|
## clipboard.read(data[, type])
|
||||||
|
|
||||||
|
* `data` String
|
||||||
|
* `type` String
|
||||||
|
|
||||||
|
Reads the `data` in clipboard.
|
||||||
|
|
||||||
**Note:** This API is experimental and could be removed in future.
|
**Note:** This API is experimental and could be removed in future.
|
||||||
|
|
Loading…
Reference in a new issue