Clipboard API for copy&paste
I noticed browser do things differently when copy&pasting, which results in small unexpected behaviour e.g. in ep_font_size. I'm opening this on core because we can do something about it here. Test coverage would be a requirement probably.
When using ctrl+c on selected text, browsers put different markup into the clipboard. e.g. if you have 4 letters of a 60px font and copy 2 from the middle of it
Firefox: <meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="author-a-z78z0d5qjz81zz81zz77zqz70zvz86zz122zer font-size:60">FO</span>
Chrome: <meta http-equiv="content-type" content="text/html; charset=utf-8"><span style="color: rgb(72, 83, 101); font-family: Quicksand, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; font-size: 60px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(243, 226, 222); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">FO</span>
As you can see, Firefox copies the correct span attributes, so on paste everything is perfect while Chrome tries to derive the relevant styling, while ignoring span attributes. This results in loss of authorship info and styling. Chrome copies span attributes as soon as the whole span is selected (or maybe as soon as it's crossing span boundaries), ie when you have a whole line with font size 60 and double click the line to select every text on it, Chrome does the right thing.
Authorship might be a bad example, as we probably should attribute the whole text to the author that pasted it, instead of keeping the original authorship. Font-size might serve as a better example: We could iterate over pasted styles to find out which are relevant to us or we could fill the clipboard with the correct data. Imo the latter option is better.
I'm not sure if this is a Chrome-only issue or if there are more serious bugs than the edge case above.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hey @webzwo0i, I don't know if that helps but I realized if the paste is made on a part that has a span after it, everything works as expected on Chrome.
Note that when we have the blue text we have two <span>, one for the text on red and the other for the text on blue.
https://user-images.githubusercontent.com/4945372/125994726-8dbd1c73-e96c-41e4-a281-634f3a5c1bbc.mov