Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GenericMode<Options>

This is the class that implements the generic mode. This mode decorates all the elements of the file being edited. On the basis of the schema used by wed for validation, it allows the addition of the elements authorized by the schema.

Recognized options:

  • metadata: this option can be a path (a string) pointing to a module that implements the metadata needed by the mode.

  • autoinsert: whether or not to fill newly inserted elements as much as possible. If this option is true, then when inserting a new element, the mode will try to detect whether the element has any mandatory children and if so will add these children to the element. For instance, if foo is invalid without the child baz then when inserting foo in the document, the following structure would be inserted <foo><baz></baz></foo>. This automatic insertion of children happens only in non-ambiguous cases. Taking the same example as before, if foo could contain a or b, then the mode won't add any children. This option is true by default.

Type parameters

Hierarchy

Implements

Index

Constructors

constructor

  • new GenericMode(editor: EditorAPI, options: Options): GenericMode

Properties

Protected editor

editor: EditorAPI

The editor for which this mode is created.

Protected metadata

metadata: Metadata

Protected options

options: Options

The options for the mode. Each mode defines what fields this object contains.

Protected resolver

resolver: DefaultNameResolver

Protected tagTr

tagTr: Record<string, Transformation<NamedTransformationData>>

Methods

checkOptions

documentationLinkFor

  • documentationLinkFor(name: string): string | null | undefined

getAbsoluteNamespaceMappings

  • getAbsoluteNamespaceMappings(): Record<string, string>

getAbsoluteResolver

  • getAbsoluteResolver(): DefaultNameResolver

getAttributeCompletions

  • getAttributeCompletions(_attribute: Attr): string[]

getContextualActions

  • getContextualActions(transformationType: string | string[], _tag: string, _container: Node, _offset: number): Action<__type>[]

getModeOptions

  • getModeOptions(): Options

getStylesheets

  • getStylesheets(): string[]

getToolbarButtons

  • getToolbarButtons(): Button[]

getValidator

getWedOptions

  • getWedOptions(): WedOptions

init

  • init(): Promise<void>

makeDecorator

makeMetadata

  • Make a Metadata object for use with this mode. The default implementation requires that there be a metadata option set and uses that to load a metadata file. Derived classes can override this as needed.

    Returns Promise<Metadata>

makePlaceholderFor

  • makePlaceholderFor(_element: Element): Element

nodesAroundEditableContents

  • nodesAroundEditableContents(element: Element): [Node | null, Node | null]

shortDescriptionFor

  • shortDescriptionFor(name: string): string | null | undefined
  • Returns a short description for an element. The element should be named according to the mappings reported by the resolve returned by "wed/mode".Mode.getAbsoluteResolver. The generic mode delegates the call to the metadata.

    Parameters

    • name: string

      The name of the element.

    Returns string | null | undefined

    The description. If the value returned is undefined, then the description is not available. If the value returned is null, the description has not been loaded yet.

unresolveName

  • unresolveName(name: EName): string | undefined

Object literals

optionTemplate

optionTemplate: object

The template that checkOptions uses to check the options passed to this mode. Consider this object to be immutable.

autoinsert

autoinsert: false = false

metadata

metadata: true = true

Protected wedOptions

wedOptions: object

label_levels

label_levels: object

initial

initial: number = 1

max

max: number = 1

metadata

metadata: object

authors

authors: string[] = ["Louis-Dominique Dubeau"]

copyright

copyright: string = "Mangalam Research Center for Buddhist Languages"

description

description: string = "The base mode. You should not be using it directly."

license

license: string = "MPL 2.0"

name

name: string = "Base Mode (you should not be using this)"

Generated using TypeDoc