|
| 1 | +# clipboard |
| 2 | + |
| 3 | +`clipboard`モジュールは、コピーとペースト操作を実行するメソッドを提供します。次の例は、クリップボードに文字列を書き込む方法を示しています: |
| 4 | + |
| 5 | +```javascript |
| 6 | +const clipboard = require('electron').clipboard; |
| 7 | +clipboard.writeText('Example String'); |
| 8 | +``` |
| 9 | + |
| 10 | +X Windowsシステム上では、セレクションクリップボードがあります。それを操作するために、それぞれのメソッドで、`selection`を通す必要があります。 |
| 11 | + |
| 12 | +```javascript |
| 13 | +clipboard.writeText('Example String', 'selection'); |
| 14 | +console.log(clipboard.readText('selection')); |
| 15 | +``` |
| 16 | + |
| 17 | +## メソッド |
| 18 | + |
| 19 | +`clipboard`モジュールには、次のメソッドがあります: |
| 20 | + |
| 21 | +**Note:** 実験的APIには、そのようにマークしてあり、将来的には削除される可能性があります。 |
| 22 | + |
| 23 | +### `clipboard.readText([type])` |
| 24 | + |
| 25 | +* `type` String (optional) |
| 26 | + |
| 27 | +プレーンテキストとしてクリップボードの内容を返します。 |
| 28 | + |
| 29 | +### `clipboard.writeText(text[, type])` |
| 30 | + |
| 31 | +* `text` String |
| 32 | +* `type` String (optional) |
| 33 | + |
| 34 | +プレーンテキストとしてクリップボードに`text`を書き込みます。 |
| 35 | + |
| 36 | +### `clipboard.readHtml([type])` |
| 37 | + |
| 38 | +* `type` String (optional) |
| 39 | + |
| 40 | +HTMLマークアップとして、クリップボードの内容を返します。 |
| 41 | + |
| 42 | +### `clipboard.writeHtml(markup[, type])` |
| 43 | + |
| 44 | +* `markup` String |
| 45 | +* `type` String (optional) |
| 46 | + |
| 47 | +クリップボードにHTMLマークアップとして書き込みます。 |
| 48 | + |
| 49 | +### `clipboard.readImage([type])` |
| 50 | + |
| 51 | +* `type` String (optional) |
| 52 | + |
| 53 | +[NativeImage](native-image.md)としてクリップボードの内容を返します。 |
| 54 | + |
| 55 | +### `clipboard.writeImage(image[, type])` |
| 56 | + |
| 57 | +* `image` [NativeImage](native-image.md) |
| 58 | +* `type` String (optional) |
| 59 | + |
| 60 | +`image` としてクリップボードに書き込みます。 |
| 61 | + |
| 62 | +### `clipboard.clear([type])` |
| 63 | + |
| 64 | +* `type` String (optional) |
| 65 | + |
| 66 | +クリップボードの内容をクリアします。 |
| 67 | + |
| 68 | +### `clipboard.availableFormats([type])` |
| 69 | + |
| 70 | +* `type` String (optional) |
| 71 | + |
| 72 | +`type`のクリップボードがサポートしているフォーマット配列を返します。 |
| 73 | + |
| 74 | +### `clipboard.has(data[, type])` _実験_ |
| 75 | + |
| 76 | +* `data` String |
| 77 | +* `type` String (optional) |
| 78 | + |
| 79 | +`data`で指定したフォーマットをクリップボードがサポートしているかどうかを返します。 |
| 80 | + |
| 81 | +```javascript |
| 82 | +console.log(clipboard.has('<p>selection</p>')); |
| 83 | +``` |
| 84 | + |
| 85 | +### `clipboard.read(data[, type])` _実験_ |
| 86 | + |
| 87 | +* `data` String |
| 88 | +* `type` String (optional) |
| 89 | + |
| 90 | +クリップボードから`data`を読み込みます。 |
| 91 | + |
| 92 | +### `clipboard.write(data[, type])` |
| 93 | + |
| 94 | +* `data` Object |
| 95 | + * `text` String |
| 96 | + * `html` String |
| 97 | + * `image` [NativeImage](native-image.md) |
| 98 | +* `type` String (optional) |
| 99 | + |
| 100 | +```javascript |
| 101 | +clipboard.write({text: 'test', html: "<b>test</b>"}); |
| 102 | +``` |
| 103 | +クリップボードに`data`を書き込みます。 |
0 commit comments