FANDOM


AjaxEdit allows users to edit without opening the editor. It replicates most of the functionality of source editor, while also adding some new tools, configuration options, and mobile support. Additionally, it supports section editing. However, it should be noted that it is not intended to replace the editor but only to complement it. Users will probably find the normal editor preferable for large scale edits, while AjaxEdit is useful for quick changes.

Installation

Customization

This script has 12 customization options, none of which are required, and all of which are under the window.AjaxEdit object.

List

Name Description Default Type
minor Default check the minor checkbox. Preferences Boolean
reloadContent Re-gets the source when returning to AjaxEdit. false Boolean
restart Don't save changes when temporarily leaving AjaxEdit. false Boolean
watchlist Watchlist changes when editing. Preferences String
hideRail Hide right rail while editing. false Boolean
height Textbox height. 500px String
replaceGlobal Check Find and Replace global matching checkbox. true Boolean
replaceCase Check Find and Replace case sensitive checkbox. false Boolean
replaceRegex Check Find and Replace regex checkbox. false Boolean
summaries Add select dropdown with default summaries. false Object
summaryNotice Prepend [AjaxEdit] to the edit summary. false Boolean
buttons Add custom edit buttons. false Array or String
reload Actually reload the page. false Boolean
button Add the link as a page header button instead of a list item. false Boolean
section Whether edit section links should be enabled. true Boolean

Summaries

To add commonly used edit summaries, similarly to Standard Edit Summary, add an object where they key is the text and the value is the edit summary box value. For example, Spam: [[w:Help:Spam|Spam]] will add an option, its text being Spam and its content being [[w:Help:Spam|Spam]].

Buttons

To add custom edit buttons, there are two options. If you use 'defaults', it will add several buttons that behave similarly to those inside source editor. Alternately, you can specify buttons in the below format.

window.AjaxEdit = {
    buttons: [
        {
            label: 'Hi',// required - button text
            open: 'Hi',// optional - before text
            middle: 'Hi',// optional - middle text that replaces selected text
            close: 'Hi'// optional - after text
        }
    ]
};

Default

Here is the default configuration.

window.AjaxEdit = {
    minor: mw.user.options.get('minordefault') === '1',
    reloadContent: false,
    restart: false,
    watchlist: 'preferences',
    hideRail: false,
    height: '500px',
    replaceGlobal: true,
    replaceCase: false,
    replaceRegex: false,
    summaries: false,
    summaryNotice: false,
    buttons: false,
    reload: false,
    button: false,
    section: true
};

Usage

This script adds a link to the edit dropdown, which, when clicked, hides the article and opens a menu with a textbox for editing and buttons for performing various actions. The buttons are explained below:

  • Back: hides the editor and shows the article, but saves your changes (optional).
  • Restart: reverts all of your changes.
  • Publish: saves your edit and refreshes the page.
  • Diff: opens a modal that shows the changes you've made.
  • Preview: opens a modal that shows what your edit will look like.
  • Find and Replace: opens a modal to find and replace content inside the textbox.

Attribution

This script contains code based on the following scripts.

It also uses some code by Dorumin, KhangND, Puxlit, and Ursuul.


Changelog

v1.0 — March 5, 2019
TheGoldenPatrik1: Initial revision
v1.1 — March 7, 2019
TheGoldenPatrik1: Don't reload, just refresh when publishing
v1.2 — April 10, 2019
TheGoldenPatrik1 and Puxlit: Numerous bugfixes and added functionality
v1.3 — May 20, 2019
TheGoldenPatrik1 and Ursuul: Full mobile support
v1.4 — November 12, 2019
TheGoldenPatrik1 and KhangND: Add section editing
Text above can be found here (edit)
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+