Expand all

abstract ve.init.Target

Extends

Constructor

new ve.init.Target([config], [register])abstract #

Generic Initialization target.

Parameters:

Name Type Attributes Default Description
config Object optional

Configuration options

Properties:
Name Type Attributes Default Description
toolbarConfig Object optional
{}

Configuration options for the toolbar

toolbarGroups Object optional

Toolbar groups, defaults to this.constructor.static.toolbarGroups

actionGroups Object optional

Toolbar groups, defaults to this.constructor.static.actionGroups

modes Array.<string> optional

Available editing modes. Defaults to static.modes

defaultMode string optional

Default mode for new surfaces. Must be in this.modes and defaults to first item.

register boolean optional
true

Register the target at ve.init.target

Mixes in:
Source:
Generic Initialization target.

Properties

actionGroupsstatic #

Toolbar definition for the actions side of the toolbar

Properties:

Type Description
Array
Deprecated:
  • Use align:'after' in the regular toolbarGroups instead.
Source:
Toolbar definition for the actions side of the toolbar

annotateImportedData :booleanstatic #

Apply the meta/importedData annotation to pasted/dropped data

Type:

  • boolean
Source:
Apply the meta/importedData annotation to pasted/dropped data

documentCommands :Array.<string>static #

List of commands which can be triggered anywhere from within the document

Type:

Source:
List of commands which can be triggered anywhere from within the document

excludeCommands :Array.<string>static #

List of commands to exclude from the target entirely

Type:

Source:
List of commands to exclude from the target entirely

importRules :Objectstatic #

Surface import rules

One set for external (non-VE) paste sources and one for all paste sources.

Most rules are handled in ve.dm.ElementLinearData#sanitize, but htmlBlacklist is handled in ve.ce.Surface#afterPaste.

Type:

Source:

Surface import rules

One set for external (non-VE) paste sources and one for all paste sources.

includeCommands :Array.<string>|nullstatic #

List of commands to include in the target

Null means all commands in the registry are used (excluding excludeCommands)

Type:

Source:

List of commands to include in the target

Null means all commands in the registry are used (excluding excludeCommands)

modesstatic #

Editing modes available in the target.

Must contain at least one mode. Overridden if the #modes config option is used.

Properties:

Type Description
Array.<string>
Source:
Editing modes available in the target.

targetCommands :Array.<string>static #

List of commands which can be triggered from within the target element

Type:

Source:
List of commands which can be triggered from within the target element

toolbarGroupsstatic #

Toolbar definition, passed to ve.ui.Toolbar#setup

Properties:

Type Description
Array
Source:
Toolbar definition, passed to ve.ui.Toolbar#setup

Methods

activateSurfaceForToolbar()protected #

Activate the surface. Restore any properties saved in #deactivate.

Source:
Activate the surface.

addSurface(dmDocOrSurface, [config]) → {ve.ui.Surface} #

Add a surface to the target

Parameters:

Name Type Attributes Description
dmDocOrSurface ve.dm.Document | ve.dm.Surface

Document model or surface model

config Object optional

Configuration options

Source:

Returns:

Type
ve.ui.Surface
Add a surface to the target

attachToolbar() #

Attach the toolbar to the DOM

Source:
Attach the toolbar to the DOM

bindHandlers() #

Bind event handlers to target and document

Source:
Bind event handlers to target and document

clearSurfaces() #

Destroy and remove all surfaces from the target

Source:
Destroy and remove all surfaces from the target

createSurface(dmDocOrSurface, [config]) → {ve.ui.Surface} #

Create a surface.

Parameters:

Name Type Attributes Description
dmDocOrSurface ve.dm.Document | ve.dm.Surface

Document model or surface model

config Object optional

Configuration options

Source:

Returns:

Type
ve.ui.Surface
Create a surface.

createTargetWidget([config]) → {ve.ui.TargetWidget} #

Create a target widget.

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Source:

Returns:

Type
ve.ui.TargetWidget
Create a target widget.

deactivateSurfaceForToolbar()protected #

Deactivate the surface. Maybe save some properties that should be restored when it's activated.

Source:
Deactivate the surface.

destroy() → {jQuery.Promise} #

Destroy the target

Source:

Returns:

Promise which resolves when the target has been destroyed

Type
jQuery.Promise
Destroy the target

getActions() → {ve.ui.TargetToolbar} #

Get the actions toolbar

Deprecated:
  • Yes
Source:

Returns:

