Fri 23 Jun 2006
When planning for how to improve the Editor2 widget, I noted several concerns about the current implementation:
- Editor2Toolbar hard-codes all the available command buttons and the event handlers for them. This is particularly an issue if we want to make it extensible. In addition, context menu is also planned, so the event handlers should not be incorporated in the Editor2Toolbar widget.
- Another Editor2Toolbar widget related concerns is that, the layout is given in a template file, which again hard codes the event handlers.
- Widget Editor2 also suffers from the same issue. In addition, it checks all available command states in updateToolbar() which is not necessary when only a portion of them is actually used in a toolbar.
The following is my plan to tackle them:
- In Editor2, introduce a new variable to hold the current focused instance of Editor2 (such as dojo.widget.html._CurrentEditor2Instance) which is set when focuses in a Editor and unset when blurs
- Introduce a command class (EditorCommand), which capsulates the information about a command: state (disabled/highlight on/highlight off), how to execute the command. The class for the built-in commands is something like this: (this principle is borrowed from FCKeditor)
var dojo.widget.html.Editor2NamedCommand = function( commandName ) { this.Name = commandName ; } dojo.widget.html.Editor2NamedCommand.prototype.Execute = function() { dojo.widget.html._CurrentEditor2Instance.execCommand( this.Name ) ; } dojo.widget.html.Editor2NamedCommand.prototype.GetState = function() { return dojo.widget.html._CurrentEditor2Instance.queryCommandState( this.Name ) ; } - Rewrite Editor2 to make use of EditorCommand
- Rewrite Editor2Toolbar so that it makes use of EditorCommand as well. There are two possibilities to do this:
- use template support as it is, so if the users want to customize the toolbar he have to modify the html template
- generate the toolbar pragmatically (as in FCKeditor): toolbar can be configed in an option of an array of strings specifying which buttons to use and the layout, rather then in the html template. This is not as flexible as template files, however I do not think most users are interested to modify the more complex template file instead of an simple option in the editor. As it is done in FCKeditor, theme is also possible in this manner: the theme has to comply with a specified format.
RSS feed for comments on this post. TrackBack this post
June 28th, 2007 at 6:56 pm
Hi Heng,
First I would like to thank you for all the awesome work you have done for dojo. My question is regarding the new command/action architecture you want to implement (which looks a lot like eclipse’s RCP command/action plugin stuff): First, will these commands be undoable, with something like canUndo and undo methods? Also, it seems like the current undo stack is maintained by the document, since you call its execCommand method to do all the work…so where you thinking about just pushing all the commands onto your own stack? Or perhaps there is a way to push your commands onto the document stack..?
cheers,
-R