Re: [Clipboard API] Add a flag to indicate paste-as-text to beforepaste and paste events

>> We (Google) would like to propose to add a boolean flag indicating whether
>> the user intended to paste as plain text or rich text.
>
> Perhaps we can add event.clipboardData.intendedType ? I.e.
>
> if( event.clipboardData.intendedType=='text/plain' ){
>  // user used "paste as text" command
> }else{
>
> }

It would be better if the UA could negotiate the type. E.g.

onbeforepaste = function(event){
    event.clipboardData.typesAllowed = ['text/plain', 'text/html'];
}

The UA can then present a paste menu with the options to paste as
plain text or HTML. The UA can then choose to exclude any type that is
not "intended". The UA can also include all types if no intention was
made. If the user chooses plain text, only plain text is included.

onpaste = function(event){
    event.clipboardData.types; // ['text/plain']
}

The UA should also include clipboardData.types in the onbeforepaste
event to indicate what is available. To allow anything BUT text/plain
the web page could something like this:

onbeforepaste = function(event){
    event.clipboardData.typesAllowed =
event.clipboardData.types.filter((type) => type != 'text/plain');
}

Received on Friday, 24 August 2012 16:53:22 UTC