Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify "8.1. The copy action" in regards to copying selected data #49

Open
danburzo opened this issue Aug 24, 2017 · 1 comment
Open

Comments

@danburzo
Copy link

danburzo commented Aug 24, 2017

I've initially logged it on w3c/editing#168 but was directed to the Selection API / Clipboard API repos — not sure what the interdependencies are, so I'm logging it here.

I think the Copy action needs some clarification on:

3.1. Copy the selected contents, if any, to the clipboard. Implementations should create alternate text/html and text/plain clipboard formats when content in a web page is selected.

In regards to how the selection translates to HTML content. Case in point, browsers treat a Selection whose Range is set to either a Node (via range.selectNode) or a Node's contents (via range.selectNodeContents) the same way:

  • Firefox will copy the Node's inner HTML to the clipboard
  • Chrome and Safari will copy the Node's outer HTML to the clipboard

I believe there needs to be a way for authors to specify if the Node as a whole should be included in the clipboard, or just its content.

@mbrodesser
Copy link

To achieve compatibility across browsers, it should additionally be specified how the selected contents are copied.

For instance, when selecting rows in a table, current browser behavior (Chrome, Firefox) when pasting them to the clipboard is to create a tab between the content of two adjacent cells.

Example: open the following in a browser, select all and copy-paste to a text editor:
data:text/html,<table><tr><td>x</td><td>y</td><tr/> <tr><td>a</td> <td>b</td></tr> </table>

However, if the selected elements have the display property block, Chrome and Firefox create line breaks between two adjacent cells.

Example: open the following in a browser, select all and copy-paste to a text editor:
data:text/html,<table><tr><td><p>x</td><td><p>y</td><tr/> <tr> <td><p>a</td> <td><p>b</td> </tr> </table>

Having such and potentially other related details specified would help achieving a reasonable and consistent behavior across browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants