Show:
Extends: Y.Plugin.Base
Module: content-editable
Parent Module: editor

Creates a component to work with an elemment.

Constructor

ContentEditable

()

Methods

_defReadyFn

() private

Binds DOM events and fires the ready event

_DOMPaste

(
  • e
)
private

Simple pass thru handler for the paste event so we can do content cleanup

Parameters:

_getDefaultBlock

() String private

Retrieves defaultblock value from host attribute

Returns:

String:

_getDir

() String private

Retrieves dir value from host attribute

Returns:

String:

_getExtraCSS

() String private

Retrieves extracss value from host attribute

Returns:

String:

_getHostValue

(
  • The
)
String | Object private

Retrieves a value from host attribute

Parameters:

  • The Attr

    attribute which value should be returned from the host

Returns:

String | Object:

_getHTML

(
  • html
)
String private

Get the content from the container

Parameters:

  • html String

    The raw HTML from the container.

Returns:

String:

_instanceLoaded

(
  • inst
)
private

Called from the first YUI instance that sets up the internal instance. This loads the content into the ContentEditable element and attaches the contentready event.

Parameters:

  • inst YUI

    The internal YUI instance bound to the ContentEditable element

_onContentReady on the internal instance so that the modules are loaded properly.

() private

Called once the content is available in the ContentEditable element and calls the final use call

_onDomEvent

(
  • e
)
private

Generic handler for all DOM events fired by the Editor container. This handler takes the current EventFacade and augments it to fire on the ContentEditable host. It adds two new properties to the EventFacade called frameX and frameY which adds the scroll and xy position of the ContentEditable element to the original pageX and pageY of the event so external nodes can be positioned over the element. In case of ContentEditable element these will be equal to pageX and pageY of the container.

Parameters:

_setDir

(
  • value
)
String private

Sets the dir (language direction) attribute on the container.

Parameters:

  • value String

    The language direction

Returns:

String:

_setExtraCSS

(
  • css
)
String private

Set's the extra CSS on the instance.

Parameters:

  • css String

    The CSS style to be set as extra css

Returns:

String:

_setHTML

(
  • html
)
String private

Set the content of the container

Parameters:

  • html String

    The raw HTML to set to the container.

Returns:

String:

_setLang

(
  • value
)
String private

Sets the language value on the instance.

Parameters:

  • value String

    The language to be set

Returns:

String:

_setLinkedCSS

(
  • css
)
String private

Sets the linked CSS on the instance.

Parameters:

  • css String

    The linkedcss value

Returns:

String:

_validateLinkedCSS

() private

Validates linkedcss property

delegate

(
  • type
  • fn
  • cont
  • sel
)
EventHandle

A delegate method passed to the instance's delegate method

Parameters:

  • type String

    The type of event to listen for

  • fn Function

    The method to attach

  • cont String, Node

    The container to act as a delegate, if no "sel" passed, the container is assumed.

  • sel String

    The selector to match in the event (optional)

Returns:

EventHandle:

The Event handle returned from Y.delegate

destructor

() protected

Destroys the instance.

focus

(
  • fn
)
ContentEditable chainable

Set the focus to the container

Parameters:

  • fn Function

    Callback function to execute after focus happens

Returns:

getInstance

() YUI

Get a reference to the internal YUI instance.

Returns:

YUI:

The internal YUI instance

hide

() ContentEditable chainable

Hide the iframe instance

Returns:

initializer

() protected

Initializes the ContentEditable instance

render

(
  • node
)
ContentEditable chainable

Parameters:

  • node String/HTMLElement/Node

    The node to render to

Returns:

show

() ContentEditable chainable

Show the iframe instance

Returns:

use

()

This is a scoped version of the normal YUI.use method & is bound to the ContentEditable element At setup, the inst.use method is mapped to this method.

Properties

_instance

YUI private

Internal reference to the YUI instance bound to the element

_rendered

Boolean private

Internal reference set when render is called.

DOM_EVENTS

Object static

The DomEvents that the frame automatically attaches and bubbles

HTML

String static

The template string used to create the ContentEditable element

NAME

String static

The name of the class (contentEditable)

NS

String static

The namespace on which ContentEditable plugin will reside.

Default: 'contentEditable'

THROTTLE_TIME

Number static

The throttle time for key events in IE

Default: 100

Attributes

container

String/HTMLElement/Node

The container to set contentEditable=true or to create on render.

content

String

The string to inject as Editor content. Default '<br>'

defaultblock

String

The default tag to use for block level items, defaults to: p

dir

String

The default text direction for this ContentEditable element. Default: ltr

extracss

String

A string of CSS to add to the Head of the Editor

id

String

Set the id of the new Node. (optional)

lang

String

The default language. Default: en-US

linkedcss

String | Array

An array of url's to external linked style sheets

node

Node

The Node instance of the container.

use

Array

Array of modules to include in the scoped YUI instance at render time. Default: ['node-base', 'editor-selection', 'stylesheet']