Hi Petr,

On Tuesday 20 October 2009 Petr Kobalíček wrote:
> Is there any mechanism how to turn text to bold manually? 
In sense of direct manipulating the DOM node: no and yes. No because the 
HtmlArea does not offer a direct API for this. And yes, because you can take 
the body element (with the "getContentBody" method) and work with a CSS 
selector like "qx.bom.Collection" against this body element and change the DOM 
elements manually.
But the drawback at this approach is that you *might* break the Undo/Redo 
mechanism at least in Firefox. This browser is really sensible when changes 
are made to an editable document which are not made via the "execCommand" 
method, because the Undo/Redo is working too with the "execCommand".
So if you do not need Undo/Redo you can manipulate the content / DOM with a 
CSS selector engine.

> Is this possible to just traverse selected dom elements and add <span> tags? 
The selection object is highly browser-dependent. Firefox e.g. does offer  
"anchorNode" and "focusNode" with the selection object ("getSelection" method 
of the HtmlArea). 
However IE does not work on a DOM node base. The only connection to the DOM is 
the "parentElement" method of the range object which can be retrieved by the 
"createRange" method of the selection object. The second approach for IE is to 
use the "htmlText" property of the range object, but this is given as string 
which need to be serialized to DOM nodes before.
So it's not that easy to implement this feature and the Htmlarea does still 
not support this.
 
> So my first question is, how to get html area selection and how to get
> position in starting and ending dom element? You can reply to the wiki
> and just provide the link. Simply, I'd like to be able to traverse
> selection and do some manipulation.
The selection is retrieved by the "getSelection" method.
The second part of your question is not that easy to solve because you are 
entering the browser hell gates here :)
Firefox/Opera/Webkit are able to provide you with both nodes (anchor and 
focus).
IE is tricky in this case since it does not work DOM oriented here (with one 
exception: "parentElement" method of the range object).
You can also retrieve the range ("getRange" method) and the focusNode in IE 
("getFocusNode" method) but no anchor node.

Hope this helps,
  Alex

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to