Expand all

mw.libs.ve.targetLoader

Methods

addPlugin(plugin)static #

Add a plugin module or callback.

If a module name is passed, that module will be loaded alongside the other modules.

If a callback is passed, it will be executed after the modules have loaded. The callback may optionally return a jQuery.Promise; if it does, loading won't be complete until that promise is resolved.

Parameters:

Name Type Description
plugin string | function

Plugin module name or callback

Source:
Add a plugin module or callback.

createCheckboxFields(checkboxesDef, [widgetConfig]) → {Object}static #

Creates an OOUI checkbox inside an inline field layout

Parameters:

Name Type Attributes Description
checkboxesDef Array.<Object>

Checkbox definitions from the API

widgetConfig Object optional

Additional widget config

Source:

Returns:

Result object with checkboxFields (OO.ui.FieldLayout[]) and checkboxesByName (keyed object of OO.ui.CheckboxInputWidget).

Type
Object
Creates an OOUI checkbox inside an inline field layout

loadModules(mode) → {jQuery.Promise}static #

Load modules needed for VisualEditor, as well as plugins.

This loads the base VE modules as well as any registered plugin modules. Once those are loaded, any registered plugin callbacks are executed, and we wait for all promises returned by those callbacks to resolve.

Parameters:

Name Type Description
mode string

Initial editor mode, for tracking

Source:

Returns:

Promise resolved when the loading process is complete

Type
jQuery.Promise
Load modules needed for VisualEditor, as well as plugins.

requestPageData(mode, pageName, [options]) → {jQuery.Promise}static #

Request the page data and various metadata from the MediaWiki API (which will use Parsoid or RESTBase).

Parameters:

Name Type Attributes Description
mode string

Target mode: 'visual' or 'source'

pageName string

Page name to request, in prefixed DB key form (underscores instead of spaces)

options Object optional
Properties:
Name Type Attributes Description
sessionStore boolean optional

Store result in session storage (by page+mode+section) for auto-save

section null | string optional

Section to edit; number, 'T-'-prefixed, null or 'new' (currently just source mode)

oldId number optional

Old revision ID. Current if omitted.

targetName string optional

Optional target name for tracking

modified boolean optional

The page has been modified before loading (e.g. in source mode)

wikitext string optional

Wikitext to convert to HTML. The original document is fetched if undefined.

editintro string optional

Name of a page to use as edit intro message

preload string optional

Name of a page to use as preloaded content if pageName is empty

preloadparams Array.<string> optional

Parameters to substitute into preload if it's used

Source:

Returns:

Abortable promise resolved with a JSON object

Type
jQuery.Promise

Request the page data and various metadata from the MediaWiki API (which will use Parsoid or RESTBase).

requestParsoidData(pageName, [options], [noRestbase], [noMetadata]) → {jQuery.Promise}static #

Request the page HTML and various metadata from the MediaWiki API (which will use Parsoid or RESTBase).

Parameters:

Name Type Attributes Default Description
pageName string

See #requestPageData

options Object optional

See #requestPageData

noRestbase boolean optional
false

Don't query RESTBase directly

noMetadata boolean optional
false

Don't fetch document metadata when querying RESTBase. Metadata is not required for some use cases, e.g. diffing.

Source:

Returns:

Abortable promise resolved with a JSON object

Type
jQuery.Promise

Request the page HTML and various metadata from the MediaWiki API (which will use Parsoid or RESTBase).

requestWikitext(pageName, [options]) → {jQuery.Promise}static #

Request the page wikitext and various metadata from the MediaWiki API.

Parameters:

Name Type Attributes Description
pageName string

See #requestPageData

options Object optional

See #requestPageData

Source:

Returns:

Abortable promise resolved with a JSON object

Type
jQuery.Promise
Request the page wikitext and various metadata from the MediaWiki API.