Hello, the caretRangeFromPoint API spec was recently changed: CSSOM View Module (csswg.org) <https://drafts.csswg.org/cssom-view/#ref-for-dom-document-caretpositionfrompoint>. The API now takes a caretpositionfrompointoptions <https://drafts.csswg.org/cssom-view/#dictdef-caretpositionfrompointoptions>argument which takes an array of shadow roots which can be pierced into by the API.
Chromium has implemented the API and is enabled by default. Can you give it a try and see if it can solve your problem? Thanks, Siye On Monday, September 16, 2024 at 8:39:39 AM UTC-7 anton wrote: > Is it possible to call caretPositionFromPoint() for shadowRoot? > понедельник, 19 октября 2015 г. в 09:13:48 UTC+5, Yoshifumi Inoue: > >> Thanks for using shadowDOM. >> >> To get caret position in shadow tree, you need to use >> ShadowRoot.caretPositionFromPoint(x, y) instead of >> Document.caretPositionFromPoint(x, y) >> http://w3c.github.io/webcomponents/spec/shadow/#the-shadowroot-interface >> >> However, current Blink doesn't implement caretPositionFromPoint() on >> Document and ShadowRoot. Note: caretRangeFromPoint() is replaced by >> caretPointFromPoint() in current CSSOM specification. >> >> Please start following bug in Blink issue tracker to raise priority of >> implementing caretPositionFromPoint() >> http://crbug.com/388976 >> >> Thanks! >> -yosi >> >> >> >> >> 2015年10月18日(日) 11:51 <nazar.mo...@gmail.com>: >> >>> I'm working on Shadow DOM support in TinyMCE (namely, make it working >>> under Shadow DOM). >>> It is quite big piece of software, but everything seems to be quite good >>> so far. >>> >>> The problem I've faced currently is with >>> `document.caretRangeFromPoint()` method called in `drop` event handler >>> after dragging text selection within `<p>` element. >>> When `div[contenteditable=true]` is under Shadow DOM this method returns >>> Range where all relevant properties (commonAncestorContainer, endContainer >>> and startContainer) contain direct parent of shadow's host element, while I >>> expect text node. >>> So, I'm getting: `html > body > form`. >>> While I was expecting: `html > body > form > x-editor::shadow > >>> div[contenteditable] > p > TEXT_NODE >>> TEXT_NODE is where content was dropped, so text from one `<p>` dragged >>> and dropped at the end of another. >>> >>> Is this an expected behavior and how to workaround that if so? >>> Chromium 45.0.2454.101. >>> >> -- You received this message because you are subscribed to the Google Groups "blink-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscr...@chromium.org. To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/a11e960a-5959-42d4-8963-226becfc4455n%40chromium.org.