Expand all

abstract ve.ce.FocusableNode

Constructor

new ve.ce.FocusableNode([$focusable], [config])abstract #

ContentEditable focusable node.

Focusable elements have a special treatment by ve.ce.Surface. When the user selects only a single node, if it is focusable, the surface will set the focusable node's focused state. Other systems, such as the context, may also use a focusable node's $focusable property as a hint of where the primary element in the node is. Typically, and by default, the primary element is the root element, but in some cases it may need to be configured to be a specific child element within the node's DOM rendering.

If your focusable node changes size and the highlight must be redrawn, call redrawHighlights(). 'resizeEnd' and 'rerender' are already bound to call this.

Parameters:

Name Type Attributes Default Description
$focusable jQuery optional
this.$element

Primary element user is focusing on

config Object optional

Configuration options

Properties:
Name Type Attributes Default Description
$bounding jQuery optional
$focusable

Element to consider for bounding box calculations (e.g. attaching inspectors)

classes Array.<string> optional

CSS classes to be added to the highlight container

Source:
ContentEditable focusable node.

Properties

deleteCommandNamestatic #

Command to execute when Delete or Backspace is pressed while this node is focused.

Properties:

Type Description
string | null
Source:
Command to execute when Delete or Backspace is pressed while this node is focused.

iconWhenInvisiblestatic #

Icon to use when the rendering is considered not visible, as defined in #hasRendering

No icon is show if null.

Properties:

Type Description
string | null
Source:

Icon to use when the rendering is considered not visible, as defined in #hasRendering

No icon is show if null.

primaryCommandNamestatic #

Command to execute when Enter is pressed while this node is focused, or when the node is double-clicked.

Properties:

Type Description
string | null
Source:
Command to execute when Enter is pressed while this node is focused, or when the node is double-clicked.

Methods

calculateHighlights() #

Re-calculate position of highlights

Source:
Re-calculate position of highlights

clearHighlights() #

Clears highlight.

Source:
Clears highlight.

createHighlight() → {jQuery} #

Create a highlight element.

Source:

Returns:

A highlight element

Type
jQuery
Create a highlight element.

createHighlights() #

Creates highlights.

Source:
Creates highlights.

createInvisibleIcon() #

Create a element to show if the node is invisible

Source:
Create a element to show if the node is invisible

executeCommand() #

Execute the command associated with this node.

Source:
Execute the command associated with this node.

getBoundingRect() → {Object|null} #

Get the bounding rectangle of the focusable node highlight relative to the surface

Source:

Returns:

Top, left, bottom & right positions of the focusable node relative to the surface

Type
Object | null
Get the bounding rectangle of the focusable node highlight relative to the surface

getExtraHighlightClasses() → {Array.<string>} #

Array of CSS classes to add to highlights

Source:

Returns:

Type
Array.<string>
Array of CSS classes to add to highlights

getInvisibleIconLabel() → {jQuery|string|OO.ui.HtmlSnippet|function|null} #

Get a label for the invisible icon

Defaults to #getDescription

Source:

Returns:

Invisible icon label

Type
jQuery | string | OO.ui.HtmlSnippet | function | null

Get a label for the invisible icon

Defaults to #getDescription

getRects() → {Array.<Object>} #

Get list of rectangles outlining the shape of the node relative to the surface

Source:

Returns:

List of rectangle objects

Type
Array.<Object>
Get list of rectangles outlining the shape of the node relative to the surface

getStartAndEndRects() → {Object.<string, Object>|null} #

Get start and end rectangles of an inline focusable node relative to the surface

Source:

Returns:

Start and end rectangles

Type
Object.<string, Object> | null
Get start and end rectangles of an inline focusable node relative to the surface

hasRendering() → {boolean} #

Check if the rendering is visible

"Visible", in this case, is defined as at least 10px × 4px or 4px × 10px in dimensions (T307527)

Source:

Returns:

The node has a visible rendering

Type
boolean

Check if the rendering is visible

"Visible", in this case, is defined as at least 10px × 4px or 4px × 10px in dimensions (T307527)

