BXE 2.0 RelaxNGEnhancement

Namespace:

xmlns:bxe="http://bitfluxeditor.org/schema/2.0"

"Nice" Names

This allows for displaying nice names in the status bar and the context menu

<element name="author">
  <bxe:name>Der Autor</bxe:name>
 </element>

helptext

Will add a browser-native yellow popup with the text to menuentries of that element and attribute texts in attribute dialog

<element name="author">
  <bxe:helptext>To specify the author name, add this element</bxe:helptext>
 </element>

Don't Show in context menu

There are cases, where you don't want to display certain tags in the context menu or the menulist on the top left. With <bxe:dontshow/> you remove them from those lists. Works also for attributes. This can be useful, if you have legacy elements in your documents, but you don't want, that people can choose them for newly created content.

<bxe:dontshow/>

Not Editable

If you want to make an element non editable, assign the bxe:noteditable instruction. If the element has subelements, then those are still editable.

<bxe:noteditable/>

also possible

<bxe:noteditable contextmenu="true"/>

the context menu will then still be available, but the content is still not editable.

Automatic Next Element On Return

Appends for example a <p> element after a <h1> element, when you hit return. By default the same element will be appended. It only does append the nextelement, if the cursor is at the end of the element. If you are in the middle of it, then it just splits it.

<element name="h1">
  <bxe:nextelement>p</bxe:nextelement>
 </element>

or with a namespace

<element name="h1">
  <bxe:nextelement ns="http://www.w3.org/1999/xhtml">p</bxe:nextelement>
 </element>

Default Content

If we append or insert a new element, some text usually has to be inserted. If you don't specify bxe:defaultcontent then BXE just inserts the localname of that element. Otherwise it takes the content of this tag.

This works also for attributes.

type="function"

Furthermore you can call a userdefined function, if you define the type attribute. This can for example be used for automatically inserting the current date. (See http://svn.liip.ch/repos/bxe/branches/bxe_2_0/examples/rss/rss.js for such an example)

<bxe:defaultcontent type="function">Some Content or function</bxe:defaultcontent>

This works also for attributes.

type="element"

<element name="block">
  <bxe:name>Block</bxe:name>
  <bxe:defaultcontent type="element">para</bxe:defaultcontent>

Inserts now automatically also a para element, when you insert a block element.

Caution: You have to be sure, that you the XML document is valid afterwards. There will be no auto-appending of other elements currently (even if the RNG says so). If you need to insert more than one element, you have to create your own onnew function handler (for the block element in this example)

OnNew Callback

The onnew instruction is used, when a new element (or attribute) is created. It's similar to defaultcontent, but instead of just defining the content of the text node, you can do much more advanced stuff here as you can manipulate the whole node.

If you define type="popup", then a popup is opened with the url defined. From there you can for example show a image chooser dialog and then insert that image to the document.

For more information about that topic, see OnNewCallbacks

(for attributes only function-type is supported)

<bxe:onnew type="seebelow" >value</bxe:onnew>
  • type="popup": calls a popup with the url defined in the textnode
  • type="function": calls the function defined in the textnode

Difference to defaultcontent

The difference between onnew and defaultcontent is (with type="function"), that onnew has full control over the element (meaning, it has to set the content by itself or the attribute), but defaultcontent can only return a text-string.

onempty callback

bxe:onempty defines, what should happen, if an element is "emptied" (by deleting the textcontent)

to be improved and translataed

1) wenn ein <bxe:onempty ... /> gesetzt ist, wird immer das ausgeführt.
Als optionen gibt's type="delete", dann wird das element gelöscht,
oder type="function", dann wird diese funktion aufgerufen, wo man dann
individuell was machen kann.

2) wenn kein bxe:onempty, aber bxe:defaultcontent, dann wird dieser
eingesetzt, sollte das element leer sein (egal ob mit selection/delete
oder jedes zeichen einzeln gelöscht wird)

3) wenn kein bxe:onempty und kein bxe:defaultcontent -> element wird
komplett gelöscht (egal ob mit selection/delete oder jedes zeichen
einzeln gelöscht wird)

3a) wird fall 3) ausgeführt, sind auch das Parent-Element (und
entsprechend Parents von dem) auf onempty anweisungen zu überprüfen.

Eine Beispiel funktion würde folgendermassen aussehen:

function onempty_image_tag(e) {
	if (e._node.getAttribute("src") == 'irgendwas') {
		return false;	
	} else {
		return true;
	}
}

Wenn man return false macht, dann wird der node gelöscht, wenn true,
dann macht der BXE nichts mehr weiter mit dem node

Add Menu entry

You can add context menu entries based on the element called.

<bxe:menuentry type="seebelow" name="Text for menu entry">value</bxe:menuentry>

The popup and function calls work similar to the one mentioned above in bxe:onnew. For popup calls window.bxe_lastNode is set with the calling element, for function calls, the calling element is in the first parameter (both as XMLNode Objects)

  • type="popup": calls a popup with the url defined in the textnode
  • type="function": calls the function defined in the textnode

Attribute selector

Offers a [ ... ] box in "Edit Attributes.." instead of just a textfield (or a selector)

<bxe:selector type="seebelow">value</bxe:selector>

  • type="popup": calls a popup with the url defined in the textnode
  • type="function": calls the function defined in the textnode

If you use the popup type, you have to use the function bxe_insertAttributeValue to insert the choosen value. Example:

window.opener.bxe_insertAttributeValue("chregu@bitflux.ch");

If you use a callback function, it has to return a string with the value. Or if you do it asynchronous, you can also use the bxe_insertAttributeValue function.

In popup, it's possible to get actual value of attribute with bxe_getAttributeValue. Example :

print window.opener.bxe_getAttributeValue();

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
These projects are supported by Liip AG