Actions toolbar (same as the normal toolbar)

Type
ve.ui.TargetToolbar
Get the actions toolbar

getDefaultMode() → {string} #

Get default editing mode for new surfaces

Source:

Returns:

Editing mode

Type
string
Get default editing mode for new surfaces

getScrollContainer() → {jQuery} #

Get the target's scroll container

Source:

Returns:

The target's scroll container

Type
jQuery
Get the target's scroll container

getSurface() → {ve.ui.Surface|null} #

Get the target's active surface, if it exists

Source:

Returns:

Type
ve.ui.Surface | null
Get the target's active surface, if it exists

getSurfaceConfig(config) → {Object} #

Get surface configuration options

Parameters:

Name Type Description
config Object

Configuration option overrides

Source:

Returns:

Surface configuration options

Type
Object
Get surface configuration options

getToolbar() → {ve.ui.TargetToolbar} #

Get the target's toolbar

Source:

Returns:

Toolbar

Type
ve.ui.TargetToolbar
Get the target's toolbar

isModeAvailable(mode) → {boolean} #

Check if a specific editing mode is available

Parameters:

Name Type Description
mode string

Editing mode

Source:

Returns:

Editing mode is available

Type
boolean
Check if a specific editing mode is available

onContainerScroll() #

Handle scroll container scroll events

Source:
Handle scroll container scroll events

onDocumentKeyDown(e) #

Handle key down events on the document

Parameters:

Name Type Description
e jQuery.Event

Key down event

Source:
Handle key down events on the document

onDocumentKeyUp(e) #

Handle key up events on the document

Parameters:

Name Type Description
e jQuery.Event

Key up event

Source:
Handle key up events on the document

onDocumentVisibilityChange(e) #

Handle visibility change events on the document

Parameters:

Name Type Description
e jQuery.Event

Visibility change event

Source:
Handle visibility change events on the document

onSurfaceViewFocus(surface) #

Handle focus events from a surface's view

Parameters:

Name Type Description
surface ve.ui.Surface

Surface firing the event

Source:
Handle focus events from a surface's view

onTargetKeyDown(e) #

Handle key down events on the target

Parameters:

Name Type Description
e jQuery.Event

Key down event

Source:
Handle key down events on the target

onToolbarActive(active) #

Handle active events from the toolbar

Parameters:

Name Type Description
active boolean

The toolbar is active

Source:
Handle active events from the toolbar

onToolbarResize() #

Handle toolbar resize events

Source:
Handle toolbar resize events

setDefaultMode(defaultMode) #

Set default editing mode for new surfaces

Parameters:

Name Type Description
defaultMode string

Editing mode, see static.modes

Source:
Set default editing mode for new surfaces

setSurface(surface) #

Set the target's active surface

Parameters:

Name Type Description
surface ve.ui.Surface
Source:
Set the target's active surface

setupToolbar(surface) #

Set up the toolbar, attaching it to a surface.

Parameters:

Name Type Description
surface ve.ui.Surface
Source:
Set up the toolbar, attaching it to a surface.

setupTriggerListeners() #

Set up trigger listeners

Source:
Set up trigger listeners

teardown() → {jQuery.Promise} #

Teardown the target, removing all surfaces, toolbars and handlers

Source:

Returns:

Promise which resolves when the target has been torn down

Type
jQuery.Promise
Teardown the target, removing all surfaces, toolbars and handlers

teardownToolbar() → {jQuery.Promise} #

Teardown the toolbar

Source:

Returns:

Promise which resolves when the toolbar has been torn down

Type
jQuery.Promise
Teardown the toolbar

unbindHandlers() #

Unbind event handlers on target and document

Source:
Unbind event handlers on target and document

createModelFromDom(doc, mode, options) → {ve.dm.Document}static #

Create a document model from an HTML document.

Parameters:

Name Type Description
doc HTMLDocument | string

HTML document or source text

mode string

Editing mode

options Object

Conversion options

Source:

Returns:

Document model

Type
ve.dm.Document
Create a document model from an HTML document.

parseDocument(documentString, mode) → {HTMLDocument|string}static #

Parse document string into an HTML document

Parameters:

Name Type Description
documentString string

Document. Note that this must really be a whole document with a single root tag.

mode string

Editing mode

Source:

Returns:

HTML document, or document string (source mode)

Type
HTMLDocument | string
Parse document string into an HTML document

Events

surfaceReady() #

Must be fired after the surface is initialized

Source:
Must be fired after the surface is initialized