# clipboard
`clipboard` 模塊提供方法來供復制和粘貼操作 .
下面例子展示了如何將一個字符串寫道 clipboard 上:
```javascript
const clipboard = require('electron').clipboard;
clipboard.writeText('Example String');
```
在 X Window 系統上, 有一個可選的 clipboard. 你可以為每個方法使用 `selection` 來控制它:
```javascript
clipboard.writeText('Example String', 'selection');
console.log(clipboard.readText('selection'));
```
## 方法
`clipboard` 模塊有以下方法:
**注意:** 測試 APIs 已經標明,并且在將來會被刪除 .
### `clipboard.readText([type])`
* `type` String (可選)
以純文本形式從 clipboard 返回內容 .
### `clipboard.writeText(text[, type])`
* `text` String
* `type` String (可選)
以純文本形式向 clipboard 添加內容 .
### `clipboard.readHtml([type])`
* `type` String (可選)
返回 clipboard 中的標記內容.
### `clipboard.writeHtml(markup[, type])`
* `markup` String
* `type` String (可選)
向 clipboard 添加 `markup` 內容 .
### `clipboard.readImage([type])`
* `type` String (可選)
從 clipboard 中返回 [NativeImage](native-image.md) 內容.
### `clipboard.writeImage(image[, type])`
* `image` [NativeImage](native-image.md)
* `type` String (可選)
向 clipboard 中寫入 `image` .
### `clipboard.readRtf([type])`
* `type` String (可選)
從 clipboard 中返回 RTF 內容.
### `clipboard.writeRtf(text[, type])`
* `text` String
* `type` String (可選)
向 clipboard 中寫入 RTF 格式的 `text` .
### `clipboard.clear([type])`
* `type` String (可選)
清空 clipboard 內容.
### `clipboard.availableFormats([type])`
* `type` String (可選)
返回 clipboard 支持的格式數組 .
### `clipboard.has(data[, type])` _Experimental_
* `data` String
* `type` String (可選)
返回 clipboard 是否支持指定 `data` 的格式.
```javascript
console.log(clipboard.has('<p>selection</p>'));
```
### `clipboard.read(data[, type])` _Experimental_
* `data` String
* `type` String (可選)
讀取 clipboard 的 `data`.
### `clipboard.write(data[, type])`
* `data` Object
* `text` String
* `html` String
* `image` [NativeImage](native-image.md)
* `type` String (可選)
```javascript
clipboard.write({text: 'test', html: "<b>test</b>"});
```
向 clipboard 寫入 `data` .
- 介紹
- 常見問題
- Electron 常見問題
- 向導
- 支持平臺
- 分發應用
- 提交應用到 Mac App Store
- 打包應用
- 使用 Node 原生模塊
- 主進程調試
- 使用 Selenium 和 WebDriver
- 使用開發人員工具擴展
- 使用 Pepper Flash 插件
- 使用 Widevine CDM 插件
- 教程
- 快速入門
- 桌面環境集成
- 在線/離線事件探測
- API文檔
- 簡介
- 進程對象
- 支持的 Chrome 命令行開關
- 環境變量
- 自定義的 DOM 元素
- File 對象
- &lt;webview&gt; 標簽
- window.open 函數
- 在主進程內可用的模塊
- app
- autoUpdater
- BrowserWindow
- contentTracing
- dialog
- globalShortcut
- ipcMain
- Menu
- MenuItem
- powerMonitor
- powerSaveBlocker
- protocol
- session
- webContents
- Tray
- 在渲染進程(網頁)內可用的模塊
- desktopCapturer
- ipcRenderer
- remote
- webFrame
- 在兩種進程中都可用的模塊
- clipboard
- crashReporter
- nativeImage
- screen
- shell
- 開發
- 代碼規范
- 源碼目錄結構
- 與 NW.js(原 node-webkit)在技術上的差異
- 構建系統概覽
- 構建步驟(OS X)
- 構建步驟(Windows)
- 構建步驟(Linux)
- 在調試中使用 Symbol Server