Skip to content

Type Editor


Type Editor / @type-editor/menu / menu-items/file-upload-item / fileUploadItem

Function: fileUploadItem()

ts
function fileUploadItem(title?, fileType?, codeBlockNodeType?): MenuItem;

Defined in: packages/menu/src/menu-items/file-upload-item.ts:96

Creates a menu item for uploading and managing file attachments in the editor.

This menu item provides functionality to:

  • Upload new files via file picker or drag-and-drop
  • Generate thumbnail previews for supported file types (images, PDFs)
  • Update existing file attachments
  • Download attached files

When the selection is empty, files are inserted as thumbnail previews (if available) or as text links. When text is selected, the file mark is applied to the selection.

Parameters

ParameterTypeDefault valueDescription
titlestring'File Upload'The display title for the menu item. Defaults to 'File Upload'.
fileTypeMarkTypeschema.marks.fileThe mark type used for file attachments. Defaults to schema.marks.file.
codeBlockNodeTypeNodeTypeschema.nodes.code_blockThe node type for code blocks (used to disable the item in code blocks). Defaults to schema.nodes.code_block.

Returns

MenuItem

A configured MenuItem instance for file uploads.

Example

typescript
import { fileUploadItem } from "@type-editor/menu";

const menuItem = fileUploadItem("Attach File");