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.ElementLinearData | 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 |
- Source:
Returns:
- Type
- ve.ui.LinearContext
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 |
- Source:
Returns:
Surface model
- Type
- ve.dm.Surface
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 |
- Source:
Returns:
Promise which resolves with a progress bar widget and fails if cancelled
- Type
- jQuery.Promise
createView(model) → {ve.ce.Surface}
#
Create a surface view
Parameters:
Name | Type | Description |
---|---|---|
model |
ve.dm.Surface | Surface model |
- Source:
Returns:
Surface view
- Type
- ve.ce.Surface
destroy() → {ve.ui.Surface}chainable
#
Destroy the surface, releasing all memory and removing all DOM elements.
- Source:
Returns:
- Type
- ve.ui.Surface
Fires:
execute(triggerOrAction, [method], […args]) → {boolean}
#
Execute an action or command
This is a compatability 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 |
- Source:
Returns:
Action or command was executed
- Type
- boolean
Execute an action or command
This is a compatability wrapper for executeCommandWithSource.
executeCommand(commandName) → {boolean}
#
Execute a command by name
Parameters:
Name | Type | Description |
---|---|---|
commandName |
string | Command name |
- Source:
Returns:
The command was executed
- Type
- boolean
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 |
- Source:
Returns:
Action or command was executed
- Type
- boolean
focus()
#
Give focus to the surface
- Source:
getBoundingClientRect() → {Object|null
}
#
null
}
#
Get the bounding rectangle of the surface, relative to the viewport.
- Source:
Returns:
Object with top, bottom, left, right, width and height properties. Null if the surface is not attached.
- Type
-
Object
|
null
getCommands() → {Array.<string>}
#
getContext() → {ve.ui.LinearContext}
#
getDialogs() → {ve.ui.WindowManager}
#
getDir() → {string}
#
Surface 'dir' property (GUI/User-Level Direction)
- Source:
Returns:
'ltr' or 'rtl'
- Type
- string
getDom() → {HTMLDocument|string}
#
Get the DOM representation of the surface's current state.
- Source:
Returns:
HTML document (visual mode) or text (source mode)
- Type
- HTMLDocument | string
getGlobalOverlay() → {ve.ui.Overlay}
#
Get the global overlay.
Global overlays are attached to the top-most frame.
- Source:
Returns:
Global overlay
- Type
- ve.ui.Overlay
getHtml() → {string}
#
Get the HTML representation of the surface's current state.
- Source:
Returns:
HTML
- Type
- string
getImportRules() → {Object}
#
getInDialog() → {string}
#
Get the name of the dialog this surface is in
- Source:
Returns:
The name of the dialog this surface is in
- Type
- string
getLocalOverlay() → {ve.ui.Overlay}
#
Get the local overlay.
Local overlays are attached to the same frame as the surface.
- Source:
Returns:
Local overlay
- Type
- ve.ui.Overlay
getMode() → {string}
#
Get the surface's editing mode
- Source:
Returns:
Editing mode
- Type
- string
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 obsured 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.
- Source:
Returns:
Get the current content area padding
Padding in this context means areas of the surface which are rendered but are obsured by some other UI element, e.g.
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 |
- Source:
Returns:
Toolbar dialogs window set
- Type
- ve.ui.WindowManager
getView() → {ve.ce.Surface}
#
getViewportDimensions() → {Object|null
}
#
null
}
#
Get vertical measurements of the visible area of the surface viewport
- Source:
Returns:
Object with top, left, bottom, and height properties. Null if the surface is not attached.
- Type
-
Object
|
null
initialize() → {ve.ui.Surface}chainable
#
Initialize surface.
This must be called after the surface has been attached to the DOM.
- Source:
Returns:
- Type
- ve.ui.Surface
Fires:
isMultiline() → {boolean}
#
Check if the surface is multi-line
- Source:
Returns:
Surface is multi-line
- Type
- boolean
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([wasSynchronizing])
#
Handle position events from the view
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
wasSynchronizing |
boolean |
optional |
- 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 |
- Source:
Fires:
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. |
- 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 |
- Source:
Fires:
setupDebugBar()
#
Set up the debug bar and insert it into the DOM.
- 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:
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: