Fri 21 Jul 2006
Besides fixing bugs related to the code I am working on (mostly widget related), I implemented the initial NamedCommand class in Editor2.js and added several public APIs to dojo.widget.Editor2 for handling commands, such as registering new command (plugins can use it to register new commands) and query which commands are available.
A command class was introduced which has following APIs:
execute() //execute the command getState() //get the state of the command: Disabled/On/Off
A new class dojo.widget.Editor2.NamedCommand was introduced to wrap the built-in commands in browsers.
The _CurrentInstance was also migrated to getter/setter API, rather than accessing the _CurrentInstance variable directly.
However, when trying to migrate the Editor2Toolbar to make use of the new "Command Principle", I encountered an issue:
In order to eliminate the hard coded command handling functions in Editor2Toolbar, the command name has to be available in the onClick event handler for the buttons (including other controllers, such as a select) in the toolbar. It is possible to add another attribute to the span element which contains the button, such as dojoEditorCmd="bold", and retrieve it from the element e.currentTarget, however this only works in FF, not in IE.
I admit the above approach is not so decent, but I can not come up with another one.
The plan for next week is to propose a way to work around the issue and migrate Editor2/Editor2Toolbar to use it.
RSS feed for comments on this post. TrackBack this post