MicrosoftEdge / MSEdgeExplainers

Home for explainer documents originated by the Microsoft Edge team
Creative Commons Attribution 4.0 International
1.3k stars 206 forks source link

[Delayed Clipboard Rendering] How should dynamic content changes be handled? #612

Open sanketj opened 1 year ago

sanketj commented 1 year ago

With delayed clipboard rendering, serialization of the copied content is differed until it is actually needed. However, the content may change - ex. due to DOM mutations, style changes - after it is copied, but before it is pasted. How should copy serialization work when this happens?

Some thoughts: If we undefer (ie. generate the clipboard data) as soon as a conflicting content change happens, this would prevent information loss, but may negate any benefit that delayed clipboard rendering provides. If we continue to defer and perform a "live" serialization when requested, will the serialized content be useful to the user? Also, do we need a range object to keep track of the part of the page that was copied?

anaskim commented 1 year ago

Added this as an open question. We may need to add functionality to update callbacks. Otherwise, web authors will have to use delayed clipboard rendering on data that will still be relevant to the user regardless of when they perform copy and paste.

snianu commented 1 year ago

@anaskim I'm a little confused. The author has complete control over the content that is being copied, and they are also aware of all the DOM mutations, so I'm not sure if this will be an issue at all. The async API is exposed to web developers that enables them to read/write clipboard without the native clipboard copy/paste intervention. The content that the user has copied will be stored somewhere by the web authors, so even if the DOM changed after the copy operation, the user doesn't expect to paste things that they hadn't selected when they copied the content from the page.