Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    Class ProseMirrorImagePlugin

    A class responsible for handle drag-and-drop and pasting of image content. Ensuring no base64 data is injected directly into the journal content and it is instead uploaded to the user's data directory.

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • schema: Schema

        The ProseMirror schema.

      • options: { document: ClientDocument } = {}

        Additional options to configure the plugin's behaviour.

        • document: ClientDocument

          A related Document to store extract base64 images for.

      Returns ProseMirrorImagePlugin

    Accessors

    • get key(): PluginKey<any>

      A unique key for this plugin that can be used to identify a plugin instance in any given editor.

      Returns PluginKey<any>

    Methods

    • Protected

      Detect base64 image data embedded in an HTML string and extract it.

      Parameters

      • html: string

        The HTML data as a string.

      Returns [full: string, mime: string, data: string][]

    • Protected

      Handle a drop onto the editor.

      Parameters

      • view: EditorView

        The ProseMirror editor view.

      • event: DragEvent

        The drop event.

      • slice: Slice

        A slice of editor content.

      • moved: boolean

        Whether the slice has been moved from a different part of the editor.

      Returns true | undefined

    • Protected

      Handle a paste into the editor.

      Parameters

      • view: EditorView

        The ProseMirror editor view.

      • event: ClipboardEvent

        The paste event.

      Returns true | undefined

    • Protected

      Capture any base64-encoded images embedded in the rich text paste and upload them.

      Parameters

      • view: EditorView

        The ProseMirror editor view.

      • html: string

        The HTML data as a string.

      • images: [full: string, mime: string, data: string][]

        An array of extracted base64 image data.

      Returns Promise<void>

    • Protected

      Upload any image files encountered in the drop.

      Parameters

      • view: EditorView

        The ProseMirror editor view.

      • files: FileList

        The files to upload.

      • Optionalpos: number

        The position in the document to insert at. If not provided, the current selection will be replaced instead.

      Returns Promise<void>

    • Convert a base64 string into a File object.

      Parameters

      • data: string

        Base64 encoded data.

      • filename: string

        The filename.

      • mimetype: string

        The file's mimetype.

      Returns File

    • Build the plugin.

      Parameters

      • schema: any

        The ProseMirror schema to build the plugin against.

      • options: {} = {}

        Additional options to pass to the plugin.

      Returns Plugin<any>