ProseMirror / prosemirror

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

[Bug] nested spans font-sizes parsed into incorrect marks #1483

Open qlp-mathias opened 3 weeks ago

qlp-mathias commented 3 weeks ago

Note: I originally posted this as a Re-Mirror issue but was re-directed here.

I'm dealing with some HTML created by a legacy rich text editor. This editor sometimes seems to have produced some unnecessary - albeit valid - nesting, which is not getting parsed correctly.

Steps to reproduce

Given a Remirror instance with

<!-- Input -->
<p>
<span style="font-size: 18px;">
  Text in 18px
  <span style="font-size: 24px;">
    Text in 24px
    <span style="font-size: 18px;"><!-- this is sanitised, even though it's a valid new font-size -->
      Text in 18px
      <span style="font-size: 24px;"><!-- this is sanitised, but not noticeable in the end result because the parent 18px is sanitised -->
        Text in 24px
      </span>
    </span>
  </span>
</span>
</p>

This results in the following rendered HTML (Notice that the text in the red box should also have a font-size of 18px) Screenshot 2024-07-23 at 10 18 08

It also seems to be scoped to font-size. If I instead replace the font-size style with, say, font-weight in a similar fashion it renders as expected.

qlp-mathias commented 3 weeks ago

I just noticed that this might be a duplicate of https://github.com/ProseMirror/prosemirror/issues/907