ProseMirror / prosemirror

The ProseMirror WYSIWYM editor
http://prosemirror.net/
MIT License
7.61k stars 336 forks source link

Incorrect marks when pasting HTML with nested list #1347

Closed john-edwardson closed 1 year ago

john-edwardson commented 1 year ago

We've encountered an issue when pasting in nested lists from Google Docs where nested list items have styles that conflict with parent items. For a minimal repro, consider this HTML:

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  </head>
  <body>
    <meta charset="utf-8" />
    <ul>
      <li style="font-style: italic">
        Italics
        <ul>
          <li style="font-style: normal; font-weight: 400">Normal</li>
          <li style="font-style: normal; font-weight: 700">Bold</li>
          <li style="font-style: italic; font-weight: 400">Italics</li>
        </ul>
      </li>
      <li style="font-weight: 700">
        Bold
        <ul>
          <li style="font-style: normal; font-weight: 400;">Normal</li>
          <li style="font-style: normal; font-weight: 700">Bold</li>
          <li style="font-style: italic; font-weight: 400">Italics</li>
        </ul>
      </li>
    </ul>
  </body>
</html>

When I open this as an HTML file in the browser it looks like this: image

When I paste this into prosemirror I get this: image

As you can see, the styles from the parent list item are taking precedence over the styles from the children. I would expect the child styles to take precedence, as it does when I view the HTML file in a browser

marijnh commented 1 year ago

Attached patches should help with this.