Phenomenon
In late 2025 (affecting prosemirror-view prior to 1.41.5), a specific interaction with Safari 18’s improved but still buggy composition engine was identified. When composing Japanese/Korean text in a completely empty <td>, the Committed text “leaks” out to the parent container. This happens because WebKit’s selection mapping fails to find a stable anchor within the empty cell after the temporary composition nodes are removed.
Reproduction Steps
- Use ProseMirror-view < 1.41.5.
- Create a document with an empty table cell.
- Open in Safari 18.2+.
- Focus the cell and type using a CJK IME.
- Press Enter to confirm.
Observed Behavior
- DOM Leaking: The text appears outside the table at the document level.
- Inconsistent State: ProseMirror’s
EditorStatestill thinks the cursor is in the cell, or it may crash if the mutation happens in an unmanaged area.
Expected Behavior
The text should stay within the <td> boundaries.
Browser Comparison
- Safari 18.2: High reproduction rate.
- Chrome/Firefox: Correct behavior.
References & Solutions
Mitigation: The “Invisible Content” Hack
ProseMirror fixed this in v1.41.5 by ensuring that empty table cells always contain at least a <br> or a zero-width space during selection to anchor the WebKit engine.
/* ProseMirror-view internal-like fix */
function fixEmptyCell(dom) {
if (isSafari && dom.nodeName === 'TD' && !dom.firstChild) {
dom.appendChild(document.createElement('br'));
}
}