:memo: Thai: translated accessibility.md
[platform/framework/web/crosswalk-tizen.git] / docs-translations / th-TH / api / clipboard.md
1 # clipboard
2
3 > Perform copy and paste operations on the system clipboard.
4
5 Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)
6
7 The following example shows how to write a string to the clipboard:
8
9 ```javascript
10 const {clipboard} = require('electron')
11 clipboard.writeText('Example String')
12 ```
13
14 On X Window systems, there is also a selection clipboard. To manipulate it
15 you need to pass `selection` to each method:
16
17 ```javascript
18 const {clipboard} = require('electron')
19 clipboard.writeText('Example String', 'selection')
20 console.log(clipboard.readText('selection'))
21 ```
22
23 ## Methods
24
25 The `clipboard` module has the following methods:
26
27 **Note:** Experimental APIs are marked as such and could be removed in future.
28
29 ### `clipboard.readText([type])`
30
31 * `type` String (optional)
32
33 Returns `String` - The content in the clipboard as plain text.
34
35 ### `clipboard.writeText(text[, type])`
36
37 * `text` String
38 * `type` String (optional)
39
40 Writes the `text` into the clipboard as plain text.
41
42 ### `clipboard.readHTML([type])`
43
44 * `type` String (optional)
45
46 Returns `String` - The content in the clipboard as markup.
47
48 ### `clipboard.writeHTML(markup[, type])`
49
50 * `markup` String
51 * `type` String (optional)
52
53 Writes `markup` to the clipboard.
54
55 ### `clipboard.readImage([type])`
56
57 * `type` String (optional)
58
59 Returns [`NativeImage`](native-image.md) - The image content in the clipboard.
60
61 ### `clipboard.writeImage(image[, type])`
62
63 * `image` [NativeImage](native-image.md)
64 * `type` String (optional)
65
66 Writes `image` to the clipboard.
67
68 ### `clipboard.readRTF([type])`
69
70 * `type` String (optional)
71
72 Returns `String` - The content in the clipboard as RTF.
73
74 ### `clipboard.writeRTF(text[, type])`
75
76 * `text` String
77 * `type` String (optional)
78
79 Writes the `text` into the clipboard in RTF.
80
81 ### `clipboard.readBookmark()` _macOS_ _Windows_
82
83 Returns `Object`:
84
85 * `title` String
86 * `url` String
87
88 Returns an Object containing `title` and `url` keys representing the bookmark in
89 the clipboard. The `title` and `url` values will be empty strings when the
90 bookmark is unavailable.
91
92 ### `clipboard.writeBookmark(title, url[, type])` _macOS_ _Windows_
93
94 * `title` String
95 * `url` String
96 * `type` String (optional)
97
98 Writes the `title` and `url` into the clipboard as a bookmark.
99
100 **Note:** Most apps on Windows don't support pasting bookmarks into them so
101 you can use `clipboard.write` to write both a bookmark and fallback text to the
102 clipboard.
103
104 ```js
105 clipboard.write({
106   text: 'http://electron.atom.io',
107   bookmark: 'Electron Homepage'
108 })
109 ```
110
111 ### `clipboard.readFindText()` _macOS_
112
113 Returns `String` - The text on the find pasteboard. This method uses synchronous
114 IPC when called from the renderer process. The cached value is reread from the
115 find pasteboard whenever the application is activated.
116
117 ### `clipboard.writeFindText(text)` _macOS_
118
119 * `text` String
120
121 Writes the `text` into the find pasteboard as plain text. This method uses
122 synchronous IPC when called from the renderer process.
123
124 ### `clipboard.clear([type])`
125
126 * `type` String (optional)
127
128 Clears the clipboard content.
129
130 ### `clipboard.availableFormats([type])`
131
132 * `type` String (optional)
133
134 Returns `String[]` - An array of supported formats for the clipboard `type`.
135
136 ### `clipboard.has(data[, type])` _Experimental_
137
138 * `data` String
139 * `type` String (optional)
140
141 Returns `Boolean` - Whether the clipboard supports the format of specified `data`.
142
143 ```javascript
144 const {clipboard} = require('electron')
145 console.log(clipboard.has('<p>selection</p>'))
146 ```
147
148 ### `clipboard.read(data[, type])` _Experimental_
149
150 * `data` String
151 * `type` String (optional)
152
153 Returns `String` - Reads `data` from the clipboard.
154
155 ### `clipboard.write(data[, type])`
156
157 * `data` Object
158   * `text` String (optional)
159   * `html` String (optional)
160   * `image` [NativeImage](native-image.md) (optional)
161   * `rtf` String (optional)
162   * `bookmark` String (optional) - The title of the url at `text`.
163 * `type` String (optional)
164
165 ```javascript
166 const {clipboard} = require('electron')
167 clipboard.write({text: 'test', html: '<b>test</b>'})
168 ```
169 Writes `data` to the clipboard.