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).
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.
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.
Yup. Looked into those and below is a function I was came up with.
function getSelectionElement(){ var editor = iged_getById('<%= WebHtmlEditor1.ClientID %>'); var ret = null; if(editor._ie) { if(editor._sel().type == "Control") ret = editor._range().item(0); else ret = editor._range().parentElement(); } else { ret = editor._elem.contentWindow.getSelection().parentElement(); } return ret; }
Thanks for the info.