Re: Midas in XUL througg <editor> does not format text - throw error instead
Arivald <arivald_@AT_interia_DOT_pl.mozilla.org>
| Newsgroups | gmane.comp.mozilla.devel.xpfe |
|---|---|
| Message-ID | <[email protected]> |
W dniu 2011-07-12 17:59, Adam Victor Nazareth Brandizzi pisze:
> <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';
delete this line. it is not needed for <editor> because editor is always
editable. All You need is to initialize, by setting editortype to 'text'
or 'html', or by calling editor.makeEditable();
> }
>
> function onBoldButtonCommand() {
> editor.contentDocument.execCommand('bold', false, null);
Editor use different command model. It is not just editable document.
So use this instead:
editor.commandManager.doCommand('cmd_bold', {}, editor.contentWindow);
You may also register Your own commands.
> }
>
> 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>
--
Arivald