ProseMirror / prosemirror

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

Bug: Issues with Japanese - Kana keyboard on iOS (Shadow DOM only) #1455

Open gwidonw opened 3 months ago

gwidonw commented 3 months ago

Hi, I am struggling to fix a problem with Japanese-Kana keyboard input on iOS devices (Safari, Chrome) that only appears when ProseMirror is created in shadow DOM. It seems to be related to prosemirror-view and the safariShadowSelectionRange function, and removing the code below seems to fix it, but I'm not sure (and don't have enough context) what else might be broken without that code 👇.

  // Since such a range doesn't distinguish between anchor and head,
  // use a heuristic that flips it around if its end matches the
  // current anchor.
  if (
    isEquivalentPosition(
      currentAnchor.node,
      currentAnchor.offset,
      focusNode,
      focusOffset
    )
  )
    [anchorNode, anchorOffset, focusNode, focusOffset] = [
      focusNode,
      focusOffset,
      anchorNode,
      anchorOffset,
    ];

Video https://github.com/ProseMirror/prosemirror/assets/8656036/2e4e12b9-1c45-4540-8b13-5699e2888546

Steps to reproduce

  1. Add Japanese - Kana keyboard on your iOS device
  2. Open demo page
  3. Change your keyboard to Japanese and try to enter some characters in all 3 editors

Result For ProseMirror in Shadow DOM, after typing any character, all characters are highlighted. User cannot enter more than one word as words are replaced

Expected result Should behave exactly the same as in editor that was created in Light DOM

Affected devices & browsers

Demo: Codepan - editor Codepan - preview