slate icon indicating copy to clipboard operation
slate copied to clipboard

findEventRange in shadow-DOM: "Cannot resolve a Slate point from DOM point", in Chrome

Open kledk opened this issue 2 years ago • 1 comments

Description I have an editor in a shadow-dom root. When using onMouseDown and calling findEventRange with the associated event an "Cannot resolve a Slate point from DOM point" is thrown, when Chrome. I have tried in firefox, confirming that it works.

Recording Kapture 2022-09-01 at 09 17 16

Sandbox https://codesandbox.io/s/sweet-wilson-u19ved?file=/src/App.tsx:738-752

Steps To reproduce the behavior:

  1. Go to sandbox
  2. Click on the text in the editor
  3. See error

Expectation Not throwing when in shadow-dom.

Environment

  • Slate Version: 0.82.1
  • Operating System: osx
  • Browser: Chrome

Context I found that findEventRange, calls document.caretRangeFromPoint in chrome, but I suspect that it gives misleading results in chrome.

kledk avatar Sep 01 '22 07:09 kledk

https://crbug.com/388976#c34 Looks like caretRangeFromPoint doesn't work in ShadowDOM.

yume-chan avatar Sep 01 '22 14:09 yume-chan