dijit/_editor/plugins/ViewSource (version 1.10)

dijit/_editor/_Plugin

Summary

This plugin provides a simple view source capability. When view source mode is enabled, it disables all other buttons/plugins on the RTE. It also binds to the hotkey: CTRL-SHIFT-F11 for toggling ViewSource mode.

Usage

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

Initial settings for any of the attributes.

See the dijit/_editor/plugins/ViewSource reference documentation for more information.

Property Summary

  • _fsPluginReference to a registered fullscreen plugin so that viewSource knows how to scale.
  • 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
  • readOnlyBoolean flag used to indicate if the source view should be readonly or not.
  • stripCommentsBoolean flag used to indicate if comment tags should be stripped from the document.
  • stripIFrames
  • stripScriptsBoolean flag used to indicate if script tags should be stripped from the document.
  • useDefaultCommandIf true, this plugin executes by calling Editor.execCommand() with the argument specified in command.

Method Summary

  • _createSourceView() Internal function for creating the source view area.
  • _filter(html) Internal function to perform some filtering on the HTML.
  • _getAttrNames(name) Helper function for get() and set().
  • _initButton() Over-ride for creation of the resize button.
  • _resize() Internal function to resize the source view
  • _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.
  • _showSource(source) Function to toggle between the source and RTE views.
  • _stripComments(html) Strips out comments from the HTML used in editor.
  • _stripIFrames(html) Strips out iframe tags from the content, to avoid iframe script style injection attacks.
  • _stripScripts(html) Strips out script tags from the HTML used in editor.
  • 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() Over-ride to remove the node used to correct for IE's zoom bug.
  • 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) Tell the plugin which Editor it is associated with.
  • setSourceAreaCaret() Internal function to set the caret in the sourceArea to 0x0
  • setToolbar(toolbar) Tell the plugin to add it's controller widget (often a button) to the toolbar.
  • toggle() Function to allow programmatic toggling of the view.
  • updateState() Over-ride for button state control for disabled to work.

Properties

_fsPlugin

Reference to a registered fullscreen plugin so that viewSource knows how to scale.

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

readOnly

Boolean flag used to indicate if the source view should be readonly or not. Cannot be changed after initialization of the plugin. Defaults to false.

stripComments

Boolean flag used to indicate if comment tags should be stripped from the document. Defaults to true.

stripIFrames
stripScripts

Boolean flag used to indicate if script tags should be stripped from the document. Defaults to true.

useDefaultCommand
Defined by: dijit/_editor/_Plugin

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

Methods

_createSourceView()

Internal function for creating the source view area.

_filter(html)

Internal function to perform some filtering on the HTML.

Parameter Type Description
html String

The HTML to filter

Returns:undefined
_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
_initButton()

Over-ride for creation of the resize button.

_resize()

Internal function to resize the source view

_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
_showSource(source)

Function to toggle between the source and RTE views.

Parameter Type Description
source boolean

Boolean value indicating if it should be in source mode or not.

_stripComments(html)

Strips out comments from the HTML used in editor.

Parameter Type Description
html String

The HTML to filter

Returns:undefined
_stripIFrames(html)

Strips out iframe tags from the content, to avoid iframe script style injection attacks.

Parameter Type Description
html String

The HTML to filter

Returns:undefined
_stripScripts(html)

Strips out script tags from the HTML used in editor.

Parameter Type Description
html String

The HTML to filter

Returns: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()

Over-ride to remove the node used to correct for IE's zoom bug.

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)

Tell the plugin which Editor it is associated with.

Parameter Type Description
editor Object

The editor object to attach the print capability to.

setSourceAreaCaret()

Internal function to set the caret in the sourceArea to 0x0

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
toggle()

Function to allow programmatic toggling of the view.

updateState()

Over-ride for button state control for disabled to work.

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