Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Constructors

  • Parameters

    • schema: Schema

      The ProseMirror schema.

    • options: { document: Document } = {}

      Additional options to configure the plugin's behaviour.

      • document: Document

        A related Document to store extract base64 images for.

    Returns ProseMirrorImagePlugin

Methods

  • _onDrop(view: EditorView, event: DragEvent, slice: Slice, moved: boolean): boolean
  • 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 boolean

  • _onPaste(view: EditorView, event: ClipboardEvent): boolean
  • Handle a paste into the editor.

    Parameters

    • view: EditorView

      The ProseMirror editor view.

    • event: ClipboardEvent

      The paste event.

    Returns boolean

  • _uploadImages(view: EditorView, files: FileList, pos: number): Promise<void>
  • Upload any image files encountered in the drop.

    Parameters

    • view: EditorView

      The ProseMirror editor view.

    • files: FileList

      The files to upload.

    • pos: number

    Returns Promise<void>

  • _replaceBase64Images(view: EditorView, html: string, images: [full: string, mime: string, data: string][]): Promise<void>
  • 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>

  • _extractBase64Images(html: string): [full: string, mime: string, data: string][]
  • 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][]

  • build(schema: any, options?: {}): Plugin<any>
  • Build the plugin.

    Parameters

    • schema: any

      The ProseMirror schema to build the plugin against.

    • options: {} = {}

      Returns Plugin<any>

    • base64ToFile(data: string, filename: string, mimetype: string): File
    • 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