Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TagMode

Abstract class for representing a type of page for the tag module.

Hierarchy

  • TagMode

Index

Constructors

constructor

Properties

Window

Window: simpleWindow

assumeUnknownTagsGroupable

assumeUnknownTagsGroupable: boolean = true

Should tags that are not present in tag configuration be considered groupable? This includes custom tags set in user-level preferences, and tags found existing on the page which are absent in the config.

existingTags

existingTags: string[] = []

flatObject

flatObject: Record<string, tagData>

form

form: quickForm

groupMinSize

groupMinSize: number = 1

Minimum number of tags that a group should contain

groupTemplateName

groupTemplateName: string = null

Name of grouping template.

A group template is a template container that takes the form

{{group template name| {{tag template 1}} {{tag template 2}} }}

Any other kind of "grouping" is not supported.

If groupTemplateName is null, grouping is always disabled for the mode.

Individual tags can be excluded from grouping by setting excludeInGroup=true for that template in tag data configuration.

Grouping can also be disabled depending on user input or other factors by setting this.params.disableGrouping = true in the preprocessParams() hook.

Default: null, which indicates no grouping template for the mode.

groupTemplateNameRegex

groupTemplateNameRegex: string

Regex that matches the name of the group template name and its popular redirects

groupTemplateNameRegexFlags

groupTemplateNameRegexFlags: string

Regex flags to apply to go along with groupTemplateNameRegex

Abstract name

name: string

Name of the tag mode

pageText

pageText: string

pageobj

pageobj: Page

params

params: Record<string, any>

removalSupported

removalSupported: boolean = false

result

result: HTMLFormElement

scrollbox

scrollbox: element

Abstract tagList

tagList: tagListType

List of tags available for use, grouped by sections.

templateParams

templateParams: Record<string, Record<string, string>>

Static tagList

tagList: tagListType

Unused. XXX

Methods

action

  • action(): PromiseBase<api, any, any, api, any, any, api, any, any, api, any, any>

addAndRearrangeTags

  • addAndRearrangeTags(): void

addTagsIntoGroup

  • addTagsIntoGroup(tagText: string): void
  • Given that the group exists on pageText (either added by us now or existed before), move given tagText into the group

    Parameters

    • tagText: string

    Returns void

addTagsOutsideGroup

  • addTagsOutsideGroup(tags: any): void

canRemove

  • canRemove(): boolean
  • Removal of tags is possible only if this returns true: when the user is viewing the article in read mode or a permalink of the latest version.

    Returns boolean

captureFormData

  • captureFormData(): void

checkInputs

  • checkInputs(): string | void
  • Validate input. Return a string in case of issues; this string is used as the message for a browser prompt(). Return nothing if all inputs are valid. Use validateInput for customisation.

    internal
    sealed

    Returns string | void

constructFlatObject

  • constructFlatObject(): void

evaluate

  • evaluate(): void

finalCleanup

  • finalCleanup(): void

formAppendPatrolLink

  • formAppendPatrolLink(): void

formRender

  • formRender(): void

getMenuTooltip

  • getMenuTooltip(): string

getParameterText

  • getParameterText(tag: string): string
  • Generate the parameter text from the data stored in this.templateParams. this.templateParams is populated automatically based on param names from the configs and values from user input. If any additional changes to templateParams are required, you can do that in preprocessParams().

    Parameters

    • tag: string

    Returns string

getRedirectsQuery

  • getRedirectsQuery(tags: string[]): { action: string; format: string; lhlimit: string; lhnamespace: string; lhshow: string; prop: string; redirects: number; titles: string[] }
  • Get the API query used for querying redirects to the template

    Parameters

    • tags: string[]

    Returns { action: string; format: string; lhlimit: string; lhnamespace: string; lhshow: string; prop: string; redirects: number; titles: string[] }

    • action: string
    • format: string
    • lhlimit: string
    • lhnamespace: string
    • lhshow: string
    • prop: string
    • redirects: number
    • titles: string[]

getTagRegex

  • getTagRegex(tag: string): RegExp
  • Get the regex to be used to search for or remove a tag.

    Parameters

    • tag: string

    Returns RegExp

getTagText

  • getTagText(tag: string): string

getTemplateParameters

  • getTemplateParameters(): void

getWindowTitle

  • getWindowTitle(): string

groupRegex

  • groupRegex(): RegExp
  • Get regex that matches the start of the grouping template (the opening braces plus the template name. The template name is captured as a regex group (pun unintended).

    Returns RegExp

initialCleanup

  • initialCleanup(): void

insertTagText

  • insertTagText(tagText: string, pageText: string): string
  • Controls how the final text of new tags is inserted into the page. Defaults to just putting them at the very top of the page, along with two newlines. You may want to override this if you want them to go below any hatnotes or deletion notices (use Morebits.wikitext.page#insertAfterTemplates, see enwiki ArticleMode).

    Parameters

    • tagText: string
    • pageText: string

    Returns string

isGroupable

  • isGroupable(tag: string): boolean
  • This function assumes that grouping is enabled in the first place.

    Parameters

    • tag: string

    Returns boolean

makeExistingTagList

  • makeExistingTagList(container: element): void

makeForm

  • makeForm(Window: any): void

makeTagList

  • makeTagList(container: element): void

makeTagListGroup

  • makeTagListGroup(list: tagData[], container?: quickForm | element): void

makeTagSetText

  • makeTagSetText(tags: string[]): string

parseExistingTags

  • parseExistingTags(): void
  • Parse existing tags. This is NOT asynchronous. Should be overridden for tag modes where removalSupported is true. Populate this.existingTags with the names of tags present on the page.

    Returns void

postRender

  • postRender(): void
  • Actions carried out after the form has been rendered and the Dialog has become visible.

    Returns void

preprocessParams

  • preprocessParams(): void

removeTags

  • removeTags(): Promise<void, any, any>

removeTemplate

  • removeTemplate(tag: any): boolean

savePage

  • savePage(): Promise<api, any, any>

shiftTag

  • shiftTag(tag: any): boolean
  • If the tag is present in pageText, removes it from pageText and adds it to params.groupableExistingTagsText.

    Parameters

    • tag: any

    Returns boolean

shouldAddGroup

  • shouldAddGroup(): boolean
  • Returns true if a group template is to be added to the page, otherwise false.

    Returns boolean

sortTags

  • sortTags(): void

spliceGroupableExistingTags

  • spliceGroupableExistingTags(): Promise<string, any, any>
  • Get the wikitext of the groupable existing tags, removes it from the page text and adds them to params.groupableExistingTagsText, which the returned promise resolves to.

    Returns Promise<string, any, any>

validateInput

  • validateInput(): string | void
  • If inputs are invalid, return a string that is shown to the user via alert(). If inputs are valid, don't return anything.

    Returns string | void

Static isActive

  • isActive(): boolean

Generated using TypeDoc