Expand all

abstract ve.init.Target

Extends

Constructor

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

Generic Initialization target.

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

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

Configuration options for the toolbar

toolbarGroups Array.<Object> optional

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

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

$scrollContainer #

Properties:

Name Type Description
$scrollContainer jQuery
Source:

$scrollListener #

Properties:

Name Type Description
$scrollListener jQuery
Source:

activeToolbars #

Properties:

Name Type Description
activeToolbars number
Source:

modes #

Properties:

Name Type Description
modes Array.<string>
Source:

surface #

Properties:

Name Type Description
surface ve.ui.Surface | null
Source:

surfaces #

Properties:

Name Type Description
surfaces Array.<ve.ui.Surface>
Source:

teardownPromise #

Properties:

Name Type Description
teardownPromise jQuery.Promise | null
Source:

toolbar #

Properties:

Name Type Description
toolbar ve.ui.TargetToolbar | null
Source:

toolbarConfig #

Properties:

Name Type Description
toolbarConfig Object
Source:

toolbarGroups #

Properties:

Name Type Description
toolbarGroups Array.<Object>
Source:

toolbarScrollOffset #

Properties:

Name Type Description
toolbarScrollOffset number
Source:

wasSurfaceActive #

Properties:

Name Type Description
wasSurfaceActive boolean | null
Source:

allowTabFocusChange :booleanstatic #

Allow changing focus from target surfaces with tab/shift+tab

Prevents any ve.ui.Trigger's using these shortcuts from running.

Type:

  • boolean
Source:

Allow changing focus from target surfaces with tab/shift+tab

Prevents any ve.ui.Trigger's using these shortcuts from running.

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

enforceResizesContent :booleanstatic #

Enforce interactive-widget=resizes-content

When this target is setup, enforce interactive-widget=resizes-content in the tag.

This should be done if the target uses a position:fixed toolbar on a device which may have a virtual keyboard.

Type:

  • boolean
Source:

Enforce interactive-widget=resizes-content

When this target is setup, enforce interactive-widget=resizes-content in the tag.

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.LinearData#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

Returns:

Type
ve.ui.Surface
Source:
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

Returns:

Type
ve.ui.Surface
Source:
Create a surface.

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

Create a target widget.

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Returns:

Type
ve.ui.TargetWidget
Source:
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

Returns:

Promise which resolves when the target has been destroyed

Type
jQuery.Promise
Source:
Destroy the target

getDefaultMode() → {string} #

Get default editing mode for new surfaces

Returns:

Editing mode

Type
string
Source:
Get default editing mode for new surfaces

getScrollContainer() → {jQuery} #

Get the target's scroll container

Returns:

The target's scroll container

Type
jQuery
Source:
Get the target's scroll container

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

Get the target's active surface, if it exists

Returns:

Type
ve.ui.Surface | null
Source:
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

Returns:

Surface configuration options

Type
Object
Source:
Get surface configuration options

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

Get the target's toolbar, if it exists

Returns:

Type
ve.ui.TargetToolbar | null
Source:
Get the target's toolbar, if it exists

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

Get an object describing the amount of padding the toolbar adds to the surface.

Returns:

Padding object, or null

Type
ve.ui.Surface.Padding | null
Source:
Get an object describing the amount of padding the toolbar adds to the surface.

isModeAvailable(mode) → {boolean} #

Check if a specific editing mode is available

Parameters:

Name Type Description
mode string

Editing mode

Returns:

Editing mode is available

Type
boolean
Source:
Check if a specific editing mode is available

isVirtualKeyboardOpen() → {boolean} #

Check if a virtual keyboard is open

Returns:

Whether a keyboard is open

Type
boolean
Source:
Check if a virtual keyboard is open

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

onVirtualKeyboardChange() #

Handle events which may have changed the visibility of the virtual keyboard

Fires:

Source:
Handle events which may have changed the visibility of the virtual keyboard

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(newSurface) #

Set up the toolbar if it doesn't exist, and attach it to a surface

If the toolbar already exists it can still be attached to another surface.

Parameters:

Name Type Description
newSurface ve.ui.Surface
Source:

Set up the toolbar if it doesn't exist, and attach it to a surface

If the toolbar already exists it can still be attached to another surface.

setupTriggerListeners() #

Set up trigger listeners

Source:
Set up trigger listeners

teardown() → {jQuery.Promise} #

Teardown the target, removing all surfaces, toolbars and handlers

Returns:

Promise which resolves when the target has been torn down

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

teardownToolbar() → {jQuery.Promise} #

Teardown the toolbar

Returns:

Promise which resolves when the toolbar has been torn down

Type
jQuery.Promise
Source:
Teardown the toolbar

toggleResizesContent([set]) #

Toggle "resizes content" mode of the viewport

See #static-enforceResizesContent

Parameters:

Name Type Attributes Default Description
set boolean optional
false

Set (true) or restore initial value (false)

Source:

Toggle "resizes content" mode of the viewport

See #static-enforceResizesContent

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

Returns:

Document model

Type
ve.dm.Document
Source:
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

Returns:

HTML document, or document string (source mode)

Type
HTMLDocument | string
Source:
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

virtualKeyboardChange(isOpen) #

The virtual keyboard has been opened or closed

Parameters:

Name Type Description
isOpen boolean

The virtual keyboard is open

Source:
The virtual keyboard has been opened or closed