I have a question on a javascript i need to loop through user selection(highlighted text) and change the text direction from trl or ltr . here what i did :
this._execCom("FormatBlock",'<div>');
var node = null;
if (this.area.contentWindow.getSelection) {
node = this.area.contentWindow.getSelection().anchorNode.parentNode;
}
else if (this.area.contentWindow.document.selection) {
var range = this.area.contentWindow.document.selection.createRange();
if (range) {
node = range.parentElement();
}
var walker=this.area.contentWindow.document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, null, false);
while (walker.nextNode())
{
x=walker.currentNode.tagName;
if( x == 'DIV')
walker.currentNode.style.direction="ltr";
}
this changes the direction for all divs even if they are within the highlighted text or not and i need the changes to be done on the user selection only .
can you help me please .
many thanks