Hey all,

I'm playing around with contentEditable and I'm current working with
styling (bold, italic, etc...) of the current selection
(window.getSelection()). Now, I know I can do this via
document.execCommand (in certain browsers), but I'd like to implement
my own method. I can easily apply a style node (b, i, u, etc...) to
the selected text, but I also know that I need to be aware that the
style may already be applied to parts of the (or the entire)
selection. For instance, selecting part of a bold sentence, then
applying bold to that part will result in that part being plain, and
the original bold element will be broken up into 2 bold elements with
textnodes, and just a textnode in between them.

So, I'm wondering if there exists a pattern for tree traversal to
check for this type of thing. For those of you not familar with the
Selection object, you get a startContainer and endContainer for the
start and end node of the current selection, respectively. You also
get a commonAncestor. All of the elements are there, I just don't want
to re-invent the wheel.

Thanks!

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to