Expand all

mw.libs.ve.targetSaver

Methods

deflate(html) → {jQuery.Promise}static #

Compress a string with deflate.

Parameters:

Name Type Description
html string

HTML to deflate

Source:

Returns:

Promise resolved with deflated HTML

Type
jQuery.Promise
Compress a string with deflate.

deflateDoc(doc, [oldDoc]) → {jQuery.Promise}static #

Serialize and deflate an HTML document

Parameters:

Name Type Attributes Description
doc HTMLDocument

Document generated by ve.dm.Converter. Will be modified.

oldDoc HTMLDocument optional

Old document to copy attributes from.

Source:

Returns:

Promise resolved with deflated HTML

Type
jQuery.Promise
Serialize and deflate an HTML document

getHtml(newDoc, [oldDoc]) → {string}static #

Get HTML to send to Parsoid.

If the document was generated from scratch (e.g. inside VisualEditor's converter), the source document can be passed in to transplant the head tag, as well as the attributes on the html and body tags.

Parameters:

Name Type Attributes Description
newDoc HTMLDocument

Document generated by ve.dm.Converter. Will be modified.

oldDoc HTMLDocument optional

Old document to copy attributes from.

Source:

Returns:

Full HTML document

Type
string
Get HTML to send to Parsoid.

postContent(data, [options]) → {jQuery.Promise}static #

Post content to the API, using mw.Api#postWithToken to retry automatically when encountering a 'badtoken' error.

By default uses action=visualeditoredit, paction=save.

Parameters:

Name Type Attributes Description
data string

Content data

options Object optional
Properties:
Name Type Attributes Description
api mw.Api optional

Api to use

now function optional

Function returning current time in milliseconds for tracking, e.g. ve.now

track function optional

Tracking function

eventName string optional

Event name for tracking

Source:

Returns:

Promise which resolves with API save data, or rejects with error details

Type
jQuery.Promise

Post content to the API, using mw.Api#postWithToken to retry automatically when encountering a 'badtoken' error.

postHtml(html, [cacheKey], [extraData], [options]) → {jQuery.Promise}static #

Post HTML to the API.

By default uses action=visualeditoredit, paction=save.

Parameters:

Name Type Attributes Description
html string

HTML to post. Deflating is optional but recommended. Should be included for retries even if a cache key is provided.

cacheKey string optional

Optional cache key of HTML stashed on server.

extraData Object optional

Extra data to send to the API

options Object optional
Source:

Returns:

Promise which resolves with API save data, or rejects with error details

Type
jQuery.Promise
Post HTML to the API.

postWikitext(wikitext, [extraData], [options]) → {jQuery.Promise}static #

Post wikitext to the API.

By default uses action=visualeditoredit, paction=save.

Parameters:

Name Type Attributes Description
wikitext string

Wikitext to post. Deflating is optional but recommended.

extraData Object optional

Extra data to send to the API

options Object optional
Properties:
Name Type Attributes Description
api mw.Api optional

Api to use

now function optional

Function returning current time in milliseconds for tracking, e.g. ve.now

track function optional

Tracking function

eventName string optional

Event name for tracking

Source:

Returns:

Promise which resolves with API save data, or rejects with error details

Type
jQuery.Promise
Post wikitext to the API.

preloadDeflate()static #

Preload the library required for deflating so the user doesn't have to wait when postHtml is called.

Source:

Preload the library required for deflating so the user doesn't have to wait when postHtml is called.

saveDoc(doc, [extraData], [options]) → {jQuery.Promise}static #

Post an HTML document to the API.

Serializes the document to HTML, deflates it, then passes to #postHtml.

Parameters:

Name Type Attributes Description
doc HTMLDocument

Document to save

extraData Object optional

Extra data to send to the API

options Object optional
Source:

Returns:

Promise which resolves if the post was successful

Type
jQuery.Promise
Post an HTML document to the API.