[Mozile] Just the commands, please
James A. Overton
james at overton.ca
Sat Feb 10 08:47:08 PST 2007
Hi Gary,
You're right that the docs don't give a good explanation for how to
do what you want to do. So I put together a new demo:
http://mozile.mozdev.org/0.8/demos/custom.html
The demo uses the Mozile rich editing code and the default Mozile
Editing Scheme, but not the GUI and toolbar. Some example commands
are created using JavaScript. You can also create custom commands by
modifying the lib/xhtml.rng file, and the docs explain how to do that.
You call can call any command using mozile.execCommand
('commandName'), and that will execute the command and add it to the
undo stack. In the demo I call mozile.execCommand() with "onclick"
event handlers.
The default MES defines a whole range of commands. If you don't want
these commands you can remove this line
mozile.useSchema("lib/xhtml.rng");
and then then only the commands you define will be available.
As for defining new commands, there are lots of examples in lib/
xhtml.rng, a couple more in the new demo, and there's this
documentation which summarizes the various command classes:
file:///Users/james/Development/CVS/mozile/www/0.8/doc/html/
mozile.html#Commands
You can usually do what you want by using Wrap, Insert, Replace, or
Style. More advanced commands start with the Command class and then
define new test(), prepare(), execute(), and unexecute() methods.
Let me know if this new demo is what you're looking for, and what
else you need to know.
James
On 2007-02-09, at 9:06 PM, Gary Wilhelm wrote:
> I have an IE-only homegrown CMS that uses the “contentEditable”
> attribute and generates “crufty old HTML.” I need to extend this
> CMS to add support for Firefox, and I didn’t get anywhere with the
> classic Mozilla designMode stuff that’s been around for a while.
>
> What I’d like to be able to do is just pull the appropriate
> Javascript out of the Mozile 0.8 code so I can recreate stuff like
> the bold, italic, and underline commands on my own CMS’s toolbar
> rather than using the one that’s built in. From what I gather, all
> I have to do is to create a Javascript command so that it wraps
> selected text with the appropriate CSS or inserts XHTML in the
> appropriate spot, but I can’t quite figure out how to do that from
> picking through the documentation. Any help would be appreciated.
>
> Thanks,
>
> Gary
>
> --
>
> Gary Wilhelm, MSIS
> Applications Analyst
> School of Law, UNC-Chapel Hill
> 5140 Van Hecke-Wettach Hall, CB 3380
> Chapel Hill, NC 27599-3380
> gary_wilhelm at unc.edu
>
>
> _______________________________________________
> Mozile mailing list
> Mozile at mozdev.org
> http://mozdev.org/mailman/listinfo/mozile
More information about the Mozile
mailing list