Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface PreviewHandler

A PreviewHandler manages the integration of one or more previews.

It indicates whether a preview shall be rendered for a given resource URI and, if yes, renders the content. Additionally it optionally provides methods with which the scroll state of the preview and corresponding editor can be managed.

See MarkdownPreviewHandler for an example implementation.

Hierarchy

  • PreviewHandler

Index

Properties

iconClass?: string

One or more classes which specify the preview widget icon.

Methods

  • canHandle(uri: URI): number
  • Indicates whether and with which priority (larger is better) this preview handler is responsible for the resource identified by the given URI. If multiple handlers return the same priority it's undefined which one will be used.

    Parameters

    • uri: URI

      the URI identifying a resource.

    Returns number

    a number larger than 0 if the handler is applicable, 0 or a negative number otherwise.

  • findElementForFragment(content: HTMLElement, fragment: string): undefined | HTMLElement
  • Search and return the HTMLElement which corresponds to the given fragment. This is used to initially reveal elements identified via the URI fragment.

    Parameters

    • content: HTMLElement

      the preview widget element containing the content previously rendered by PreviewHandler.renderContent.

    • fragment: string

      the URI fragment for which the corresponding element shall be returned

    Returns undefined | HTMLElement

    the HTMLElement which is part of content and corresponds to the given fragment, undefined otherwise.

  • findElementForSourceLine(content: HTMLElement, sourceLine: number): undefined | HTMLElement
  • Search and return the HTMLElement which corresponds to the given line number. This is used to scroll the preview when the source editor scrolls.

    Parameters

    • content: HTMLElement

      the preview widget element containing the previously rendered by PreviewHandler.renderContent.

    • sourceLine: number

      the line number for which the corresponding element shall be returned.

    Returns undefined | HTMLElement

    the HTMLElement which is part of content and corresponds to the given line number, undefined otherwise.

  • getSourceLineForOffset(content: HTMLElement, offset: number): undefined | number
  • Returns the line number which corresponds to the preview element at the given offset. This is used to scroll the source editor when the preview scrolls.

    Parameters

    • content: HTMLElement

      the preview widget element containing the previously rendered by PreviewHandler.renderContent.

    • offset: number

      the total amount by which the preview widget is scrolled.

    Returns undefined | number

    the source line number which corresponds to the preview element at the given offset, undefined otherwise.