Classes
- EditingTabDialog
- Dialog for allowing new users to change editing tab preferences.
- MWEditModeSourceTool
- MediaWiki edit mode source tool.
- MWEditModeTool
- MediaWiki edit mode tool.
- MWEditModeVisualTool
- MediaWiki edit mode visual tool.
- MWTempWikitextEditorWidget
MediaWiki temporary wikitext editor widget
This widget can be used to show the user a basic editing interface while VE libraries are still loading.
- ProgressBarWidget
Progress bar widget
This widget can be used to show a progress bar while VE libraries are still loading.
- SwitchPopupWidget
- WelcomeDialog
- Dialog for welcoming new users.
- diffLoader
- Diff loader.
- targetLoader
- Target loader.
- targetSaver
- Target saver.
Methods
decodeURIComponentIntoArticleTitle(s, [preserveUnderscores]) → {string}static
#
Decode a URI component into a mediawiki article title
N.B. Illegal article titles can result from fairly reasonable input (e.g. "100%25beef"); see https://phabricator.wikimedia.org/T137847 T137847} .
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
s |
string | String to decode |
||
preserveUnderscores |
boolean |
optional |
false | Don't convert underscores to spaces |
Returns:
Decoded string, or original string if decodeURIComponent failed
- Type
- string
Decode a URI component into a mediawiki article title
N.B.
deduplicateStyles(element)static
#
De-duplicate TemplateStyles, like Parsoid does.
Parameters:
| Name | Type | Description |
|---|---|---|
element |
HTMLElement | Parent element, e.g. document body |
disableDuplicateStyles(element) → {number}static
#
Disable redundant copies of TemplateStyles in a rendered surface.
#reduplicateStyles expands Parsoid's deduplicated TemplateStyles into one copy per occurrence, and ve.ce.MWTransclusionNode#filterRenderedDomElements keeps them in rendered content, so a template-heavy article has hundreds of copies of a handful of stylesheets all taking part in style resolution. They are identical, so only the first for each key has any effect.
Disabling rather than removing keeps the cascade unchanged and leaves the rendered DOM intact. Safe to re-run: the first surviving copy of each key is enabled and the rest disabled, so a survivor is promoted if the enabled copy is deleted mid-edit.
Parameters:
| Name | Type | Description |
|---|---|---|
element |
HTMLElement | Parent element, e.g. the surface's DOM node |
Returns:
Number of stylesheets whose state was changed
- Type
- number
encodeParsoidResourceName(title) → {string}static
#
Encode a page title into a Parsoid resource name.
Parameters:
| Name | Type | Description |
|---|---|---|
title |
string |
Returns:
- Type
- string
fixFragmentLinks(container, docTitle, [prefix])static
#
Fix fragment links which should be relative to the current document
This prevents these links from trying to navigate to another page, or open in a new window.
Call this after ve.targetLinksToNewWindow, as it removes the target attribute. Call this after LinkCache.styleParsoidElements, as it breaks that method by including the query string.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
container |
HTMLElement | Parent element, e.g. document body |
|
docTitle |
mw.Title | Current title, only links to this title will be normalized |
|
prefix |
string |
optional |
Prefix to add to fragment and target ID to avoid collisions |
Fix fragment links which should be relative to the current document
This prevents these links from trying to navigate to another page, or open in a new window.
getRegexFromUrlPattern(urlPattern) → {RegExp}static
#
Convert a URL pattern with a $1 placeholder into a RegExp
Parameters:
| Name | Type | Description |
|---|---|---|
urlPattern |
string |
Returns:
- Type
- RegExp
getTargetDataFromHref(href, doc) → {mw.libs.ve.TargetData}static
#
Parse URL to get title it points to.
Parameters:
| Name | Type | Description |
|---|---|---|
href |
string | |
doc |
HTMLDocument | Document whose base URL to use |
Returns:
Information about the given href
normalizeParsoidResourceName(resourceName) → {string}static
#
Extract the page title from a Parsoid resource name.
Parameters:
| Name | Type | Description |
|---|---|---|
resourceName |
string | Resource name, from a |
Returns:
Full page title in text form (with namespace, and spaces instead of underscores)
- Type
- string
parseParsoidResourceName(resourceName) → {mw.libs.ve.ParsedResource}static
#
Split Parsoid resource name into the href prefix and the page title.
Parameters:
| Name | Type | Description |
|---|---|---|
resourceName |
string | Resource name, from a |
Returns:
Parsed resource name
reduplicateStyles(element)static
#
Re-duplicate deduplicated TemplateStyles, for correct rendering when editing a section or when templates are removed during the edit.
Parameters:
| Name | Type | Description |
|---|---|---|
element |
HTMLElement | Parent element, e.g. document body |
Re-duplicate deduplicated TemplateStyles, for correct rendering when editing a section or when templates are removed during the edit.
resolveUrlOrTitle(urlOrTitle) → {string}static
#
Take a string that might be a URL or a page title and return a URL
Parameters:
| Name | Type | Description |
|---|---|---|
urlOrTitle |
string |
Returns:
url
- Type
- string
smoothScrollTo(scrollTop)static
#
Smoothly scroll the window to a specific vertical position
Parameters:
| Name | Type | Description |
|---|---|---|
scrollTop |
number | Vertical position to scroll to |
stripParsoidFallbackIds(element)static
#
Strip legacy (non-HTML5) IDs; typically found as section IDs inside headings.
Parameters:
| Name | Type | Description |
|---|---|---|
element |
HTMLElement | Parent element, e.g. document body |
Strip legacy (non-HTML5) IDs; typically found as section IDs inside headings.
stripParsoidSections(html) → {string|null}static
#
null}static
#
Remove Parsoid section wrappers from a Parsoid HTML string
This produces the same document as #unwrapParsoidSections, minus the section IDs that method copies onto headings, so only use it where those are not needed, e.g. diffing.
It is much cheaper. #unwrapParsoidSections moves every child out of every section, and the cost of a DOM move is proportional to the subtree moved, so a long article pays for its whole tree. Doing it on the string instead costs nothing beyond the parse that follows.
Wikitext cannot produce a <section> element, so every closing tag belongs to one of Parsoid's
wrappers. Should that ever stop holding, this returns null and the caller can unwrap the DOM.
Parameters:
| Name | Type | Description |
|---|---|---|
html |
string | Parsoid HTML |
Returns:
HTML without section wrappers, or null if it could not be done safely
- Type
-
string
|
null
Remove Parsoid section wrappers from a Parsoid HTML string
This produces the same document as #unwrapParsoidSections, minus the section IDs that method copies onto headings, so only use it where those are not needed, e.g.
unwrapParsoidSections(element, [keepSection])static
#
Unwrap Parsoid sections
data-mw-section-id attributes are copied to the first child (the heading) during this step so that we can place the cursor in the correct place when section editing. These attributes must be removed before being sent back to Parsoid to avoid unnecessary re-serialization.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
element |
HTMLElement | Parent element, e.g. document body |
|
keepSection |
string |
optional |
Section to keep |
Unwrap Parsoid sections
data-mw-section-id attributes are copied to the first child (the heading) during this step so that we can place the cursor in the correct place when section editing.
Type Definitions
ParsedResource
#
Properties:
| Name | Type | Description |
|---|---|---|
title |
string | Full page title in text form (with namespace, and spaces instead of underscores) |
TargetData
#
Type:
Properties:
| Name | Type | Description |
|---|---|---|
title |
string | The title of the internal link (if the href is internal) |
isInternal |
boolean | True if the href pointed to the local wiki, false if href is external |