Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Mode<ModeOptions>

Type parameters

Hierarchy

  • Mode

Implemented by

Index

Methods

documentationLinkFor

  • documentationLinkFor(name: string): string | null | undefined
  • Returns a URL to the documentation for an element. The element should be named according to the mappings reported by the resolve returned by getAbsoluteResolver. The default implementation returns undefined for everything.

    Parameters

    • name: string

      The name of the element.

    Returns string | null | undefined

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

getAbsoluteNamespaceMappings

  • getAbsoluteNamespaceMappings(): Record<string, string>
  • This method returns a mappings of prefix to namespace URI that are set to resolve names outside the context of an XML tree. It is sometimes useful to use qualified names that do not depend on how a specific XML document is structured, this method provides for such functionality.

    Returns Record<string, string>

    The mappings. This is a new copy which you can modify at will.

getAbsoluteResolver

  • getAbsoluteResolver(): DefaultNameResolver
  • This method returns a name resolver that uses the map returned by getAbsoluteNamespaceMappings. The resolver is created once and for all. So code using the resolver should not modify it because it will modify the resolver for all clients. If you need a resolver you can modify, use getAbsoluteNamespaceMappings and initialize a resolver from it.

    Returns DefaultNameResolver

    The resolver.

getAttributeCompletions

  • getAttributeCompletions(attribute: Attr): string[]
  • Provide the possible value completions for an attribute. This allows a mode to support dynamic computations for completions.

    Parameters

    • attribute: Attr

      The attribute for which we want completions.

    Returns string[]

    The possible completions.

getContextualActions

  • getContextualActions(transformationType: string | string[], tag: string, container: Node, offset?: undefined | number): Action<__type>[]
  • Modes must implement this method to specify what transformations they allow based on state. The implementation should rely on the container and offset position rather than use the caret because the editor may be seeking information about possible actions near to the caret.

    Parameters

    • transformationType: string | string[]

      The type or types of transformations to return.

    • tag: string

      The tag name we are interested in. This should be in a prefix:localName format where "prefix" is one of the prefixes defined in the absolute mappings known to the mode.

    • container: Node

      The position in the data tree.

    • Optional offset: undefined | number

      The position in the data tree.

    Returns Action<__type>[]

    The actions.

getModeOptions

  • getModeOptions(): ModeOptions
  • Gets the mode options.

    Returns ModeOptions

getStylesheets

  • getStylesheets(): string[]
  • Get additional stylesheets to use to render the HTML.

    Returns string[]

    An array of paths to the stylesheets to load for this mode. The paths must not require any additional interpretation from wed.

getToolbarButtons

  • getToolbarButtons(): Button[]
  • Get the toolbar actions that this mode wants the editor to present.

    Returns Button[]

    The toolbar actions for this mode.

getValidator

  • Allows the mode to perform mode-specific checks on the document. This method will be called by wed to obtain a mode-specific validator to give to wed's own validator. Mode-specific validators are meant to provide checks that cannot be provided by a schema. It would be conceivable for instance to call a schematron processor.

    Returns ModeValidator | undefined

    The validator if this mode has one.

getWedOptions

  • getWedOptions(): WedOptions
  • Gets the options that the mode wants wed to use with this mode.

    Returns WedOptions

    The options. Callers are not allowed to modify the value returned.

init

  • init(): Promise<void>
  • This is called by the editor when a mode is ready to be initialized. The mode could use this to add a toolbar above the editor or add listeners to key events, etc.

    Returns Promise<void>

    A promise that resolves once the mode is done initializing.

makeDecorator

makePlaceholderFor

  • makePlaceholderFor(element: Element): Element
  • This method can be overriden by modes to provide the editor with different placeholders for different elements. The default implementation returns a default placeholder for all elements.

    Parameters

    • element: Element

      This is the element for which to make a placeholder.

    Returns Element

    A placeholder for the element.

nodesAroundEditableContents

  • nodesAroundEditableContents(element: Element): [Node | null, Node | null]
  • Find the nodes that are children of element and that are just before and just after the content of element that is editable.

    Parameters

    • element: Element

      This is the element to examine. MUST BE PART OF THE GUI TREE.

    Returns [Node | null, Node | null]

    An array of two elements. The first is the node before editable contents, the second is the node after. Either node can be null if there is nothing before or after editable contents. Both are null if there is nothing around the editable content.

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 getAbsoluteResolver.

    Parameters

    • name: string

      The name of the element.

    Returns string | null | undefined

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

unresolveName

  • unresolveName(name: EName): string | undefined
  • Unresolve a name according to the absolute reverse mapping.

    If the forward mappings define multiple prefixes pointing to the same URI, the unresolving algorithm will arbitrarily select one of the prefixes as the value corresponding to the URI. Modes may impose whatever rules they desire to select which prefix they should privilege.

    Parameters

    • name: EName

      The name to unresolve.

    Returns string | undefined

    The unresolved name or undefined if the name cannot be unresolved.

Generated using TypeDoc