Re: [w3c/editing] [beforeinput] PreventDefault() on InputType=cut differs from Clipboard API (#144)

> While I can see several solutions working, I think consistency should be important. Without consistency, this will be increasingly difficult to use.

Yes, but current `Clipboard API` has a weird default action, where it's like a switch to choose data source.

> ...The only thing is that in either case is the problem of then getting the changed content into the clipboard. If I recall correctly, the only way of getting something into the clipboard is by adding it to the DOM, then selecting it, then calling document.execCommand('copy') and removing it from the DOM again (unless one wants it to stay there). Is this still the case? That seems a little bit less than ideal.

I'm not sure if I understand correctly, but:

1. If JS wants to write back to the clipboard they can listen to `Clipboard API - copy and cut`.

    ```javascript
    document.addEventListener('copy', function(e){
        e.clipboardData.setData('text/plain', 'Hello, world!');
        e.clipboardData.setData('text/html', '<b>Hello, world!</b>');
        e.preventDefault(); // We want our data, not data from any selection, to be written to the clipboard
    });
    ```

2. Otherwise they can use `'beforeinput'` to cancel everything and implement it's own single-site clipboard.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/editing/issues/144#issuecomment-240248594

Received on Tuesday, 16 August 2016 21:42:34 UTC