Fix(view): Resolve Safari IME style pollution and table truncation #188
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR addresses critical compatibility issues with Safari IME (Input Method Editor), specifically resolving "style pollution" (unwanted styles/tags) and "content truncation" in complex nodes like tables.
1. Style Pollution Fix (Garbage Cleanup)
<font>tags or adds inlinestyleattributes (e.g.,color: ...,font-size: ...) to elements during composition. This often persists after composition ends, corrupting the document model.DOMObservernow detects and records specific "pollution" mutations (FONTtag insertions,styleattribute changes) into asafariDirtyNodeslist during composition (while still effectively ignoring them for general parsing transactions).compositionend,InputStateconsumes this list to surgically remove the recorded styles/tags and triggersmarkDirtyon the affected nodes.2. Table Content Truncation Fix (Structural Guard)
<br>,<div>,<p>) during composition updates. ProseMirror often interprets this as a structural split (e.g., ending the cell), causing subsequent text to be moved outside the table, appearing as data loss.DOMChangeto detect and abort these invalid structural insertions (DIV/P/BR) specifically during Safari composition. This prevents the parser from breaking the table structure.3. Composition Start Safety
compositionstartlogic to prioritize the physical DOM caret position over abstract ProseMirror selections (likeCellSelection).CellSelectionis active, ProseMirror considers the whole cell selected. If composition starts, standard logic might overwrite (delete) the cell. Using the DOM caret ensures text is inserted inside the cell as intended.Videos
before:
https://github.com/user-attachments/assets/66c72429-3ce8-4d89-b373-ac83af2225f2
https://github.com/user-attachments/assets/6ea5f0c6-de6c-4211-9271-c30e2255d096
after:
https://github.com/user-attachments/assets/ad1d0959-1107-4a1a-9658-483627c362ff
https://github.com/user-attachments/assets/fd53ab3c-050f-4c16-9ab0-20cbe3358d37
I was able to reproduce this issue in table cells. However, I was not able to ever see
<font>tags being created. Can you provide detailed reproduction instructions for a situation where that happens?Similarly, I haven't been able to reproduce the issue in headings, as described in the TipTap bug report. Can you reproduce that in plain ProseMirror?
Lastly, was any of this code generated with the help of a language model (AI)?
I'm going to guess that yes, this PR was generated with a language model. That kind of 'contribution' is not welcome to this project.
If you can provide me information about the header problem (assuming the connection with the table issue wasn't a hallucination), I'd be interested in looking at that. For now, I've pushed a patch
1773eacthat tries to work around the table problem.Pull request closed