In Code View, when a user selects/highlights some text and
executes my custom action i would like to get to the text's top
level element.
a simple example:
the text in code view looks like this to the user:
<html>
<body>
<p><font>my text</font></p>
</body>
</html>
In the above example i am trying to get to the <p> tag.
here is the code (in its simplest form for ease of use) that i am
using:
var dom = dw.getDocumentDOM();
var theSelection = dom.getSelectedNode();
if (theSelection.nodeType == Node.TEXT) {
dom.setSelectedNode(theSelection);
dom.source.selectParentTag(); --> this would be the
<font> tag
dom.source.selectParentTag(); --> this would be the
<p> tag
var test = dom.getSelectedNode();
alert(test.tagName); --> i would expect this to be the
<p> tag, but it always seems to be the <font> tag
}
when looking at the text in Code View, everything is selected
correctly all the way up to the <p> tag, but when i get the
selected node and alert its tag name, it still seems to be set at
the <font> element. my code doesnt seem to recognize that i
am at the <p> tag element.
any suggestions?