Constructor
new mw.editcheck.TextMatchRule(rule, id, collator)
#
TextMatchRule
Class to represent a single matchRule for TextMatchEditCheck
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
rule |
Object | Match rule Properties:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
id |
string | ID of matchRule in config |
||||||||||||||||||||||||||||||||||||||||||||||||||||
collator |
Intl.Collator | Collator to use for comparisons |
TextMatchRule
Class to represent a single matchRule for TextMatchEditCheck
Methods
getExpandedFragment(fragment) → {ve.dm.SurfaceFragment}
#
Expand a fragment given the match rule's config
Parameters:
| Name | Type | Description |
|---|---|---|
fragment |
ve.dm.SurfaceFragment |
Returns:
Expanded fragment
getReplacement(term) → {string}
#
Return the corresponding replacement word, as defined for the given word in this matchRule's query
Parameters:
| Name | Type | Description |
|---|---|---|
term |
string | to get replacement for |
Returns:
replacement term
- Type
- string
Return the corresponding replacement word, as defined for the given word in this matchRule's query
getSubTag(term) → {string}
#
Get a unique subtag for this matchRule-term pair. Builds the subtag from:
- the index of the matchRule when created
- and, optionally, the index of the term in the list of keys from the matchRule's query
Parameters:
| Name | Type | Description |
|---|---|---|
term |
string |
Returns:
A subtag in the format '-{matchIndex}-{termIndex}'
- Type
- string
isCaseSensitive() → {boolean}
#
Returns:
if this matchRule is configured to be case sensitive
- Type
- boolean
isRangeInNode(range, surfaceModel) → {boolean}
#
Check if a range is inside the required inNode type.
Parameters:
| Name | Type | Description |
|---|---|---|
range |
ve.Range | |
surfaceModel |
ve.dm.Surface |
Returns:
- Type
- boolean
normalizeQuery(query) → {Object.<string, string>}
#
Transform any query type into a dictionary of terms and their replacements, with a null replacement if none exists
Parameters:
Returns:
Dictionary of each term and its replacement
- Type
- Object.<string, string>
Transform any query type into a dictionary of terms and their replacements, with a null replacement if none exists