.. _dijit/Editor: dijit.Editor ============ :Status: Draft :Version: 1.0 :Authors: Becky Gibson, Bill Keese, Nikolai Onken, Marcus Reimann, Jared Jurkiewicz :Developers: Liu Cougar, Bill Keese, Douglas Hays, Becky Gibson, Jared Jurkiewicz :Available: since V1.0 .. contents:: :depth: 2 Dijit's Rich Text editor, Dijit.Editor, is a text box on steroids. Designed to look and work like a word processor. The editor features a toolbar, HTML output, and a plugin architecture that supports new commands, new buttons and other new features. ======== Features ======== * Provides Rich Text (word processor-like), editing of HTML documents. * Extensible toolbar with a default set of icons for common actions (bold, italic, underline, indent, and so on) * Cross-browser support. The RTE cababilities of browsers vary in what they provide and how they are set up. The dijitEditor abtracts this away and provides a single wat to create a rich-text editing field in your pages. * Built-in filtering support. The editor provides hooks to register HTML and DOM filters with the editor, to pre and post process data going in, or coming out of, the document being edited. * Pluggable architecture. The editor's functionality can be extended by implementing and registering plugins with the editor. In fact, all the base commands of editor are effectively plugins. The plugin architecture makes it relatively easy to add new buttons and actions to the toolbar, to being 'headless', where it simply registers filters or augments existing actions. =========== Limitations =========== * The dijit.Editor uses an iframe to separate the document being edited from the rest of the content of your page. This helps protect your main page from being corrupted by editor content and vice-versa. But because of it being iframe isolated, the editor initializes asynchronously. To avoid any actions firing too early against editor content, you should make use of the 'onLoadDeferred' object of the editor. For example, see the following example that changes the content after init completes: .. cv:: html
This is the initial content.
This instance is created from a div directly with default toolbar and plugins
This instance is created with a subset of functions enabled in the order we want
This instance is created with additional toolbar/ plugins
This instance is created with customized toolbar/ plugins
,
, etc) | | |formatBlock | | +---------------------------------------------+-----------------+----------------------------------------------------------------------+ |dijit._editor.plugins.LinkDialog |createLink |A plugin that provides two actions involving links to external | | |insertImage |content. The actions handle inserting hyperlinks ( tags) and | | | |inserting images (tags). The plugin provides basic, but | | | |decent validating Tooltip Dialog editors for working with both types | | | |of external links. | +---------------------------------------------+-----------------+----------------------------------------------------------------------+ |dijit._editor.plugins.FullScreen |fullscreen |A toolbar button plus hotkey for invoking an | | | |action that will toggle the editor's fullscreen mode, where it | | | |takes over the full viewport of the browser window object. Note that | | | |running the editor in an iframe means the editor can only take over | | | |the iframe. | | | |**New to Dojo toolkit 1.4.** | +---------------------------------------------+-----------------+----------------------------------------------------------------------+ |dijit._editor.plugins.ViewSource |viewsource |A toolbar button plus hotkey for invoking an action that toggles the | | | |viewport of the editor between Rich-Text and HTML view. | | | |**New to Dojo toolkit 1.4.** | +---------------------------------------------+-----------------+----------------------------------------------------------------------+ |dijit._editor.plugins.Print |print |A toolbar button that allows you to print the contents of the editor | | | |**New to Dojo toolkit 1.4.** | +---------------------------------------------+-----------------+----------------------------------------------------------------------+ |dijit._editor.plugins.NewPage |newpage |A toolbar button that allows you clear the contents of the editor | | | |to a default state, such as blank. **New to Dojo toolkit 1.4.** | +---------------------------------------------+-----------------+----------------------------------------------------------------------+ Please refer to each plugin's detail page for more information about it. DojoX (Dojo eXtensions) contains even more plugins for improving the capabilities of the dijit.Editor. These are functions that were deemed 'less common' requirements and were therefore put in the extensions namespace. Please refer to the :ref:`landing page
` for more information about them. Below is a quick description of each. +---------------------------------------------+----------------------+----------------------------------------------------------------------+ |**Plugin** |**Short Name(s)** |**Description** | +---------------------------------------------+----------------------+----------------------------------------------------------------------+ |dojox.editor.plugins.PrettyPrint |prettyprint |A headless (no button), plugin that improves the formatting of the | | | |HTML returned from editor.attr("value"). | | | |**New to Dojo toolkit 1.4.** | +---------------------------------------------+----------------------+----------------------------------------------------------------------+ |dojox.editor.plugins.PageBreak |pagebreak |A toolbar button and hotkey for inserting a 'page break' into the | | | |document. When the document is printed, the printer will break to | | | |output to new pages at those points. | | | |**New to Dojo toolkit 1.4.** | +---------------------------------------------+----------------------+----------------------------------------------------------------------+ |dojox.editor.plugins.ShowBlockNodes |showblocknodes |A toolbar button and hotkey for showing the block html elements being | | | |used to lay out the editor content. | | | |**New to Dojo toolkit 1.4.** | +---------------------------------------------+----------------------+----------------------------------------------------------------------+ |dojox.editor.plugins.Preview |preview |A toolbar button that allows you to view the content in a new window | | | |You can also have it apply custom stylesheets so that the content is | | | |is styled differently from how it appears in the editor. | | | |**New to Dojo toolkit 1.4.** | +---------------------------------------------+----------------------+----------------------------------------------------------------------+ |dojox.editor.plugins.Save |save |A toolbar button that allows you to post back the content of the | | | |editor to a remote service easily. It is intended for subclassing to | | | |customize save behavior. | | | |**New to Dojo toolkit 1.4.** | +---------------------------------------------+----------------------+----------------------------------------------------------------------+ |dojox.editor.plugins.ToolbarLineBreak ||| or |A simple plugin for splitting the toolbar up into multiple lines. | | |toolbarlinebreak |Useful in controlling how the dijit.Editor toolbar wraps. | | | |**New to Dojo toolkit 1.4.** | +---------------------------------------------+----------------------+----------------------------------------------------------------------+ |dojox.editor.plugins.NormalizeIndentOutdent |normalizeindentoutdent|A headless plugin that tries to standardize how browsers hander | | | |indent and outdent operations on content. This plugin is experimental| | | |**New to Dojo toolkit 1.4.** | +---------------------------------------------+----------------------+----------------------------------------------------------------------+ |dojox.editor.plugins.Breadcrumb |breadcrumb |A plugin that adds a footer toolbar to the editor that allows you to | | | |see the node position of the cursor. It also provides selection, | | | |deletion, and cursor move functions. This plugin is experimental. | | | |**New to Dojo toolkit 1.4.** | +---------------------------------------------+----------------------+----------------------------------------------------------------------+ |dojox.editor.plugins.FindReplace |findreplace |A plugin that provides a find and replace togglable toolbar to the | | | |editor. This plugin is experimental. | | | |**New to Dojo toolkit 1.4.** | +---------------------------------------------+----------------------+----------------------------------------------------------------------+ ===================== Auto-expanding editor ===================== Typically an editor has a constant height, and if there's a lot of content it gets a scrollbar. This is in addition to the main scrollbar for the page. Editor also has a mode like dijit.form.Textarea where the more a user types, the more the text box expands. However, that's a bit tricky because if implemented naively the toolbar would eventually scroll off the top of the page. The AlwaysShowToolbar plugin prevents that. It's used along with setting height="" parameter setting. .. cv-compound:: .. cv:: javascript .. cv:: html ====================================== Accessibility (1.0 and later versions) ====================================== Keyboard for Editor ------------------- ==================================================================== ====================================================================== Action Key ==================================================================== ====================================================================== Move focus to the next widget in the tab order. Tab (must press tab twice in some situations - see Known Issues below) Move focus to the prior widget in the tab order (the editor toolbar) Shift+Tab (must press shift-tab twice in some situations - see Known Issues below) ==================================================================== ====================================================================== Keyboard for Editor Toolbar --------------------------- ==================================================================== ====================================================================== Action Key ==================================================================== ====================================================================== Move focus to the next enabled button in the toolbar. arrow right in left to right locales, arrow left in right to left locales Move focus to the previous widget in the toolbar arrow left in left to right locales; arrow right in right to left locales. ==================================================================== ====================================================================== The arrow keys will not work within any optional drop down lists such as ComboBox or FilteringSelect in the editor toolbar until the drop down list of choices has been activated. Use the backspace or escape key to clear the current selection in the textbox associated with the drop down. When the list of choices is not activated, the arrow keys will move between toolbar buttons rather than within the combobox or select. Known Issues ------------ * On Firefox, the user must press the Tab key twice before keyboard focus moves to the next widget. This is a permanent restriction on Firefox 2. The reason for this is because Firefox implements usage of the tab key within the editor to indent text and shift-tab to outdent text. There is no keyboard mechanism in Firefox to move focus out of the editor. So, the dijit editor traps the tab key in the editor and sets focus to the editor iframe. From there pressing tab again will move to the next focusable item after the editor. When shift-tab is pressed within the editor, focus is set to the toolbar associated with the editor (currently there is always a toolbar defined for a dijit editor). Even though Firefox 3 now supports the use of the contentEditable attribute to create the editor using a div element, the dijit editor is still implemented using an iframe in Firefox 3 and this tabbing issue remains. Some people are unhappy with the loss of the tab key functionality within the editor. Version 1.2 includes a plug-in option to allow the use of tab and shift-tab within the editor to indent and outdent text. * In IE6 or 7 when the editor has been created from a textarea the user must press tab twice to set focus into the editor to begin inserting or editing text. Likewise, with focus within editor text the user must press shift-tab twice to set focus back to the toolbar.This editor is created from a div with AlwaysShowToolbar plugin (do not forget to set height="").