Comments (13)
Proposal: https://docs.google.com/document/d/1sMcajoYAQ_M_VOIn1RLokG1sVB7skjoeviqt9aZOcDk/edit
from clipboard-apis.
@garykac Applications that own the clipboard with delayed data usually warn on quit. For example, Adobe Illustrator shows this:
Keep Data
generates data for all formats and adds them to the clipboard so that they can outlive the application.
from clipboard-apis.
For maximum compatibility, it might be useful for the image to provide a number of different representations, including PNG, JPEG, TIFF, GIF, and so on.
This doesn't necessarily mitigate the desire to account for it, but note that Chrome is unlikely to support copying images without browser-side re-encoding for sanitization (that's one major motivation for the asynchronous API). So it wouldn't be beneficial to generate various image formats before passing to the API in that case.
from clipboard-apis.
data.items.add("expensive", function () {
// Called only when something tries to read data of the "expensive" type
return generateExpensiveData();
});
Presumably most OSes require pushing the data actively to the clipboard. Would it make sense to use a Promise here, since we are directly triggering the write with the API?
from clipboard-apis.
This doesn't necessarily mitigate the desire to account for it, but note that Chrome is unlikely to support copying images without browser-side re-encoding for sanitization (that's one major motivation for the asynchronous API). So it wouldn't be beneficial to generate various image formats before passing to the API in that case.
That's fine for our needs, at least. We need this for non-image data (e.g. PDF for interop with Adobe products).
Presumably most OSes require pushing the data actively to the clipboard. Would it make sense to use a Promise here, since we are directly triggering the write with the API?
All major desktop platforms (i.e. Windows, macOS, and Linux) have a way to add format(s) to the clipboard and provide the data only when requested.
A promise does not solve the problem we're trying to address. In our case, we are developing a design tool that ideally would interoperate with e.g. Adobe Illustrator, Sketch, Glyphs, etc. To maximize the number of interoperable applications, we need to be able to place arbitrary formats on the clipboard (e.g. com.adobe.pdf
, image/svg+xml
, etc.) without generating the data for all of those formats. If we were to do everything on copy, our app would appear frozen/unresponsive while it generates all that data. Generating a single format only on paste would be a much better user experience.
from clipboard-apis.
All major desktop platforms (i.e. Windows, macOS, and Linux) have a way to add format(s) to the clipboard and provide the data only when requested.
Ooh, cool, I did not know.
That makes me think of Chrome Remote Desktop, which could make use of a delayed clipboard the other way. Right now, I believe reads the clipboard every time you switch the app, and pushes that to the remote computer. If it had a clipboard listener whose handler could asynchronously query for formats it could also benefit from those OS mechanisms, right?
from clipboard-apis.
That makes me think of Chrome Remote Desktop, which could make use of a delayed clipboard the other way. Right now, I believe reads the clipboard every time you switch the app, and pushes that to the remote computer. If it had a clipboard listener whose handler could asynchronously query for formats it could also benefit from those OS mechanisms, right?
The remote Chrome instance would have to block whatever thread processes the clipboard data request until it receives the data from the local Chrome instance. It is probably doable, but network latency could be a problem.
from clipboard-apis.
@poiru :
All major desktop platforms (i.e. Windows, macOS, and Linux) have a way to add format(s) to the clipboard and provide the data only when requested.
Could you please clarify this?
Assuming I understood the scenario correctly, I am not aware of a way to tell the clipboard to go back and get the format needed from the origin on Windows.
from clipboard-apis.
Assuming I understood the scenario correctly, I am not aware of a way to tell the clipboard to go back and get the format needed from the origin on Windows.
I linked to this earlier. Let me know if that page is not helpful!
from clipboard-apis.
Thanks, taking a look.
I've also noticed in your code example, you were using APIs from the modern clipboard spec navigator.clipboard.write(data);
. Did you mean to post the issue there?
from clipboard-apis.
@gked : That was the incubation document. We've folded the Async Clipboard API info into the main clipboard spec, so this seems like the best place to track the issue.
@poiru : Do you know how that API works with multiple apps writing to the clipboard? E.g.:
- App1 writes delayed info into clipboard
- App2 reads general clipboard data
- App1 quits
- App2 tries to read the "delayed" data from the clipboard
From a quick glance, I couldn't convince myself that it was designed to work outside of a single app managing its own clipboard.
from clipboard-apis.
The image sanitization is actually not great for our design tool. Users need the metadata and original content, so I'd recommended an early-out off sanitization detection first. If the image doesn't need to be sanitized, then pass through the original. For example, animated PNG might be converted to a regular PNG by the sanitization.
from clipboard-apis.
I see that remote chrome is already mentioned here, but I'd like to add to that that there are many other remote desktop protocols (RDP, VNC, Spice, etc.) that could all benefit from not having to transfer the data whenever the clipboard changes.
The user will in most cases not even use the clipboard so there will be a lot of wasted bandwidth. Bandwidth that could have been used for transferring image updates instead.
It would be nice if this could be added before the async API is finalised.
(This also affects DragEvent and ClipboardEvent, although it's probably rare that their inefficiency is a problem)
from clipboard-apis.
Related Issues (20)
- Undefined behaviour when handling data promise resolved value HOT 2
- Why does the Clipboard interface extends EventTarget?
- Broken references in Clipboard API and events
- Web Platform tests using "clipboard-read" HOT 2
- Async Clipboard API take more time compared to DataTransfer API to read/write data in System Clipboard HOT 1
- Read Blob data for the supported formats on-demand during getType. HOT 11
- Start and End fragment tags in text/html format on Windows HOT 1
- Add method `match` (`clipboard.match(regex)`) to check clipboard for pattern matching before reading - as it is done in iOS HOT 1
- Optional data types description seems wrong HOT 1
- Feature detection of web custom format support HOT 1
- Parallelism and task sources HOT 2
- algorithms don't enforce focus requirement
- Aljbore HOT 1
- References to permissions
- Topic: ‘unsanitized’ option to allow developers to opt-out of UA-provided sanitization HOT 1
- Merge a PR only with explicit implementor consensus (followup) HOT 4
- read(formats) ambiguous
- RTF is not exposed when using navigator.clipboard.read()
- `supports` should take a dictionary instead of a DOMString as argument for readability HOT 2
- [Async Clipboard API] Use Stream APIs to provide data during write HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clipboard-apis.