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

List:       kupu-dev
Subject:    Re: [kupu-dev] selections
From:       Tomáš_Hnilica <tomas.hnilica () webstep ! net>
Date:       2004-10-12 9:00:36
Message-ID: 416B9D34.3050902 () webstep ! net
[Download RAW message or body]

Hi,

I need the second way - break the tag I am adding.
I need to change font size of the selection. Using 
execCommand(fontsize,..) gives size atrribute, I need to use px, pt, 
etc.... But it is morte abstact - for enclosing selection with any tag.
Maybe I could use execCommand(fontsize,..), which puts tags to proper 
places and then go through all added tags (but how to know them?) and 
change them or go through all <font> tags in selection (how to get all 
nodes completely included in selection?)
It is not very clean, any better idea?

Many thanks,
Tomas



Guido Wesdorp napsal(a):

> Tomáš Hnilica wrote:
>
>> It is something like execCommand(formatblock), but this gives only 
>> p,h1,...h6 tags in IE (with mozilla it can be any tag) and formats 
>> whole block :(
>>
> What you want to do should be possible, but currently only in a 
> certain way. Say you have the following markup:
>
> <foo>some text<bar>some more text</bar>some other text</foo>
>
> and you select the following bit:
>
> more text</bar>some
>
> then just enclosing this with tags will obviously lead to broken XML. 
> To handle this, there are two things you can do (let's assume you want 
> to surround the text with a set of <baz> tags).
>
> Either you can break the offending tag in bits:
>
> <foo>some text<bar>some </bar><baz><bar>more text</bar>some</baz> 
> other text</foo>
>
> this is most useful if you want to place a block-level element. You 
> can also break the tag you're adding to ensure well-formedness:
>
> <foo>some text<bar>some <baz>more text</baz></bar><baz>some</baz> 
> other text</foo>
>
> this is more useful for making e.g. making words bold: you don't want 
> a table to be broken in bits when a user selects part of its contents 
> and part of the surrounding content and presses 'bold'.
>
> The Selection object provides only the first form, but if that's good 
> enough for your usecases, please check out silva/kupusilvatools.js, 
> not the prettiest code and it's a bit much, but the Selection code is 
> used quite extensively there (for instance, check out the Citation 
> tool). If you still have questions after looking at that, please let 
> me know.
>
> Cheers,
>
> Guido
>
>>    greetings,
>>    Tomas Hnilica
>>
>> _______________________________________________
>> kupu-dev mailing list
>> kupu-dev@codespeak.net
>> http://codespeak.net/mailman/listinfo/kupu-dev
>>
>


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

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