Re: [clipboard events] Pasting scenarios and the shape of clipboardData.getData(‘text/html’) return value

> After working with developers inside and outside Microsoft, it seems there are
> several types of paste that make sense in various scenarios. For instance, 
> 1- if pasting into a rich document, it could be important to maintain source
> styling information. 
2- When pasting into a wiki from an external source, it might make more sense
> to maintain destination styling instead. 
> 3- When copying from a wiki and pasting back into that same wiki, it makes sense
> to maintain any special formatting on that text (inline styles) but otherwise to
> use the theme (style sheets). 

Good summary, thanks!

> One possibility would be to do something similar to Firefox, but also include a
> text/css clipboard item, which contains styles relevant to what is copied

This seems like an excellent idea! I'm not sure how hard it is to implement, but it might be doable without too much effort. Some examples to make sure we're in general agreement:

## Copy paragraph with class name and styling:

Document: 
<style>.foo{border: thin solid green}.bar{border: thin solid blue}</style>
<p class="foo">Hello world</p>

The text "Hello world" is selected and copied. Data types on the clipboard (as seen through the clipboard API on paste):

text/html: <p class="foo">Hello world</p>
text/css: .foo{border: thin solid green}

## Copy part of paragraph with class name and styling:
Same document, the word "Hello" is copied. Clipboard contents:

text/html: <p class="foo">Hello</p>
text/css: .foo{border: thin solid green}

## When some styles are overridden by more specific ones, all matching selectors' declarations will still be copied

Document: 
<style>.foo{border: thin solid green}#bar{border: thin solid blue}</style>
<p class="foo" id="bar">Hello world</p>

Copy "Hello world", clipboard:

text/html: <p class="foo" id="bar">Hello world</p>
text/css: .foo{border: thin solid green}#bar{border: thin solid blue}

## Inline style attributes are kept
Document: 
<style>.foo{border: thin solid green}#bar{border: thin solid blue}</style>
<p class="foo" id="bar" style="border: 5px solid red">Hello world</p>

Copy "Hello world", clipboard:

text/html: <p class="foo" id="bar" style="border: 5px solid red">Hello world</p>
text/css: .foo{border: thin solid green}#bar{border: thin solid blue}

How hard do you think this is to implement?
-Hallvord

Received on Monday, 31 March 2014 12:31:07 UTC