Re: [Clipboard API] Copy to clipboard

2011-09-06 Thread Daniel Cheng
Why do you need to create an element? Just call execCommand('copy') and
setData('text/html', 'blah') in your copy handler.

Daniel

On Mon, Sep 5, 2011 at 03:57, João Eiras jo...@opera.com wrote:

 On Mon, 05 Sep 2011 12:47:28 +0200, Hallvord R. M. Steen 
 hallv...@opera.com wrote:

  On Mon, 05 Sep 2011 02:14:10 +0200, João Eiras joao.ei...@gmail.com
 wrote:

  Hi !

 The spec for setData [1] states that this method when calling from a
 cut/copy event sets new data on the clipboard. Unfortunately, this is
 insufficient to implement the typical copy to clipboard button


 It is indeed. However, you already have things like
 document.execCommand('copy') for that.


 So lets say I have one of features which let me copy to the clipboard a
 snippet of html to embed a video for instance, to paste somewhere.

 A script needs to create an element, put the contents inside, wrap a
 selection around it, call execCommand('copy'), remove the element and shift
 focus back to the button.

 Seems a bit overkill. Are you really sure it can't be made simpler ? The
 feature is there already, theoretically.




Re: [Clipboard API] Copy to clipboard

2011-09-06 Thread Ryosuke Niwa
Maybe execCommand('copy') isn't enabled outside editable region in some UAs?

- Ryosuke

On Tue, Sep 6, 2011 at 2:18 PM, Daniel Cheng dch...@chromium.org wrote:

 Why do you need to create an element? Just call execCommand('copy') and
 setData('text/html', 'blah') in your copy handler.

 Daniel

 On Mon, Sep 5, 2011 at 03:57, João Eiras jo...@opera.com wrote:

 On Mon, 05 Sep 2011 12:47:28 +0200, Hallvord R. M. Steen 
 hallv...@opera.com wrote:

  On Mon, 05 Sep 2011 02:14:10 +0200, João Eiras joao.ei...@gmail.com
 wrote:

  Hi !

 The spec for setData [1] states that this method when calling from a
 cut/copy event sets new data on the clipboard. Unfortunately, this is
 insufficient to implement the typical copy to clipboard button


 It is indeed. However, you already have things like
 document.execCommand('copy') for that.


 So lets say I have one of features which let me copy to the clipboard a
 snippet of html to embed a video for instance, to paste somewhere.

 A script needs to create an element, put the contents inside, wrap a
 selection around it, call execCommand('copy'), remove the element and shift
 focus back to the button.

 Seems a bit overkill. Are you really sure it can't be made simpler ? The
 feature is there already, theoretically.





Re: [Clipboard API] Copy to clipboard

2011-09-05 Thread Hallvord R. M. Steen
On Mon, 05 Sep 2011 02:14:10 +0200, João Eiras joao.ei...@gmail.com  
wrote:



Hi !

The spec for setData [1] states that this method when calling from a  
cut/copy event sets new data on the clipboard. Unfortunately, this is  
insufficient to implement the typical copy to clipboard button


It is indeed. However, you already have things like  
document.execCommand('copy') for that.


Perhaps the spec should somehow include a way for a webpage, or origin,  
to request the user more privileges accessing the clipboard ?


I don't think it is in scope for this spec beyond recommending that UAs  
take into account the privacy and security issues a clipboard API raises.  
As far as I know, UAs already have preferences and limitations that  
regulate access to the existing clipboard commands.


--
Hallvord R. M. Steen, Core Tester, Opera Software
http://www.opera.com http://my.opera.com/hallvors/



Re: [Clipboard API] Copy to clipboard

2011-09-05 Thread João Eiras
On Mon, 05 Sep 2011 12:47:28 +0200, Hallvord R. M. Steen  
hallv...@opera.com wrote:


On Mon, 05 Sep 2011 02:14:10 +0200, João Eiras joao.ei...@gmail.com  
wrote:



Hi !

The spec for setData [1] states that this method when calling from a  
cut/copy event sets new data on the clipboard. Unfortunately, this is  
insufficient to implement the typical copy to clipboard button


It is indeed. However, you already have things like  
document.execCommand('copy') for that.




So lets say I have one of features which let me copy to the clipboard a  
snippet of html to embed a video for instance, to paste somewhere.


A script needs to create an element, put the contents inside, wrap a  
selection around it, call execCommand('copy'), remove the element and  
shift focus back to the button.


Seems a bit overkill. Are you really sure it can't be made simpler ? The  
feature is there already, theoretically.




[Clipboard API] Copy to clipboard

2011-09-04 Thread João Eiras

Hi !

The spec for setData [1] states that this method when calling from a cut/copy 
event sets new data on the clipboard. Unfortunately, this is insufficient to 
implement the typical copy to clipboard button, or going even further, the 
clipboard toolbar with buttons for the 3 actions (copy, cut, paste) typically 
seen in text editors.

Perhaps the spec should somehow include a way for a webpage, or origin, to 
request the user more privileges accessing the clipboard ? But this could 
somehow be abused, therefore such solution should not give direct access to the 
system clipboard that easily.

[1] 
http://dev.w3.org/2006/webapi/clipops/clipops.html#widl-clipboardData-setData-boolean-DOMString-type-DOMString-data