Re: Prevent linebreaks in inline elements
Christian Stocker <[email protected]> Fri, 19 Nov 2004 12:02:52 +0100
| Newsgroups | gmane.editors.bitflux.general |
|---|---|
| Message-ID | <[email protected]> |
Hi I hopefully fixed this issue. It's in the trunk/ tree and the bxe_1_0 branch. More details in my post to [email protected] : http://lists.bitflux.ch/pipermail/bx-editor-dev/2004-November/000385.html chregu On 17.11.2004 0:27 Uhr, Christian Stocker wrote: > Hi > > Thanks for your long reply. I have to take a deeper look into the issue. > I already have an idea, where this happens. > > Will reply more, when I'm through it. > > and yes, if you want to send patches, just send them. I'm always happy, > if someone else contributes code. This is not supposed to be a one man > show ;) > > chregu > On 16.11.2004 4:06 Uhr, Niklas Therning wrote: > >> Christian Stocker wrote: >> >>> Hi >>> >>> On 15.11.2004 1:28 Uhr, Niklas Therning wrote: >>> >>>> Hi, >>>> >>>> I'm new to BXE and so far it has served me well. I've run into a >>>> small problem regarding linebreaks: >>>> >>>> In my RelaxNG I have an element, inline, which may only have text >>>> content: >>>> >>>> <element name="inline"> >>>> <attribute name="id"/> >>>> <text/> >>>> </element> >>>> >>>> The problem is that when I hit enter in the editor a new <p> will be >>>> created and whatever was in the <inline> before will be wrapped in >>>> another <p>. Is there any way I can prevent this behaviour? >>> >>> >>> >>> >>> I assume, your XML looks something like this: >>> >>> <root> >>> <p>foobar <inline>hello world</inline> </p> >>> </root> >>> >>> and if you hit enter in <inline>, then you should get >>> >>> <root> >>> <p>foobar <inline>hello</inline></p> >>> <p><inline>world</inline></p> >>> </root> >>> >>> At least, that happens, when I hit return on inline elements in the >>> demo. >>> >> The thing is that only the contents of <inline> is editable. Let me >> walk you through my setup. >> >> I'm developing a multi-language site. The English language version of >> each page is the template for other language versions and looks >> something like: >> >> <a:content> >> <a:main> >> <a:block id="header"> >> <h1>The header</h1> >> </a:block> >> <a:block id="content"> >> <p>This is the main page content</p> >> </a:block> >> <p> >> <a href="somepage.html"><a:inline id="link-text">Go to some >> page</a:inline></a> >> </p> >> </a:main> >> </a:content> >> >> The Swedish translation of the page above would look like this: >> >> <a:content> >> <a:translated-block id="header"> >> <h1>Rubriken</h1> >> </a:translated-block> >> <a:translated-block id="content"> >> <p>Detta är huvudinnehållet</p> >> </a:translated-block> >> <a:translated-inline id="link-text">Gå till någon >> sida</a:translated-inline> >> </a:content> >> >> When the English version of a page is requested it is simply >> transformed into XHTML using a simple stylesheet. When the Swedish >> version is requested the English version will be used as a template. >> For each a:block in the English version the contents of the >> corresponding a:translated-block in the Swedish XML will be used >> instead of the original contents. The same applies to the a:inline >> elements. >> >> My RelaxNG is based on xtml-basic which comes with Lenya (which I >> think is similar to the one which comes with the uni example but they >> are using strict). The RelaxNG adds <a:block> to the XHTML Block.class >> and is simply a placeholder for other XHTML block elements: >> >> <define name="Block.class" combine="choice"> >> <choice> >> <ref name="a.block"/> >> </choice> >> </define> >> >> <define name="a.block"> >> <element name="a:block"> >> <attribute name="id"/> >> <ref name="Block.model"/> >> </element> >> </define> >> >> a:inline is added to Inline.class and may contain XHTML inline elements: >> >> <define name="Inline.class" combine="choice"> >> <choice> >> <ref name="a.inline"/> >> </choice> >> </define> >> >> <define name="a.inline"> >> <element name="a:inline"> >> <attribute name="id"/> >> <ref name="Inline.model"/> >> </element> >> </define> >> >> a:translated-block and a:inline are defined similarly: >> >> <element name="a:translated-block"> >> <attribute name="id"/> >> <ref name="Block.model"/> >> </element> >> >> <element name="a:translated-inline"> >> <attribute name="id"/> >> <ref name="Inline.model"/> >> </element> >> >> but may only occur directly in the root element (a:content). >> >> When a user edits the English version of a page everything within >> <a:main> should be editable. So I create a div with bxe_path set to >> /a:content/a:main in the XHTML presented by BXE. >> >> When a user edits the Swedish translation above you will only be able >> to edit what is inside the a:translated-* elements. So for each >> a:block and a:inline I create a div with bxe_path set to >> /a:content/a:translated-*[@id='...'] in the XHTML presented by BXE. >> >> Now this is where the problem is. A a:translated-inline should only be >> able to have inline elements inside (when I think about it only pure >> text content should be allowed). But when I edit the contents of an >> a:translated-inline and hit enter BXE will create a new <p> and wrap >> whatever was there before in another <p> even though <p> is not >> allowed as a child of a:translated-inline: >> >> <a:translated-inline> >> Some text >> </a:translated-inline> >> >> will become >> >> <a:translated-inline> >> <p>Some</p> >> <p>text</p> >> </a:translated-inline> >> >> When I try to save this BXE will complain: p is not allowed as child >> of a:translated-inline. >> >> Is there anyway this could be prevented? >> >> To summarize what I would like to achieve: >> When hitting enter and neither the element the cursor is in nor any of >> its ancestors up to the root of the editable area (in this case >> a:translated-inline) allow <p> as a child, nothing should happen. If >> this isn't implemented I would be happy to contribute a patch. >> >> BTW, I just tried to hit enter in the header ("Der Slogan") in the uni >> example on cvsdemo.bitfluxeditor.org. According to the RelaxNG of this >> example the element slogan may only have pure text content. But indeed >> a <p> is inserted when I do this. >> >> Another thing is that the first of the two created <p>:s doesn't get a >> parent. I have a fix against this problem if it hasn't been fixed >> already. I have no idea if it's a nice solution but at least it >> pinpoints the problem. I would be happy to send you the fix if you >> want it. >> >> I'm sorry for sending such a long reply. Thanks for taking the time to >> read it all! ;-) >> >> /Niklas >> >> > -- christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.bitflux.ch | [email protected] | gnupg-keyid 0x5CE1DECB -- bx-editor-users mailing list [email protected] http://lists.bitflux.ch/cgi-bin/listinfo/bx-editor-users