[clipboard] document.execCommand and clipboard actions

Hi,
so I hit a bit of an issue: I've written some parts of the clipboard spec
with the assumption that it will be invoked from a
document.execCommand('copy'/'cut'/'paste') call (although 'paste' would
require some extra permission work which no UA but IE has attempted so far).

Meanwhile, the editing task force has gathered feedback on developing
editor features from implementors and drawn the conclusion that the current
"stuff" including contentEditable=true and document.execCommand() is
unsalvageable. So their aim is to deprecate and remove execCommand(). If it
were to be removed, I obviously can't expect it to be used for clipboard
actions. On the other hand, my expectation that I can build stuff on top of
execCommand() makes life more complicated for them when they aim to
deprecate it.. Some discussion ensues:

https://github.com/w3c/editing/issues/61
https://lists.w3.org/Archives/Public/public-editing-tf/2015Aug/0001.html

I'm not sure how to proceed. Now, "the old stuff isn't good enough, let's
have a clean slate and do new and shiny things" is an approach that hasn't
worked very well so far when writing specs for the web. This time might of
course be different. (Personally I doubt it though. I'm not even sure if
they developers who told them "the old stuff is something we don't want to
touch, let's forget about contentEditable=true" had given this enough
thought..)

It's also true that the current approach in the clipboard spec - especially
for writing stuff to the clipboard - is a bit hackish. Perhaps I (unlike
the Editing task force) have been *too* deferential to the existing
implementations, including stuff like onbefore* events that no browser so
far did a good job implementing. (Nope, not even IE although it was
invented there). I can see why Johannes Wilm suggests making a new API
instead..

If we came up with a completely new "write to clipboard" API - for example
something like

if(window.clipboard){
  var items = new DataTransferItems(); // ignore that we can't currently
construct this..
  items.add('text/plain', 'Hello world');
  items.add('text/html', '<p>Hello world</p>');
  items.imageFromElement('image/jpeg', document.images[0]);
  window.clipboard.write(items).then(function(){
    alert('Copied all parts to clipboard!');
  });
}

Would implementors want to support that?
- Hallvord

Received on Tuesday, 4 August 2015 21:32:26 UTC