[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kafka
Subject:    Re: text plugin
From:       "Stephan Heigl" <stephan () eisscholle ! de>
Date:       2001-03-26 18:19:20
[Download RAW message or body]

> On Monday 26 March 2001 19:25, Stephan Heigl wrote:
> > > On Monday 26 March 2001 17:23, Stephan Heigl wrote:
> > > So let me explain how i understood it:
> > > 1. find the node that contains both selectionStartNode and
> >
> > selectionEndNode
> >
> > > 2. for start and end node: if offset != 0 and offset != offsetLength,
we
> > > recurse through the DOM tree downwards to the child, and in every
> >
> > recursion
> >
> > > level, we reparent the nodes on the right of the next one that we'll
> >
> > recurse
> >
> > > into inside a new DOM subtree.
> > > 3. we insert the 0-2 subtrees created that way to the topNode
> > > 4. we remove the original but stripped subtree to insert it in its new
> > > position
> > > 5. if the new position is inside a text node, we split up that text
node
> sorry, i was thinking about moving again.
> (You see, moving selection and applying style elements to a selection is
> pretty much the same.)
> 5. we do a insertItemRecursive(DOM::SubTree &, DOM::ELEMENTID) (will
explain
> that below)
>
> > > 6. we insert the subtree in its new position
> > >
> > > did you mean it that way?
> > > If not, i'd suggest we switch to german for further discussion of this
> >
> > thread.
> >
> > > So basically, you replicate all elements that lead from the topnode to
> > > the selection's (start,end). This can lead to illegal html. Imagine
your
> > > selection starts inside a <td> and ends outside the corresponding
table.
> > >
> > > Is that what we want?
> >
> > ok, you won. i haven't thought about tables.
>
> Well, i currently do, and i think this is solvable with a recursive
algorithm.
> you simply need to check whether <I>, <B> or <U> is allowed as a parent
for
> your subtree and if so, do the reparenting, else make the same for all
child
> nodes.
> After this, you can simply collapse adjactent <I>'s, <B>'s and <U>'s
>
> But i will neither be able to do this now nor in 5 minutes. I think it'll
> become rather complicated.

Well, i dont know excatly what you mean since myself, babelfish and Oxford
Avanced Learner's Dict don't know the word "adjactent" ;-)
but after drawing lots of DOM Trees on papers i noticed that my example was
wrong...since i think #text nodes cannot have children...
but anyway...here's my next try:

1. get the start node
2. create a new formatting node NEXT to the starting node (same parent) e.g.
<B>
3. put the 2nd half of the start node in a new textnode inside the node in
(2.)
4. for the nodes inside the selection, create the formatting node in their
parent nodes and just reparent them to the created formatting node.
5. do the same thing as with starting node..just the otherway round.

example

|-Table
|    |_ TR
|         |_ TD
|         |     |_ bla [ bla blah text
|         |_ TD
|              |_ bla blah blah 2
|-B
|  |_ finish ] text

[] = selection

now it would look like this

|-Table
|    |_ TR
|         |_ TD
|         |     |_ bla
|         |     |_U
|         |         |_ bla blah text
|         |_ TD
|              |_ U
|                   |_ bla blah blah 2
|-B
|  |_U
|  |   |_ finish
|  |_ text

so i just get the parent of the textnodes, add a <U>,<U>,<WHATEVER>...and
reparent the text to this node.
for start and end node i separate the text in 2 nodes i do the same as
above.

perhaps we should talk about that in irc....would be easier

regards

stephan

_______________________________________________
Kde-kafka mailing list
Kde-kafka@master.kde.org
http://master.kde.org/mailman/listinfo/kde-kafka

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic