- From: Chong Zhang <notifications@github.com>
- Date: Wed, 17 Aug 2016 14:43:12 -0700
- To: w3c/editing <editing@noreply.github.com>
- Message-ID: <w3c/editing/issues/144/240558462@github.com>
After more thinking, I guess we are making `'beforeinput'` too complex to include Clipboard. If we consider Clipboard part of DOM we should also add `'copy'`, otherwise `'beforeinput'` shouldn't care about Clipboard. Here is what I propose: 1. `'beforeinput'` doesn't care about Clipboard 2. Rename `InputType::cut` to `InputType::deleteByCut`, so it becomes part of the `delete` series, and the default action is delete selection 3. Rename `InputType::paste` to `InputType::insertFromPaste` or similar 4. Event order for `cut`: * Default action: `Clipboard::cut`->'ClipboardUpdate'->`beforeinput::deleteByCut`->'DomUpdate'->`input::deleteByCut` * Prevent default on `Clipboard::cut`: `Clipboard::cut`->'JS handles DOM update'->'Pass custom data'->'ClipboardUpdate' 5. Similar event order for `paste` Use Cases: 1. If JS really want to prevent Clipboard update, they should just disable `cut` * It's weird to allow deleting text but not writing anything to Clipboard 2. If JS wants to write custom data to Clipboard, they should use `Clipboard API` 3. If JS wants to do custom deletion but doesn't care about `Clipboard`, they should use `'beforeinput'` ```javascript document.addEventListener('beforeinput', e => { if (e.inputType.indexOf('delete') == 0) { const ranges = e.getTargetRanges() || getSelection(); strikeThrough(ranges); e.preventDefault(); } }) ``` Note that 'use case 3' is hard to do with `Clipboard API` as you have to manage Clipboard if you call `preventDefault()`. I'm not sure but does it look useful? -- 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-240558462
Received on Wednesday, 17 August 2016 21:43:42 UTC