* 仕様書

[REFS[
- [28] [CITE@en[Clipboard API and events]] ([TIME[2016-08-19 00:30:44 +09:00]]) <https://w3c.github.io/clipboard-apis/>
]REFS]

* 命令

[32] 次の [CODE[execCommand]] [[命令]]があります。
[FIG(short list)[
- [CODE[cut]]
- [CODE[copy]]
- [CODE[paste]]
]FIG]

* 処理

[33] 次の[[動作]]があります。
[FIG(short list)[
- [[切り取り]]
- [[複製]]
- [[貼り付け]]
]FIG]

* 利用者インターフェイス

[14] 多くの [[Webブラウザー]]は、表示中の文書の選択範囲や[[画像]]の[[コピー]]機能を提供しています。

[15] 多くの [[Webブラウザー]] (や [[OS]]、[[ウィンドウマネージャー]]等) は表示中の文書中の[[テキストボックス]]における[[切り取り]]、[[コピー]]、[[貼り付け]]機能を提供しています。

[16] 多くの [[Webブラウザー]]は、表示中の文書中の[[リンク]]や[[画像]]の [[URL]]
の[[コピー]]機能を提供しています。

-*-*-

[29] 多くの [[Webブラウザー]]では、[[編集可能文脈]]で[[貼り付け]]の[[ショートカットキー]]
([[Windows]] では [KBD[Ctrl]] + [KBD[V]]) を押すと、[[クリップボード]]の内容をその位置に挿入します。
[[選択][選択 (Web)]]があれば、[[選択範囲]]がそれで置き換えられます。

* MIME 型


[52] 
[[Windows]]
の
[[Chrome]]
は
[CODE[navigator.clipboard.write]]
で
[CODE[text/plain]]
を書き込めます。
[CODE[text/csv]],
[CODE[text/html]],
[CODE[application/xml]],
[CODE[application/json]]
は未対応エラーになります。
[TIME[2020-10-23T02:52:32.000Z]]

* 歴史

[31] [CITE[最速インターフェース研究会 :: Firefoxでテキストをクリップボードにコピーする方法]] <http://la.ma.la/blog/diary_200601100445.htm>
([[名無しさん]] [WEAK[2006-01-10 01:36:54 +00:00]])

[30] [CITE[Clipboard Operations for the Web 1.0: Copy, Paste, Drag and Drop.]] <http://www.w3.org/TR/2006/WD-clipboard-apis-20061115/>
([[名無しさん]] [WEAK[2006-11-16 12:23:16 +00:00]])


[1] [CITE[Clipboard API and events]]
( ([TIME[2010-12-24 09:03:51 +09:00]] 版))
<http://lists.w3.org/Archives/Public/public-webapps/2010OctDec/att-1067/cbapispec.html>

[2] [CITE@en[Clipboard API and events]]
( ([TIME[2012-02-23 07:06:18 +09:00]] 版))
<http://www.w3.org/TR/2012/WD-clipboard-apis-20120223/>

[3] [CITE@en[''''''[''''''clipboard'''''']'''''' Feature detect Clipboard API support?]]
([[James M. Greene]] 著, [TIME[2015-02-12 03:21:19 +09:00]] 版)
<https://lists.w3.org/Archives/Public/public-webapps/2015JanMar/0592.html>

[4] [CITE@en[Clipboard API and events]]
( ([TIME[2011-04-12 23:16:05 +09:00]] 版))
<http://www.w3.org/TR/2011/WD-clipboard-apis-20110412/>

[5] [CITE@en[Clipboard API and events]]
( ([TIME[2013-04-11 22:10:26 +09:00]] 版))
<http://www.w3.org/TR/2013/WD-clipboard-apis-20130411/>

[6] [CITE@en[Clipboard API and events]]
( ([TIME[2014-03-11 00:24:11 +09:00]] 版))
<http://www.w3.org/TR/2014/WD-clipboard-apis-20140313/>

[7] [CITE@en[Clipboard API and events]]
( ([TIME[2014-09-18 18:22:06 +09:00]] 版))
<http://www.w3.org/TR/2014/WD-clipboard-apis-20140918/>

[8] [CITE@en[Clipboard API and events]]
( ([TIME[2014-12-09 01:46:29 +09:00]] 版))
<http://www.w3.org/TR/2014/WD-clipboard-apis-20141209/>

