Adding support to write RTF to clipboard.

This commit is contained in:
Vjekoslav Ratkajec 2016-02-04 19:38:47 +01:00
Родитель a0792237a0
Коммит acd5d40ab0
2 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -60,6 +60,11 @@ void Write(const mate::Dictionary& data,
if (data.Get("text", &text))
writer.WriteText(text);
if (data.Get("rtf", &text)) {
std::string rtf = base::UTF16ToUTF8(text);
writer.WriteRTF(rtf);
}
if (data.Get("html", &html))
writer.WriteHTML(html, std::string());
@ -88,6 +93,11 @@ void WriteText(const base::string16& text, mate::Arguments* args) {
writer.WriteText(text);
}
void WriteRtf(const std::string& text, mate::Arguments* args) {
ui::ScopedClipboardWriter writer(GetClipboardType(args));
writer.WriteRTF(text);
}
base::string16 ReadHtml(mate::Arguments* args) {
base::string16 data;
base::string16 html;
@ -129,6 +139,7 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
dict.SetMethod("write", &Write);
dict.SetMethod("readText", &ReadText);
dict.SetMethod("writeText", &WriteText);
dict.SetMethod("writeRtf", &WriteRtf);
dict.SetMethod("readHtml", &ReadHtml);
dict.SetMethod("writeHtml", &WriteHtml);
dict.SetMethod("readImage", &ReadImage);

Просмотреть файл

@ -61,6 +61,12 @@ Returns the content in the clipboard as a [NativeImage](native-image.md).
Writes `image` to the clipboard.
### `clipboard.writeRtf(text)`
* `text` String
Writes the `text` into the clipboard in RTF.
### `clipboard.clear([type])`
* `type` String (optional)