Skip to content

Commit 7afe27e

Browse files
authored
contentsID -> contentsId (#4)
* contentsID -> contentsId * Fix CI - fill index.bs
1 parent e9ed040 commit 7afe27e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
This proposal is an early design sketch by ChromeOS team to describe the problem below and solicit feedback on the
22
proposed solution. It has not been approved to ship in Chrome.
33

4-
# Explainer: `navigator.clipboard.contentsID()`
4+
# Explainer: `navigator.clipboard.contentsId()`
55

66
## Authors:
77

@@ -44,7 +44,7 @@ so that:
4444
2. When a user copies something on the remote machine and switches away from the VDI app, they can paste the copied
4545
content locally.
4646

47-
Without `contentsID()`, there are two primary ways to achieve the first scenario:
47+
Without `contentsId()`, there are two primary ways to achieve the first scenario:
4848

4949
- Upon refocusing the VDI app, automatically send the content from the local clipboard to the remote machine.
5050
- Upon refocusing the VDI app, read the clipboard contents, compare them with the last known state, and send to the
@@ -66,7 +66,7 @@ and
6666
[Android](https://developer.android.com/reference/android/content/ClipboardManager.OnPrimaryClipChangedListener) and
6767
[iOS](https://developer.apple.com/documentation/uikit/uipasteboard/changecount)) offer efficient ways to track clipboard content changes
6868
without directly reading the data. This is often achieved through clipboard sequence numbers or change notifications.
69-
The `navigator.clipboard.contentsID()` API aims to leverage these capabilities. It allows websites to request a numeric
69+
The `navigator.clipboard.contentsId()` API aims to leverage these capabilities. It allows websites to request a numeric
7070
token (a 128-bit integer) representing the current clipboard state. If this token differs from a previously retrieved
7171
one, it indicates that the clipboard contents have changed between the two calls. Importantly, this operation has a
7272
constant time complexity (O(1)), independent of the clipboard's size. Therefore, even frequent checks (e.g., on window
@@ -88,14 +88,14 @@ refocus) remain efficient, even when dealing with large amounts of copied data.
8888

8989
One of the goals of this API is to enable cross-app synchronization of clipboard \- so this should be as close to the
9090
stability of the clipboard itself as possible. So, every site under the same browser process should get the same token
91-
from calling `contentsID()`.
91+
from calling `contentsId()`.
9292

9393
## How to use it?
9494

9595
Frankly, quite straightforwardly. Signature of the method will look somewhat like this:
9696

9797
```javascript
98-
Promise < BigInt > contentsID();
98+
Promise < BigInt > contentsId();
9999
```
100100

101101
So in the mentioned VDI case, the code could look somewhat like this:
@@ -106,7 +106,7 @@ var lastToken = null;
106106
// Handler called on every window refocus.
107107
// It checks if it's necessary to sync clipboard contents to remote.
108108
window.addEventListener("focus", () => {
109-
navigator.clipboard.contentsID().then((token) => {
109+
navigator.clipboard.contentsId().then((token) => {
110110
if (token !== lastToken) {
111111
// Clipboard contents have changed!
112112
// Send to remote machine
@@ -118,7 +118,7 @@ window.addEventListener("focus", () => {
118118
// Function that is called by the client app when user copies something on remote.
119119
async function onRemoteClipboardChanged(remoteClipboardItems) {
120120
await navigator.clipboard.write(remoteClipboardItems);
121-
lastToken = await navigator.clipboard.contentsID();
121+
lastToken = await navigator.clipboard.contentsId();
122122
}
123123
```
124124

@@ -136,7 +136,7 @@ ways:
136136
clipboard and updating the last-known token value.
137137

138138
Both however would require some synchronization of the handler and `onRemoteClipboardChanged` to prevent handlers
139-
getting between `write` and `contentsID`.
139+
getting between `write` and `contentsId`.
140140

141141
**Note:** In any case, this will be in some degree prone to inherent race conditions due to lack of clipboard atomic
142142
operations \- which will show themselves mostly in case of user switching apps very rapidly. This API exists in order to
@@ -165,7 +165,7 @@ and standardized, it operates differently. Instead of determining if a change ha
165165
it provides real-time notifications for every change, without detailed information about the cause. Therefore, if your
166166
app also writes to the clipboard, it can be challenging to determine whether you or another source caused the change
167167
(especially with multiple windows/tabs of the same app open), potentially leading to unnecessary data transfers or
168-
having to implement comparison anyway. In case of `contentsID()`, you can save the new token just after writing \- and
168+
having to implement comparison anyway. In case of `contentsId()`, you can save the new token just after writing \- and
169169
it will be irrelevant for all active tabs/windows irrelevant what caused the change, only that this change is already in
170170
sync with the remote and no action is needed.
171171

@@ -177,7 +177,7 @@ There are several ways in which the token could look like, including:
177177
2. Timestamp of the last change (or call that detected it)
178178
3. Hash of the clipboard contents
179179
4. Random 128-bit number without any specified scheme or significance \- other than “after something is written to the
180-
clipboard, `contentsID()` should yield a different value than it did before the write”
180+
clipboard, `contentsId()` should yield a different value than it did before the write”
181181

182182
Preferred approach is 4, for the following reasons:
183183

index.bs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Title: The TODO API
33
Shortname: todo
44
Level: None
55
Status: w3c/UD
6-
Repository: explainers-by-googlers/todo-your-repo-name
6+
Repository: explainers-by-googlers/clipboard-contents-id
77
URL: https://explainers-by-googlers.github.io/todo-your-repo-name
88
Editor: Luke Klimek, Google https://google.com, [email protected]
99
Abstract: An API for getting a unique ID of current clipboard contents.
@@ -20,7 +20,7 @@ Include Can I Use Panels: yes
2020
Introduction {#intro}
2121
=====================
2222

23-
For now, see the [explainer]([REPOSITORYURL]).
23+
For now, see the [explainer](https://github.com/explainers-by-googlers/clipboard-contents-id).
2424

2525
See [https://garykac.github.io/procspec/](https://garykac.github.io/procspec/),
2626
[https://dlaliberte.github.io/bikeshed-intro/index.html](https://dlaliberte.github.io/bikeshed-intro/index.html),

0 commit comments

Comments
 (0)