Bug 186224

Summary: Copying from inline flex behaves like block level elements.
Product: WebKit Reporter: Samuel Williams <samuel>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: megan_gardner, rniwa, samuel, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 11   
Hardware: Mac   
OS: macOS 10.13   

Description Samuel Williams 2018-06-01 21:41:55 PDT
When copying the text from

```
<div style="display: inline-flex; white-space: pre">
  <span>This </span>
  <span>is </span>
  <span>flex </span>
</div>
```

The data that would be pasted would contain multiple lines:

```
This 
is 
flex 
```

And yet that is not similar to how it is presented in the browser:

```
This is flex
```
Comment 1 Radar WebKit Bug Importer 2018-06-03 14:42:43 PDT
<rdar://problem/40758006>
Comment 2 Samuel Williams 2018-06-03 20:44:29 PDT
I would like to add, this isn't just specific to inline-flex. It's possible that other flex box layouts do strange things when copying/pasting to plain text. Basically, copying/pasting from flex boxes generates unexpected output.
Comment 3 Ryosuke Niwa 2018-06-04 10:08:55 PDT
We don't have any code to handle flex box for copy & paste so anything is possible. We probably need to do some work to support both flex box & grid layouts in our copy & paste logic somehow.
Comment 4 Samuel Williams 2018-06-05 22:24:53 PDT
I did work around the issue by using an `oncopy` event handler:

https://github.com/ioquatix/jquery-syntax/blob/3cf6353facbc807c94b53cdf48c372547b7ac089/source/jquery.syntax.core.js#L45-L66
Comment 5 Samuel Williams 2019-04-07 05:46:31 PDT
I am just reporting that this is still an issue. You can see a live example here:

https://www.codeotaku.com/journal/2018-06/improving-ruby-fibers/index

Try copying only the code, it will invoke the copy handler which copies it as plain text.

If you try to copy it including some of the preceding paragraph, it won't invoke the copy handler. If you paste the result into, say, TextEdit, you will get odd output.
Comment 6 Ryosuke Niwa 2019-04-11 21:24:35 PDT
Yes, this is an issue. We need to handle flexbox in our copy & paste code. We don't currently have the support for it.