dojox/editor/plugins/NormalizeIndentOutdent (version 1.10)

dijit/_editor/_Plugin

Summary

This plugin provides improved indent and outdent handling to the editor. It tries to generate valid HTML, as well as be consistent about how it indents and outdents lists and blocks/elements.

Usage

var foo = new NormalizeIndentOutdent(args);
dijit/_editor/_Plugin
Parameter Type Description
args Object
Optional

Initial settings for any of the attributes.

See the dojox/editor/plugins/NormalizeIndentOutdent reference documentation for more information.

Property Summary

  • buttonPointer to dijit/form/Button or other widget (ex: dijit/form/FilteringSelect) that is added to the toolbar to control this plugin.
  • commandString like "insertUnorderedList", "outdent", "justifyCenter", etc. that represents an editor command.
  • disabledFlag to indicate if this plugin has been disabled and should do nothing helps control button state, among other things.
  • editorPoints to the parent editor
  • iconClassPrefixThe CSS class name for the button node is formed from iconClassPrefix and command
  • indentByThe amount to indent by.
  • indentUnitsThe units to apply to the indent amount.
  • useDefaultCommandIf true, this plugin executes by calling Editor.execCommand() with the argument specified in command.

Method Summary

  • _convertIndent(indent) Function to convert the current indent style to the units we're using by some heuristic.
  • _getAttrNames(name) Helper function for get() and set().
  • _getTagName(node) Internal function to get the tag name of an element if any.
  • _indentElement(node) Function to indent a block type tag.
  • _indentImpl(html) Improved implementation of indent, generates correct indent for ul/ol
  • _indentList(listItem) Internal function to handle indenting a list element.
  • _initButton() Initialize the button or other widget that will control this plugin.
  • _isEmpty(node) Internal function to determine if a node is 'empty' Eg, contains only blank text.
  • _isIndentableElement(tag) Internal function to detect what element types are indent-controllable by us.
  • _isInlineFormat(tag) Function to determine if the current tag is an inline element that does formatting, as we don't want to break/indent around it, as it can screw up text.
  • _isLtr() Function to detect if the editor body is in RTL or LTR.
  • _isRootInline(node) This functions tests whether an indicated node is in root as inline or rooted inline elements in the page.
  • _isTextElement(node) Helper function to check for text nodes.
  • _outdentElement(node) Function to outdent a block type tag.
  • _outdentImpl(html) Improved implementation of outdent, generates correct indent for ul/ol and other elements.
  • _outdentList(listItem) Internal function to handle outdenting a list element.
  • _queryCommandEnabled(command) An over-ride for the editor's query command enabled, so that we can prevent indents, etc, on bad elements or positions (like first element in a list).
  • _set(name,value) Helper function to set new value for specified attribute
  • _setDisabledAttr(disabled) Function to set the plugin state and call updateState to make sure the button is updated appropriately.
  • buttonClass() Class of widget (ex: dijit.form.Button or dijit/form/FilteringSelect) that is added to the toolbar to control this plugin.
  • connect(o,f,tf) Deprecated.
  • destroy()
  • get(name) Get a property from a plugin.
  • getLabel(key) Returns the label to use for the button
  • own() Track specified handles and remove/destroy them when this instance is destroyed, unless they were already removed/destroyed manually.
  • set(name,value) Set a property on a plugin
  • setEditor(editor) Over-ride for the setting of the editor.
  • setToolbar(toolbar) Tell the plugin to add it's controller widget (often a button) to the toolbar.
  • updateState() Change state of the plugin to respond to events in the editor.

Properties

button
Defined by: dijit/_editor/_Plugin

Pointer to dijit/form/Button or other widget (ex: dijit/form/FilteringSelect) that is added to the toolbar to control this plugin. If not specified, will be created on initialization according to buttonClass

command
Defined by: dijit/_editor/_Plugin

String like "insertUnorderedList", "outdent", "justifyCenter", etc. that represents an editor command. Passed to editor.execCommand() if useDefaultCommand is true.

disabled
Defined by: dijit/_editor/_Plugin

Flag to indicate if this plugin has been disabled and should do nothing helps control button state, among other things. Set via the setter api.

editor
Defined by: dijit/_editor/_Plugin

Points to the parent editor

iconClassPrefix
Defined by: dijit/_editor/_Plugin

The CSS class name for the button node is formed from iconClassPrefix and command

indentBy

The amount to indent by. Valid values are 1+. This is combined with the indentUnits parameter to determine how much to indent or outdent by for regular text. It does not affect lists.

indentUnits

The units to apply to the indent amount. Usually 'px', but can also be em.

useDefaultCommand
Defined by: dijit/_editor/_Plugin

If true, this plugin executes by calling Editor.execCommand() with the argument specified in command.

Methods

_convertIndent(indent)

Function to convert the current indent style to the units we're using by some heuristic.

Parameter Type Description
indent undefined

The indent amount to convert.

Returns:number
_getAttrNames(name)

Helper function for get() and set(). Caches attribute name values so we don't do the string ops every time.

Parameter Type Description
name undefined
Returns:undefined | object
_getTagName(node)

Internal function to get the tag name of an element if any.

Parameter Type Description
node undefined

The node to look at.

Returns:string
_indentElement(node)

