Skip to main content

extension-file

package @remirror/extension-file

class DataUrlFileUploader

Signature:

export declare class DataUrlFileUploader implements FileUploader<FileAttributes> 

Implements: FileUploader<FileAttributes>

DataUrlFileUploader.(constructor)

Constructs a new instance of the DataUrlFileUploader class

Signature:

constructor();

method abort

Signature:

abort(): void;

Returns:

void

method insert

Signature:

insert(file: File): FileAttributes;

Parameters:

ParameterTypeDescription
fileFile

Returns:

FileAttributes

method upload

Signature:

upload(): Promise<FileAttributes>;

Returns:

Promise<FileAttributes>

class FileExtension

Add a file node to the editor.

Signature:

export declare class FileExtension extends NodeExtension<FileOptions> 

Extends: NodeExtension<FileOptions>

(Some inherited members may not be shown because they are not represented in the documentation.)

property name

Signature:

get name(): "file";

property ReactComponent

Signature:

ReactComponent: ComponentType<NodeViewComponentProps>;

method backspaceShortcut

Signature:

backspaceShortcut(props: KeyBindingProps): boolean;

Parameters:

ParameterTypeDescription
propsKeyBindingProps

Returns:

boolean

method createNodeSpec

Signature:

createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec;

Parameters:

ParameterTypeDescription
extraApplySchemaAttributes
overrideNodeSpecOverride

Returns:

NodeExtensionSpec

method createPasteRules

Signature:

createPasteRules(): PasteRule[];

Returns:

PasteRule[]

method createTags

Signature:

createTags(): "block"[];

Returns:

"block"[]

method deleteFile

Signature:

deleteFile(pos: number): CommandFunction;

Parameters:

ParameterTypeDescription
posnumber

Returns:

CommandFunction

method insertFile

Signature:

insertFile(attributes: FileAttributes, selection?: PrimitiveSelection): CommandFunction;

Parameters:

ParameterTypeDescription
attributesFileAttributes
selectionPrimitiveSelection(Optional)

Returns:

CommandFunction

method renameFile

Signature:

renameFile(pos: number, fileName: string): CommandFunction;

Parameters:

ParameterTypeDescription
posnumber
fileNamestring

Returns:

CommandFunction

method updateFile

Signature:

updateFile(pos: number, attrs: FileAttributes): CommandFunction;

Parameters:

ParameterTypeDescription
posnumber
attrsFileAttributes

Returns:

CommandFunction

method uploadFiles

Signature:

uploadFiles(files: File[]): CommandFunction;

Parameters:

ParameterTypeDescription
filesFile[]

Returns:

CommandFunction

function createBaseuploadFileUploader()

Signature:

export declare function createBaseuploadFileUploader(): FileUploader<FileAttributes>;

Returns:

FileUploader<FileAttributes>

function createDataUrlFileUploader()

Signature:

export declare function createDataUrlFileUploader(): DataUrlFileUploader;

Returns:

DataUrlFileUploader

function createObjectUrlFileUploader()

Signature:

export declare function createObjectUrlFileUploader(): FileUploader<FileAttributes>;

Returns:

FileUploader<FileAttributes>

function createSlowFileUploader()

Mock implementation of a FileUploader to test slow file uploads

Signature:

export declare function createSlowFileUploader(): FileUploader<FileAttributes>;

Returns:

FileUploader<FileAttributes>

function getDefaultFileAttrs()

Signature:

export declare function getDefaultFileAttrs(file: File): FileAttributes;

Parameters:

ParameterTypeDescription
fileFile

Returns:

FileAttributes

interface FileAttributes

Signature:

export interface FileAttributes 

property error

Error state for the file, e.g. upload failed

Signature:

error?: string | null;

property fileName

Name of the file

Signature:

fileName?: string;

property fileSize

File size in bytes

Signature:

fileSize?: number;

property fileType

Mime type of the file, e.g. "image/jpeg"

Signature:

fileType?: string;

property id

Unique identifier for a file During the file uploading process, this is a temporary unique ID

Signature:

id?: unknown;

property url

URL where the file is stored

Signature:

url?: string;

interface FileOptions

Signature:

export interface FileOptions 

property onDeleteFile

Called after the commands.deleteFile has been called.

Signature:

onDeleteFile?: Handler<(props: {
tr: Transaction;
pos: number;
node: ProsemirrorNode;
}) => void>;

property pasteRuleRegexp

A regex test for the file type when users paste files.

Signature:

pasteRuleRegexp?: RegExp;

property render

Signature:

render?: (props: FileComponentProps) => React.ReactElement<HTMLElement> | null;

property uploadFileHandler

A function returns a FileUploader which will handle the upload process.

Signature:

uploadFileHandler?: UploadFileHandler<FileAttributes>;