Methods
deflate(html) → {jQuery.Promise}static
#
Compress a string with deflate.
Parameters:
Name | Type | Description |
---|---|---|
html |
string | HTML to deflate |
Returns:
Promise resolved with deflated HTML
- Type
- jQuery.Promise
deflateDoc(doc, [oldDoc]) → {jQuery.Promise}static
#
Serialize and deflate an HTML document
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
doc |
HTMLDocument | Document generated by |
|
oldDoc |
HTMLDocument |
optional |
Old document to copy attributes from. |
Returns:
Promise resolved with deflated HTML
- Type
- jQuery.Promise
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 |
|
oldDoc |
HTMLDocument |
optional |
Old document to copy attributes from. |
Returns:
Full HTML document
- Type
- string
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:
|
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 |
Returns:
Promise which resolves with API save data, or rejects with error details
- Type
- jQuery.Promise
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:
|
Returns:
Promise which resolves with API save data, or rejects with error details
- Type
- jQuery.Promise
preloadDeflate()static
#
Preload the library required for deflating so the user doesn't have to wait when postHtml is called.
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 |
Returns:
Promise which resolves if the post was successful
- Type
- jQuery.Promise