Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
405
Is there a way to determine parent element of current selection/caret
posted

Is it possible to determine the element (eg. table, tr, td) which contains the current selection in the editor when for example a custom menu item is clicked?

Our ultimate goal for this is to add a custom attribute to the current or parent element containing the selection but to do that we'd need  way to know the element or if there is no element (just all text in the editor). I don't think we can use insertAtCaret for this (or i could be wrong). 

Parents
  • 24497
    posted

    Hi Ryan,

    There is no public features related to selection. The best you can do, is to look at implementations of ig_htmleditor_ie.js and ig_htmleditor_moz.js files which are used for IE and Mozilla.

    You may find global objects. Under IE that is iged_all._curRange, so, you may try

    iged_all._curRange.parentElement()

    Under Firefox, you may try iged_all._cur._sel(). You may debug (like firebug) to find out how to get element from that selection. Probably something like

    sel.getRangeAt(0).startContainer

    There is no support in case of misbehavior or any other problems related to usage of those internal features.

Reply Children
No Data