proposal: changes in bxeFunctions.js
Michael Wohlfart <[email protected]> Thu, 23 Jun 2005 10:35:35 +0200
| Newsgroups | gmane.editors.bitflux.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I played around with BXE and want to propose some enhancements for the
code in bxeFunctions.js. This aren't really bugs in BXE but would improve
the usability (at least in my opinion).
I used the Subversion Trunk Snapshot from 17th June and the
"Bitflux Editor Website with inline loading and XHTML Elements" Example.
proposal1
---------
If you start Editing by selecting the bold, italic, sub or sup Button but
without prior selecting an editable region on the page, my Java Script debugger
shows the following stack trace:
Exception ``[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsISelection.getRangeAt]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: file:///C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/mozile/mozCE.js :: anonymous :: line 748" data: no]'' thrown from function anonymous() in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/mozile/mozCE.js> line 748.
Exception ``[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsISelection.getRangeAt]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: file:///C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/mozile/mozCE.js :: anonymous :: line 748" data: no]'' thrown from function anonymous() in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/mozile/mozCE.js> line 748.
Error ``sel.anchorNode has no properties'' [xs] in file ``file:///C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/js/bxeFunctions.js'', line 485, character 0.
Exception ``TypeError: sel.anchorNode has no properties'' thrown from function bxe_toggleTextClass(e=Object:{4}) in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/js/bxeFunctions.js> line 485.
[e] message = [string] "sel.anchorNode has no properties"
Exception ``TypeError: sel.anchorNode has no properties'' thrown from function anonymous(event=Object:{4}) in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/js/eDOMEvents.js> line 56.
[e] message = [string] "sel.anchorNode has no properties"
Exception ``TypeError: sel.anchorNode has no properties'' thrown from function anonymous(eventType=string:"ToggleTextClass") in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/js/eDOMEvents.js> line 75.
[e] message = [string] "sel.anchorNode has no properties"
Exception ``TypeError: sel.anchorNode has no properties'' thrown from function eDOMEventCall(eventType=string:"ToggleTextClass", target=HTMLDocument:{1}, addInfo=Object:{2}) in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/js/eDOMEvents.js> line 89.
[e] message = [string] "sel.anchorNode has no properties"
Exception ``TypeError: sel.anchorNode has no properties'' thrown from function anonymous(e=Event:{0}) in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/js/widget.js> line 483.
[e] message = [string] "sel.anchorNode has no properties"
this isn't really a problem since the exception is never shown to the user,
however I think this can be improved by adding the following code inside the
method bxe_toggleTextClass() in the bxeFunctions.js File (around line 480)
just before or after the check for SourceMode.
if (cssr == null) {
alert("Not possible to use this button. You must select a field to edit first");
return false;
}
as far as I understand cssr is null if no editable range has been selected,
this would prevent the Exception and show a nice warning to the user.
proposal2
---------
If you select the title of the Article in the Example and use the ul or ol Buttons
in Butflux I get the following stack trace in my debugger:
Error ``lastTextNode has no properties'' [xs] in file ``file:///C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/mozile/eDOM.js'', line 4106, character 0.
Exception ``TypeError: lastTextNode has no properties'' thrown from function anonymous() in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/mozile/eDOM.js> line 4106.
[e] message = [string] "lastTextNode has no properties"
Exception ``TypeError: lastTextNode has no properties'' thrown from function anonymous() in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/mozile/eDOM.js> line 4142.
[e] message = [string] "lastTextNode has no properties"
Exception ``TypeError: lastTextNode has no properties'' thrown from function anonymous() in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/mozile/eDOM.js> line 3945.
[e] message = [string] "lastTextNode has no properties"
Exception ``TypeError: lastTextNode has no properties'' thrown from function anonymous(cssr=Range:{3}) in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/mozile/mozCE.js> line 773.
[e] message = [string] "lastTextNode has no properties"
Exception ``TypeError: lastTextNode has no properties'' thrown from function anonymous(requestedList=string:"ul", alternateList=string:"ol") in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/mozile/mozCE.js> line 438.
[e] message = [string] "lastTextNode has no properties"
Exception ``TypeError: lastTextNode has no properties'' thrown from function bxe_UnorderedList() in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/js/bxeFunctions.js> line 1328.
[e] message = [string] "lastTextNode has no properties"
Exception ``TypeError: lastTextNode has no properties'' thrown from function anonymous(event=Object:{4}) in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/js/eDOMEvents.js> line 56.
[e] message = [string] "lastTextNode has no properties"
Exception ``TypeError: lastTextNode has no properties'' thrown from function anonymous(eventType=string:"UnorderedList") in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/js/eDOMEvents.js> line 75.
[e] message = [string] "lastTextNode has no properties"
Exception ``TypeError: lastTextNode has no properties'' thrown from function eDOMEventCall(eventType=string:"UnorderedList", target=HTMLDocument:{1}, addInfo=Object:{2}) in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/js/eDOMEvents.js> line 89.
[e] message = [string] "lastTextNode has no properties"
Exception ``TypeError: lastTextNode has no properties'' thrown from function anonymous(e=Event:{0}) in <file:/C:/Dokumente%20und%20Einstellungen/michael/Desktop/bxe/js/widget.js> line 483.
[e] message = [string] "lastTextNode has no properties"
This exception also isn't shown to the user but the title Element is changed
to li and can't be changed back later. To fix this for the ol button I added the
following code inside the method bxe_OrderedList() in the bxeFunctions.js
File (around line 1350) (also before or after the check for SourceMode).
// the node that needs to be changed:
var node = sel.anchorNode.parentNode.XMLNode;
// we only allow changes for the p or the ul Elements:
if ( ( node.localName != "p" ) && ( node.localName != "ul" ) ) {
alert ("Ordered List not Allowed here");
return;
}
This permits the use of ol only for p and ul Elements.
However I consider this as a bad hack since this isn't based on the schema
for the Document. A call to XMLNode.isNodeValid() or bxe_checkIsAllowedChild()
like it is done in other methodes would be a better solution at this point I
think.
I just can't figure out how, maybe anybody else got an idea about how to
do this ?
best regards
Michael
--
bx-editor-users mailing list
[email protected]
http://lists.bitflux.ch/cgi-bin/listinfo/bx-editor-users