Bug 229597 - Content loss when copying or pasting lists with an empty first list item
Summary: Content loss when copying or pasting lists with an empty first list item
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: Safari 14
Hardware: Mac (Intel) macOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-08-26 17:59 PDT by James Toohey
Modified: 2021-09-02 18:01 PDT (History)
3 users (show)

See Also:


Attachments
A simple HTML file to replicate the bug (802 bytes, text/html)
2021-08-26 17:59 PDT, James Toohey
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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>