isFocused() → {boolean} #

Check if node is focused.

Source:

Returns:

Node is focused

Type
boolean
Check if node is focused.

isInContentEditableDisabled() → {boolean} #

Check if the node is inside a ve.ce.ContentEditableNode with editing disabled

Ignore nodes which just disable CE in the DOM manually (e.g. TableNode) as focusables should still be highlightable in these.

Source:

Returns:

Editing disabled

Type
boolean

Check if the node is inside a ve.ce.ContentEditableNode with editing disabled

Ignore nodes which just disable CE in the DOM manually (e.g.

onFocusableDblClick(e) #

Handle highlight double click events.

Parameters:

Name Type Description
e jQuery.Event

Double click event

Source:
Handle highlight double click events.

onFocusableDragEnd(e) #

Handle element drag end.

If a relocation actually takes place the node is destroyed before this events fires.

Parameters:

Name Type Description
e jQuery.Event

Drag end event

Source:
Handle element drag end.

onFocusableDragStart(e) #

Handle element drag start.

Parameters:

Name Type Description
e jQuery.Event

Drag start event

Source:
Handle element drag start.

onFocusableMouseDown(e) #

Handle highlight mouse down events.

Parameters:

Name Type Description
e jQuery.Event

Mouse down event

Source:
Handle highlight mouse down events.

onFocusableMouseEnter(e) #

Handle mouse enter events.

Parameters:

Name Type Description
e jQuery.Event

Mouse enter event

Source:
Handle mouse enter events.

onFocusableRerender() #

Handle rerender event.

Source:
Handle rerender event.

onFocusableResizeEnd() #

Handle resize end event.

Source:
Handle resize end event.

onFocusableResizeStart() #

Handle resize start events.

Source:
Handle resize start events.

onFocusableSetup() #

Handle node setup.

Source:
Handle node setup.

onFocusableTeardown() #

Handle node teardown.

Source:
Handle node teardown.

onFocusableTouchMove(e) #

Handle touch move events.

Parameters:

Name Type Description
e jQuery.Event

Touch move event

Source:
Handle touch move events.

onFocusableTouchStart(e) #

Handle touch start events.

Parameters:

Name Type Description
e jQuery.Event

Touch start event

Source:
Handle touch start events.

onSurfaceActivation() #

Handle activation events from the surface

Source:
Handle activation events from the surface

onSurfaceMouseLeave(e) #

Handle surface mouse leave events.

Parameters:

Name Type Description
e jQuery.Event

Mouse leave event

Source:
Handle surface mouse leave events.

onSurfaceMouseMove(e) #

Handle surface mouse move events.

Parameters:

Name Type Description
e jQuery.Event

Mouse move event

Source:
Handle surface mouse move events.

positionHighlights() #

Positions highlights, and remove collapsed ones

Source:
Positions highlights, and remove collapsed ones

redrawHighlights() #

Redraws highlight.

Source:
Redraws highlight.

setFocused(value) #

Set the selected state of the node.

Parameters:

Name Type Description
value boolean

Node is focused

Source:

Fires:

Set the selected state of the node.

updateInvisibleIcon() #

Update the state of icon if this node is invisible

If the node doesn't have a visible rendering, we insert an icon to represent it. If the icon was already present, and this is called again when rendering has developed, we remove the icon.

Source:

Update the state of icon if this node is invisible

If the node doesn't have a visible rendering, we insert an icon to represent it.

updateInvisibleIconLabel() #

Update the invisible icon's label

Source:
Update the invisible icon's label

updateInvisibleIconSync(showIcon)private #

Synchronous part of #updateInvisibleIconSync

Parameters:

Name Type Description
showIcon boolean

Show the icon

Source:
Synchronous part of #updateInvisibleIconSync

getRectsForElement($element, [relativeRect]) → {Object}static #

Get rects for an element

Parameters:

Name Type Attributes Description
$element jQuery

Element to get highlights

relativeRect Object optional

Rect with top & left to get position relative to

Source:

Returns:

Object containing rects and boundingRect

Type
Object
Get rects for an element

Events