Extends
Constructor
new ve.ui.Surface(target, dataOrDocOrSurface, [config])abstract
#
Hierarchy
A surface is a top-level object which contains both a surface model and a surface view.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
target |
ve.init.Target | Target the surface belongs to |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dataOrDocOrSurface |
HTMLDocument | Array | ve.dm.LinearData | ve.dm.Document | ve.dm.Surface | Document data, document model, or surface model to edit |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config |
Object |
optional |
Configuration options Properties:
|
- Source:
Methods
adjustVisiblePadding()
#
Adjust visible padding on the surface to allow the whole document to be scrolled to.
- Source:
Adjust visible padding on the surface to allow the whole document to be scrolled to.
createContext(config) → {ve.ui.LinearContext}
#
Create a context.
Parameters:
| Name | Type | Description |
|---|---|---|
config |
Object | Configuration options |
Returns:
- Type
- ve.ui.LinearContext
- Source:
createDialogWindowManager() → {ve.ui.WindowManager}
#
createModel(doc, [attachedRoot]) → {ve.dm.Surface}
#
Create a surface model
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
doc |
ve.dm.Document | Document model |
|
attachedRoot |
ve.dm.BranchNode |
optional |
Node to surface |
Returns:
Surface model
- Type
- ve.dm.Surface
- Source:
createProgress(progressCompletePromise, label, nonCancellable) → {jQuery.Promise}
#
Create a progress bar in the progress dialog
Parameters:
| Name | Type | Description |
|---|---|---|
progressCompletePromise |
jQuery.Promise | Promise which resolves when the progress action is complete |
label |
jQuery | string | function | Progress bar label |
nonCancellable |
boolean | Progress item can't be cancelled |
Returns:
Promise which resolves with a progress bar widget and fails if cancelled
- Type
- jQuery.Promise
- Source:
createSidebarWindowManager() → {ve.ui.WindowManager}
#
createView(model) → {ve.ce.Surface}
#
Create a surface view
Parameters:
| Name | Type | Description |
|---|---|---|
model |
ve.dm.Surface | Surface model |
Returns:
Surface view
- Type
- ve.ce.Surface
- Source:
destroy() → {ve.ui.Surface}chainable
#
Destroy the surface, releasing all memory and removing all DOM elements.
Returns:
- Type
- ve.ui.Surface
Fires:
- Source:
doesAllowTabFocusChange() → {boolean}
#
Does the surface allow changing focus from target surfaces with tab/shift+tab
Returns:
- Type
- boolean
- Source:
execute(triggerOrAction, [method], […args]) → {boolean}
#
Execute an action or command
This is a compatibility wrapper for executeCommandWithSource.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
triggerOrAction |
ve.ui.Trigger | string | Trigger or symbolic name of action |
|
method |
string |
optional |
Action method name |
args |
any |
optional repeatable |
Additional arguments for action |
Returns:
Action or command was executed
- Type
- boolean
- Source:
Execute an action or command
This is a compatibility wrapper for executeCommandWithSource.
executeCommand(commandName) → {boolean}
#
Execute a command by name
Parameters:
| Name | Type | Description |
|---|---|---|
commandName |
string | Command name |
Returns:
The command was executed
- Type
- boolean
- Source:
executeWithSource(triggerOrAction, [method], [source], […args]) → {boolean}
#
Execute an action or command
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
triggerOrAction |
ve.ui.Trigger | string | Trigger or symbolic name of action |
|
method |
string |
optional |
Action method name |
source |
string |
optional |
Action source, for logging |
args |
any |
optional repeatable |
Additional arguments for action |
Returns:
Action or command was executed
- Type
- boolean
- Source:
focus()
#
Give focus to the surface
- Source:
getBoundingClientRect() → {Object|null}
#
null}
#
Get the bounding rectangle of the surface, relative to the viewport.
Returns:
Object with top, bottom, left, right, width and height properties. Null if the surface is not attached.
- Type
-
Object
|
null
- Source:
getCommands() → {Array.<string>}
#
getContext() → {ve.ui.LinearContext}
#
getDialogs() → {ve.ui.WindowManager}
#
getDir() → {string}
#
Surface 'dir' property (GUI/User-Level Direction)
Returns:
'ltr' or 'rtl'
- Type
- string
- Source:
getDom() → {HTMLDocument|string}
#
Get the DOM representation of the surface's current state.
Returns:
HTML document (visual mode) or text (source mode)
- Type
- HTMLDocument | string
- Source:
getGlobalOverlay() → {ve.ui.Overlay}
#
Get the global overlay.
Global overlays are attached to the top-most frame.
Returns:
Global overlay
- Type
- ve.ui.Overlay
- Source:
getHtml() → {string}
#
Get the HTML representation of the surface's current state.
Returns:
HTML
- Type
- string
- Source:
getImportRules() → {Object}
#
getInDialog() → {string}
#
Get the name of the dialog this surface is in
Returns:
The name of the dialog this surface is in
- Type
- string
- Source:
getLocalOverlay() → {ve.ui.Overlay}
#
Get the local overlay.
Local overlays are attached to the same frame as the surface.
Returns:
Local overlay
- Type
- ve.ui.Overlay
- Source:
getMode() → {string}
#
Get the surface's editing mode
Returns:
Editing mode
- Type
- string
- Source:
getModel() → {ve.dm.Surface}
#
getPadding() → {ve.ui.Surface.Padding}
#
Get the current content area padding
Padding in this context means areas of the surface which are rendered but are obscured by some other UI element, e.g. a floating toolbar (but not a static toolbar).
This can be used when deciding how to position other floating UI elements, e.g. to avoid rendering a context menu under a floating toolbar.
Returns:
- Source:
Get the current content area padding
Padding in this context means areas of the surface which are rendered but are obscured by some other UI element, e.g.
getSidebarDialogs() → {ve.ui.WindowManager}
#
Get sidebar dialogs window set.
Returns:
Sidebar dialogs window set
- Type
- ve.ui.WindowManager
- Source:
getTarget() → {ve.init.Target}
#
getToolbarDialogs([position]) → {ve.ui.WindowManager}
#
Get toolbar dialogs window set.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
position |
string |
optional |
'side' | Get the toolbar dialogs window set for a specific position |
Returns:
Toolbar dialogs window set
- Type
- ve.ui.WindowManager
- Source:
getView() → {ve.ce.Surface}
#
getViewportDimensions() → {Object|null}
#
null}
#
Get measurements of the visible area of the surface viewport
The bounding box returned is relative the viewport, e.g. a top value of 50 means the top 50px of the surface is outside the viewport.
Returns:
Object with top, bottom, left, right, width and height properties. Null if the surface is not attached.
- Type
-
Object
|
null
- Source:
Get measurements of the visible area of the surface viewport
The bounding box returned is relative the viewport, e.g.
initialize() → {ve.ui.Surface}chainable
#
Initialize surface.
This must be called after the surface has been attached to the DOM.
Returns:
- Type
- ve.ui.Surface
Fires:
- Source:
isMultiline() → {boolean}
#
Check if the surface is multi-line
Returns:
Surface is multi-line
- Type
- boolean
- Source:
isReadOnly() → {boolean}
#
onContextResize()
#
Handle resize events from the context
- Source:
onDocumentTransact(Transaction)
#
Handle transact events from the document model
Parameters:
| Name | Type | Description |
|---|---|---|
Transaction |
ve.dm.Transaction |
- Source:
onModelBlur()
#
Handle surface model blur events
- Source:
onModelFocus()
#
Handle surface model focus events
- Source:
onModelSelect()
#
Handle select events from the model
- Source:
onViewActivation()
#
Handle surface view activation events
- Source:
onViewPosition([passive])
#
Handle position events from the view
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
passive |
boolean |
optional |
false |
- Source:
recalculatePadding([scrollSelection])
#
Recalculate the content area padding based on the current state of the surface and visible components.
This should be called when the surface is resized or when UI components are toggled.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
scrollSelection |
boolean |
optional |
Scroll selection into view after recalculating padding |
- Source:
scrollSelectionIntoView([selectionModel], [scrollConfig])
#
Scroll the selection into view
Called in response to selection events.
This is done for all selections, even native ones, to account for the extra padding of the floating toolbar.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
selectionModel |
ve.dm.Selection |
optional |
Optional selection model, defaults to current selection |
scrollConfig |
Object |
optional |
Scroll config options, passed to ve.scrollIntoView |
Fires:
- Source:
Scroll the selection into view
Called in response to selection events.
setDisabled()
#
- Source:
setPadding(padding)
#
Set content area padding.
When UI components obscure the surface (e.g. the toolbar), set the appropriate amount of padding here so that scroll-into-view calculations can be adjusted.
Parameters:
| Name | Type | Description |
|---|---|---|
padding |
ve.ui.Surface.Padding | Padding object. Omit properties to leave unchanged. |
- Deprecated:
- The surface should calculate its own padding in recalculatePadding
- Source:
setPlaceholder([placeholder])
#
Set placeholder text
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
placeholder |
string |
optional |
Placeholder text, clears placeholder if not set |
- Source:
setReadOnly(readOnly)
#
Set the read-only state of the surface
Parameters:
| Name | Type | Description |
|---|---|---|
readOnly |
boolean | Make surface read-only |
Fires:
- Source:
setupDebugBar()
#
Set up the debug bar and insert it into the DOM.
- Source:
suppressScrollPadding(scrollPaddingSuppressed)
#
Suppress or unsuppress scroll padding adjustments.
This is set by the sticky toolbar when it is focussed to prevent a bug in Chromium browsers (https://issues.chromium.org/issues/40749247)
Parameters:
| Name | Type | Description |
|---|---|---|
scrollPaddingSuppressed |
boolean |
- Source:
updatePlaceholder()
#
Update placeholder rendering
- Source:
Type Definitions
Padding
#
Type:
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
top |
number |
optional |
Top padding |
right |
number |
optional |
Right padding |
bottom |
number |
optional |
Bottom padding |
left |
number |
optional |
Left padding |
- Source:
Events
cancel()
#
The surface has been cancelled by user action, e.g. Escape
- Source:
destroy()
#
When a surface is destroyed.
- Source:
padding()
#
The surface padding has changed
- Source:
readOnly(readOnly)
#
The surface read-only state has changed
Parameters:
| Name | Type | Description |
|---|---|---|
readOnly |
boolean | The surface is read-only |
- Source:
ready()
#
When a surface has been initialized
- Source:
scroll()
#
The surface was scrolled programmatically as a result of a native selection change
- Source:
The surface was scrolled programmatically as a result of a native selection change
submit()
#
The surface has been submitted by user action, e.g. Ctrl+Enter
- Source: