FANDOM


msgEditApi allows to use simple function calls to create and edit thread messages & comments. Currently supported: article comments, blogs, forum threads and message wall threads (which technically are forum threads).

Usage

When ready, the script fires nmsgeditapi.ready hook via mw.hook, with interface object as first parameter. Exports: getMessage, setMessage, settings.

getMessage
get active message content. Returns proxy to string and jQuery deferred object. Use getMessage().promise to access to the promise. String is keeped for backward-compatibility reasons, don't use it.
setMessage(msg)
set active message content to "msg", if no active message found, add new message.
settings
currrently, only "debug" parameter is exposed.

Note: in order to avoid headache with dealing with weird RTE content, getMessage and setMessage turns editor to source mode.

Example

mw.hook('nmsgeditapi.ready').add(function (editApi) {
    editApi.setMessage(editApi.getMessage() + ' hi there');
});

Installation

Importing multiple scripts? This quick guide shows how to combine the imports.
  • For site-wide use, an administrator can add the line below to the wiki's MediaWiki:ImportJS page.
dev:MsgEditApi.js
  • For personal use, add the code snippet below to your global.js page (for use on all wikis) or your common.js page on your wiki (for use on a single wiki). Note that personal JS must be enabled for your account.
importArticles({
    type: 'script',
    articles: [
        'u:dev:MediaWiki:MsgEditApi.js',
    ]
});
Community content is available under CC-BY-SA unless otherwise noted.

Fandom may earn an affiliate commission on sales made from links on this page.

Stream the best stories.

Fandom may earn an affiliate commission on sales made from links on this page.

Get Disney+