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,
ui::ClipboardType type) {
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
v8::Local<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("_availableFormats", &AvailableFormats);
+ dict.SetMethod("_has", &Has);
dict.SetMethod("_read", &Read);
dict.SetMethod("_readText", &ReadText);
dict.SetMethod("_writeText", &WriteText);
binding = process.atomBinding 'clipboard'
module.exports =
availableFormats: (type='standard') -> binding._availableFormats type
+ has: (format, type='standard') -> binding._has format, type
read: (format, type='standard') -> binding._read format, type
readText: (type='standard') -> binding._readText type
writeText: (text, type='standard') -> binding._writeText text, 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
-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.