ImprovedProseMirror is a script that adds the following functionality to the ProseMirror editor, which is used in article comments and message walls:
- Insertion of links through wikitext-like syntax
- Typing
[[page]]searches for pages on the current wiki using page as a keyword, and opens a link suggest popup containing the results. After an option is selected, a link to the selected page will be created using that page's title as the link's label. [[page|label]]uses label as the label instead of the page's title.[[page|]]performs the pipe trick on the selected page's title before using it for the label.[[|page]]reuses the search term page as the label instead of the page's title. (this is not the reverse pipe trick)[[:page]]allows you to insert an image instead of a link.- Interwiki prefixes can be used to search for pages on other wikis. Note that this feature will only work for wikis running MediaWiki software, and only if the script is able to find the wiki's public API.
- Typing
[label]opens a prompt to enter a URL, and a link will be created with that URL and label.
- Typing
- Selection of preset messages from a dropdown in the editor toolbar
- Preset messages can be set in the user's or site's JavaScript (see Configuration). When configuring:
- Link syntax for both internal wiki links and external links is supported (
[[page|label]],[[page]], and[link label]). - Line breaks are supported through
<br />,<br/>,<br>, and\n. - Variables can be declared with
%variablename%. If their values are left undefined, a prompt asking for a value will appear each time the preset is selected in the text editor. Their values can also be defined in the configuration, which will cause no prompt to appear when the preset is selected.
- Link syntax for both internal wiki links and external links is supported (
- Preset messages can be set in the user's or site's JavaScript (see Configuration). When configuring:
Installation
Configuration
The following configuration is optional, and there is no limit to the number of presets.
// Create configuration, hook is used to avoid loading order issues
mw.hook('dev.IPM').fire([
{
// Name of preset, shown in the dropdown
button: 'Warn - CIR',
// Preset content
insert: 'You are a receiving a warning for continuing to edit disruptively with no sign of improvement after being informed of issues in your previous edits. We appreciate your enthusiasm, but [[WP:CIR|competence is required]] to make our wiki the best it can be.',
// Set to true to overwrite existing content in the editor with this preset
replaceAll: true
},
{
button: 'Signature',
insert: 'Yours truly,\n[[Special:MyPage|UserName]] ([[Special:MyTalk|talk]]).'
},
{
// Nested dropdown buttons cannot have "insert"
button: 'Salutations',
nested: [
{
button: 'Hello',
insert: 'Nice to meet you, anon!'
},
{
button: 'Bye',
insert: 'Nice talking to you, anon. See you around!'
},
]
},
{
button: 'Introduction',
// Preset with defined variables "username" and "interest"
insert: 'My name is %username%, and I like %interest%.',
// Definition of variable "username" that automatically retrieves the poster's username
username: mw.config.values.wgUserName,
// Definition of variable "interest" with value "fixing typos"
interest: 'fixing typos'
},
{
button: 'Warn - Custom',
// Preset with undefined variable "reason", user will be prompted for its value each time the "Warn - Custom" preset is selected
insert: 'You are receiving a warning for %reason%.'
},
]);
Text above can be found here (edit)