Constructor
new mw.editcheck.BaseEditCheck(controller, [config], [includeSuggestions])abstract
#
BaseEditCheck
Abstract base class for edit checks. Provides common configuration, tagging, and utility methods for subclasses implementing specific edit check logic.
Subclasses should implement event handler methods such as onBeforeSave and onDocumentChange.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
controller |
Edit check controller |
|||
config |
Object |
optional |
Configuration options |
|
includeSuggestions |
boolean |
optional |
false |
BaseEditCheck
Abstract base class for edit checks.
Properties
actabstract
#
User performs an action on an check
onBeforeSaveabstract
#
Get actions to show before save
onBranchNodeChangeabstract
#
Get actions to show when the focused branch node changed
onDocumentChangeabstract
#
Get actions to show when document changed
takesFocus :booleanstatic
#
Takes focus from the surface to show the check as soon as it is detected (on mobile)
On desktop the check cards are always visible so this config does nothing.
Type:
- boolean
Takes focus from the surface to show the check as soon as it is detected (on mobile)
On desktop the check cards are always visible so this config does nothing.
Methods
canBeShown() → {boolean}
#
Find out whether the check should be applied
This is a general check for its applicability to the viewer / page, rather than a specific check based on the current edit. It's used to filter out checks before any maybe-expensive content analysis happens.
Returns:
Whether the check should be shown
- Type
- boolean
Find out whether the check should be applied
This is a general check for its applicability to the viewer / page, rather than a specific check based on the current edit.
canBeStale() → {boolean}
#
Check if the edit check can be stale
Returns:
- Type
- boolean
dismiss(action)
#
getAddedContentRanges(documentModel) → {Array.<ve.Range>}
#
Get content ranges where at least the minimum about of text has been added
Parameters:
| Name | Type | Description |
|---|---|---|
documentModel |
ve.dm.Document |
Returns:
getAddedNodes(documentModel, [type]) → {Array.<ve.dm.Node>}
#
Find nodes that were added during the edit session
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
documentModel |
ve.dm.Document | ||
type |
string |
optional |
Type of nodes to find, or all nodes if false |
Returns:
- Type
- Array.<ve.dm.Node>
getAddedRanges(documentModel, coveredNodesOnly, onlyContentRanges) → {Array.<ve.Range>}
#
Get content ranges which have been inserted
Parameters:
| Name | Type | Description |
|---|---|---|
documentModel |
ve.dm.Document | |
coveredNodesOnly |
boolean | Only include ranges which cover the whole of their node |
onlyContentRanges |
boolean | Only return ranges which are content branch node interiors |
Returns:
getContentRangesFromRange(documentModel, range, covers) → {Array.<ve.Range>}
#
Return the content ranges (content branch node interiors) contained within a range
For a content branch node entirely contained within the range, its entire interior range will be included. For a content branch node overlapping with the range boundary, only the covered part of its interior range will be included.
Parameters:
| Name | Type | Description |
|---|---|---|
documentModel |
ve.dm.Document | The documentModel to search |
range |
ve.Range | The range to include |
covers |
boolean | Only include ranges which cover the whole of their node |
Returns:
The contained content ranges (content branch node interiors)
Return the content ranges (content branch node interiors) contained within a range
For a content branch node entirely contained within the range, its entire interior range will be included.
getDescription(action) → {string}
#
getModifiedContentBranchNodes(documentModel) → {Array.<ve.dm.ContentBranchNode>}
#
Get ContentBranchNodes where some text has been changed
Parameters:
| Name | Type | Description |
|---|---|---|
documentModel |
ve.dm.Document |
Returns:
- Type
- Array.<ve.dm.ContentBranchNode>
getModifiedContentRanges(documentModel) → {Array.<ve.Range>}
#
Get content ranges where at least the minimum about of text has been changed
Parameters:
| Name | Type | Description |
|---|---|---|
documentModel |
ve.dm.Document |
Returns:
getModifiedRanges(documentModel, coveredNodesOnly, onlyContentRanges, onlyPureInsertions) → {Array.<ve.Range>}
#
Get content ranges which have been modified
Parameters:
| Name | Type | Description |
|---|---|---|
documentModel |
ve.dm.Document | |
coveredNodesOnly |
boolean | Only include ranges which cover the whole of their node |
onlyContentRanges |
boolean | Only return ranges which are content branch node interiors |
onlyPureInsertions |
boolean | Only return ranges which didn't replace any other content |
Returns:
getName() → {string}
#
Get the name of the check type
Returns:
Check type name
- Type
- string
getPrompt(action) → {jQuery|string|function|OO.ui.HtmlSnippet|undefined}
#
undefined}
#
Get the prompt for the check's actions, if any
Parameters:
| Name | Type | Description |
|---|---|---|
action |
mw.editcheck.EditCheckAction |
Returns:
- Type
-
jQuery
|
string
|
function
|
OO.ui.HtmlSnippet
|
undefined
getTitle(action) → {jQuery|string|function|OO.ui.HtmlSnippet}
#
Get the title of the check
Parameters:
| Name | Type | Description |
|---|---|---|
action |
mw.editcheck.EditCheckAction |
Returns:
- Type
- jQuery | string | function | OO.ui.HtmlSnippet
isDismissedId(id) → {boolean}
#
Check if an action with a given ID has been dismissed
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
Returns:
- Type
- boolean
isDismissedRange(range, name) → {boolean}
#
Check if this type of check has been dismissed covering a specific range
Parameters:
| Name | Type | Description |
|---|---|---|
range |
ve.Range | |
name |
string | of the tag |
Returns:
- Type
- boolean
isRangeInValidSection(range, documentModel) → {boolean}
#
Check if a modified range is a section we don't ignore (config.ignoreSections)
Parameters:
| Name | Type | Description |
|---|---|---|
range |
ve.Range | |
documentModel |
ve.dm.Document |
Returns:
Whether the range is in a section we don't ignore
- Type
- boolean
isRangeValid(range, documentModel) → {boolean}
#
Test whether the range is valid for the check to apply
Parameters:
| Name | Type | Description |
|---|---|---|
range |
ve.Range | |
documentModel |
ve.dm.Document |
Returns:
- Type
- boolean
isTaggedId(tag, id) → {boolean}
#
Check if an action with a given ID has a given tag
Parameters:
| Name | Type | Description |
|---|---|---|
tag |
string | |
id |
string |
Returns:
- Type
- boolean
isTaggedRange(tag, range, name) → {boolean}
#
Check if this type of check has a given tag
Parameters:
| Name | Type | Description |
|---|---|---|
tag |
string | |
range |
ve.Range | |
name |
string | of the tag |
Returns:
- Type
- boolean
tag(tag, action)
#
Tag a check action
TODO: This is asymmetrical. Do we want to split this into two functions, or unify isTaggedRange/isTaggedId into one function?
Parameters:
| Name | Type | Description |
|---|---|---|
tag |
string | |
action |
mw.editCheck.EditCheckAction |
Tag a check action
TODO: This is asymmetrical.
takesFocus() → {boolean}
#
untag(tag, action) → {boolean}
#
Untag a check action
TODO: This is asymmetrical. Do we want to split this into two functions, or unify isTaggedRange/isTaggedId into one function?
Parameters:
| Name | Type | Description |
|---|---|---|
tag |
string | |
action |
mw.editCheck.EditCheckAction |
Returns:
Whether anything was untagged
- Type
- boolean
Untag a check action
TODO: This is asymmetrical.
doesConfigMatch([config]) → {boolean}static
#
Find out if any conditions in the provided config are met
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
config |
Object |
optional |
Configuration options |
Returns:
Whether the config matches
- Type
- boolean