Fandom Developers Wiki
Advertisement

MiniComplete is an autocomplete library. It works by detecting when you've opened a brackets for a link [[ or a template {{ and suggests options you might be looking for based on what you typed after those opening brackets. It was made for general use back when normal editor autocomplete didn't exist, but the Fandom LinkSuggest extension replicates its functionality. However, with the Unified Community Platform, LinkSuggest is no longer an easily accessible library.

It is designed to look and function the same as the autocomplete when editing pages. If there is a feature that the editor autocomplete has, but this does not, please request it on the talk page.

Usage

This script can be used in almost any other script where an autocomplete is wanted for a textarea element. You will need to load the script and register the module containing it's dependencies and then pass the a selector to a function from this script.

The following is an example used for the demo of this script:

// Load the module
mw.loader.implement( 'minicomplete', [ '/load.php?debug=false&lang=en&mode=articles&skin=oasis&missingCallback=importArticleMissing&articles=u%3Acamtest%3AMediaWiki%3ATextareaHelper.js%7Cu%3Adev%3AColors%2Fcode.js%7Cu%3Adev%3AMiniComplete%2Fcode.js&only=scripts' ], {}, {} );

// Insert the textarea
$( '#minicomplete-demo' )
// Empty the element first in case of loading twice or more
.empty()
.append(
    $( '<textarea>' )
    .attr( {
        id: 'minicomplete-textarea',
        placeholder: 'Try the MiniComplete demo here!'
    } )
    .css( {
        resize: 'none',
        height: '80px',
        width: '98.3%',
        padding: '2px 5px'
    } )
);

// Call the modules we need and execute the script in the callback
mw.loader.using( [ 'mediawiki.api', 'minicomplete' ], function () {
    dev.minicomplete.load( '#minicomplete-textarea' );
} );

It is recommended to use the ID of the textarea, like in this example, as the selector to pass to dev.minicomplete.load(). If for some reason this cannot be done, you can use any selector you might use in CSS.

Demo

To do list

  • Allow users to turn this script on and off at their preference, as users can turn the normal editor autocomplete on and off in Special:Preferences.
  • Allow custom styling of the autocomplete options for wikis with themes not based on Special:ThemeDesigner.

Changelog

This only documents major updates, so may not correlate with the latest update in the infobox.

6th February 2015 (diff)
  • Remove Message Wall, Special:Forum and Article Comment support due to support being added by Fandom.
15th February 2014 (diff)
  • Changed to use factory method to stop unnecessary globals from being accessed.
9th November 2013 (diff)
  • Fixed for Article comments, Special:Forum posts and Message Wall comments.
31st October 2013 (diff)
  • Added support for using in other scripts.
  • Loaded non-standard dependencies in a single http request using ResourceLoader.
28th October 2013
  • Script published.
Text above can be found here (edit)
Advertisement