@witchcraft/editor
    Preparing search index...

    Test-specific file inserter handler.

    Simulates async file uploading with a configurable max delay and preview support.

    Hierarchy (View Summary)

    Index
    delay: number

    Max* delay in ms applied before resolving a file upload (useful for testing), the delay itself is randomized.

    2000
    
    insertionBatch: Map<string, BatchEntry> = ...

    Maps insert IDs to their batch info for position adjustment during concurrent replacements.

    • Return the file (or whatever type you'd like) to allow the extension to handle it.

      If the function doesn't return anything, the file will be ignored. No placeholder will be created. The event will still be preventDefaulted.

      This can be used to filter out mime types you can't handle with a library like mime. Mime type filtering is not handled by the extension since it can be complicated.

      Parameters

      • file: File

      Returns File | undefined

    • Generate a preview for the placeholder widget before saving starts.

      If a preview is returned, it should be used to update the placeholder widget immediately, allowing the user to see a preview image as the file saves. It should also be passed to saveFile.

      Parameters

      • file: File
      • _id: string
      • _editor: Editor

      Returns Promise<string>

    • Orchestrates the entire file insertion lifecycle: filter, insert placeholders, save files concurrently, replace placeholders, and cleanup batch maps.

      This is what the insertFiles command calls internally.

      Parameters

      • files: File[]
      • editor: Editor
      • Optionalpos: number

      Returns Promise<void>

    • Should load/save/upload the file and return the node attributes.

      The attrs object returned should be spread onto the file node. The previewSrc is the result of generatePreview.

      The id and editor are provided in case you're uploading the file or doing some other heavy operation and want to update the placeholder as soon as you can upload the file.

      Parameters

      • file: File
      • id: string
      • _editor: Editor
      • previewSrc: string | undefined

      Returns Promise<{ attrs: { id: string; src: string }; file: File }>