[FIG(quote)[
[FIGCAPTION[
[9] [CITE[IRC logs: freenode / #whatwg / 20150415]]
([TIME[2015-04-16 11:32:54 +09:00]] 版)
<http://krijnhoetmer.nl/irc-logs/whatwg/20150415#l-163>
]FIGCAPTION]

> # '''['''05:17''']''' <MikeSmith> does anybody remember what's holding us up from adding "Copy to clipboard" support to the platform?
> # '''['''07:49''']''' <JakeA> MikeSmith: I think we just added it to Canary
> # '''['''08:07''']''' <MikeSmith> JakeA: ah cool
> # '''['''08:33''']''' <JakeA> MikeSmith: I believe it's document.execCommand('copy') from an interaction event
> # '''['''10:03''']''' <botie> darobin, at 2015-04-15 06:54 UTC, MikeSmith said: what's the current spec for document.execCommand('copy') etc
> # '''['''10:08''']''' <darobin> MikeSmith: last I checked you still needed a mix of https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html and http://dev.w3.org/2006/webapi/clipops/clipops.html

]FIG]


[10] [CITE@en[Clipboard API and events]]
([TIME[2015-04-09 18:30:01 +09:00]] 版)
<http://dev.w3.org/2006/webapi/clipops/clipops.html>

[FIG(quote)[
[FIGCAPTION[
[11] [CITE[Cut and Copy Commands]]
([TIME[2015-04-16 11:34:28 +09:00]] 版)
<http://updates.html5rocks.com/2015/04/cut-and-copy-commands>
]FIGCAPTION]

> IE10 and above added support for the ‘cut’ and ‘copy’ commands through the Document.execCommand() method. As of Chrome version 43, these commands are also supported in Chrome.

]FIG]


[12] [CITE@en[1151429 – Allow JS to copy text to the clipboard by triggering document.execCommand('copy') or document.execCommand('cut') in user-initiated thread]]
([TIME[2015-04-16 11:36:32 +09:00]] 版)
<https://bugzilla.mozilla.org/show_bug.cgi?id=1151429>

[13] [CITE@en[1012662 – implement click-to-copy and click-to-cut permissions (semi-trusted events)]]
([TIME[2015-04-16 11:36:53 +09:00]] 版)
<https://bugzilla.mozilla.org/show_bug.cgi?id=1012662>

[17] [CITE@en[Clipboard API and events]]
( ([TIME[2015-04-17 18:23:50 +09:00]] 版))
<http://www.w3.org/TR/2015/WD-clipboard-apis-20150421/>

[18] [CITE@en[''''''[''''''clipboard'''''']'''''' Dilemma: getData('text/html') and useful CF_HTML quirks]]
([[Hallvord Reiar Michaelsen Steen]] 著, [TIME[2015-04-23 17:13:25 +09:00]] 版)
<https://lists.w3.org/Archives/Public/public-webapps/2015AprJun/0228.html>

[19] [CITE[Intent to implement and ship: document.execCommand("cut"/"copy")]]
([TIME[2015-06-03 08:47:11 +09:00]] 版)
<https://lists.mozilla.org/pipermail/dev-platform/2015-June/010180.html>

[20] [CITE@en[Bug 146336 – Implement unprivileged execCommand("copy") and execCommand("cut")]]
([TIME[2015-09-09 11:09:55 +09:00]] 版)
<https://bugs.webkit.org/show_bug.cgi?id=146336>

[21] [CITE@en[1012662 – Allow document.execCommand("cut"/"copy") to be used within the context of user generated events]]
([TIME[2015-09-09 11:10:16 +09:00]] 版)
<https://bugzilla.mozilla.org/show_bug.cgi?id=1012662>

[22] [CITE[Issue 424968 - chromium - Cannot access to clipboard access via Javascript - An open-source project to help move the web forward. - Google Project Hosting]]
([TIME[2015-09-09 11:10:26 +09:00]] 版)
<https://code.google.com/p/chromium/issues/detail?id=424968>

[23] [CITE@en[860857 – Support custom mimetypes via clipboardData for clipboard events]]
([TIME[2016-02-07 11:32:55 +09:00]] 版)
<https://bugzilla.mozilla.org/show_bug.cgi?id=860857>

[24] [CITE@en[Clipboard API and events]]
([TIME[2016-03-12 03:40:41 +09:00]] 版)
<https://www.w3.org/TR/2016/WD-clipboard-apis-20160311/>

[25] [CITE@en[Clipboard API and events]]
([TIME[2016-04-04 05:58:25 +09:00]] 版)
<https://www.w3.org/TR/2016/WD-clipboard-apis-20160403/>

[26] [CITE@en[Re: '''['''clipboard''']''' Add RTF to the "mandatory data types" list?]]
( ([[Hallvord Reiar Michaelsen Steen]]著, [TIME[2016-06-14 02:36:06 +09:00]]))
<https://lists.w3.org/Archives/Public/public-webapps/2016AprJun/0129.html>

[27] [CITE@en[New editors for Clipboard API spec]]
([[Chaals McCathie Nevile]]著, [TIME[2016-07-31 09:16:17 +09:00]])
<https://lists.w3.org/Archives/Public/public-webapps/2016JulSep/0023.html>

[34] [CITE@en[Clipboard API and events]]
([TIME[2016-12-14 04:03:55 +09:00]])
<https://www.w3.org/TR/2016/WD-clipboard-apis-20161213/>

[35] [CITE@en[Bikeshed version of current Clipboard APIs spec]]
([[garykac]]著, [TIME[2016-12-20 11:38:19 +09:00]])
<https://github.com/w3c/clipboard-apis/commit/5c704c9d92252232a7f90fb7ed4dc1eb33b0d7f8>

[36] [CITE@en[Add initial draft of Async API read() and write().]]
([[garykac]]著, [TIME[2016-12-30 11:58:04 +09:00]])
<https://github.com/w3c/clipboard-apis/commit/3ffdbba8580e0096aa7d492d49e1309001d25162>

[37] [CITE@en[Add clipboard change event]]
([[garykac]]著, [TIME[2017-05-10 03:34:11 +09:00]])
<https://github.com/w3c/clipboard-apis/commit/bd06a15292cbfee8da5b62eb70854065e2a77152>

[38] [CITE@en[Fix #54: Add '''['''Exposed''']''' to interfaces]]
([[garykac]]著, [TIME[2017-09-16 02:35:32 +09:00]])
<https://github.com/w3c/clipboard-apis/commit/4aef1c5273afcb8e022c10f2e4469e971c9ec082>

[39] [CITE@en[Clipboard API and events]]
([TIME[2017-09-30 03:38:08 +09:00]])
<https://www.w3.org/TR/2017/WD-clipboard-apis-20170929/>

[40] [CITE@en[Update permissions to be clipboard-read and clipboard-write]]
([[garykac]]著, [TIME[2017-10-24 07:41:15 +09:00]])
<https://github.com/w3c/clipboard-apis/commit/aa1f8ac45ffc3ff9035fa64519c5c822ab28469c>

[41] [CITE@en[Update security section with examples]]
([[garykac]]著, [TIME[2018-01-04 09:00:40 +09:00]])
<https://github.com/w3c/clipboard-apis/commit/3539df25f362afb96340afc26712243339fc7891>

[42] [CITE@en[Copy explainer over from garykac/clipboard/clipboard.md]]
([[garykac]]著, [TIME[2018-01-24 04:50:16 +09:00]])
<https://github.com/w3c/clipboard-apis/commit/9315cca1d51cbb423112076cec11d82d5bebadb2>

[43] [CITE@en[Add section on Clipboard Permissions]]
([[garykac]]著, [TIME[2018-01-24 13:16:00 +09:00]])
<https://github.com/w3c/clipboard-apis/commit/7418000db08f777c98e171b65882607871b539df>

[44] [CITE@en[Unblocking Clipboard Access  |  Web  |  Google Developers]]
([TIME[2018-03-16 01:10:56 +09:00]])
<https://developers.google.com/web/updates/2018/03/clipboardapi>

[45] [CITE[Clipboard API Improvements | WebKit]]
([TIME[2018-03-23 02:11:33 +09:00]])
<https://webkit.org/blog/8170/clipboard-api-improvements/>

[46] [CITE[New WebKit Features in Safari 11.1 | WebKit]]
([TIME[2018-04-13 13:40:37 +09:00]])
<https://webkit.org/blog/8216/new-webkit-features-in-safari-11-1/>

[47] [CITE@en[New in Chrome 66  |  Web  |  Google Developers]]
([TIME[2018-04-17 23:13:24 +09:00]])
<https://developers.google.com/web/updates/2018/04/nic66?utm_source=feed&utm_medium=feed&utm_campaign>

[48] [CITE@en[Remove duplicated sentence in "pick target"-algorithm]]
([[hugoholgersson]]著, [TIME[2017-12-15 18:53:24 +09:00]])
<https://github.com/w3c/clipboard-apis/commit/1f8f6a3c09bbfa3613ea977a1746de4c7121bf03>

[49] [CITE@en[Emphasize visability in the "pick target"-algorithm by hugoholgersson · Pull Request #58 · w3c/clipboard-apis]]
([TIME[2018-05-08 21:30:21 +09:00]])
<https://github.com/w3c/clipboard-apis/pull/58>

[50] [CITE@en[Clarify how ClipboardEvents' targets are chosen]]
([[hugoholgersson]]著, [TIME[2017-12-15 18:53:24 +09:00]])
<https://github.com/w3c/clipboard-apis/commit/0f1e72e2b5c019b08174c79781c9929b660d57f6>

[51] [CITE@en[Fix algorithm for firing a clipboard event]]
([[garykac]]著, [TIME[2018-02-17 04:25:50 +09:00]])
<https://github.com/w3c/clipboard-apis/commit/11619a7e2a8537f8c60eb05f76b192cfa909b30a>