Function to indent a block type tag.

Parameter Type Description
node undefined

The node who's content to indent.

Returns:undefined
_indentImpl(html)

Improved implementation of indent, generates correct indent for ul/ol

Parameter Type Description
html String
_indentList(listItem)

Internal function to handle indenting a list element.

Parameter Type Description
listItem undefined

The list item to indent.

_initButton()

Initialize the button or other widget that will control this plugin. This code only works for plugins controlling built-in commands in the editor.

_isEmpty(node)

Internal function to determine if a node is 'empty' Eg, contains only blank text. Used to determine if an empty list element should be removed or not.

Parameter Type Description
node undefined

The node to check.

Returns:boolean
_isIndentableElement(tag)

Internal function to detect what element types are indent-controllable by us.

Parameter Type Description
tag undefined

The tag to check

Returns:boolean
_isInlineFormat(tag)

Function to determine if the current tag is an inline element that does formatting, as we don't want to break/indent around it, as it can screw up text.

Parameter Type Description
tag undefined

The tag to examine

Returns:boolean
_isLtr()

Function to detect if the editor body is in RTL or LTR.

Returns:boolean
_isRootInline(node)

This functions tests whether an indicated node is in root as inline or rooted inline elements in the page.

Parameter Type Description
node undefined

The node to start at.

Returns:boolean
_isTextElement(node)

Helper function to check for text nodes.

Parameter Type Description
node undefined

The node to check.

Returns:boolean
_outdentElement(node)

Function to outdent a block type tag.

Parameter Type Description
node undefined

The node who's content to outdent.

_outdentImpl(html)

Improved implementation of outdent, generates correct indent for ul/ol and other elements.

Parameter Type Description
html String
Returns:undefined | null
_outdentList(listItem)

Internal function to handle outdenting a list element.

Parameter Type Description
listItem undefined

The list item to outdent.

_queryCommandEnabled(command)

An over-ride for the editor's query command enabled, so that we can prevent indents, etc, on bad elements or positions (like first element in a list).

Parameter Type Description
command undefined

The command passed in to check enablement.

Returns:boolean | undefined
_set(name,value)

Helper function to set new value for specified attribute

Parameter Type Description
name String
value anything
_setDisabledAttr(disabled)

Function to set the plugin state and call updateState to make sure the button is updated appropriately.

Parameter Type Description
disabled undefined
buttonClass()

Class of widget (ex: dijit.form.Button or dijit/form/FilteringSelect) that is added to the toolbar to control this plugin. This is used to instantiate the button, unless button itself is specified directly.

connect(o,f,tf)

Deprecated. Use this.own() with dojo/on or dojo/aspect.instead.

Make a connect.connect() that is automatically disconnected when this plugin is destroyed. Similar to dijit/_Widget.connect().

Parameter Type Description
o undefined
f undefined
tf undefined
destroy()
get(name)

Get a property from a plugin.

Get a named property from a plugin. The property may potentially be retrieved via a getter method. If no getter is defined, this just retrieves the object's property. For example, if the plugin has a properties "foo" and "bar" and a method named "_getFooAttr", calling:

plugin.get("foo");

would be equivalent to writing:

plugin._getFooAttr();

and:

plugin.get("bar");

would be equivalent to writing:

plugin.bar;
Parameter Type Description
name undefined

The property to get.

Returns:undefined
getLabel(key)

Returns the label to use for the button

Parameter Type Description
key String
Returns:undefined
own()
Defined by dijit/Destroyable

Track specified handles and remove/destroy them when this instance is destroyed, unless they were already removed/destroyed manually.

Returns:any | undefined

The array of specified handles, so you can do for example:

var handle = this.own(on(...))[0];
set(name,value)

Set a property on a plugin

Sets named properties on a plugin which may potentially be handled by a setter in the plugin. For example, if the plugin has a properties "foo" and "bar" and a method named "_setFooAttr", calling:

plugin.set("foo", "Howdy!");

would be equivalent to writing:

plugin._setFooAttr("Howdy!");

and:

plugin.set("bar", 3);

would be equivalent to writing:

plugin.bar = 3;

set() may also be called with a hash of name/value pairs, ex:

plugin.set({
    foo: "Howdy",
    bar: 3
})

This is equivalent to calling set(foo, "Howdy") and set(bar, 3)

Parameter Type Description
name attribute

The property to set.

value anything

The value to set in the property.

Returns:function | string

Set a property on a plugin

setEditor(editor)

Over-ride for the setting of the editor.

Parameter Type Description
editor Object

The editor to configure for this plugin to use.

setToolbar(toolbar)

Tell the plugin to add it's controller widget (often a button) to the toolbar. Does nothing if there is no controller widget.

Parameter Type Description
toolbar dijit/Toolbar
updateState()

Change state of the plugin to respond to events in the editor.

This is called on meaningful events in the editor, such as change of selection or caret position (but not simple typing of alphanumeric keys). It gives the plugin a chance to update the CSS of its button.

For example, the "bold" plugin will highlight/unhighlight the bold button depending on whether the characters next to the caret are bold or not.

Only makes sense when useDefaultCommand is true, as it calls Editor.queryCommandEnabled(command).

Error in the documentation? Can’t find what you are looking for? Let us know!