Midas in XUL througg <editor> does not format text - throw error instead
Adam Victor Nazareth Brandizzi <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.xpfe |
|---|---|
| Message-ID | <CAHEH7E5DyvA8FDeuidSJvTgWXL4pJdmMO-FZpFEzv=_FXTNbtg@mail.gmail.com> |
Hello, all!
I am trying to use Midas through the element of XUL following the
instructions of this article. So far I have the code below:
<window id="main" title="Anunciador Blog Editor" width="300" height="300"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<script type="application/x-javascript">
<![CDATA[
var editor = null;
function onLoad() {
editor = document.getElementById('editor');
editor.contentDocument.designMode = 'on';
}
function onBoldButtonCommand() {
editor.contentDocument.execCommand('bold', false, null);
}
window.addEventListener("load", onLoad, false);
]]>
</script>
<button label="Bold" oncommand="onBoldButtonCommand();" />
<editor id="editor" type="content-primary" editortype="html"
src="about:blank" flex="1" />
</window>
However, when I click in the "Bold" button with some text selected in
the <editor>, the text is not altered and the JS console presents the
following error:
Error: uncaught exception: [Exception... "Component returned failure
code: 0x80004005
(NS_ERROR_FAILURE) [nsIDOMNSHTMLDocument.execCommand]" nsresult: "0x80004005
(NS_ERROR_FAILURE)" location: "JS frame ::
chrome://anunciador/content/main.xul ::
onBoldButtonCommand :: line 14" data: no]
That does not make sense to me because I have enabled the edit mode with:
editor.contentDocument.designMode = 'on';
Did I forget something?
Thanks in advance!
--
Adam Victor Nazareth Brandizzi
http://brandizzi.googlepages.com/