PasteFileHandler
Type Stability: stable
What an extension does with a FILE pasted from the clipboard (a screenshot, a file copied from the OS): it makes a block
of it. The engine reads the bytes, stores them through Files (in the document, or sent to files.onBeforePersist with the
optimistic pending block) and inserts the blocks at the caret, in the order of the files, as ONE undo step. The engine
names no block type: whatever an extension accepts is its own business.
Definition
TypeScript
import type { PasteFileHandler } from '@aionbuilders/nabu/extend';TypeScript
interface PasteFileHandler {
accepts: (file: File, nabu: Nabu) => boolean;
block: (file: File, nabu: Nabu) => PasteBlock | null;
priority?: number;
}Properties
| Property | Type | Description |
|---|---|---|
accepts | (file: File, nabu: Nabu) => boolean | Whether this handler takes |
block | (file: File, nabu: Nabu) => PasteBlock | null | The block the file becomes: |
priorityoptional | number | Higher is asked first (default 0). The first handler that accepts a file takes it. |
Source: src/lib/utils/extensions.js:34