views:

133

answers:

1

I want to be able to change text direction, per line, inside iframe's document.
Like in Gmail compose mail textbox.
(By the way how Gmail accomplish that?)

For now I define this:

iframe's outerHTML =
    "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'&gt;" +
    "<html xmlns='http://www.w3.org/1999/xhtml'&gt;" +
    "<head>" + meta +
    "<title>Design Editor Frame</title>" +
    "<style type='text/css'>" +
    "body {background-color:White;}*{cursor:text;}p {margin:0;}" +
    "</style>" +
    "</head>" +
    "<body></body>" +
    "</html>";

designMode ="on"

Update:

Maybe I do can something like this, intercept 'Enter' keypress in iframe, and then wrap the new line with 'p' tag.
And on p tag I can apply the dir.

A: 
getElementById("your_element").dir="rtl"

You're probably need something more complex, to handle every element even when you have no ID's, so I'd recommend you to use jQuery javascript library.

yoda
what should I use within jQuery?
markiz
yes, i know about dir="rtl", but as you've said it's per element and not per line...
markiz
that's what I ment about using jquery. you get to do the work faster and more reliable, as you can select a line inside an element and create a span to that contents line with that css property. That's how almost every rich text editors work.
yoda
@yoda, I am not so familiar with jQuery can you point me to some documentation accessing text elements within iframe?
markiz
http://docs.jquery.com/Main_Page -> documentationhttp://code.google.com/p/jwysiwyg/ -> example of WYSIWYG editor made with jquery, should be worth take a look.
yoda