lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Bug: Equation import to dom failing

Open marekves opened this issue 3 years ago • 2 comments

Hello,

I have a problem with equations not beeing parsed correctly from DOM once created. Creation works fine, but once it parse HTML into the editor it transforms the functions into text and they are lost on a new save.

Once created the equation is fine Katexcreated

Parsed the before created question results in equation loss and transform to text. Katexparsed

I tried fixing but no success.

marekves avatar Oct 06 '23 13:10 marekves

I randomly tried setting priority to 4 and now it works. Could anybody please explain what the reason for this behavior is? How can I prevent running into more issues like this in the future?

marekves avatar Oct 09 '23 11:10 marekves

This is fixed in the current codebase. The playground's EquationsExtension now registers a DOMImportExtension rule that matches <span>/<div> elements with a data-lexical-equation attribute, so the equation data round-trips correctly through HTML export/import.

The original issue was that EquationNode had no importDOM(), so its exported HTML fell through to the generic <span> handler and lost the equation data. The new rule-based import system resolves this without needing a priority workaround.

mayrang avatar Jul 13 '26 08:07 mayrang