Bug 229597

Summary: Content loss when copying or pasting lists with an empty first list item
Product: WebKit Reporter: James Toohey <james>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: megan_gardner, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: Mac (Intel)   
OS: macOS 11   
Attachments:
Description Flags
A simple HTML file to replicate the bug none

Description James Toohey 2021-08-26 17:59:16 PDT
Created attachment 436596 [details]
A simple HTML file to replicate the bug

Hi team,

We discovered some cases where copying or pasting content in Safari 14 would cause content loss.

Context: Google Docs uses a `b` element to wrap their content with the document id when copying content e.g. `<b id="docs-internal-guid-[uuid goes here]">`. When creating a Google Doc with an empty line or empty list item as the first element, Safari converts this element into a style and strips other elements.

I have attached a very simple HTML reproduction case with the following example:

Input (clipboard content):
<b data-important-attr="xyz">
  <ul>
    <li></li>
    <li>text</li>
  </ul>
</b>

Output (result from paste):
<br>
<div>
  <span style="font-weight: bold;">text</span>
</div>

Adding any content into the first list item results in the expected output:

Input (clipboard content):
<b data-important-attr="xyz">
  <ul>
    <li>text</li>
    <li>text</li>
  </ul>
</b>

Output (result from paste):
<b data-important-attr="xyz">
  <ul>
    <li>text</li>
    <li>text</li>
  </ul>
</b>

It is also worth noting that this occurs even without the wrapping `b` element:

Input (clipboard content):
<ul>
  <li></li>
  <li>text</li>
</ul>

Output (result from paste):
<br>
<div>text</div>
Comment 1 Radar WebKit Bug Importer 2021-09-02 18:01:01 PDT
<rdar://problem/82701564>